From 73154769b3eba60fe48a7c08882e8e64b1545e3f Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Mon, 30 Apr 2012 16:18:17 -0400 Subject: splitting up go specific code. too much for one file IMO. more progress. almost done with structs. --- nexgb/xgbgen/go_event.go | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 nexgb/xgbgen/go_event.go (limited to 'nexgb/xgbgen/go_event.go') diff --git a/nexgb/xgbgen/go_event.go b/nexgb/xgbgen/go_event.go new file mode 100644 index 0000000..d91fd7a --- /dev/null +++ b/nexgb/xgbgen/go_event.go @@ -0,0 +1,38 @@ +package main + +// Event types +func (e *Event) Define(c *Context) { + c.Putln("// Event definition %s (%d)", e.SrcName(), e.Number) +} + +func (e *Event) Read(c *Context, prefix string) { + c.Putln("// Event read %s", e.SrcName()) +} + +func (e *Event) Write(c *Context, prefix string) { + c.Putln("// Event write %s", e.SrcName()) +} + +// EventCopy types +func (e *EventCopy) Define(c *Context) { + c.Putln("// EventCopy definition %s (%d)", e.SrcName(), e.Number) + c.Putln("") + c.Putln("const %s = %d", e.SrcName(), e.Number) + c.Putln("") + c.Putln("type %s %s", e.EvType(), e.Old.(*Event).EvType()) + c.Putln("") + c.Putln("func New%s(buf []byte) %s {", e.SrcName(), e.EvType()) + c.Putln("return (%s)(New%s(buf))", e.EvType(), e.Old.SrcName()) + c.Putln("}") + c.Putln("") + c.Putln("func (ev %s) ImplementsEvent() { }", e.EvType()) + c.Putln("") + c.Putln("func (ev %s) Bytes() []byte {", e.EvType()) + c.Putln("return (%s)(ev).Bytes()", e.Old.(*Event).EvType()) + c.Putln("}") + c.Putln("") + c.Putln("func init() {") + c.Putln("newEventFuncs[%d] = New%s", e.Number, e.SrcName()) + c.Putln("}") + c.Putln("") +} -- cgit v1.2.3-70-g09d2 From 83a71d464887f4b6cf9124d2f8c565e6f17f2bd3 Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Tue, 1 May 2012 01:08:03 -0400 Subject: unions, events and errors... oh my --- nexgb/xgbgen/field.go | 27 +++++++- nexgb/xgbgen/go_error.go | 30 +++++++-- nexgb/xgbgen/go_event.go | 97 ++++++++++++++++++++++++++--- nexgb/xgbgen/go_list.go | 10 +-- nexgb/xgbgen/go_single_field.go | 36 +++++++++-- nexgb/xgbgen/go_struct.go | 9 +-- nexgb/xgbgen/go_union.go | 134 +++++++++++++++++++++++++++++++++++++++- nexgb/xgbgen/type.go | 4 +- 8 files changed, 313 insertions(+), 34 deletions(-) (limited to 'nexgb/xgbgen/go_event.go') diff --git a/nexgb/xgbgen/field.go b/nexgb/xgbgen/field.go index 0f2323e..6d39af2 100644 --- a/nexgb/xgbgen/field.go +++ b/nexgb/xgbgen/field.go @@ -9,6 +9,7 @@ type Field interface { Initialize(p *Protocol) SrcName() string XmlName() string + SrcType() string Size() Size Define(c *Context) @@ -30,6 +31,10 @@ func (p *PadField) XmlName() string { panic("illegal to take XML name of a pad field") } +func (f *PadField) SrcType() string { + panic("it is illegal to call SrcType on a SwitchField field") +} + func (p *PadField) Size() Size { return newFixedSize(p.Bytes) } @@ -53,6 +58,10 @@ func (f *SingleField) XmlName() string { return f.xmlName } +func (f *SingleField) SrcType() string { + return f.Type.SrcName() +} + func (f *SingleField) Size() Size { return f.Type.Size() } @@ -72,9 +81,9 @@ func (f *ListField) XmlName() string { return f.xmlName } -// func (f *ListField) Size() Size { - // return newExpressionSize(f.LengthExpr).Multiply(f.Type.Size()) -// } +func (f *ListField) SrcType() string { + return fmt.Sprintf("[]%s", f.Type.SrcName()) +} func (f *ListField) Size() Size { simpleLen := &Function{ @@ -126,6 +135,10 @@ func (f *ExprField) XmlName() string { return f.xmlName } +func (f *ExprField) SrcType() string { + return f.Type.SrcName() +} + func (f *ExprField) Size() Size { return f.Type.Size() } @@ -150,6 +163,10 @@ func (f *ValueField) XmlName() string { panic("it is illegal to call XmlName on a ValueField field") } +func (f *ValueField) SrcType() string { + return f.MaskType.SrcName() +} + func (f *ValueField) Size() Size { return f.MaskType.Size() } @@ -174,6 +191,10 @@ func (f *SwitchField) XmlName() string { panic("it is illegal to call XmlName on a SwitchField field") } +func (f *SwitchField) SrcType() string { + panic("it is illegal to call SrcType on a SwitchField field") +} + // XXX: This is a bit tricky. The size has to be represented as a non-concrete // expression that finds *which* bitcase fields are included, and sums the // sizes of those fields. diff --git a/nexgb/xgbgen/go_error.go b/nexgb/xgbgen/go_error.go index 0cb77cc..493a8b9 100644 --- a/nexgb/xgbgen/go_error.go +++ b/nexgb/xgbgen/go_error.go @@ -22,18 +22,36 @@ func (e *ErrorCopy) Define(c *Context) { c.Putln("") c.Putln("type %s %s", e.ErrType(), e.Old.(*Error).ErrType()) c.Putln("") + + // Read defines a function that transforms a byte slice into this + // error struct. + e.Read(c) + + // Write defines a function that transoforms this error struct into + // a byte slice. + e.Write(c) + + // Makes sure that this error type is an Error interface. + c.Putln("func (err %s) ImplementsError() { }", e.ErrType()) + c.Putln("") + + // Let's the XGB know how to read this error. + c.Putln("func init() {") + c.Putln("newErrorFuncs[%d] = New%s", e.Number, e.SrcName()) + c.Putln("}") + c.Putln("") +} + +func (e *ErrorCopy) Read(c *Context) { c.Putln("func New%s(buf []byte) %s {", e.SrcName(), e.ErrType()) c.Putln("return (%s)(New%s(buf))", e.ErrType(), e.Old.SrcName()) c.Putln("}") c.Putln("") - c.Putln("func (err %s) ImplementsError() { }", e.ErrType()) - c.Putln("") +} + +func (e *ErrorCopy) Write(c *Context) { c.Putln("func (err %s) Bytes() []byte {", e.ErrType()) c.Putln("return (%s)(err).Bytes()", e.Old.(*Error).ErrType()) c.Putln("}") c.Putln("") - c.Putln("func init() {") - c.Putln("newErrorFuncs[%d] = New%s", e.Number, e.SrcName()) - c.Putln("}") - c.Putln("") } diff --git a/nexgb/xgbgen/go_event.go b/nexgb/xgbgen/go_event.go index d91fd7a..e6d40b0 100644 --- a/nexgb/xgbgen/go_event.go +++ b/nexgb/xgbgen/go_event.go @@ -3,14 +3,75 @@ package main // Event types func (e *Event) Define(c *Context) { c.Putln("// Event definition %s (%d)", e.SrcName(), e.Number) + c.Putln("// Size: %s", e.Size()) + c.Putln("type %s struct {", e.EvType()) + c.Putln("Sequence uint16") + for _, field := range e.Fields { + field.Define(c) + } + c.Putln("}") + c.Putln("") + + // Read defines a function that transforms a byte slice into this + // event struct. + e.Read(c) + + // Write defines a function that transoforms this event struct into + // a byte slice. + e.Write(c) + + // Makes sure that this event type is an Event interface. + c.Putln("func (v %s) ImplementsEvent() { }", e.EvType()) + c.Putln("") + + // Let's the XGB event loop read this event. + c.Putln("func init() {") + c.Putln("newEventFuncs[%d] = New%s", e.Number, e.SrcName()) + c.Putln("}") + c.Putln("") } -func (e *Event) Read(c *Context, prefix string) { +func (e *Event) Read(c *Context) { c.Putln("// Event read %s", e.SrcName()) + c.Putln("func New%s(buf []byte) %s {", e.SrcName(), e.EvType()) + c.Putln("v := %s{}", e.EvType()) + c.Putln("b := 1 // don't read event number") + c.Putln("") + for i, field := range e.Fields { + if i == 1 && !e.NoSequence { + c.Putln("v.Sequence = get16(buf[b:])") + c.Putln("b += 2") + c.Putln("") + } + field.Read(c) + c.Putln("") + } + c.Putln("return v") + c.Putln("}") + c.Putln("") } -func (e *Event) Write(c *Context, prefix string) { +func (e *Event) Write(c *Context) { c.Putln("// Event write %s", e.SrcName()) + c.Putln("func (v %s) Bytes() []byte {", e.EvType()) + c.Putln("buf := make([]byte, %s)", e.Size()) + c.Putln("b := 0") + c.Putln("") + c.Putln("// write event number") + c.Putln("buf[b] = %d", e.Number) + c.Putln("b += 1") + c.Putln("") + for i, field := range e.Fields { + if i == 1 && !e.NoSequence { + c.Putln("b += 2 // skip sequence number") + c.Putln("") + } + field.Write(c) + c.Putln("") + } + c.Putln("return buf") + c.Putln("}") + c.Putln("") } // EventCopy types @@ -21,18 +82,36 @@ func (e *EventCopy) Define(c *Context) { c.Putln("") c.Putln("type %s %s", e.EvType(), e.Old.(*Event).EvType()) c.Putln("") + + // Read defines a function that transforms a byte slice into this + // event struct. + e.Read(c) + + // Write defines a function that transoforms this event struct into + // a byte slice. + e.Write(c) + + // Makes sure that this event type is an Event interface. + c.Putln("func (v %s) ImplementsEvent() { }", e.EvType()) + c.Putln("") + + // Let's the XGB event loop read this event. + c.Putln("func init() {") + c.Putln("newEventFuncs[%d] = New%s", e.Number, e.SrcName()) + c.Putln("}") + c.Putln("") +} + +func (e *EventCopy) Read(c *Context) { c.Putln("func New%s(buf []byte) %s {", e.SrcName(), e.EvType()) c.Putln("return (%s)(New%s(buf))", e.EvType(), e.Old.SrcName()) c.Putln("}") c.Putln("") - c.Putln("func (ev %s) ImplementsEvent() { }", e.EvType()) - c.Putln("") - c.Putln("func (ev %s) Bytes() []byte {", e.EvType()) +} + +func (e *EventCopy) Write(c *Context) { + c.Putln("func (v %s) Bytes() []byte {", e.EvType()) c.Putln("return (%s)(ev).Bytes()", e.Old.(*Event).EvType()) c.Putln("}") c.Putln("") - c.Putln("func init() {") - c.Putln("newEventFuncs[%d] = New%s", e.Number, e.SrcName()) - c.Putln("}") - c.Putln("") } diff --git a/nexgb/xgbgen/go_list.go b/nexgb/xgbgen/go_list.go index 03da22e..a95ba71 100644 --- a/nexgb/xgbgen/go_list.go +++ b/nexgb/xgbgen/go_list.go @@ -12,8 +12,6 @@ func (f *ListField) Define(c *Context) { } func (f *ListField) Read(c *Context) { - c.Putln("") - switch t := f.Type.(type) { case *Resource: length := f.LengthExpr.Reduce("v.", "") @@ -34,6 +32,10 @@ func (f *ListField) Read(c *Context) { c.Putln("}") c.Putln("b = pad(b)") } + case *Union: + c.Putln("v.%s = make([]%s, %s)", + f.SrcName(), t.SrcName(), f.LengthExpr.Reduce("v.", "")) + c.Putln("b += Read%sList(buf[b:], v.%s)", t.SrcName(), f.SrcName()) case *Struct: c.Putln("v.%s = make([]%s, %s)", f.SrcName(), t.SrcName(), f.LengthExpr.Reduce("v.", "")) @@ -45,8 +47,6 @@ func (f *ListField) Read(c *Context) { } func (f *ListField) Write(c *Context) { - c.Putln("") - switch t := f.Type.(type) { case *Resource: length := f.LengthExpr.Reduce("v.", "") @@ -65,6 +65,8 @@ func (f *ListField) Write(c *Context) { c.Putln("}") c.Putln("b = pad(b)") } + case *Union: + c.Putln("b += %sListBytes(buf[b:], v.%s)", t.SrcName(), f.SrcName()) case *Struct: c.Putln("b += %sListBytes(buf[b:], v.%s)", t.SrcName(), f.SrcName()) default: diff --git a/nexgb/xgbgen/go_single_field.go b/nexgb/xgbgen/go_single_field.go index 3c354e7..bf31259 100644 --- a/nexgb/xgbgen/go_single_field.go +++ b/nexgb/xgbgen/go_single_field.go @@ -25,6 +25,16 @@ func ReadSimpleSingleField(c *Context, name string, typ Type) { c.Putln("%s = %s(get64(buf[b:]))", name, t.SrcName()) } case *Base: + // If this is a bool, stop short and do something special. + if t.SrcName() == "bool" { + c.Putln("if buf[b] == 1 {") + c.Putln("%s = true", name) + c.Putln("} else {") + c.Putln("%s = false", name) + c.Putln("}") + break + } + var val string switch t.Size().Eval() { case 1: @@ -44,7 +54,7 @@ func ReadSimpleSingleField(c *Context, name string, typ Type) { } c.Putln("%s = %s", name, val) default: - log.Fatalf("Cannot read field '%s' as a simple field with %T type.", + log.Panicf("Cannot read field '%s' as a simple field with %T type.", name, typ) } @@ -62,9 +72,11 @@ func (f *SingleField) Read(c *Context) { case *Struct: c.Putln("v.%s = %s{}", f.SrcName(), t.SrcName()) c.Putln("b += Read%s(buf[b:], &v.%s)", t.SrcName(), f.SrcName()) - c.Putln("") + case *Union: + c.Putln("v.%s = %s{}", f.SrcName(), t.SrcName()) + c.Putln("b += Read%s(buf[b:], &v.%s)", t.SrcName(), f.SrcName()) default: - log.Fatalf("Cannot read field '%s' with %T type.", f.XmlName(), f.Type) + log.Panicf("Cannot read field '%s' with %T type.", f.XmlName(), f.Type) } } @@ -84,6 +96,16 @@ func WriteSimpleSingleField(c *Context, name string, typ Type) { c.Putln("put64(buf[b:], uint64(%s))", name) } case *Base: + // If this is a bool, stop short and do something special. + if t.SrcName() == "bool" { + c.Putln("if %s {", name) + c.Putln("buf[b] = 1") + c.Putln("} else {") + c.Putln("buf[b] = 0") + c.Putln("}") + break + } + switch t.Size().Eval() { case 1: if t.SrcName() != "byte" { @@ -126,11 +148,17 @@ func (f *SingleField) Write(c *Context) { ReadSimpleSingleField(c, fmt.Sprintf("v.%s", f.SrcName()), t) case *Base: ReadSimpleSingleField(c, fmt.Sprintf("v.%s", f.SrcName()), t) + case *Union: + c.Putln("{") + c.Putln("unionBytes := v.%s.Bytes()", f.SrcName()) + c.Putln("copy(buf[b:], unionBytes)") + c.Putln("b += pad(len(unionBytes))") + c.Putln("}") case *Struct: c.Putln("{") c.Putln("structBytes := v.%s.Bytes()", f.SrcName()) c.Putln("copy(buf[b:], structBytes)") - c.Putln("b += len(structBytes)") + c.Putln("b += pad(len(structBytes))") c.Putln("}") default: log.Fatalf("Cannot read field '%s' with %T type.", f.XmlName(), f.Type) diff --git a/nexgb/xgbgen/go_struct.go b/nexgb/xgbgen/go_struct.go index 6925c88..600ebaf 100644 --- a/nexgb/xgbgen/go_struct.go +++ b/nexgb/xgbgen/go_struct.go @@ -13,7 +13,7 @@ func (s *Struct) Define(c *Context) { // Write function that reads bytes and produces this struct. s.Read(c) - // Write function that reads a list of this structs. + // Write function that reads bytes and produces a list of this struct. s.ReadList(c) // Write function that writes bytes given this struct. @@ -68,7 +68,7 @@ func (s *Struct) ReadList(c *Context) { func (s *Struct) Write(c *Context) { c.Putln("// Struct write %s", s.SrcName()) c.Putln("func (v %s) Bytes() []byte {", s.SrcName()) - c.Putln("buf := make([]byte, %s)", s.Size().Reduce("s.", "")) + c.Putln("buf := make([]byte, %s)", s.Size().Reduce("v.", "")) c.Putln("b := 0") c.Putln("") for _, field := range s.Fields { @@ -88,10 +88,11 @@ func (s *Struct) WriteList(c *Context) { c.Putln("for _, item := range list {") c.Putln("structBytes = item.Bytes()") c.Putln("copy(buf[b:], len(structBytes))") - c.Putln("b += len(structBytes)") + c.Putln("b += pad(len(structBytes))") c.Putln("}") c.Putln("return b") c.Putln("}") + c.Putln("") } func (s *Struct) WriteListSize(c *Context) { @@ -101,7 +102,7 @@ func (s *Struct) WriteListSize(c *Context) { c.Putln("for _, item := range list {") c.Putln("size += %s", s.Size().Reduce("item.", "")) c.Putln("}") - c.Putln("return pad(size)") + c.Putln("return size") c.Putln("}") c.Putln("") } diff --git a/nexgb/xgbgen/go_union.go b/nexgb/xgbgen/go_union.go index 5721c49..3b7365d 100644 --- a/nexgb/xgbgen/go_union.go +++ b/nexgb/xgbgen/go_union.go @@ -3,13 +3,143 @@ package main // Union types func (u *Union) Define(c *Context) { c.Putln("// Union definition %s", u.SrcName()) + c.Putln("// Note that to *create* a Union, you should *never* create") + c.Putln("// this struct directly (unless you know what you're doing).") + c.Putln("// Instead use one of the following constructors for '%s':", + u.SrcName()) + for _, field := range u.Fields { + c.Putln("// New%s%s(%s %s) %s", u.SrcName(), field.SrcName(), + field.SrcName(), field.SrcType(), u.SrcName()) + } + + c.Putln("type %s struct {", u.SrcName()) + for _, field := range u.Fields { + field.Define(c) + } + c.Putln("}") + c.Putln("") + + // Write functions for each field that create instances of this + // union using the corresponding field. + u.New(c) + + // Write function that reads bytes and produces this union. + u.Read(c) + + // Write function that reads bytes and produces a list of this union. + u.ReadList(c) + + // Write function that writes bytes given this union. + u.Write(c) + + // Write function that writes a list of this union. + u.WriteList(c) + + // Write function that computes the size of a list of these unions. + u.WriteListSize(c) } -func (u *Union) Read(c *Context, prefix string) { +func (u *Union) New(c *Context) { + for _, field := range u.Fields { + c.Putln("// Union constructor for %s for field %s.", + u.SrcName(), field.SrcName()) + c.Putln("func New%s%s(%s %s) %s {", + u.SrcName(), field.SrcName(), field.SrcName(), + field.SrcType(), u.SrcName()) + c.Putln("var b int") + c.Putln("buf := make([]byte, %s)", u.Size()) + c.Putln("") + field.Write(c) + c.Putln("") + c.Putln("// Create the Union type") + c.Putln("v := %s{}", u.SrcName()) + c.Putln("") + c.Putln("// Now copy buf into all fields") + c.Putln("") + for _, field2 := range u.Fields { + c.Putln("b = 0 // always read the same bytes") + field2.Read(c) + c.Putln("") + } + c.Putln("return v") + c.Putln("}") + c.Putln("") + } +} + +func (u *Union) Read(c *Context) { c.Putln("// Union read %s", u.SrcName()) + c.Putln("func Read%s(buf []byte, v *%s) int {", u.SrcName(), u.SrcName()) + c.Putln("var b int") + c.Putln("") + for _, field := range u.Fields { + c.Putln("b = 0 // re-read the same bytes") + field.Read(c) + c.Putln("") + } + c.Putln("return %s", u.Size()) + c.Putln("}") + c.Putln("") +} + +func (u *Union) ReadList(c *Context) { + c.Putln("// Union list read %s", u.SrcName()) + c.Putln("func Read%sList(buf []byte, dest []%s) int {", + u.SrcName(), u.SrcName()) + c.Putln("b := 0") + c.Putln("for i := 0; i < len(dest); i++ {") + c.Putln("dest[i] = %s{}", u.SrcName()) + c.Putln("b += Read%s(buf[b:], &dest[i])", u.SrcName()) + c.Putln("}") + c.Putln("return pad(b)") + c.Putln("}") + c.Putln("") } -func (u *Union) Write(c *Context, prefix string) { +// This is a bit tricky since writing from a Union implies that only +// the data inside ONE of the elements is actually written. +// However, we only currently support unions where every field has the +// *same* *fixed* size. Thus, we make sure to always read bytes into +// every field which allows us to simply pick the first field and write it. +func (u *Union) Write(c *Context) { c.Putln("// Union write %s", u.SrcName()) + c.Putln("// Each field in a union must contain the same data.") + c.Putln("// So simply pick the first field and write that to the wire.") + c.Putln("func (v %s) Bytes() []byte {", u.SrcName()) + c.Putln("buf := make([]byte, %s)", u.Size().Reduce("v.", "")) + c.Putln("b := 0") + c.Putln("") + u.Fields[0].Write(c) + c.Putln("return buf") + c.Putln("}") + c.Putln("") +} + +func (u *Union) WriteList(c *Context) { + c.Putln("// Union list write %s", u.SrcName()) + c.Putln("func %sListBytes(buf []byte, list []%s) int {", + u.SrcName(), u.SrcName()) + c.Putln("b := 0") + c.Putln("var unionBytes []byte") + c.Putln("for _, item := range list {") + c.Putln("unionBytes = item.Bytes()") + c.Putln("copy(buf[b:], len(unionBytes))") + c.Putln("b += pad(len(unionBytes))") + c.Putln("}") + c.Putln("return b") + c.Putln("}") + c.Putln("") +} + +func (u *Union) WriteListSize(c *Context) { + c.Putln("// Union list size %s", u.SrcName()) + c.Putln("func %sListSize(list []%s) int {", u.SrcName(), u.SrcName()) + c.Putln("size := 0") + c.Putln("for _, item := range list {") + c.Putln("size += %s", u.Size().Reduce("item.", "")) + c.Putln("}") + c.Putln("return size") + c.Putln("}") + c.Putln("") } diff --git a/nexgb/xgbgen/type.go b/nexgb/xgbgen/type.go index 9fbef65..1e06bda 100644 --- a/nexgb/xgbgen/type.go +++ b/nexgb/xgbgen/type.go @@ -191,7 +191,7 @@ func (e *Event) XmlName() string { } func (e *Event) Size() Size { - panic("Cannot take size of Event type.") + return newExpressionSize(&Value{v: 32}) } func (e *Event) Initialize(p *Protocol) { @@ -358,7 +358,7 @@ func (u *Union) Size() Size { } func (u *Union) Initialize(p *Protocol) { - u.srcName = TypeSrcName(p, u) + u.srcName = fmt.Sprintf("%sUnion", TypeSrcName(p, u)) for _, field := range u.Fields { field.Initialize(p) } -- cgit v1.2.3-70-g09d2 From 39507f86ab0468292c24081a80f41c1799d6b477 Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Wed, 2 May 2012 01:46:30 -0400 Subject: finally starting on the crescendo: requests and replies. --- nexgb/xgbgen/context.go | 3 ++ nexgb/xgbgen/field.go | 4 ++- nexgb/xgbgen/go.go | 9 ------ nexgb/xgbgen/go_error.go | 65 ++++++++++++++++++++++++++++++------------ nexgb/xgbgen/go_event.go | 21 ++++++++------ nexgb/xgbgen/go_list.go | 4 +-- nexgb/xgbgen/go_reply.go | 19 ++++++++++++ nexgb/xgbgen/representation.go | 53 ++++++++++++++++++++++++++++++++++ nexgb/xgbgen/translation.go | 12 ++++---- nexgb/xgbgen/type.go | 9 ++++-- nexgb/xgbgen/xml.go | 2 +- 11 files changed, 153 insertions(+), 48 deletions(-) create mode 100644 nexgb/xgbgen/go_reply.go (limited to 'nexgb/xgbgen/go_event.go') diff --git a/nexgb/xgbgen/context.go b/nexgb/xgbgen/context.go index 67801c7..33641b3 100644 --- a/nexgb/xgbgen/context.go +++ b/nexgb/xgbgen/context.go @@ -51,4 +51,7 @@ func (c *Context) Morph(xmlBytes []byte) { for _, typ := range c.protocol.Types { typ.Define(c) } + for _, req := range c.protocol.Requests { + req.Define(c) + } } diff --git a/nexgb/xgbgen/field.go b/nexgb/xgbgen/field.go index 6d39af2..8d8412c 100644 --- a/nexgb/xgbgen/field.go +++ b/nexgb/xgbgen/field.go @@ -102,8 +102,10 @@ func (f *ListField) Size() Size { return newExpressionSize(simpleLen) case *Resource: return newExpressionSize(simpleLen) + case *TypeDef: + return newExpressionSize(simpleLen) default: - log.Fatalf("Cannot compute list size with type '%T'.", f.Type) + log.Panicf("Cannot compute list size with type '%T'.", f.Type) } panic("unreachable") } diff --git a/nexgb/xgbgen/go.go b/nexgb/xgbgen/go.go index 11e413b..b7b153e 100644 --- a/nexgb/xgbgen/go.go +++ b/nexgb/xgbgen/go.go @@ -105,57 +105,48 @@ func (f *PadField) Write(c *Context) { // Local fields func (f *LocalField) Define(c *Context) { c.Putln("// local field: %s %s", f.SrcName(), f.Type.SrcName()) - panic("todo") } func (f *LocalField) Read(c *Context) { c.Putln("// reading local field: %s (%s) :: %s", f.SrcName(), f.Size(), f.Type.SrcName()) - panic("todo") } func (f *LocalField) Write(c *Context) { c.Putln("// writing local field: %s (%s) :: %s", f.SrcName(), f.Size(), f.Type.SrcName()) - panic("todo") } // Expr fields func (f *ExprField) Define(c *Context) { c.Putln("// expression field: %s %s (%s)", f.SrcName(), f.Type.SrcName(), f.Expr) - panic("todo") } func (f *ExprField) Read(c *Context) { c.Putln("// reading expression field: %s (%s) (%s) :: %s", f.SrcName(), f.Size(), f.Expr, f.Type.SrcName()) - panic("todo") } func (f *ExprField) Write(c *Context) { c.Putln("// writing expression field: %s (%s) (%s) :: %s", f.SrcName(), f.Size(), f.Expr, f.Type.SrcName()) - panic("todo") } // Value field func (f *ValueField) Define(c *Context) { c.Putln("// valueparam field: type: %s, mask name: %s, list name: %s", f.MaskType.SrcName(), f.MaskName, f.ListName) - panic("todo") } func (f *ValueField) Read(c *Context) { c.Putln("// reading valueparam: type: %s, mask name: %s, list name: %s", f.MaskType.SrcName(), f.MaskName, f.ListName) - panic("todo") } func (f *ValueField) Write(c *Context) { c.Putln("// writing valueparam: type: %s, mask name: %s, list name: %s", f.MaskType.SrcName(), f.MaskName, f.ListName) - panic("todo") } // Switch field diff --git a/nexgb/xgbgen/go_error.go b/nexgb/xgbgen/go_error.go index 493a8b9..17c0db5 100644 --- a/nexgb/xgbgen/go_error.go +++ b/nexgb/xgbgen/go_error.go @@ -3,15 +3,53 @@ package main // Error types func (e *Error) Define(c *Context) { c.Putln("// Error definition %s (%d)", e.SrcName(), e.Number) + c.Putln("// Size: %s", e.Size()) + c.Putln("") + c.Putln("const %s = %d", e.ErrConst(), e.Number) + c.Putln("") + c.Putln("type %s struct {", e.ErrType()) + c.Putln("Sequence uint16") + c.Putln("NiceName string") + for _, field := range e.Fields { + field.Define(c) + } + c.Putln("}") c.Putln("") -} -func (e *Error) Read(c *Context, prefix string) { - c.Putln("// Error read %s", e.SrcName()) + // Read defines a function that transforms a byte slice into this + // error struct. + e.Read(c) + + // Makes sure that this error type is an Error interface. + c.Putln("func (v %s) ImplementsError() { }", e.ErrType()) + c.Putln("") + + // Let's the XGB event loop read this error. + c.Putln("func init() {") + c.Putln("newErrorFuncs[%d] = New%s", e.Number, e.ErrType()) + c.Putln("}") + c.Putln("") } -func (e *Error) Write(c *Context, prefix string) { - c.Putln("// Error write %s", e.SrcName()) +func (e *Error) Read(c *Context) { + c.Putln("// Error read %s", e.SrcName()) + c.Putln("func New%s(buf []byte) %s {", e.ErrType(), e.ErrType()) + c.Putln("v := %s{}", e.ErrType()) + c.Putln("v.NiceName = \"%s\"", e.SrcName()) + c.Putln("") + c.Putln("b := 1 // skip error determinant") + c.Putln("b += 1 // don't read error number") + c.Putln("") + c.Putln("v.Sequence = get16(buf[b:])") + c.Putln("b += 2") + c.Putln("") + for _, field := range e.Fields { + field.Read(c) + c.Putln("") + } + c.Putln("return v") + c.Putln("}") + c.Putln("") } // ErrorCopy types @@ -27,31 +65,20 @@ func (e *ErrorCopy) Define(c *Context) { // error struct. e.Read(c) - // Write defines a function that transoforms this error struct into - // a byte slice. - e.Write(c) - // Makes sure that this error type is an Error interface. c.Putln("func (err %s) ImplementsError() { }", e.ErrType()) c.Putln("") // Let's the XGB know how to read this error. c.Putln("func init() {") - c.Putln("newErrorFuncs[%d] = New%s", e.Number, e.SrcName()) + c.Putln("newErrorFuncs[%d] = New%s", e.Number, e.ErrType()) c.Putln("}") c.Putln("") } func (e *ErrorCopy) Read(c *Context) { - c.Putln("func New%s(buf []byte) %s {", e.SrcName(), e.ErrType()) - c.Putln("return (%s)(New%s(buf))", e.ErrType(), e.Old.SrcName()) - c.Putln("}") - c.Putln("") -} - -func (e *ErrorCopy) Write(c *Context) { - c.Putln("func (err %s) Bytes() []byte {", e.ErrType()) - c.Putln("return (%s)(err).Bytes()", e.Old.(*Error).ErrType()) + c.Putln("func New%s(buf []byte) %s {", e.ErrType(), e.ErrType()) + c.Putln("return %s(New%s(buf))", e.ErrType(), e.Old.(*Error).ErrType()) c.Putln("}") c.Putln("") } diff --git a/nexgb/xgbgen/go_event.go b/nexgb/xgbgen/go_event.go index e6d40b0..fe2a77e 100644 --- a/nexgb/xgbgen/go_event.go +++ b/nexgb/xgbgen/go_event.go @@ -4,8 +4,13 @@ package main func (e *Event) Define(c *Context) { c.Putln("// Event definition %s (%d)", e.SrcName(), e.Number) c.Putln("// Size: %s", e.Size()) + c.Putln("") + c.Putln("const %s = %d", e.SrcName(), e.Number) + c.Putln("") c.Putln("type %s struct {", e.EvType()) - c.Putln("Sequence uint16") + if !e.NoSequence { + c.Putln("Sequence uint16") + } for _, field := range e.Fields { field.Define(c) } @@ -16,7 +21,7 @@ func (e *Event) Define(c *Context) { // event struct. e.Read(c) - // Write defines a function that transoforms this event struct into + // Write defines a function that transforms this event struct into // a byte slice. e.Write(c) @@ -26,14 +31,14 @@ func (e *Event) Define(c *Context) { // Let's the XGB event loop read this event. c.Putln("func init() {") - c.Putln("newEventFuncs[%d] = New%s", e.Number, e.SrcName()) + c.Putln("newEventFuncs[%d] = New%s", e.Number, e.EvType()) c.Putln("}") c.Putln("") } func (e *Event) Read(c *Context) { c.Putln("// Event read %s", e.SrcName()) - c.Putln("func New%s(buf []byte) %s {", e.SrcName(), e.EvType()) + c.Putln("func New%s(buf []byte) %s {", e.EvType(), e.EvType()) c.Putln("v := %s{}", e.EvType()) c.Putln("b := 1 // don't read event number") c.Putln("") @@ -97,21 +102,21 @@ func (e *EventCopy) Define(c *Context) { // Let's the XGB event loop read this event. c.Putln("func init() {") - c.Putln("newEventFuncs[%d] = New%s", e.Number, e.SrcName()) + c.Putln("newEventFuncs[%d] = New%s", e.Number, e.EvType()) c.Putln("}") c.Putln("") } func (e *EventCopy) Read(c *Context) { - c.Putln("func New%s(buf []byte) %s {", e.SrcName(), e.EvType()) - c.Putln("return (%s)(New%s(buf))", e.EvType(), e.Old.SrcName()) + c.Putln("func New%s(buf []byte) %s {", e.EvType(), e.EvType()) + c.Putln("return %s(New%s(buf))", e.EvType(), e.Old.(*Event).EvType()) c.Putln("}") c.Putln("") } func (e *EventCopy) Write(c *Context) { c.Putln("func (v %s) Bytes() []byte {", e.EvType()) - c.Putln("return (%s)(ev).Bytes()", e.Old.(*Event).EvType()) + c.Putln("return %s(ev).Bytes()", e.Old.(*Event).EvType()) c.Putln("}") c.Putln("") } diff --git a/nexgb/xgbgen/go_list.go b/nexgb/xgbgen/go_list.go index a95ba71..67ecd34 100644 --- a/nexgb/xgbgen/go_list.go +++ b/nexgb/xgbgen/go_list.go @@ -41,7 +41,7 @@ func (f *ListField) Read(c *Context) { f.SrcName(), t.SrcName(), f.LengthExpr.Reduce("v.", "")) c.Putln("b += Read%sList(buf[b:], v.%s)", t.SrcName(), f.SrcName()) default: - log.Fatalf("Cannot read list field '%s' with %T type.", + log.Panicf("Cannot read list field '%s' with %T type.", f.XmlName(), f.Type) } } @@ -70,7 +70,7 @@ func (f *ListField) Write(c *Context) { case *Struct: c.Putln("b += %sListBytes(buf[b:], v.%s)", t.SrcName(), f.SrcName()) default: - log.Fatalf("Cannot read list field '%s' with %T type.", + log.Panicf("Cannot read list field '%s' with %T type.", f.XmlName(), f.Type) } } diff --git a/nexgb/xgbgen/go_reply.go b/nexgb/xgbgen/go_reply.go new file mode 100644 index 0000000..e561d9c --- /dev/null +++ b/nexgb/xgbgen/go_reply.go @@ -0,0 +1,19 @@ +package main + +func (r *Request) Define(c *Context) { + c.Putln("// Request %s", r.SrcName()) + c.Putln("// size: %s", r.Size(c)) + c.Putln("") + if r.Reply != nil { + c.Putln("// Request reply for %s", r.SrcName()) + c.Putln("// size: %s", r.Reply.Size()) + c.Putln("type %s struct {", r.ReplyName()) + c.Putln("Sequence uint16") + for _, field := range r.Reply.Fields { + field.Define(c) + } + c.Putln("}") + c.Putln("") + } +} + diff --git a/nexgb/xgbgen/representation.go b/nexgb/xgbgen/representation.go index 2d33a45..e5d2202 100644 --- a/nexgb/xgbgen/representation.go +++ b/nexgb/xgbgen/representation.go @@ -1,5 +1,10 @@ package main +import ( + "fmt" + "log" +) + type Protocol struct { Name string ExtXName string @@ -44,10 +49,58 @@ func (r *Request) Initialize(p *Protocol) { } } +func (r *Request) SrcName() string { + return r.srcName +} + +func (r *Request) XmlName() string { + return r.xmlName +} + +func (r *Request) ReplyName() string { + if r.Reply == nil { + log.Panicf("Cannot call 'ReplyName' on request %s, which has no reply.", + r.SrcName()) + } + return fmt.Sprintf("%sReply", r.SrcName()) +} + +// Size for Request needs a context. +// Namely, if this is an extension, we need to account for *four* bytes +// of a header (extension opcode, request opcode, and the sequence number). +// If it's a core protocol request, then we only account for *three* +// bytes of the header (remove the extension opcode). +func (r *Request) Size(c *Context) Size { + size := newFixedSize(0) + + if c.protocol.Name == "xproto" { + size = size.Add(newFixedSize(3)) + } else { + size = size.Add(newFixedSize(4)) + } + + for _, field := range r.Fields { + size = size.Add(field.Size()) + } + return size +} + type Reply struct { Fields []Field } +func (r *Reply) Size() Size { + size := newFixedSize(0) + + // Account for reply discriminant, sequence number and reply length + size = size.Add(newFixedSize(7)) + + for _, field := range r.Fields { + size = size.Add(field.Size()) + } + return size +} + func (r *Reply) Initialize(p *Protocol) { for _, field := range r.Fields { field.Initialize(p) diff --git a/nexgb/xgbgen/translation.go b/nexgb/xgbgen/translation.go index 36daa8b..9c7603b 100644 --- a/nexgb/xgbgen/translation.go +++ b/nexgb/xgbgen/translation.go @@ -210,11 +210,13 @@ func (x *XMLRequest) Translate() *Request { // computation of the 'odd_length' field. However, 'string_len' is not // defined. Therefore, let's forcefully add it as a 'local field'. // (i.e., a parameter in the caller but does not get send over the wire.) - stringLenLocal := &LocalField{&SingleField{ - xmlName: "string_len", - Type: newTranslation("CARD16"), - }} - r.Fields = append(r.Fields, stringLenLocal) + if x.Name == "QueryTextExtents" { + stringLenLocal := &LocalField{&SingleField{ + xmlName: "string_len", + Type: newTranslation("CARD16"), + }} + r.Fields = append(r.Fields, stringLenLocal) + } return r } diff --git a/nexgb/xgbgen/type.go b/nexgb/xgbgen/type.go index 1e06bda..d8e76a2 100644 --- a/nexgb/xgbgen/type.go +++ b/nexgb/xgbgen/type.go @@ -221,7 +221,7 @@ func (e *EventCopy) XmlName() string { } func (e *EventCopy) Size() Size { - panic("Cannot take size of EventCopy type.") + return newExpressionSize(&Value{v: 32}) } func (e *EventCopy) Initialize(p *Protocol) { @@ -252,11 +252,14 @@ func (e *Error) XmlName() string { } func (e *Error) Size() Size { - panic("Cannot take size of Error type.") + return newExpressionSize(&Value{v: 32}) } func (e *Error) Initialize(p *Protocol) { e.srcName = TypeSrcName(p, e) + for _, field := range e.Fields { + field.Initialize(p) + } } func (e *Error) ErrConst() string { @@ -283,7 +286,7 @@ func (e *ErrorCopy) XmlName() string { } func (e *ErrorCopy) Size() Size { - panic("Cannot take size of ErrorCopy type.") + return newExpressionSize(&Value{v: 32}) } func (e *ErrorCopy) Initialize(p *Protocol) { diff --git a/nexgb/xgbgen/xml.go b/nexgb/xgbgen/xml.go index f219c2d..1b2f89a 100644 --- a/nexgb/xgbgen/xml.go +++ b/nexgb/xgbgen/xml.go @@ -135,7 +135,7 @@ type XMLEvents []*XMLEvent type XMLEvent struct { Name string `xml:"name,attr"` Number int `xml:"number,attr"` - NoSequence bool `xml:"no-sequence-number,true"` + NoSequence bool `xml:"no-sequence-number,attr"` Fields XMLFields `xml:",any"` } -- cgit v1.2.3-70-g09d2 From 5cdae5950c357564300c0ee3fb4dc9e7bbf4946b Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Thu, 3 May 2012 01:00:01 -0400 Subject: holy toldeo... things might actually be working --- nexgb/xgb.go | 72 +- nexgb/xgb_help.go | 82 +- nexgb/xgbgen/context.go | 21 + nexgb/xgbgen/expression.go | 73 +- nexgb/xgbgen/field.go | 75 +- nexgb/xgbgen/go.go | 53 +- nexgb/xgbgen/go_error.go | 88 +- nexgb/xgbgen/go_event.go | 15 +- nexgb/xgbgen/go_list.go | 97 +- nexgb/xgbgen/go_reply.go | 19 - nexgb/xgbgen/go_request_reply.go | 140 + nexgb/xgbgen/go_single_field.go | 62 +- nexgb/xgbgen/go_struct.go | 19 +- nexgb/xgbgen/go_union.go | 17 +- nexgb/xgbgen/representation.go | 19 +- nexgb/xgbgen/translation.go | 17 +- nexgb/xgbgen/type.go | 12 + nexgb/xproto.go | 11215 +++++++++++++++++++++++++++++++++++++ 18 files changed, 11831 insertions(+), 265 deletions(-) delete mode 100644 nexgb/xgbgen/go_reply.go create mode 100644 nexgb/xgbgen/go_request_reply.go create mode 100644 nexgb/xproto.go (limited to 'nexgb/xgbgen/go_event.go') diff --git a/nexgb/xgb.go b/nexgb/xgb.go index ce2cc54..0dd8163 100644 --- a/nexgb/xgb.go +++ b/nexgb/xgb.go @@ -95,31 +95,20 @@ type Event interface { // newEventFuncs is a map from event numbers to functions that create // the corresponding event. -var newEventFuncs map[int]func(buf []byte) Event - -// Error contains protocol errors returned to us by the X server. -type Error struct { - Detail uint8 - Major uint8 - Minor uint16 - Cookie uint16 - Id Id -} +var newEventFuncs = map[int]func(buf []byte) Event{} -// Error2 is an interface that can contain any of the errors returned by +// Error is an interface that can contain any of the errors returned by // the server. Use a type assertion switch to extract the Error structs. -type Error2 interface { +type Error interface { ImplementsError() + SequenceId() uint16 + BadId() Id + Error() string } // newErrorFuncs is a map from error numbers to functions that create // the corresponding error. -var newErrorFuncs map[int]func(buf []byte) Error2 - -func (e *Error) Error() string { - return fmt.Sprintf("Bad%s (major=%d minor=%d cookie=%d id=0x%x)", - errorNames[e.Detail], e.Major, e.Minor, e.Cookie, e.Id) -} +var newErrorFuncs = map[int]func(buf []byte) Error{} // NewID generates a new unused ID for use with requests like CreateWindow. func (c *Conn) NewId() Id { @@ -136,7 +125,7 @@ func (c *Conn) NewId() Id { // the extensions map. func (c *Conn) RegisterExtension(name string) error { nameUpper := strings.ToUpper(name) - reply, err := c.QueryExtension(nameUpper) + reply, err := c.QueryExtension(uint16(len(nameUpper)), nameUpper) switch { case err != nil: @@ -253,25 +242,26 @@ func (c *Conn) newReadChannels() { switch buf[0] { case 0: - err := &Error{ - Detail: buf[1], - Cookie: uint16(get16(buf[2:])), - Id: Id(get32(buf[4:])), - Minor: get16(buf[8:]), - Major: buf[10], - } - if cookie, ok := c.cookies[err.Cookie]; ok { + // err := &Error{ + // Detail: buf[1], + // Cookie: uint16(get16(buf[2:])), + // Id: Id(get32(buf[4:])), + // Minor: get16(buf[8:]), + // Major: buf[10], + // } + err := newErrorFuncs[int(buf[1])](buf) + if cookie, ok := c.cookies[err.SequenceId()]; ok { cookie.errorChan <- err } else { fmt.Fprintf(os.Stderr, "x protocol error: %s\n", err) } case 1: - seq := uint16(get16(buf[2:])) + seq := uint16(Get16(buf[2:])) if _, ok := c.cookies[seq]; !ok { continue } - size := get32(buf[4:]) + size := Get32(buf[4:]) if size > 0 { bigbuf := make([]byte, 32+size*4, 32+size*4) copy(bigbuf[0:32], buf) @@ -317,7 +307,8 @@ func (c *Conn) waitForReply(cookie *Cookie) ([]byte, error) { func (c *Conn) WaitForEvent() (Event, error) { for { if reply := c.events.dequeue(c); reply != nil { - return parseEvent(reply) + evCode := reply[0] & 0x7f + return newEventFuncs[int(evCode)](reply), nil } if !<-c.eventChan { return nil, errors.New("Event channel has been closed.") @@ -331,7 +322,8 @@ func (c *Conn) WaitForEvent() (Event, error) { // Only use this function to empty the queue without blocking. func (c *Conn) PollForEvent() (Event, error) { if reply := c.events.dequeue(c); reply != nil { - return parseEvent(reply) + evCode := reply[0] & 0x7f + return newEventFuncs[int(evCode)](reply), nil } return nil, nil } @@ -369,11 +361,11 @@ func Dial(display string) (*Conn, error) { buf := make([]byte, 12+pad(len(authName))+pad(len(authData))) buf[0] = 0x6c buf[1] = 0 - put16(buf[2:], 11) - put16(buf[4:], 0) - put16(buf[6:], uint16(len(authName))) - put16(buf[8:], uint16(len(authData))) - put16(buf[10:], 0) + Put16(buf[2:], 11) + Put16(buf[4:], 0) + Put16(buf[6:], uint16(len(authName))) + Put16(buf[8:], uint16(len(authData))) + Put16(buf[10:], 0) copy(buf[12:], []byte(authName)) copy(buf[12+pad(len(authName)):], authData) if _, err = c.conn.Write(buf); err != nil { @@ -386,9 +378,9 @@ func Dial(display string) (*Conn, error) { } code := head[0] reasonLen := head[1] - major := get16(head[2:]) - minor := get16(head[4:]) - dataLen := get16(head[6:]) + major := Get16(head[2:]) + minor := Get16(head[4:]) + dataLen := Get16(head[6:]) if major != 11 || minor != 0 { return nil, errors.New(fmt.Sprintf("x protocol version mismatch: %d.%d", major, minor)) @@ -405,7 +397,7 @@ func Dial(display string) (*Conn, error) { return nil, errors.New(fmt.Sprintf("x protocol authentication refused: %s", string(reason))) } - getSetupInfo(buf, &c.Setup) + ReadSetupInfo(buf, &c.Setup) if c.defaultScreen >= len(c.Setup.Roots) { c.defaultScreen = 0 diff --git a/nexgb/xgb_help.go b/nexgb/xgb_help.go index acb35de..f7b4948 100644 --- a/nexgb/xgb_help.go +++ b/nexgb/xgb_help.go @@ -1,5 +1,10 @@ package xgb +import ( + "fmt" + "strings" +) + // getExtensionOpcode retrieves the extension opcode from the extensions map. // If one doesn't exist, just return 0. An X error will likely result. func (c *Conn) getExtensionOpcode(name string) byte { @@ -14,52 +19,50 @@ func (c *Conn) bytesString(str string) []byte { return c.bytesPadding([]byte(str)) } -func (c *Conn) bytesStrList(list []Str, length int) []byte { - buf := make([]byte, 0) - for _, str := range list { - buf = append(buf, []byte(str.Name)...) - } - return c.bytesPadding(buf) -} - -func (c *Conn) bytesUInt32List(list []uint32) []byte { - buf := make([]byte, len(list)*4) - for i, item := range list { - put32(buf[i*4:], item) - } - return c.bytesPadding(buf) +// stringsJoin is an alias to strings.Join. It allows us to avoid having to +// import 'strings' in each of the generated Go files. +func stringsJoin(ss []string, sep string) string { + return strings.Join(ss, sep) } -func (c *Conn) bytesIdList(list []Id, length int) []byte { - buf := make([]byte, length*4) - for i, item := range list { - put32(buf[i*4:], uint32(item)) - } - return c.bytesPadding(buf) +// sprintf is so we don't need to import 'fmt' in the generated Go files. +func sprintf(format string, v ...interface{}) string { + return fmt.Sprintf(format, v...) } // Pad a length to align on 4 bytes. func pad(n int) int { return (n + 3) & ^3 } -func put16(buf []byte, v uint16) { +func Put16(buf []byte, v uint16) { + buf[0] = byte(v) + buf[1] = byte(v >> 8) +} + +func Put32(buf []byte, v uint32) { buf[0] = byte(v) buf[1] = byte(v >> 8) + buf[2] = byte(v >> 16) + buf[3] = byte(v >> 24) } -func put32(buf []byte, v uint32) { +func Put64(buf []byte, v uint64) { buf[0] = byte(v) buf[1] = byte(v >> 8) buf[2] = byte(v >> 16) buf[3] = byte(v >> 24) + buf[4] = byte(v >> 32) + buf[5] = byte(v >> 40) + buf[6] = byte(v >> 48) + buf[7] = byte(v >> 56) } -func get16(buf []byte) uint16 { +func Get16(buf []byte) uint16 { v := uint16(buf[0]) v |= uint16(buf[1]) << 8 return v } -func get32(buf []byte) uint32 { +func Get32(buf []byte) uint32 { v := uint32(buf[0]) v |= uint32(buf[1]) << 8 v |= uint32(buf[2]) << 16 @@ -67,6 +70,18 @@ func get32(buf []byte) uint32 { return v } +func Get64(buf []byte) uint64 { + v := uint64(buf[0]) + v |= uint64(buf[1]) << 8 + v |= uint64(buf[2]) << 16 + v |= uint64(buf[3]) << 24 + v |= uint64(buf[4]) << 32 + v |= uint64(buf[5]) << 40 + v |= uint64(buf[6]) << 48 + v |= uint64(buf[7]) << 56 + return v +} + // Voodoo to count the number of bits set in a value list mask. func popCount(mask0 int) int { mask := uint32(mask0) @@ -82,22 +97,3 @@ func popCount(mask0 int) int { // DefaultScreen returns the Screen info for the default screen, which is // 0 or the one given in the display argument to Dial. func (c *Conn) DefaultScreen() *ScreenInfo { return &c.Setup.Roots[c.defaultScreen] } - -// ClientMessageData holds the data from a client message, -// duplicated in three forms because Go doesn't have unions. -// type ClientMessageData struct { - // Data8 [20]byte - // Data16 [10]uint16 - // Data32 [5]uint32 -// } -// -// func getClientMessageData(b []byte, v *ClientMessageData) int { - // copy(v.Data8[:], b) - // for i := 0; i < 10; i++ { - // v.Data16[i] = get16(b[i*2:]) - // } - // for i := 0; i < 5; i++ { - // v.Data32[i] = get32(b[i*4:]) - // } - // return 20 -// } diff --git a/nexgb/xgbgen/context.go b/nexgb/xgbgen/context.go index 33641b3..3e484f3 100644 --- a/nexgb/xgbgen/context.go +++ b/nexgb/xgbgen/context.go @@ -5,6 +5,7 @@ import ( "encoding/xml" "fmt" "log" + "time" ) type Context struct { @@ -47,6 +48,26 @@ func (c *Context) Morph(xmlBytes []byte) { // Translate XML types to nice types c.protocol = parsedXml.Translate() + // Start with Go header. + c.Putln("package xgb") + c.Putln("") + c.Putln("/*") + c.Putln("\tThis file was generated by %s.xml on %s.", + c.protocol.Name, time.Now().Format("Jan 2 2006 3:04:05pm MST")) + c.Putln("\tThis file is automatically generated. Edit at your peril!") + c.Putln("*/") + c.Putln("") + + // Write imports in comments + if len(c.protocol.Imports) > 0 { + c.Putln("// Imports are not necessary for XGB because everything is ") + c.Putln("// in one package. They are still listed here for reference.") + for _, imp := range c.protocol.Imports { + c.Putln("// import \"%s\"", imp.Name) + } + c.Putln("") + } + // Now write Go source code for _, typ := range c.protocol.Types { typ.Define(c) diff --git a/nexgb/xgbgen/expression.go b/nexgb/xgbgen/expression.go index a975320..12bcb19 100644 --- a/nexgb/xgbgen/expression.go +++ b/nexgb/xgbgen/expression.go @@ -8,7 +8,7 @@ import ( type Expression interface { Concrete() bool Eval() uint - Reduce(prefix, fun string) string + Reduce(prefix string) string String() string Initialize(p *Protocol) } @@ -29,12 +29,12 @@ func (e *Function) Eval() uint { panic("unreachable") } -func (e *Function) Reduce(prefix, fun string) string { - return fmt.Sprintf("%s(%s)", e.Name, e.Expr.Reduce(prefix, fun)) +func (e *Function) Reduce(prefix string) string { + return fmt.Sprintf("%s(%s)", e.Name, e.Expr.Reduce(prefix)) } func (e *Function) String() string { - return e.Reduce("", "") + return e.Reduce("") } func (e *Function) Initialize(p *Protocol) { @@ -89,16 +89,34 @@ func (e *BinaryOp) Eval() uint { panic("unreachable") } -func (e *BinaryOp) Reduce(prefix, fun string) string { +func (e *BinaryOp) Reduce(prefix string) string { if e.Concrete() { return fmt.Sprintf("%d", e.Eval()) } + + // An incredibly dirty hack to make sure any time we perform an operation + // on a field, we're dealing with ints... + expr1, expr2 := e.Expr1, e.Expr2 + switch expr1.(type) { + case *FieldRef: + expr1 = &Function{ + Name: "int", + Expr: expr1, + } + } + switch expr2.(type) { + case *FieldRef: + expr2 = &Function{ + Name: "int", + Expr: expr2, + } + } return fmt.Sprintf("(%s %s %s)", - e.Expr1.Reduce(prefix, fun), e.Op, e.Expr2.Reduce(prefix, fun)) + expr1.Reduce(prefix), e.Op, expr2.Reduce(prefix)) } func (e *BinaryOp) String() string { - return e.Reduce("", "") + return e.Reduce("") } func (e *BinaryOp) Initialize(p *Protocol) { @@ -125,15 +143,15 @@ func (e *UnaryOp) Eval() uint { panic("unreachable") } -func (e *UnaryOp) Reduce(prefix, fun string) string { +func (e *UnaryOp) Reduce(prefix string) string { if e.Concrete() { return fmt.Sprintf("%d", e.Eval()) } - return fmt.Sprintf("(%s (%s))", e.Op, e.Expr.Reduce(prefix, fun)) + return fmt.Sprintf("(%s (%s))", e.Op, e.Expr.Reduce(prefix)) } func (e *UnaryOp) String() string { - return e.Reduce("", "") + return e.Reduce("") } func (e *UnaryOp) Initialize(p *Protocol) { @@ -152,15 +170,15 @@ func (e *PopCount) Eval() uint { return popCount(e.Expr.Eval()) } -func (e *PopCount) Reduce(prefix, fun string) string { +func (e *PopCount) Reduce(prefix string) string { if e.Concrete() { return fmt.Sprintf("%d", e.Eval()) } - return fmt.Sprintf("popCount(%s)", e.Expr.Reduce(prefix, fun)) + return fmt.Sprintf("popCount(%s)", e.Expr.Reduce(prefix)) } func (e *PopCount) String() string { - return e.Reduce("", "") + return e.Reduce("") } func (e *PopCount) Initialize(p *Protocol) { @@ -179,12 +197,12 @@ func (e *Value) Eval() uint { return e.v } -func (e *Value) Reduce(prefix, fun string) string { +func (e *Value) Reduce(prefix string) string { return fmt.Sprintf("%d", e.v) } func (e *Value) String() string { - return e.Reduce("", "") + return e.Reduce("") } func (e *Value) Initialize(p *Protocol) {} @@ -201,12 +219,12 @@ func (e *Bit) Eval() uint { return 1 << e.b } -func (e *Bit) Reduce(prefix, fun string) string { +func (e *Bit) Reduce(prefix string) string { return fmt.Sprintf("%d", e.Eval()) } func (e *Bit) String() string { - return e.Reduce("", "") + return e.Reduce("") } func (e *Bit) Initialize(p *Protocol) {} @@ -224,19 +242,16 @@ func (e *FieldRef) Eval() uint { panic("unreachable") } -func (e *FieldRef) Reduce(prefix, fun string) string { +func (e *FieldRef) Reduce(prefix string) string { val := e.Name if len(prefix) > 0 { val = fmt.Sprintf("%s%s", prefix, val) } - if len(fun) > 0 { - val = fmt.Sprintf("%s(%s)", fun, val) - } return val } func (e *FieldRef) String() string { - return e.Reduce("", "") + return e.Reduce("") } func (e *FieldRef) Initialize(p *Protocol) { @@ -257,16 +272,12 @@ func (e *EnumRef) Eval() uint { panic("unreachable") } -func (e *EnumRef) Reduce(prefix, fun string) string { - val := fmt.Sprintf("%s%s", e.EnumKind, e.EnumItem) - if len(fun) > 0 { - val = fmt.Sprintf("%s(%s)", fun, val) - } - return val +func (e *EnumRef) Reduce(prefix string) string { + return fmt.Sprintf("%s%s", e.EnumKind, e.EnumItem) } func (e *EnumRef) String() string { - return e.Reduce("", "") + return e.Reduce("") } func (e *EnumRef) Initialize(p *Protocol) { @@ -287,7 +298,7 @@ func (e *SumOf) Eval() uint { panic("unreachable") } -func (e *SumOf) Reduce(prefix, fun string) string { +func (e *SumOf) Reduce(prefix string) string { if len(prefix) > 0 { return fmt.Sprintf("sum(%s%s)", prefix, e.Name) } @@ -295,7 +306,7 @@ func (e *SumOf) Reduce(prefix, fun string) string { } func (e *SumOf) String() string { - return e.Reduce("", "") + return e.Reduce("") } func (e *SumOf) Initialize(p *Protocol) { diff --git a/nexgb/xgbgen/field.go b/nexgb/xgbgen/field.go index 8d8412c..ddc2028 100644 --- a/nexgb/xgbgen/field.go +++ b/nexgb/xgbgen/field.go @@ -3,6 +3,7 @@ package main import ( "fmt" "log" + "strings" ) type Field interface { @@ -13,8 +14,8 @@ type Field interface { Size() Size Define(c *Context) - Read(c *Context) - Write(c *Context) + Read(c *Context, prefix string) + Write(c *Context, prefix string) } func (pad *PadField) Initialize(p *Protocol) {} @@ -32,7 +33,7 @@ func (p *PadField) XmlName() string { } func (f *PadField) SrcType() string { - panic("it is illegal to call SrcType on a SwitchField field") + panic("it is illegal to call SrcType on a PadField field") } func (p *PadField) Size() Size { @@ -82,22 +83,48 @@ func (f *ListField) XmlName() string { } func (f *ListField) SrcType() string { + if strings.ToLower(f.Type.XmlName()) == "char" { + return fmt.Sprintf("string") + } return fmt.Sprintf("[]%s", f.Type.SrcName()) } +func (f *ListField) Length() Size { + if f.LengthExpr == nil { + return newExpressionSize(&Function{ + Name: "len", + Expr: &FieldRef{ + Name: f.SrcName(), + }, + }) + } + return newExpressionSize(f.LengthExpr) +} + func (f *ListField) Size() Size { simpleLen := &Function{ Name: "pad", - Expr: newBinaryOp("*", f.LengthExpr, f.Type.Size().Expression), + Expr: newBinaryOp("*", f.Length().Expression, f.Type.Size().Expression), } - switch f.Type.(type) { + switch field := f.Type.(type) { case *Struct: - sizeFun := &Function{ - Name: fmt.Sprintf("%sListSize", f.Type.SrcName()), - Expr: &FieldRef{Name: f.SrcName()}, + if field.HasList() { + sizeFun := &Function{ + Name: fmt.Sprintf("%sListSize", f.Type.SrcName()), + Expr: &FieldRef{Name: f.SrcName()}, + } + return newExpressionSize(sizeFun) + } else { + return newExpressionSize(simpleLen) } - return newExpressionSize(sizeFun) + case *Union: + return newExpressionSize(simpleLen) + // sizeFun := &Function{ + // Name: fmt.Sprintf("%sListSize", f.Type.SrcName()), + // Expr: &FieldRef{Name: f.SrcName()}, + // } + // return newExpressionSize(sizeFun) case *Base: return newExpressionSize(simpleLen) case *Resource: @@ -152,6 +179,7 @@ func (f *ExprField) Initialize(p *Protocol) { } type ValueField struct { + Parent interface{} MaskType Type MaskName string ListName string @@ -170,7 +198,34 @@ func (f *ValueField) SrcType() string { } func (f *ValueField) Size() Size { - return f.MaskType.Size() + maskSize := f.MaskType.Size() + listSize := newExpressionSize(&Function{ + Name: "pad", + Expr: &BinaryOp{ + Op: "*", + Expr1: &Value{v: 4}, + Expr2: &PopCount{ + Expr: &Function{ + Name: "int", + Expr: &FieldRef{ + Name: f.MaskName, + }, + }, + }, + }, + }) + return maskSize.Add(listSize) +} + +func (f *ValueField) ListLength() Size { + return newExpressionSize(&PopCount{ + Expr: &Function{ + Name: "int", + Expr: &FieldRef{ + Name: f.MaskName, + }, + }, + }) } func (f *ValueField) Initialize(p *Protocol) { diff --git a/nexgb/xgbgen/go.go b/nexgb/xgbgen/go.go index b7b153e..771cfcf 100644 --- a/nexgb/xgbgen/go.go +++ b/nexgb/xgbgen/go.go @@ -1,5 +1,9 @@ package main +import ( + "fmt" +) + // xgbResourceIdName is the name of the type used for all resource identifiers. // As of right now, it needs to be declared somewhere manually. var xgbGenResourceIdName = "Id" @@ -94,26 +98,28 @@ func (f *PadField) Define(c *Context) { c.Putln("// padding: %d bytes", f.Bytes) } -func (f *PadField) Read(c *Context) { +func (f *PadField) Read(c *Context, prefix string) { c.Putln("b += %s // padding", f.Size()) } -func (f *PadField) Write(c *Context) { +func (f *PadField) Write(c *Context, prefix string) { c.Putln("b += %s // padding", f.Size()) } // Local fields func (f *LocalField) Define(c *Context) { c.Putln("// local field: %s %s", f.SrcName(), f.Type.SrcName()) + panic("unreachable") } -func (f *LocalField) Read(c *Context) { +func (f *LocalField) Read(c *Context, prefix string) { c.Putln("// reading local field: %s (%s) :: %s", f.SrcName(), f.Size(), f.Type.SrcName()) + panic("unreachable") } -func (f *LocalField) Write(c *Context) { - c.Putln("// writing local field: %s (%s) :: %s", +func (f *LocalField) Write(c *Context, prefix string) { + c.Putln("// skip writing local field: %s (%s) :: %s", f.SrcName(), f.Size(), f.Type.SrcName()) } @@ -121,32 +127,49 @@ func (f *LocalField) Write(c *Context) { func (f *ExprField) Define(c *Context) { c.Putln("// expression field: %s %s (%s)", f.SrcName(), f.Type.SrcName(), f.Expr) + panic("unreachable") } -func (f *ExprField) Read(c *Context) { +func (f *ExprField) Read(c *Context, prefix string) { c.Putln("// reading expression field: %s (%s) (%s) :: %s", f.SrcName(), f.Size(), f.Expr, f.Type.SrcName()) + panic("unreachable") } -func (f *ExprField) Write(c *Context) { - c.Putln("// writing expression field: %s (%s) (%s) :: %s", - f.SrcName(), f.Size(), f.Expr, f.Type.SrcName()) +func (f *ExprField) Write(c *Context, prefix string) { + // Special case for bools, grrr. + if f.Type.SrcName() == "bool" { + c.Putln("buf[b] = byte(%s)", f.Expr.Reduce(prefix)) + c.Putln("b += 1") + } else { + WriteSimpleSingleField(c, f.Expr.Reduce(prefix), f.Type) + } } // Value field func (f *ValueField) Define(c *Context) { c.Putln("// valueparam field: type: %s, mask name: %s, list name: %s", f.MaskType.SrcName(), f.MaskName, f.ListName) + panic("todo") } -func (f *ValueField) Read(c *Context) { +func (f *ValueField) Read(c *Context, prefix string) { c.Putln("// reading valueparam: type: %s, mask name: %s, list name: %s", f.MaskType.SrcName(), f.MaskName, f.ListName) + panic("todo") } -func (f *ValueField) Write(c *Context) { - c.Putln("// writing valueparam: type: %s, mask name: %s, list name: %s", - f.MaskType.SrcName(), f.MaskName, f.ListName) +func (f *ValueField) Write(c *Context, prefix string) { + // big time mofos + if rq, ok := f.Parent.(*Request); !ok || rq.SrcName() != "ConfigureWindow" { + WriteSimpleSingleField(c, + fmt.Sprintf("%s%s", prefix, f.MaskName), f.MaskType) + } + c.Putln("for i := 0; i < %s; i++ {", f.ListLength().Reduce(prefix)) + c.Putln("Put32(buf[b:], %s%s[i])", prefix, f.ListName) + c.Putln("b += 4") + c.Putln("}") + c.Putln("b = pad(b)") } // Switch field @@ -155,12 +178,12 @@ func (f *SwitchField) Define(c *Context) { panic("todo") } -func (f *SwitchField) Read(c *Context) { +func (f *SwitchField) Read(c *Context, prefix string) { c.Putln("// reading switch field: %s (%s)", f.Name, f.Expr) panic("todo") } -func (f *SwitchField) Write(c *Context) { +func (f *SwitchField) Write(c *Context, prefix string) { c.Putln("// writing switch field: %s (%s)", f.Name, f.Expr) panic("todo") } diff --git a/nexgb/xgbgen/go_error.go b/nexgb/xgbgen/go_error.go index 17c0db5..5a51064 100644 --- a/nexgb/xgbgen/go_error.go +++ b/nexgb/xgbgen/go_error.go @@ -1,5 +1,9 @@ package main +import ( + "fmt" +) + // Error types func (e *Error) Define(c *Context) { c.Putln("// Error definition %s (%d)", e.SrcName(), e.Number) @@ -20,9 +24,8 @@ func (e *Error) Define(c *Context) { // error struct. e.Read(c) - // Makes sure that this error type is an Error interface. - c.Putln("func (v %s) ImplementsError() { }", e.ErrType()) - c.Putln("") + // Makes sure this error type implements the xgb.Error interface. + e.ImplementsError(c) // Let's the XGB event loop read this error. c.Putln("func init() {") @@ -33,18 +36,18 @@ func (e *Error) Define(c *Context) { func (e *Error) Read(c *Context) { c.Putln("// Error read %s", e.SrcName()) - c.Putln("func New%s(buf []byte) %s {", e.ErrType(), e.ErrType()) + c.Putln("func New%s(buf []byte) Error {", e.ErrType()) c.Putln("v := %s{}", e.ErrType()) c.Putln("v.NiceName = \"%s\"", e.SrcName()) c.Putln("") c.Putln("b := 1 // skip error determinant") c.Putln("b += 1 // don't read error number") c.Putln("") - c.Putln("v.Sequence = get16(buf[b:])") + c.Putln("v.Sequence = Get16(buf[b:])") c.Putln("b += 2") c.Putln("") for _, field := range e.Fields { - field.Read(c) + field.Read(c, "v.") c.Putln("") } c.Putln("return v") @@ -52,6 +55,24 @@ func (e *Error) Read(c *Context) { c.Putln("") } +// ImplementsError writes functions to implement the XGB Error interface. +func (e *Error) ImplementsError(c *Context) { + c.Putln("func (err %s) ImplementsError() { }", e.ErrType()) + c.Putln("") + c.Putln("func (err %s) SequenceId() uint16 {", e.ErrType()) + c.Putln("return err.Sequence") + c.Putln("}") + c.Putln("") + c.Putln("func (err %s) BadId() Id {", e.ErrType()) + c.Putln("return Id(err.BadValue)") + c.Putln("}") + c.Putln("") + c.Putln("func (err %s) Error() string {", e.ErrType()) + FieldString(c, e.Fields, e.ErrConst()) + c.Putln("}") + c.Putln("") +} + // ErrorCopy types func (e *ErrorCopy) Define(c *Context) { c.Putln("// ErrorCopy definition %s (%d)", e.SrcName(), e.Number) @@ -65,9 +86,8 @@ func (e *ErrorCopy) Define(c *Context) { // error struct. e.Read(c) - // Makes sure that this error type is an Error interface. - c.Putln("func (err %s) ImplementsError() { }", e.ErrType()) - c.Putln("") + // Makes sure this error type implements the xgb.Error interface. + e.ImplementsError(c) // Let's the XGB know how to read this error. c.Putln("func init() {") @@ -77,8 +97,54 @@ func (e *ErrorCopy) Define(c *Context) { } func (e *ErrorCopy) Read(c *Context) { - c.Putln("func New%s(buf []byte) %s {", e.ErrType(), e.ErrType()) - c.Putln("return %s(New%s(buf))", e.ErrType(), e.Old.(*Error).ErrType()) + c.Putln("func New%s(buf []byte) Error {", e.ErrType()) + c.Putln("v := %s(New%s(buf).(%s))", + e.ErrType(), e.Old.(*Error).ErrType(), e.Old.(*Error).ErrType()) + c.Putln("v.NiceName = \"%s\"", e.SrcName()) + c.Putln("return v") + c.Putln("}") + c.Putln("") +} + +// ImplementsError writes functions to implement the XGB Error interface. +func (e *ErrorCopy) ImplementsError(c *Context) { + c.Putln("func (err %s) ImplementsError() { }", e.ErrType()) + c.Putln("") + c.Putln("func (err %s) SequenceId() uint16 {", e.ErrType()) + c.Putln("return err.Sequence") c.Putln("}") c.Putln("") + c.Putln("func (err %s) BadId() Id {", e.ErrType()) + c.Putln("return Id(err.BadValue)") + c.Putln("}") + c.Putln("") + c.Putln("func (err %s) Error() string {", e.ErrType()) + FieldString(c, e.Old.(*Error).Fields, e.ErrConst()) + c.Putln("}") + c.Putln("") +} + +// FieldString works for both Error and ErrorCopy. It assembles all of the +// fields in an error and formats them into a single string. +func FieldString(c *Context, fields []Field, errName string) { + c.Putln("fieldVals := make([]string, 0, %d)", len(fields)) + c.Putln("fieldVals = append(fieldVals, \"NiceName: \" + err.NiceName)") + c.Putln("fieldVals = append(fieldVals, " + + "sprintf(\"Sequence: %s\", err.Sequence))", "%d") + for _, field := range fields { + switch field.(type) { + case *PadField: + continue + default: + if field.SrcType() == "string" { + c.Putln("fieldVals = append(fieldVals, \"%s: \" + err.%s)", + field.SrcName(), field.SrcName()) + } else { + format := fmt.Sprintf("sprintf(\"%s: %s\", err.%s)", + field.SrcName(), "%d", field.SrcName()) + c.Putln("fieldVals = append(fieldVals, %s)", format) + } + } + } + c.Putln("return \"%s {\" + stringsJoin(fieldVals, \", \") + \"}\"", errName) } diff --git a/nexgb/xgbgen/go_event.go b/nexgb/xgbgen/go_event.go index fe2a77e..71252a7 100644 --- a/nexgb/xgbgen/go_event.go +++ b/nexgb/xgbgen/go_event.go @@ -38,17 +38,17 @@ func (e *Event) Define(c *Context) { func (e *Event) Read(c *Context) { c.Putln("// Event read %s", e.SrcName()) - c.Putln("func New%s(buf []byte) %s {", e.EvType(), e.EvType()) + c.Putln("func New%s(buf []byte) Event {", e.EvType()) c.Putln("v := %s{}", e.EvType()) c.Putln("b := 1 // don't read event number") c.Putln("") for i, field := range e.Fields { if i == 1 && !e.NoSequence { - c.Putln("v.Sequence = get16(buf[b:])") + c.Putln("v.Sequence = Get16(buf[b:])") c.Putln("b += 2") c.Putln("") } - field.Read(c) + field.Read(c, "v.") c.Putln("") } c.Putln("return v") @@ -71,7 +71,7 @@ func (e *Event) Write(c *Context) { c.Putln("b += 2 // skip sequence number") c.Putln("") } - field.Write(c) + field.Write(c, "v.") c.Putln("") } c.Putln("return buf") @@ -108,15 +108,16 @@ func (e *EventCopy) Define(c *Context) { } func (e *EventCopy) Read(c *Context) { - c.Putln("func New%s(buf []byte) %s {", e.EvType(), e.EvType()) - c.Putln("return %s(New%s(buf))", e.EvType(), e.Old.(*Event).EvType()) + c.Putln("func New%s(buf []byte) Event {", e.EvType()) + c.Putln("return %s(New%s(buf).(%s))", + e.EvType(), e.Old.(*Event).EvType(), e.Old.(*Event).EvType()) c.Putln("}") c.Putln("") } func (e *EventCopy) Write(c *Context) { c.Putln("func (v %s) Bytes() []byte {", e.EvType()) - c.Putln("return %s(ev).Bytes()", e.Old.(*Event).EvType()) + c.Putln("return %s(v).Bytes()", e.Old.(*Event).EvType()) c.Putln("}") c.Putln("") } diff --git a/nexgb/xgbgen/go_list.go b/nexgb/xgbgen/go_list.go index 67ecd34..41cfb76 100644 --- a/nexgb/xgbgen/go_list.go +++ b/nexgb/xgbgen/go_list.go @@ -3,74 +3,107 @@ package main import ( "fmt" "log" + "strings" ) // List fields func (f *ListField) Define(c *Context) { - c.Putln("%s []%s // size: %s", - f.SrcName(), f.Type.SrcName(), f.Size()) + c.Putln("%s %s // size: %s", + f.SrcName(), f.SrcType(), f.Size()) } -func (f *ListField) Read(c *Context) { +func (f *ListField) Read(c *Context, prefix string) { switch t := f.Type.(type) { case *Resource: - length := f.LengthExpr.Reduce("v.", "") - c.Putln("v.%s = make([]Id, %s)", f.SrcName(), length) - c.Putln("for i := 0; i < %s; i++ {", length) - ReadSimpleSingleField(c, fmt.Sprintf("v.%s[i]", f.SrcName()), t) + length := f.LengthExpr.Reduce(prefix) + c.Putln("%s%s = make([]Id, %s)", prefix, f.SrcName(), length) + c.Putln("for i := 0; i < int(%s); i++ {", length) + ReadSimpleSingleField(c, fmt.Sprintf("%s%s[i]", prefix, f.SrcName()), t) c.Putln("}") c.Putln("b = pad(b)") case *Base: - length := f.LengthExpr.Reduce("v.", "") - c.Putln("v.%s = make([]%s, %s)", f.SrcName(), t.SrcName(), length) - if t.SrcName() == "byte" { - c.Putln("copy(v.%s[:%s], buf[b:])", f.SrcName(), length) - c.Putln("b += pad(%s)", length) + length := f.LengthExpr.Reduce(prefix) + if strings.ToLower(t.XmlName()) == "char" { + c.Putln("{") + c.Putln("byteString := make([]%s, %s)", t.SrcName(), length) + c.Putln("copy(byteString[:%s], buf[b:])", length) + c.Putln("%s%s = string(byteString)", prefix, f.SrcName()) + c.Putln("b += pad(int(%s))", length) + c.Putln("}") + } else if t.SrcName() == "byte" { + c.Putln("%s%s = make([]%s, %s)", + prefix, f.SrcName(), t.SrcName(), length) + c.Putln("copy(%s%s[:%s], buf[b:])", prefix, f.SrcName(), length) + c.Putln("b += pad(int(%s))", length) } else { - c.Putln("for i := 0; i < %s; i++ {", length) - ReadSimpleSingleField(c, fmt.Sprintf("v.%s[i]", f.SrcName()), t) + c.Putln("%s%s = make([]%s, %s)", + prefix, f.SrcName(), t.SrcName(), length) + c.Putln("for i := 0; i < int(%s); i++ {", length) + ReadSimpleSingleField(c, + fmt.Sprintf("%s%s[i]", prefix, f.SrcName()), t) c.Putln("}") c.Putln("b = pad(b)") } + case *TypeDef: + length := f.LengthExpr.Reduce(prefix) + c.Putln("%s%s = make([]%s, %s)", + prefix, f.SrcName(), t.SrcName(), length) + c.Putln("for i := 0; i < int(%s); i++ {", length) + ReadSimpleSingleField(c, fmt.Sprintf("%s%s[i]", prefix, f.SrcName()), t) + c.Putln("}") + c.Putln("b = pad(b)") case *Union: - c.Putln("v.%s = make([]%s, %s)", - f.SrcName(), t.SrcName(), f.LengthExpr.Reduce("v.", "")) - c.Putln("b += Read%sList(buf[b:], v.%s)", t.SrcName(), f.SrcName()) + c.Putln("%s%s = make([]%s, %s)", + prefix, f.SrcName(), t.SrcName(), f.LengthExpr.Reduce(prefix)) + c.Putln("b += Read%sList(buf[b:], %s%s)", + t.SrcName(), prefix, f.SrcName()) case *Struct: - c.Putln("v.%s = make([]%s, %s)", - f.SrcName(), t.SrcName(), f.LengthExpr.Reduce("v.", "")) - c.Putln("b += Read%sList(buf[b:], v.%s)", t.SrcName(), f.SrcName()) + c.Putln("%s%s = make([]%s, %s)", + prefix, f.SrcName(), t.SrcName(), f.LengthExpr.Reduce(prefix)) + c.Putln("b += Read%sList(buf[b:], %s%s)", + t.SrcName(), prefix, f.SrcName()) default: log.Panicf("Cannot read list field '%s' with %T type.", f.XmlName(), f.Type) } } -func (f *ListField) Write(c *Context) { +func (f *ListField) Write(c *Context, prefix string) { switch t := f.Type.(type) { case *Resource: - length := f.LengthExpr.Reduce("v.", "") - c.Putln("for i := 0; i < %s; i++", length) - WriteSimpleSingleField(c, fmt.Sprintf("v.%s[i]", f.SrcName()), t) + length := f.Length().Reduce(prefix) + c.Putln("for i := 0; i < int(%s); i++ {", length) + WriteSimpleSingleField(c, + fmt.Sprintf("%s%s[i]", prefix, f.SrcName()), t) c.Putln("}") c.Putln("b = pad(b)") case *Base: - length := f.LengthExpr.Reduce("v.", "") + length := f.Length().Reduce(prefix) if t.SrcName() == "byte" { - c.Putln("copy(buf[b:], v.%s[:%s])", f.SrcName(), length) - c.Putln("b += pad(%s)", length) + c.Putln("copy(buf[b:], %s%s[:%s])", prefix, f.SrcName(), length) + c.Putln("b += pad(int(%s))", length) } else { - c.Putln("for i := 0; i < %s; i++ {", length) - WriteSimpleSingleField(c, fmt.Sprintf("v.%s[i]", f.SrcName()), t) + c.Putln("for i := 0; i < int(%s); i++ {", length) + WriteSimpleSingleField(c, + fmt.Sprintf("%s%s[i]", prefix, f.SrcName()), t) c.Putln("}") c.Putln("b = pad(b)") } + case *TypeDef: + length := f.Length().Reduce(prefix) + c.Putln("for i := 0; i < int(%s); i++ {", length) + WriteSimpleSingleField(c, + fmt.Sprintf("%s%s[i]", prefix, f.SrcName()), t) + c.Putln("}") + c.Putln("b = pad(b)") case *Union: - c.Putln("b += %sListBytes(buf[b:], v.%s)", t.SrcName(), f.SrcName()) + c.Putln("b += %sListBytes(buf[b:], %s%s)", + t.SrcName(), prefix, f.SrcName()) case *Struct: - c.Putln("b += %sListBytes(buf[b:], v.%s)", t.SrcName(), f.SrcName()) + c.Putln("b += %sListBytes(buf[b:], %s%s)", + t.SrcName(), prefix, f.SrcName()) default: - log.Panicf("Cannot read list field '%s' with %T type.", + log.Panicf("Cannot write list field '%s' with %T type.", f.XmlName(), f.Type) } } diff --git a/nexgb/xgbgen/go_reply.go b/nexgb/xgbgen/go_reply.go deleted file mode 100644 index e561d9c..0000000 --- a/nexgb/xgbgen/go_reply.go +++ /dev/null @@ -1,19 +0,0 @@ -package main - -func (r *Request) Define(c *Context) { - c.Putln("// Request %s", r.SrcName()) - c.Putln("// size: %s", r.Size(c)) - c.Putln("") - if r.Reply != nil { - c.Putln("// Request reply for %s", r.SrcName()) - c.Putln("// size: %s", r.Reply.Size()) - c.Putln("type %s struct {", r.ReplyName()) - c.Putln("Sequence uint16") - for _, field := range r.Reply.Fields { - field.Define(c) - } - c.Putln("}") - c.Putln("") - } -} - diff --git a/nexgb/xgbgen/go_request_reply.go b/nexgb/xgbgen/go_request_reply.go new file mode 100644 index 0000000..e6180a1 --- /dev/null +++ b/nexgb/xgbgen/go_request_reply.go @@ -0,0 +1,140 @@ +package main + +import ( + "fmt" + "strings" +) + +func (r *Request) Define(c *Context) { + c.Putln("// Request %s", r.SrcName()) + c.Putln("// size: %s", r.Size(c)) + if r.Reply != nil { + c.Putln("func (c *Conn) %s(%s) (*%s, error) {", + r.SrcName(), r.ParamNameTypes(), r.ReplyName()) + c.Putln("return c.%s(c.%s(%s))", + r.ReplyName(), r.ReqName(), r.ParamNames()) + c.Putln("}") + c.Putln("") + + r.WriteRequest(c) + r.ReadReply(c) + } else { + c.Putln("// Write request to wire for %s", r.SrcName()) + c.Putln("func (c *Conn) %s(%s) {", r.SrcName(), r.ParamNameTypes()) + r.WriteRequestFields(c) + c.Putln("c.sendRequest(false, buf)") + c.Putln("}") + c.Putln("") + } +} + +func (r *Request) ReadReply(c *Context) { + c.Putln("// Request reply for %s", r.SrcName()) + c.Putln("// size: %s", r.Reply.Size()) + c.Putln("type %s struct {", r.ReplyName()) + c.Putln("Sequence uint16") + c.Putln("Length uint32") + for _, field := range r.Reply.Fields { + field.Define(c) + } + c.Putln("}") + c.Putln("") + + c.Putln("// Read reply %s", r.SrcName()) + c.Putln("func (c *Conn) %s(cook *Cookie) (*%s, error) {", + r.ReplyName(), r.ReplyName()) + c.Putln("buf, err := c.waitForReply(cook)") + c.Putln("if err != nil {") + c.Putln("return nil, err") + c.Putln("}") + c.Putln("") + c.Putln("v := new(%s)", r.ReplyName()) + c.Putln("b := 1 // skip reply determinant") + c.Putln("") + for i, field := range r.Reply.Fields { + if i == 1 { + c.Putln("v.Sequence = Get16(buf[b:])") + c.Putln("b += 2") + c.Putln("") + c.Putln("v.Length = Get32(buf[b:]) // 4-byte units") + c.Putln("b += 4") + c.Putln("") + } + field.Read(c, "v.") + c.Putln("") + } + c.Putln("return v, nil") + c.Putln("}") + c.Putln("") +} + +func (r *Request) WriteRequest(c *Context) { + c.Putln("// Write request to wire for %s", r.SrcName()) + c.Putln("func (c *Conn) %s(%s) *Cookie {", r.ReqName(), r.ParamNameTypes()) + r.WriteRequestFields(c) + c.Putln("return c.sendRequest(true, buf)") + c.Putln("}") + c.Putln("") +} + +func (r *Request) WriteRequestFields(c *Context) { + c.Putln("size := %s", r.Size(c)) + c.Putln("b := 0") + c.Putln("buf := make([]byte, size)") + c.Putln("") + c.Putln("buf[b] = %d // request opcode", r.Opcode) + c.Putln("b += 1") + c.Putln("") + for i, field := range r.Fields { + if i == 1 { + c.Putln("Put16(buf[b:], uint16(size / 4)) "+ + "// write request size in 4-byte units") + c.Putln("b += 2") + c.Putln("") + } + field.Write(c, "") + c.Putln("") + } +} + +func (r *Request) ParamNames() string { + names := make([]string, 0, len(r.Fields)) + for _, field := range r.Fields { + switch f := field.(type) { + case *ValueField: + names = append(names, f.MaskName) + names = append(names, f.ListName) + case *PadField: + continue + case *ExprField: + continue + default: + names = append(names, fmt.Sprintf("%s", field.SrcName())) + } + } + return strings.Join(names, ",") +} + +func (r *Request) ParamNameTypes() string { + nameTypes := make([]string, 0, len(r.Fields)) + for _, field := range r.Fields { + switch f := field.(type) { + case *ValueField: + // mofos... + if r.SrcName() != "ConfigureWindow" { + nameTypes = append(nameTypes, + fmt.Sprintf("%s %s", f.MaskName, f.MaskType.SrcName())) + } + nameTypes = append(nameTypes, + fmt.Sprintf("%s []uint32", f.ListName)) + case *PadField: + continue + case *ExprField: + continue + default: + nameTypes = append(nameTypes, + fmt.Sprintf("%s %s", field.SrcName(), field.SrcType())) + } + } + return strings.Join(nameTypes, ",") +} diff --git a/nexgb/xgbgen/go_single_field.go b/nexgb/xgbgen/go_single_field.go index bf31259..ea43d55 100644 --- a/nexgb/xgbgen/go_single_field.go +++ b/nexgb/xgbgen/go_single_field.go @@ -12,17 +12,17 @@ func (f *SingleField) Define(c *Context) { func ReadSimpleSingleField(c *Context, name string, typ Type) { switch t := typ.(type) { case *Resource: - c.Putln("%s = get32(buf[b:])", name) + c.Putln("%s = Id(Get32(buf[b:]))", name) case *TypeDef: switch t.Size().Eval() { case 1: c.Putln("%s = %s(buf[b])", name, t.SrcName()) case 2: - c.Putln("%s = %s(get16(buf[b:]))", name, t.SrcName()) + c.Putln("%s = %s(Get16(buf[b:]))", name, t.SrcName()) case 4: - c.Putln("%s = %s(get32(buf[b:]))", name, t.SrcName()) + c.Putln("%s = %s(Get32(buf[b:]))", name, t.SrcName()) case 8: - c.Putln("%s = %s(get64(buf[b:]))", name, t.SrcName()) + c.Putln("%s = %s(Get64(buf[b:]))", name, t.SrcName()) } case *Base: // If this is a bool, stop short and do something special. @@ -40,11 +40,11 @@ func ReadSimpleSingleField(c *Context, name string, typ Type) { case 1: val = fmt.Sprintf("buf[b]") case 2: - val = fmt.Sprintf("get16(buf[b:])") + val = fmt.Sprintf("Get16(buf[b:])") case 4: - val = fmt.Sprintf("get32(buf[b:])") + val = fmt.Sprintf("Get32(buf[b:])") case 8: - val = fmt.Sprintf("get64(buf[b:])") + val = fmt.Sprintf("Get64(buf[b:])") } // We need to convert base types if they aren't uintXX or byte @@ -61,20 +61,20 @@ func ReadSimpleSingleField(c *Context, name string, typ Type) { c.Putln("b += %s", typ.Size()) } -func (f *SingleField) Read(c *Context) { +func (f *SingleField) Read(c *Context, prefix string) { switch t := f.Type.(type) { case *Resource: - ReadSimpleSingleField(c, fmt.Sprintf("v.%s", f.SrcName()), t) + ReadSimpleSingleField(c, fmt.Sprintf("%s%s", prefix, f.SrcName()), t) case *TypeDef: - ReadSimpleSingleField(c, fmt.Sprintf("v.%s", f.SrcName()), t) + ReadSimpleSingleField(c, fmt.Sprintf("%s%s", prefix, f.SrcName()), t) case *Base: - ReadSimpleSingleField(c, fmt.Sprintf("v.%s", f.SrcName()), t) + ReadSimpleSingleField(c, fmt.Sprintf("%s%s", prefix, f.SrcName()), t) case *Struct: - c.Putln("v.%s = %s{}", f.SrcName(), t.SrcName()) - c.Putln("b += Read%s(buf[b:], &v.%s)", t.SrcName(), f.SrcName()) + c.Putln("%s%s = %s{}", prefix, f.SrcName(), t.SrcName()) + c.Putln("b += Read%s(buf[b:], &%s%s)", t.SrcName(), prefix, f.SrcName()) case *Union: - c.Putln("v.%s = %s{}", f.SrcName(), t.SrcName()) - c.Putln("b += Read%s(buf[b:], &v.%s)", t.SrcName(), f.SrcName()) + c.Putln("%s%s = %s{}", prefix, f.SrcName(), t.SrcName()) + c.Putln("b += Read%s(buf[b:], &%s%s)", t.SrcName(), prefix, f.SrcName()) default: log.Panicf("Cannot read field '%s' with %T type.", f.XmlName(), f.Type) } @@ -83,17 +83,17 @@ func (f *SingleField) Read(c *Context) { func WriteSimpleSingleField(c *Context, name string, typ Type) { switch t := typ.(type) { case *Resource: - c.Putln("put32(buf[b:], uint32(%s))", name) + c.Putln("Put32(buf[b:], uint32(%s))", name) case *TypeDef: switch t.Size().Eval() { case 1: c.Putln("buf[b] = byte(%s)", name) case 2: - c.Putln("put16(buf[b:], uint16(%s))", name) + c.Putln("Put16(buf[b:], uint16(%s))", name) case 4: - c.Putln("put32(buf[b:], uint32(%s))", name) + c.Putln("Put32(buf[b:], uint32(%s))", name) case 8: - c.Putln("put64(buf[b:], uint64(%s))", name) + c.Putln("Put64(buf[b:], uint64(%s))", name) } case *Base: // If this is a bool, stop short and do something special. @@ -115,21 +115,21 @@ func WriteSimpleSingleField(c *Context, name string, typ Type) { } case 2: if t.SrcName() != "uint16" { - c.Putln("put16(buf[b:], uint16(%s))", name) + c.Putln("Put16(buf[b:], uint16(%s))", name) } else { - c.Putln("put16(buf[b:], %s)", name) + c.Putln("Put16(buf[b:], %s)", name) } case 4: if t.SrcName() != "uint32" { - c.Putln("put32(buf[b:], uint32(%s))", name) + c.Putln("Put32(buf[b:], uint32(%s))", name) } else { - c.Putln("put32(buf[b:], %s)", name) + c.Putln("Put32(buf[b:], %s)", name) } case 8: if t.SrcName() != "uint64" { - c.Putln("put64(buf[b:], uint64(%s))", name) + c.Putln("Put64(buf[b:], uint64(%s))", name) } else { - c.Putln("put64(buf[b:], %s)", name) + c.Putln("Put64(buf[b:], %s)", name) } } default: @@ -140,23 +140,23 @@ func WriteSimpleSingleField(c *Context, name string, typ Type) { c.Putln("b += %s", typ.Size()) } -func (f *SingleField) Write(c *Context) { +func (f *SingleField) Write(c *Context, prefix string) { switch t := f.Type.(type) { case *Resource: - ReadSimpleSingleField(c, fmt.Sprintf("v.%s", f.SrcName()), t) + WriteSimpleSingleField(c, fmt.Sprintf("%s%s", prefix, f.SrcName()), t) case *TypeDef: - ReadSimpleSingleField(c, fmt.Sprintf("v.%s", f.SrcName()), t) + WriteSimpleSingleField(c, fmt.Sprintf("%s%s", prefix, f.SrcName()), t) case *Base: - ReadSimpleSingleField(c, fmt.Sprintf("v.%s", f.SrcName()), t) + WriteSimpleSingleField(c, fmt.Sprintf("%s%s", prefix, f.SrcName()), t) case *Union: c.Putln("{") - c.Putln("unionBytes := v.%s.Bytes()", f.SrcName()) + c.Putln("unionBytes := %s%s.Bytes()", prefix, f.SrcName()) c.Putln("copy(buf[b:], unionBytes)") c.Putln("b += pad(len(unionBytes))") c.Putln("}") case *Struct: c.Putln("{") - c.Putln("structBytes := v.%s.Bytes()", f.SrcName()) + c.Putln("structBytes := %s%s.Bytes()", prefix, f.SrcName()) c.Putln("copy(buf[b:], structBytes)") c.Putln("b += pad(len(structBytes))") c.Putln("}") diff --git a/nexgb/xgbgen/go_struct.go b/nexgb/xgbgen/go_struct.go index 600ebaf..1e43199 100644 --- a/nexgb/xgbgen/go_struct.go +++ b/nexgb/xgbgen/go_struct.go @@ -22,8 +22,11 @@ func (s *Struct) Define(c *Context) { // Write function that writes a list of this struct. s.WriteList(c) - // Write function that computes the size of a list of these structs. - s.WriteListSize(c) + // Write function that computes the size of a list of these structs, + // IF there is a list field in this struct. + if s.HasList() { + s.WriteListSize(c) + } } // Read for a struct creates a function 'ReadStructName' that takes a source @@ -37,7 +40,8 @@ func (s *Struct) Read(c *Context) { c.Putln("b := 0") c.Putln("") for _, field := range s.Fields { - field.Read(c) + field.Read(c, "v.") + c.Putln("") } c.Putln("return b") @@ -68,11 +72,12 @@ func (s *Struct) ReadList(c *Context) { func (s *Struct) Write(c *Context) { c.Putln("// Struct write %s", s.SrcName()) c.Putln("func (v %s) Bytes() []byte {", s.SrcName()) - c.Putln("buf := make([]byte, %s)", s.Size().Reduce("v.", "")) + c.Putln("buf := make([]byte, %s)", s.Size().Reduce("v.")) c.Putln("b := 0") c.Putln("") for _, field := range s.Fields { - field.Write(c) + field.Write(c, "v.") + c.Putln("") } c.Putln("return buf") c.Putln("}") @@ -87,7 +92,7 @@ func (s *Struct) WriteList(c *Context) { c.Putln("var structBytes []byte") c.Putln("for _, item := range list {") c.Putln("structBytes = item.Bytes()") - c.Putln("copy(buf[b:], len(structBytes))") + c.Putln("copy(buf[b:], structBytes)") c.Putln("b += pad(len(structBytes))") c.Putln("}") c.Putln("return b") @@ -100,7 +105,7 @@ func (s *Struct) WriteListSize(c *Context) { c.Putln("func %sListSize(list []%s) int {", s.SrcName(), s.SrcName()) c.Putln("size := 0") c.Putln("for _, item := range list {") - c.Putln("size += %s", s.Size().Reduce("item.", "")) + c.Putln("size += %s", s.Size().Reduce("item.")) c.Putln("}") c.Putln("return size") c.Putln("}") diff --git a/nexgb/xgbgen/go_union.go b/nexgb/xgbgen/go_union.go index 3b7365d..9f339af 100644 --- a/nexgb/xgbgen/go_union.go +++ b/nexgb/xgbgen/go_union.go @@ -34,9 +34,6 @@ func (u *Union) Define(c *Context) { // Write function that writes a list of this union. u.WriteList(c) - - // Write function that computes the size of a list of these unions. - u.WriteListSize(c) } func (u *Union) New(c *Context) { @@ -49,7 +46,7 @@ func (u *Union) New(c *Context) { c.Putln("var b int") c.Putln("buf := make([]byte, %s)", u.Size()) c.Putln("") - field.Write(c) + field.Write(c, "") c.Putln("") c.Putln("// Create the Union type") c.Putln("v := %s{}", u.SrcName()) @@ -58,7 +55,7 @@ func (u *Union) New(c *Context) { c.Putln("") for _, field2 := range u.Fields { c.Putln("b = 0 // always read the same bytes") - field2.Read(c) + field2.Read(c, "v.") c.Putln("") } c.Putln("return v") @@ -74,7 +71,7 @@ func (u *Union) Read(c *Context) { c.Putln("") for _, field := range u.Fields { c.Putln("b = 0 // re-read the same bytes") - field.Read(c) + field.Read(c, "v.") c.Putln("") } c.Putln("return %s", u.Size()) @@ -106,10 +103,10 @@ func (u *Union) Write(c *Context) { c.Putln("// Each field in a union must contain the same data.") c.Putln("// So simply pick the first field and write that to the wire.") c.Putln("func (v %s) Bytes() []byte {", u.SrcName()) - c.Putln("buf := make([]byte, %s)", u.Size().Reduce("v.", "")) + c.Putln("buf := make([]byte, %s)", u.Size().Reduce("v.")) c.Putln("b := 0") c.Putln("") - u.Fields[0].Write(c) + u.Fields[0].Write(c, "v.") c.Putln("return buf") c.Putln("}") c.Putln("") @@ -123,7 +120,7 @@ func (u *Union) WriteList(c *Context) { c.Putln("var unionBytes []byte") c.Putln("for _, item := range list {") c.Putln("unionBytes = item.Bytes()") - c.Putln("copy(buf[b:], len(unionBytes))") + c.Putln("copy(buf[b:], unionBytes)") c.Putln("b += pad(len(unionBytes))") c.Putln("}") c.Putln("return b") @@ -136,7 +133,7 @@ func (u *Union) WriteListSize(c *Context) { c.Putln("func %sListSize(list []%s) int {", u.SrcName(), u.SrcName()) c.Putln("size := 0") c.Putln("for _, item := range list {") - c.Putln("size += %s", u.Size().Reduce("item.", "")) + c.Putln("size += %s", u.Size().Reduce("item.")) c.Putln("}") c.Putln("return size") c.Putln("}") diff --git a/nexgb/xgbgen/representation.go b/nexgb/xgbgen/representation.go index e5d2202..ef62157 100644 --- a/nexgb/xgbgen/representation.go +++ b/nexgb/xgbgen/representation.go @@ -65,6 +65,10 @@ func (r *Request) ReplyName() string { return fmt.Sprintf("%sReply", r.SrcName()) } +func (r *Request) ReqName() string { + return fmt.Sprintf("%sRequest", r.SrcName()) +} + // Size for Request needs a context. // Namely, if this is an extension, we need to account for *four* bytes // of a header (extension opcode, request opcode, and the sequence number). @@ -80,7 +84,20 @@ func (r *Request) Size(c *Context) Size { } for _, field := range r.Fields { - size = size.Add(field.Size()) + switch field.(type) { + case *LocalField: + continue + case *SingleField: + // mofos!!! + if r.SrcName() == "ConfigureWindow" && + field.SrcName() == "ValueMask" { + + continue + } + size = size.Add(field.Size()) + default: + size = size.Add(field.Size()) + } } return size } diff --git a/nexgb/xgbgen/translation.go b/nexgb/xgbgen/translation.go index 9c7603b..fe5a52b 100644 --- a/nexgb/xgbgen/translation.go +++ b/nexgb/xgbgen/translation.go @@ -138,7 +138,7 @@ func (x *XMLEvent) Translate() *Event { Fields: make([]Field, len(x.Fields)), } for i, field := range x.Fields { - ev.Fields[i] = field.Translate() + ev.Fields[i] = field.Translate(ev) } return ev } @@ -158,7 +158,7 @@ func (x *XMLError) Translate() *Error { Fields: make([]Field, len(x.Fields)), } for i, field := range x.Fields { - err.Fields[i] = field.Translate() + err.Fields[i] = field.Translate(err) } return err } @@ -177,7 +177,7 @@ func (x *XMLStruct) Translate() *Struct { Fields: make([]Field, len(x.Fields)), } for i, field := range x.Fields { - s.Fields[i] = field.Translate() + s.Fields[i] = field.Translate(s) } return s } @@ -188,7 +188,7 @@ func (x *XMLUnion) Translate() *Union { Fields: make([]Field, len(x.Fields)), } for i, field := range x.Fields { - u.Fields[i] = field.Translate() + u.Fields[i] = field.Translate(u) } return u } @@ -202,7 +202,7 @@ func (x *XMLRequest) Translate() *Request { Reply: x.Reply.Translate(), } for i, field := range x.Fields { - r.Fields[i] = field.Translate() + r.Fields[i] = field.Translate(r) } // Address bug (or legacy code) in QueryTextExtents. @@ -230,7 +230,7 @@ func (x *XMLReply) Translate() *Reply { Fields: make([]Field, len(x.Fields)), } for i, field := range x.Fields { - r.Fields[i] = field.Translate() + r.Fields[i] = field.Translate(r) } return r } @@ -309,7 +309,7 @@ func (x *XMLExpression) Translate() Expression { panic("unreachable") } -func (x *XMLField) Translate() Field { +func (x *XMLField) Translate(parent interface{}) Field { switch x.XMLName.Local { case "pad": return &PadField{ @@ -339,6 +339,7 @@ func (x *XMLField) Translate() Field { } case "valueparam": return &ValueField{ + Parent: parent, MaskType: newTranslation(x.ValueMaskType), MaskName: x.ValueMaskName, ListName: x.ValueListName, @@ -365,7 +366,7 @@ func (x *XMLBitcase) Translate() *Bitcase { Fields: make([]Field, len(x.Fields)), } for i, field := range x.Fields { - b.Fields[i] = field.Translate() + b.Fields[i] = field.Translate(b) } return b } diff --git a/nexgb/xgbgen/type.go b/nexgb/xgbgen/type.go index d8e76a2..3498463 100644 --- a/nexgb/xgbgen/type.go +++ b/nexgb/xgbgen/type.go @@ -334,6 +334,18 @@ func (s *Struct) Initialize(p *Protocol) { } } +// HasList returns whether there is a field in this struct that is a list. +// When true, a more involved calculation is necessary to compute this struct's +// size. +func (s *Struct) HasList() bool { + for _, field := range s.Fields { + if _, ok := field.(*ListField); ok { + return true + } + } + return false +} + type Union struct { srcName string xmlName string diff --git a/nexgb/xproto.go b/nexgb/xproto.go new file mode 100644 index 0000000..3317b51 --- /dev/null +++ b/nexgb/xproto.go @@ -0,0 +1,11215 @@ +package xgb + +/* + This file was generated by xproto.xml on May 3 2012 12:48:47am EDT. + This file is automatically generated. Edit at your peril! +*/ + +// Skipping definition for base type 'Float' + +// Skipping definition for base type 'Id' + +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Bool' + +const ( + VisualClassStaticGray = 0 + VisualClassGrayScale = 1 + VisualClassStaticColor = 2 + VisualClassPseudoColor = 3 + VisualClassTrueColor = 4 + VisualClassDirectColor = 5 +) + +const ( + EventMaskNoEvent = 0 + EventMaskKeyPress = 1 + EventMaskKeyRelease = 2 + EventMaskButtonPress = 4 + EventMaskButtonRelease = 8 + EventMaskEnterWindow = 16 + EventMaskLeaveWindow = 32 + EventMaskPointerMotion = 64 + EventMaskPointerMotionHint = 128 + EventMaskButton1Motion = 256 + EventMaskButton2Motion = 512 + EventMaskButton3Motion = 1024 + EventMaskButton4Motion = 2048 + EventMaskButton5Motion = 4096 + EventMaskButtonMotion = 8192 + EventMaskKeymapState = 16384 + EventMaskExposure = 32768 + EventMaskVisibilityChange = 65536 + EventMaskStructureNotify = 131072 + EventMaskResizeRedirect = 262144 + EventMaskSubstructureNotify = 524288 + EventMaskSubstructureRedirect = 1048576 + EventMaskFocusChange = 2097152 + EventMaskPropertyChange = 4194304 + EventMaskColorMapChange = 8388608 + EventMaskOwnerGrabButton = 16777216 +) + +const ( + BackingStoreNotUseful = 0 + BackingStoreWhenMapped = 1 + BackingStoreAlways = 2 +) + +const ( + ImageOrderLSBFirst = 0 + ImageOrderMSBFirst = 1 +) + +const ( + ModMaskShift = 1 + ModMaskLock = 2 + ModMaskControl = 4 + ModMask1 = 8 + ModMask2 = 16 + ModMask3 = 32 + ModMask4 = 64 + ModMask5 = 128 + ModMaskAny = 32768 +) + +const ( + KeyButMaskShift = 1 + KeyButMaskLock = 2 + KeyButMaskControl = 4 + KeyButMaskMod1 = 8 + KeyButMaskMod2 = 16 + KeyButMaskMod3 = 32 + KeyButMaskMod4 = 64 + KeyButMaskMod5 = 128 + KeyButMaskButton1 = 256 + KeyButMaskButton2 = 512 + KeyButMaskButton3 = 1024 + KeyButMaskButton4 = 2048 + KeyButMaskButton5 = 4096 +) + +const ( + WindowNone = 0 +) + +const ( + ButtonMask1 = 256 + ButtonMask2 = 512 + ButtonMask3 = 1024 + ButtonMask4 = 2048 + ButtonMask5 = 4096 + ButtonMaskAny = 32768 +) + +const ( + MotionNormal = 0 + MotionHint = 1 +) + +const ( + NotifyDetailAncestor = 0 + NotifyDetailVirtual = 1 + NotifyDetailInferior = 2 + NotifyDetailNonlinear = 3 + NotifyDetailNonlinearVirtual = 4 + NotifyDetailPointer = 5 + NotifyDetailPointerRoot = 6 + NotifyDetailNone = 7 +) + +const ( + NotifyModeNormal = 0 + NotifyModeGrab = 1 + NotifyModeUngrab = 2 + NotifyModeWhileGrabbed = 3 +) + +const ( + VisibilityUnobscured = 0 + VisibilityPartiallyObscured = 1 + VisibilityFullyObscured = 2 +) + +const ( + PlaceOnTop = 0 + PlaceOnBottom = 1 +) + +const ( + PropertyNewValue = 0 + PropertyDelete = 1 +) + +const ( + TimeCurrentTime = 0 +) + +const ( + AtomNone = 0 + AtomAny = 0 + AtomPrimary = 1 + AtomSecondary = 2 + AtomArc = 3 + AtomAtom = 4 + AtomBitmap = 5 + AtomCardinal = 6 + AtomColormap = 7 + AtomCursor = 8 + AtomCutBuffer0 = 9 + AtomCutBuffer1 = 10 + AtomCutBuffer2 = 11 + AtomCutBuffer3 = 12 + AtomCutBuffer4 = 13 + AtomCutBuffer5 = 14 + AtomCutBuffer6 = 15 + AtomCutBuffer7 = 16 + AtomDrawable = 17 + AtomFont = 18 + AtomInteger = 19 + AtomPixmap = 20 + AtomPoint = 21 + AtomRectangle = 22 + AtomResourceManager = 23 + AtomRgbColorMap = 24 + AtomRgbBestMap = 25 + AtomRgbBlueMap = 26 + AtomRgbDefaultMap = 27 + AtomRgbGrayMap = 28 + AtomRgbGreenMap = 29 + AtomRgbRedMap = 30 + AtomString = 31 + AtomVisualid = 32 + AtomWindow = 33 + AtomWmCommand = 34 + AtomWmHints = 35 + AtomWmClientMachine = 36 + AtomWmIconName = 37 + AtomWmIconSize = 38 + AtomWmName = 39 + AtomWmNormalHints = 40 + AtomWmSizeHints = 41 + AtomWmZoomHints = 42 + AtomMinSpace = 43 + AtomNormSpace = 44 + AtomMaxSpace = 45 + AtomEndSpace = 46 + AtomSuperscriptX = 47 + AtomSuperscriptY = 48 + AtomSubscriptX = 49 + AtomSubscriptY = 50 + AtomUnderlinePosition = 51 + AtomUnderlineThickness = 52 + AtomStrikeoutAscent = 53 + AtomStrikeoutDescent = 54 + AtomItalicAngle = 55 + AtomXHeight = 56 + AtomQuadWidth = 57 + AtomWeight = 58 + AtomPointSize = 59 + AtomResolution = 60 + AtomCopyright = 61 + AtomNotice = 62 + AtomFontName = 63 + AtomFamilyName = 64 + AtomFullName = 65 + AtomCapHeight = 66 + AtomWmClass = 67 + AtomWmTransientFor = 68 +) + +const ( + ColormapStateUninstalled = 0 + ColormapStateInstalled = 1 +) + +const ( + ColormapNone = 0 +) + +const ( + MappingModifier = 0 + MappingKeyboard = 1 + MappingPointer = 2 +) + +const ( + WindowClassCopyFromParent = 0 + WindowClassInputOutput = 1 + WindowClassInputOnly = 2 +) + +const ( + CwBackPixmap = 1 + CwBackPixel = 2 + CwBorderPixmap = 4 + CwBorderPixel = 8 + CwBitGravity = 16 + CwWinGravity = 32 + CwBackingStore = 64 + CwBackingPlanes = 128 + CwBackingPixel = 256 + CwOverrideRedirect = 512 + CwSaveUnder = 1024 + CwEventMask = 2048 + CwDontPropagate = 4096 + CwColormap = 8192 + CwCursor = 16384 +) + +const ( + BackPixmapNone = 0 + BackPixmapParentRelative = 1 +) + +const ( + GravityBitForget = 0 + GravityWinUnmap = 0 + GravityNorthWest = 1 + GravityNorth = 2 + GravityNorthEast = 3 + GravityWest = 4 + GravityCenter = 5 + GravityEast = 6 + GravitySouthWest = 7 + GravitySouth = 8 + GravitySouthEast = 9 + GravityStatic = 10 +) + +const ( + MapStateUnmapped = 0 + MapStateUnviewable = 1 + MapStateViewable = 2 +) + +const ( + SetModeInsert = 0 + SetModeDelete = 1 +) + +const ( + ConfigWindowX = 1 + ConfigWindowY = 2 + ConfigWindowWidth = 4 + ConfigWindowHeight = 8 + ConfigWindowBorderWidth = 16 + ConfigWindowSibling = 32 + ConfigWindowStackMode = 64 +) + +const ( + StackModeAbove = 0 + StackModeBelow = 1 + StackModeTopIf = 2 + StackModeBottomIf = 3 + StackModeOpposite = 4 +) + +const ( + CirculateRaiseLowest = 0 + CirculateLowerHighest = 1 +) + +const ( + PropModeReplace = 0 + PropModePrepend = 1 + PropModeAppend = 2 +) + +const ( + GetPropertyTypeAny = 0 +) + +const ( + SendEventDestPointerWindow = 0 + SendEventDestItemFocus = 1 +) + +const ( + GrabModeSync = 0 + GrabModeAsync = 1 +) + +const ( + GrabStatusSuccess = 0 + GrabStatusAlreadyGrabbed = 1 + GrabStatusInvalidTime = 2 + GrabStatusNotViewable = 3 + GrabStatusFrozen = 4 +) + +const ( + CursorNone = 0 +) + +const ( + ButtonIndexAny = 0 + ButtonIndex1 = 1 + ButtonIndex2 = 2 + ButtonIndex3 = 3 + ButtonIndex4 = 4 + ButtonIndex5 = 5 +) + +const ( + GrabAny = 0 +) + +const ( + AllowAsyncPointer = 0 + AllowSyncPointer = 1 + AllowReplayPointer = 2 + AllowAsyncKeyboard = 3 + AllowSyncKeyboard = 4 + AllowReplayKeyboard = 5 + AllowAsyncBoth = 6 + AllowSyncBoth = 7 +) + +const ( + InputFocusNone = 0 + InputFocusPointerRoot = 1 + InputFocusParent = 2 + InputFocusFollowKeyboard = 3 +) + +const ( + FontDrawLeftToRight = 0 + FontDrawRightToLeft = 1 +) + +const ( + GcFunction = 1 + GcPlaneMask = 2 + GcForeground = 4 + GcBackground = 8 + GcLineWidth = 16 + GcLineStyle = 32 + GcCapStyle = 64 + GcJoinStyle = 128 + GcFillStyle = 256 + GcFillRule = 512 + GcTile = 1024 + GcStipple = 2048 + GcTileStippleOriginX = 4096 + GcTileStippleOriginY = 8192 + GcFont = 16384 + GcSubwindowMode = 32768 + GcGraphicsExposures = 65536 + GcClipOriginX = 131072 + GcClipOriginY = 262144 + GcClipMask = 524288 + GcDashOffset = 1048576 + GcDashList = 2097152 + GcArcMode = 4194304 +) + +const ( + GxClear = 0 + GxAnd = 1 + GxAndReverse = 2 + GxCopy = 3 + GxAndInverted = 4 + GxNoop = 5 + GxXor = 6 + GxOr = 7 + GxNor = 8 + GxEquiv = 9 + GxInvert = 10 + GxOrReverse = 11 + GxCopyInverted = 12 + GxOrInverted = 13 + GxNand = 14 + GxSet = 15 +) + +const ( + LineStyleSolid = 0 + LineStyleOnOffDash = 1 + LineStyleDoubleDash = 2 +) + +const ( + CapStyleNotLast = 0 + CapStyleButt = 1 + CapStyleRound = 2 + CapStyleProjecting = 3 +) + +const ( + JoinStyleMiter = 0 + JoinStyleRound = 1 + JoinStyleBevel = 2 +) + +const ( + FillStyleSolid = 0 + FillStyleTiled = 1 + FillStyleStippled = 2 + FillStyleOpaqueStippled = 3 +) + +const ( + FillRuleEvenOdd = 0 + FillRuleWinding = 1 +) + +const ( + SubwindowModeClipByChildren = 0 + SubwindowModeIncludeInferiors = 1 +) + +const ( + ArcModeChord = 0 + ArcModePieSlice = 1 +) + +const ( + ClipOrderingUnsorted = 0 + ClipOrderingYSorted = 1 + ClipOrderingYXSorted = 2 + ClipOrderingYXBanded = 3 +) + +const ( + CoordModeOrigin = 0 + CoordModePrevious = 1 +) + +const ( + PolyShapeComplex = 0 + PolyShapeNonconvex = 1 + PolyShapeConvex = 2 +) + +const ( + ImageFormatXYBitmap = 0 + ImageFormatXYPixmap = 1 + ImageFormatZPixmap = 2 +) + +const ( + ColormapAllocNone = 0 + ColormapAllocAll = 1 +) + +const ( + ColorFlagRed = 1 + ColorFlagGreen = 2 + ColorFlagBlue = 4 +) + +const ( + PixmapNone = 0 +) + +const ( + FontNone = 0 +) + +const ( + QueryShapeOfLargestCursor = 0 + QueryShapeOfFastestTile = 1 + QueryShapeOfFastestStipple = 2 +) + +const ( + KbKeyClickPercent = 1 + KbBellPercent = 2 + KbBellPitch = 4 + KbBellDuration = 8 + KbLed = 16 + KbLedMode = 32 + KbKey = 64 + KbAutoRepeatMode = 128 +) + +const ( + LedModeOff = 0 + LedModeOn = 1 +) + +const ( + AutoRepeatModeOff = 0 + AutoRepeatModeOn = 1 + AutoRepeatModeDefault = 2 +) + +const ( + BlankingNotPreferred = 0 + BlankingPreferred = 1 + BlankingDefault = 2 +) + +const ( + ExposuresNotAllowed = 0 + ExposuresAllowed = 1 + ExposuresDefault = 2 +) + +const ( + HostModeInsert = 0 + HostModeDelete = 1 +) + +const ( + FamilyInternet = 0 + FamilyDECnet = 1 + FamilyChaos = 2 + FamilyServerInterpreted = 5 + FamilyInternet6 = 6 +) + +const ( + AccessControlDisable = 0 + AccessControlEnable = 1 +) + +const ( + CloseDownDestroyAll = 0 + CloseDownRetainPermanent = 1 + CloseDownRetainTemporary = 2 +) + +const ( + KillAllTemporary = 0 +) + +const ( + ScreenSaverReset = 0 + ScreenSaverActive = 1 +) + +const ( + MappingStatusSuccess = 0 + MappingStatusBusy = 1 + MappingStatusFailure = 2 +) + +const ( + MapIndexShift = 0 + MapIndexLock = 1 + MapIndexControl = 2 + MapIndex1 = 3 + MapIndex2 = 4 + MapIndex3 = 5 + MapIndex4 = 6 + MapIndex5 = 7 +) + +// Skipping resource definition of 'Window' + +// Skipping resource definition of 'Pixmap' + +// Skipping resource definition of 'Cursor' + +// Skipping resource definition of 'Font' + +// Skipping resource definition of 'Gcontext' + +// Skipping resource definition of 'Colormap' + +// Skipping resource definition of 'Atom' + +// Skipping resource definition of 'Drawable' + +// Skipping resource definition of 'Fontable' + +type Visualid uint32 + +type Timestamp uint32 + +type Keysym uint32 + +type Keycode byte + +type Button byte + +// 'Char2b' struct definition +// Size: 2 +type Char2b struct { + Byte1 byte + Byte2 byte +} + +// Struct read Char2b +func ReadChar2b(buf []byte, v *Char2b) int { + b := 0 + + v.Byte1 = buf[b] + b += 1 + + v.Byte2 = buf[b] + b += 1 + + return b +} + +// Struct list read Char2b +func ReadChar2bList(buf []byte, dest []Char2b) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Char2b{} + b += ReadChar2b(buf[b:], &dest[i]) + } + return pad(b) +} + +// Struct write Char2b +func (v Char2b) Bytes() []byte { + buf := make([]byte, 2) + b := 0 + + buf[b] = v.Byte1 + b += 1 + + buf[b] = v.Byte2 + b += 1 + + return buf +} + +// Write struct list Char2b +func Char2bListBytes(buf []byte, list []Char2b) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += pad(len(structBytes)) + } + return b +} + +// 'Point' struct definition +// Size: 4 +type Point struct { + X int16 + Y int16 +} + +// Struct read Point +func ReadPoint(buf []byte, v *Point) int { + b := 0 + + v.X = int16(Get16(buf[b:])) + b += 2 + + v.Y = int16(Get16(buf[b:])) + b += 2 + + return b +} + +// Struct list read Point +func ReadPointList(buf []byte, dest []Point) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Point{} + b += ReadPoint(buf[b:], &dest[i]) + } + return pad(b) +} + +// Struct write Point +func (v Point) Bytes() []byte { + buf := make([]byte, 4) + b := 0 + + Put16(buf[b:], uint16(v.X)) + b += 2 + + Put16(buf[b:], uint16(v.Y)) + b += 2 + + return buf +} + +// Write struct list Point +func PointListBytes(buf []byte, list []Point) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += pad(len(structBytes)) + } + return b +} + +// 'Rectangle' struct definition +// Size: 8 +type Rectangle struct { + X int16 + Y int16 + Width uint16 + Height uint16 +} + +// Struct read Rectangle +func ReadRectangle(buf []byte, v *Rectangle) int { + b := 0 + + v.X = int16(Get16(buf[b:])) + b += 2 + + v.Y = int16(Get16(buf[b:])) + b += 2 + + v.Width = Get16(buf[b:]) + b += 2 + + v.Height = Get16(buf[b:]) + b += 2 + + return b +} + +// Struct list read Rectangle +func ReadRectangleList(buf []byte, dest []Rectangle) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Rectangle{} + b += ReadRectangle(buf[b:], &dest[i]) + } + return pad(b) +} + +// Struct write Rectangle +func (v Rectangle) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + Put16(buf[b:], uint16(v.X)) + b += 2 + + Put16(buf[b:], uint16(v.Y)) + b += 2 + + Put16(buf[b:], v.Width) + b += 2 + + Put16(buf[b:], v.Height) + b += 2 + + return buf +} + +// Write struct list Rectangle +func RectangleListBytes(buf []byte, list []Rectangle) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += pad(len(structBytes)) + } + return b +} + +// 'Arc' struct definition +// Size: 12 +type Arc struct { + X int16 + Y int16 + Width uint16 + Height uint16 + Angle1 int16 + Angle2 int16 +} + +// Struct read Arc +func ReadArc(buf []byte, v *Arc) int { + b := 0 + + v.X = int16(Get16(buf[b:])) + b += 2 + + v.Y = int16(Get16(buf[b:])) + b += 2 + + v.Width = Get16(buf[b:]) + b += 2 + + v.Height = Get16(buf[b:]) + b += 2 + + v.Angle1 = int16(Get16(buf[b:])) + b += 2 + + v.Angle2 = int16(Get16(buf[b:])) + b += 2 + + return b +} + +// Struct list read Arc +func ReadArcList(buf []byte, dest []Arc) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Arc{} + b += ReadArc(buf[b:], &dest[i]) + } + return pad(b) +} + +// Struct write Arc +func (v Arc) Bytes() []byte { + buf := make([]byte, 12) + b := 0 + + Put16(buf[b:], uint16(v.X)) + b += 2 + + Put16(buf[b:], uint16(v.Y)) + b += 2 + + Put16(buf[b:], v.Width) + b += 2 + + Put16(buf[b:], v.Height) + b += 2 + + Put16(buf[b:], uint16(v.Angle1)) + b += 2 + + Put16(buf[b:], uint16(v.Angle2)) + b += 2 + + return buf +} + +// Write struct list Arc +func ArcListBytes(buf []byte, list []Arc) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += pad(len(structBytes)) + } + return b +} + +// 'Format' struct definition +// Size: 8 +type Format struct { + Depth byte + BitsPerPixel byte + ScanlinePad byte + // padding: 5 bytes +} + +// Struct read Format +func ReadFormat(buf []byte, v *Format) int { + b := 0 + + v.Depth = buf[b] + b += 1 + + v.BitsPerPixel = buf[b] + b += 1 + + v.ScanlinePad = buf[b] + b += 1 + + b += 5 // padding + + return b +} + +// Struct list read Format +func ReadFormatList(buf []byte, dest []Format) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Format{} + b += ReadFormat(buf[b:], &dest[i]) + } + return pad(b) +} + +// Struct write Format +func (v Format) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + buf[b] = v.Depth + b += 1 + + buf[b] = v.BitsPerPixel + b += 1 + + buf[b] = v.ScanlinePad + b += 1 + + b += 5 // padding + + return buf +} + +// Write struct list Format +func FormatListBytes(buf []byte, list []Format) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += pad(len(structBytes)) + } + return b +} + +// 'VisualInfo' struct definition +// Size: 24 +type VisualInfo struct { + VisualId Visualid + Class byte + BitsPerRgbValue byte + ColormapEntries uint16 + RedMask uint32 + GreenMask uint32 + BlueMask uint32 + // padding: 4 bytes +} + +// Struct read VisualInfo +func ReadVisualInfo(buf []byte, v *VisualInfo) int { + b := 0 + + v.VisualId = Visualid(Get32(buf[b:])) + b += 4 + + v.Class = buf[b] + b += 1 + + v.BitsPerRgbValue = buf[b] + b += 1 + + v.ColormapEntries = Get16(buf[b:]) + b += 2 + + v.RedMask = Get32(buf[b:]) + b += 4 + + v.GreenMask = Get32(buf[b:]) + b += 4 + + v.BlueMask = Get32(buf[b:]) + b += 4 + + b += 4 // padding + + return b +} + +// Struct list read VisualInfo +func ReadVisualInfoList(buf []byte, dest []VisualInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = VisualInfo{} + b += ReadVisualInfo(buf[b:], &dest[i]) + } + return pad(b) +} + +// Struct write VisualInfo +func (v VisualInfo) Bytes() []byte { + buf := make([]byte, 24) + b := 0 + + Put32(buf[b:], uint32(v.VisualId)) + b += 4 + + buf[b] = v.Class + b += 1 + + buf[b] = v.BitsPerRgbValue + b += 1 + + Put16(buf[b:], v.ColormapEntries) + b += 2 + + Put32(buf[b:], v.RedMask) + b += 4 + + Put32(buf[b:], v.GreenMask) + b += 4 + + Put32(buf[b:], v.BlueMask) + b += 4 + + b += 4 // padding + + return buf +} + +// Write struct list VisualInfo +func VisualInfoListBytes(buf []byte, list []VisualInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += pad(len(structBytes)) + } + return b +} + +// 'DepthInfo' struct definition +// Size: (8 + pad((int(VisualsLen) * 24))) +type DepthInfo struct { + Depth byte + // padding: 1 bytes + VisualsLen uint16 + // padding: 4 bytes + Visuals []VisualInfo // size: pad((int(VisualsLen) * 24)) +} + +// Struct read DepthInfo +func ReadDepthInfo(buf []byte, v *DepthInfo) int { + b := 0 + + v.Depth = buf[b] + b += 1 + + b += 1 // padding + + v.VisualsLen = Get16(buf[b:]) + b += 2 + + b += 4 // padding + + v.Visuals = make([]VisualInfo, v.VisualsLen) + b += ReadVisualInfoList(buf[b:], v.Visuals) + + return b +} + +// Struct list read DepthInfo +func ReadDepthInfoList(buf []byte, dest []DepthInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DepthInfo{} + b += ReadDepthInfo(buf[b:], &dest[i]) + } + return pad(b) +} + +// Struct write DepthInfo +func (v DepthInfo) Bytes() []byte { + buf := make([]byte, (8 + pad((int(v.VisualsLen) * 24)))) + b := 0 + + buf[b] = v.Depth + b += 1 + + b += 1 // padding + + Put16(buf[b:], v.VisualsLen) + b += 2 + + b += 4 // padding + + b += VisualInfoListBytes(buf[b:], v.Visuals) + + return buf +} + +// Write struct list DepthInfo +func DepthInfoListBytes(buf []byte, list []DepthInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += pad(len(structBytes)) + } + return b +} + +// Struct list size DepthInfo +func DepthInfoListSize(list []DepthInfo) int { + size := 0 + for _, item := range list { + size += (8 + pad((int(item.VisualsLen) * 24))) + } + return size +} + +// 'ScreenInfo' struct definition +// Size: (40 + DepthInfoListSize(AllowedDepths)) +type ScreenInfo struct { + Root Id + DefaultColormap Id + WhitePixel uint32 + BlackPixel uint32 + CurrentInputMasks uint32 + WidthInPixels uint16 + HeightInPixels uint16 + WidthInMillimeters uint16 + HeightInMillimeters uint16 + MinInstalledMaps uint16 + MaxInstalledMaps uint16 + RootVisual Visualid + BackingStores byte + SaveUnders bool + RootDepth byte + AllowedDepthsLen byte + AllowedDepths []DepthInfo // size: DepthInfoListSize(AllowedDepths) +} + +// Struct read ScreenInfo +func ReadScreenInfo(buf []byte, v *ScreenInfo) int { + b := 0 + + v.Root = Id(Get32(buf[b:])) + b += 4 + + v.DefaultColormap = Id(Get32(buf[b:])) + b += 4 + + v.WhitePixel = Get32(buf[b:]) + b += 4 + + v.BlackPixel = Get32(buf[b:]) + b += 4 + + v.CurrentInputMasks = Get32(buf[b:]) + b += 4 + + v.WidthInPixels = Get16(buf[b:]) + b += 2 + + v.HeightInPixels = Get16(buf[b:]) + b += 2 + + v.WidthInMillimeters = Get16(buf[b:]) + b += 2 + + v.HeightInMillimeters = Get16(buf[b:]) + b += 2 + + v.MinInstalledMaps = Get16(buf[b:]) + b += 2 + + v.MaxInstalledMaps = Get16(buf[b:]) + b += 2 + + v.RootVisual = Visualid(Get32(buf[b:])) + b += 4 + + v.BackingStores = buf[b] + b += 1 + + if buf[b] == 1 { + v.SaveUnders = true + } else { + v.SaveUnders = false + } + b += 1 + + v.RootDepth = buf[b] + b += 1 + + v.AllowedDepthsLen = buf[b] + b += 1 + + v.AllowedDepths = make([]DepthInfo, v.AllowedDepthsLen) + b += ReadDepthInfoList(buf[b:], v.AllowedDepths) + + return b +} + +// Struct list read ScreenInfo +func ReadScreenInfoList(buf []byte, dest []ScreenInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = ScreenInfo{} + b += ReadScreenInfo(buf[b:], &dest[i]) + } + return pad(b) +} + +// Struct write ScreenInfo +func (v ScreenInfo) Bytes() []byte { + buf := make([]byte, (40 + DepthInfoListSize(v.AllowedDepths))) + b := 0 + + Put32(buf[b:], uint32(v.Root)) + b += 4 + + Put32(buf[b:], uint32(v.DefaultColormap)) + b += 4 + + Put32(buf[b:], v.WhitePixel) + b += 4 + + Put32(buf[b:], v.BlackPixel) + b += 4 + + Put32(buf[b:], v.CurrentInputMasks) + b += 4 + + Put16(buf[b:], v.WidthInPixels) + b += 2 + + Put16(buf[b:], v.HeightInPixels) + b += 2 + + Put16(buf[b:], v.WidthInMillimeters) + b += 2 + + Put16(buf[b:], v.HeightInMillimeters) + b += 2 + + Put16(buf[b:], v.MinInstalledMaps) + b += 2 + + Put16(buf[b:], v.MaxInstalledMaps) + b += 2 + + Put32(buf[b:], uint32(v.RootVisual)) + b += 4 + + buf[b] = v.BackingStores + b += 1 + + if v.SaveUnders { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + buf[b] = v.RootDepth + b += 1 + + buf[b] = v.AllowedDepthsLen + b += 1 + + b += DepthInfoListBytes(buf[b:], v.AllowedDepths) + + return buf +} + +// Write struct list ScreenInfo +func ScreenInfoListBytes(buf []byte, list []ScreenInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += pad(len(structBytes)) + } + return b +} + +// Struct list size ScreenInfo +func ScreenInfoListSize(list []ScreenInfo) int { + size := 0 + for _, item := range list { + size += (40 + DepthInfoListSize(item.AllowedDepths)) + } + return size +} + +// 'SetupRequest' struct definition +// Size: ((12 + pad((int(AuthorizationProtocolNameLen) * 1))) + pad((int(AuthorizationProtocolDataLen) * 1))) +type SetupRequest struct { + ByteOrder byte + // padding: 1 bytes + ProtocolMajorVersion uint16 + ProtocolMinorVersion uint16 + AuthorizationProtocolNameLen uint16 + AuthorizationProtocolDataLen uint16 + // padding: 2 bytes + AuthorizationProtocolName string // size: pad((int(AuthorizationProtocolNameLen) * 1)) + AuthorizationProtocolData string // size: pad((int(AuthorizationProtocolDataLen) * 1)) +} + +// Struct read SetupRequest +func ReadSetupRequest(buf []byte, v *SetupRequest) int { + b := 0 + + v.ByteOrder = buf[b] + b += 1 + + b += 1 // padding + + v.ProtocolMajorVersion = Get16(buf[b:]) + b += 2 + + v.ProtocolMinorVersion = Get16(buf[b:]) + b += 2 + + v.AuthorizationProtocolNameLen = Get16(buf[b:]) + b += 2 + + v.AuthorizationProtocolDataLen = Get16(buf[b:]) + b += 2 + + b += 2 // padding + + { + byteString := make([]byte, v.AuthorizationProtocolNameLen) + copy(byteString[:v.AuthorizationProtocolNameLen], buf[b:]) + v.AuthorizationProtocolName = string(byteString) + b += pad(int(v.AuthorizationProtocolNameLen)) + } + + { + byteString := make([]byte, v.AuthorizationProtocolDataLen) + copy(byteString[:v.AuthorizationProtocolDataLen], buf[b:]) + v.AuthorizationProtocolData = string(byteString) + b += pad(int(v.AuthorizationProtocolDataLen)) + } + + return b +} + +// Struct list read SetupRequest +func ReadSetupRequestList(buf []byte, dest []SetupRequest) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = SetupRequest{} + b += ReadSetupRequest(buf[b:], &dest[i]) + } + return pad(b) +} + +// Struct write SetupRequest +func (v SetupRequest) Bytes() []byte { + buf := make([]byte, ((12 + pad((int(v.AuthorizationProtocolNameLen) * 1))) + pad((int(v.AuthorizationProtocolDataLen) * 1)))) + b := 0 + + buf[b] = v.ByteOrder + b += 1 + + b += 1 // padding + + Put16(buf[b:], v.ProtocolMajorVersion) + b += 2 + + Put16(buf[b:], v.ProtocolMinorVersion) + b += 2 + + Put16(buf[b:], v.AuthorizationProtocolNameLen) + b += 2 + + Put16(buf[b:], v.AuthorizationProtocolDataLen) + b += 2 + + b += 2 // padding + + copy(buf[b:], v.AuthorizationProtocolName[:v.AuthorizationProtocolNameLen]) + b += pad(int(v.AuthorizationProtocolNameLen)) + + copy(buf[b:], v.AuthorizationProtocolData[:v.AuthorizationProtocolDataLen]) + b += pad(int(v.AuthorizationProtocolDataLen)) + + return buf +} + +// Write struct list SetupRequest +func SetupRequestListBytes(buf []byte, list []SetupRequest) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += pad(len(structBytes)) + } + return b +} + +// Struct list size SetupRequest +func SetupRequestListSize(list []SetupRequest) int { + size := 0 + for _, item := range list { + size += ((12 + pad((int(item.AuthorizationProtocolNameLen) * 1))) + pad((int(item.AuthorizationProtocolDataLen) * 1))) + } + return size +} + +// 'SetupFailed' struct definition +// Size: (8 + pad((int(ReasonLen) * 1))) +type SetupFailed struct { + Status byte + ReasonLen byte + ProtocolMajorVersion uint16 + ProtocolMinorVersion uint16 + Length uint16 + Reason string // size: pad((int(ReasonLen) * 1)) +} + +// Struct read SetupFailed +func ReadSetupFailed(buf []byte, v *SetupFailed) int { + b := 0 + + v.Status = buf[b] + b += 1 + + v.ReasonLen = buf[b] + b += 1 + + v.ProtocolMajorVersion = Get16(buf[b:]) + b += 2 + + v.ProtocolMinorVersion = Get16(buf[b:]) + b += 2 + + v.Length = Get16(buf[b:]) + b += 2 + + { + byteString := make([]byte, v.ReasonLen) + copy(byteString[:v.ReasonLen], buf[b:]) + v.Reason = string(byteString) + b += pad(int(v.ReasonLen)) + } + + return b +} + +// Struct list read SetupFailed +func ReadSetupFailedList(buf []byte, dest []SetupFailed) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = SetupFailed{} + b += ReadSetupFailed(buf[b:], &dest[i]) + } + return pad(b) +} + +// Struct write SetupFailed +func (v SetupFailed) Bytes() []byte { + buf := make([]byte, (8 + pad((int(v.ReasonLen) * 1)))) + b := 0 + + buf[b] = v.Status + b += 1 + + buf[b] = v.ReasonLen + b += 1 + + Put16(buf[b:], v.ProtocolMajorVersion) + b += 2 + + Put16(buf[b:], v.ProtocolMinorVersion) + b += 2 + + Put16(buf[b:], v.Length) + b += 2 + + copy(buf[b:], v.Reason[:v.ReasonLen]) + b += pad(int(v.ReasonLen)) + + return buf +} + +// Write struct list SetupFailed +func SetupFailedListBytes(buf []byte, list []SetupFailed) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += pad(len(structBytes)) + } + return b +} + +// Struct list size SetupFailed +func SetupFailedListSize(list []SetupFailed) int { + size := 0 + for _, item := range list { + size += (8 + pad((int(item.ReasonLen) * 1))) + } + return size +} + +// 'SetupAuthenticate' struct definition +// Size: (8 + pad(((int(Length) * 4) * 1))) +type SetupAuthenticate struct { + Status byte + // padding: 5 bytes + Length uint16 + Reason string // size: pad(((int(Length) * 4) * 1)) +} + +// Struct read SetupAuthenticate +func ReadSetupAuthenticate(buf []byte, v *SetupAuthenticate) int { + b := 0 + + v.Status = buf[b] + b += 1 + + b += 5 // padding + + v.Length = Get16(buf[b:]) + b += 2 + + { + byteString := make([]byte, (int(v.Length) * 4)) + copy(byteString[:(int(v.Length)*4)], buf[b:]) + v.Reason = string(byteString) + b += pad(int((int(v.Length) * 4))) + } + + return b +} + +// Struct list read SetupAuthenticate +func ReadSetupAuthenticateList(buf []byte, dest []SetupAuthenticate) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = SetupAuthenticate{} + b += ReadSetupAuthenticate(buf[b:], &dest[i]) + } + return pad(b) +} + +// Struct write SetupAuthenticate +func (v SetupAuthenticate) Bytes() []byte { + buf := make([]byte, (8 + pad(((int(v.Length) * 4) * 1)))) + b := 0 + + buf[b] = v.Status + b += 1 + + b += 5 // padding + + Put16(buf[b:], v.Length) + b += 2 + + copy(buf[b:], v.Reason[:(int(v.Length)*4)]) + b += pad(int((int(v.Length) * 4))) + + return buf +} + +// Write struct list SetupAuthenticate +func SetupAuthenticateListBytes(buf []byte, list []SetupAuthenticate) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += pad(len(structBytes)) + } + return b +} + +// Struct list size SetupAuthenticate +func SetupAuthenticateListSize(list []SetupAuthenticate) int { + size := 0 + for _, item := range list { + size += (8 + pad(((int(item.Length) * 4) * 1))) + } + return size +} + +// 'SetupInfo' struct definition +// Size: (((40 + pad((int(VendorLen) * 1))) + pad((int(PixmapFormatsLen) * 8))) + ScreenInfoListSize(Roots)) +type SetupInfo struct { + Status byte + // padding: 1 bytes + ProtocolMajorVersion uint16 + ProtocolMinorVersion uint16 + Length uint16 + ReleaseNumber uint32 + ResourceIdBase uint32 + ResourceIdMask uint32 + MotionBufferSize uint32 + VendorLen uint16 + MaximumRequestLength uint16 + RootsLen byte + PixmapFormatsLen byte + ImageByteOrder byte + BitmapFormatBitOrder byte + BitmapFormatScanlineUnit byte + BitmapFormatScanlinePad byte + MinKeycode Keycode + MaxKeycode Keycode + // padding: 4 bytes + Vendor string // size: pad((int(VendorLen) * 1)) + PixmapFormats []Format // size: pad((int(PixmapFormatsLen) * 8)) + Roots []ScreenInfo // size: ScreenInfoListSize(Roots) +} + +// Struct read SetupInfo +func ReadSetupInfo(buf []byte, v *SetupInfo) int { + b := 0 + + v.Status = buf[b] + b += 1 + + b += 1 // padding + + v.ProtocolMajorVersion = Get16(buf[b:]) + b += 2 + + v.ProtocolMinorVersion = Get16(buf[b:]) + b += 2 + + v.Length = Get16(buf[b:]) + b += 2 + + v.ReleaseNumber = Get32(buf[b:]) + b += 4 + + v.ResourceIdBase = Get32(buf[b:]) + b += 4 + + v.ResourceIdMask = Get32(buf[b:]) + b += 4 + + v.MotionBufferSize = Get32(buf[b:]) + b += 4 + + v.VendorLen = Get16(buf[b:]) + b += 2 + + v.MaximumRequestLength = Get16(buf[b:]) + b += 2 + + v.RootsLen = buf[b] + b += 1 + + v.PixmapFormatsLen = buf[b] + b += 1 + + v.ImageByteOrder = buf[b] + b += 1 + + v.BitmapFormatBitOrder = buf[b] + b += 1 + + v.BitmapFormatScanlineUnit = buf[b] + b += 1 + + v.BitmapFormatScanlinePad = buf[b] + b += 1 + + v.MinKeycode = Keycode(buf[b]) + b += 1 + + v.MaxKeycode = Keycode(buf[b]) + b += 1 + + b += 4 // padding + + { + byteString := make([]byte, v.VendorLen) + copy(byteString[:v.VendorLen], buf[b:]) + v.Vendor = string(byteString) + b += pad(int(v.VendorLen)) + } + + v.PixmapFormats = make([]Format, v.PixmapFormatsLen) + b += ReadFormatList(buf[b:], v.PixmapFormats) + + v.Roots = make([]ScreenInfo, v.RootsLen) + b += ReadScreenInfoList(buf[b:], v.Roots) + + return b +} + +// Struct list read SetupInfo +func ReadSetupInfoList(buf []byte, dest []SetupInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = SetupInfo{} + b += ReadSetupInfo(buf[b:], &dest[i]) + } + return pad(b) +} + +// Struct write SetupInfo +func (v SetupInfo) Bytes() []byte { + buf := make([]byte, (((40 + pad((int(v.VendorLen) * 1))) + pad((int(v.PixmapFormatsLen) * 8))) + ScreenInfoListSize(v.Roots))) + b := 0 + + buf[b] = v.Status + b += 1 + + b += 1 // padding + + Put16(buf[b:], v.ProtocolMajorVersion) + b += 2 + + Put16(buf[b:], v.ProtocolMinorVersion) + b += 2 + + Put16(buf[b:], v.Length) + b += 2 + + Put32(buf[b:], v.ReleaseNumber) + b += 4 + + Put32(buf[b:], v.ResourceIdBase) + b += 4 + + Put32(buf[b:], v.ResourceIdMask) + b += 4 + + Put32(buf[b:], v.MotionBufferSize) + b += 4 + + Put16(buf[b:], v.VendorLen) + b += 2 + + Put16(buf[b:], v.MaximumRequestLength) + b += 2 + + buf[b] = v.RootsLen + b += 1 + + buf[b] = v.PixmapFormatsLen + b += 1 + + buf[b] = v.ImageByteOrder + b += 1 + + buf[b] = v.BitmapFormatBitOrder + b += 1 + + buf[b] = v.BitmapFormatScanlineUnit + b += 1 + + buf[b] = v.BitmapFormatScanlinePad + b += 1 + + buf[b] = byte(v.MinKeycode) + b += 1 + + buf[b] = byte(v.MaxKeycode) + b += 1 + + b += 4 // padding + + copy(buf[b:], v.Vendor[:v.VendorLen]) + b += pad(int(v.VendorLen)) + + b += FormatListBytes(buf[b:], v.PixmapFormats) + + b += ScreenInfoListBytes(buf[b:], v.Roots) + + return buf +} + +// Write struct list SetupInfo +func SetupInfoListBytes(buf []byte, list []SetupInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += pad(len(structBytes)) + } + return b +} + +// Struct list size SetupInfo +func SetupInfoListSize(list []SetupInfo) int { + size := 0 + for _, item := range list { + size += (((40 + pad((int(item.VendorLen) * 1))) + pad((int(item.PixmapFormatsLen) * 8))) + ScreenInfoListSize(item.Roots)) + } + return size +} + +// 'Timecoord' struct definition +// Size: 8 +type Timecoord struct { + Time Timestamp + X int16 + Y int16 +} + +// Struct read Timecoord +func ReadTimecoord(buf []byte, v *Timecoord) int { + b := 0 + + v.Time = Timestamp(Get32(buf[b:])) + b += 4 + + v.X = int16(Get16(buf[b:])) + b += 2 + + v.Y = int16(Get16(buf[b:])) + b += 2 + + return b +} + +// Struct list read Timecoord +func ReadTimecoordList(buf []byte, dest []Timecoord) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Timecoord{} + b += ReadTimecoord(buf[b:], &dest[i]) + } + return pad(b) +} + +// Struct write Timecoord +func (v Timecoord) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + Put32(buf[b:], uint32(v.Time)) + b += 4 + + Put16(buf[b:], uint16(v.X)) + b += 2 + + Put16(buf[b:], uint16(v.Y)) + b += 2 + + return buf +} + +// Write struct list Timecoord +func TimecoordListBytes(buf []byte, list []Timecoord) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += pad(len(structBytes)) + } + return b +} + +// 'Fontprop' struct definition +// Size: 8 +type Fontprop struct { + Name Id + Value uint32 +} + +// Struct read Fontprop +func ReadFontprop(buf []byte, v *Fontprop) int { + b := 0 + + v.Name = Id(Get32(buf[b:])) + b += 4 + + v.Value = Get32(buf[b:]) + b += 4 + + return b +} + +// Struct list read Fontprop +func ReadFontpropList(buf []byte, dest []Fontprop) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Fontprop{} + b += ReadFontprop(buf[b:], &dest[i]) + } + return pad(b) +} + +// Struct write Fontprop +func (v Fontprop) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + Put32(buf[b:], uint32(v.Name)) + b += 4 + + Put32(buf[b:], v.Value) + b += 4 + + return buf +} + +// Write struct list Fontprop +func FontpropListBytes(buf []byte, list []Fontprop) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += pad(len(structBytes)) + } + return b +} + +// 'Charinfo' struct definition +// Size: 12 +type Charinfo struct { + LeftSideBearing int16 + RightSideBearing int16 + CharacterWidth int16 + Ascent int16 + Descent int16 + Attributes uint16 +} + +// Struct read Charinfo +func ReadCharinfo(buf []byte, v *Charinfo) int { + b := 0 + + v.LeftSideBearing = int16(Get16(buf[b:])) + b += 2 + + v.RightSideBearing = int16(Get16(buf[b:])) + b += 2 + + v.CharacterWidth = int16(Get16(buf[b:])) + b += 2 + + v.Ascent = int16(Get16(buf[b:])) + b += 2 + + v.Descent = int16(Get16(buf[b:])) + b += 2 + + v.Attributes = Get16(buf[b:]) + b += 2 + + return b +} + +// Struct list read Charinfo +func ReadCharinfoList(buf []byte, dest []Charinfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Charinfo{} + b += ReadCharinfo(buf[b:], &dest[i]) + } + return pad(b) +} + +// Struct write Charinfo +func (v Charinfo) Bytes() []byte { + buf := make([]byte, 12) + b := 0 + + Put16(buf[b:], uint16(v.LeftSideBearing)) + b += 2 + + Put16(buf[b:], uint16(v.RightSideBearing)) + b += 2 + + Put16(buf[b:], uint16(v.CharacterWidth)) + b += 2 + + Put16(buf[b:], uint16(v.Ascent)) + b += 2 + + Put16(buf[b:], uint16(v.Descent)) + b += 2 + + Put16(buf[b:], v.Attributes) + b += 2 + + return buf +} + +// Write struct list Charinfo +func CharinfoListBytes(buf []byte, list []Charinfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += pad(len(structBytes)) + } + return b +} + +// 'Str' struct definition +// Size: (1 + pad((int(NameLen) * 1))) +type Str struct { + NameLen byte + Name string // size: pad((int(NameLen) * 1)) +} + +// Struct read Str +func ReadStr(buf []byte, v *Str) int { + b := 0 + + v.NameLen = buf[b] + b += 1 + + { + byteString := make([]byte, v.NameLen) + copy(byteString[:v.NameLen], buf[b:]) + v.Name = string(byteString) + b += pad(int(v.NameLen)) + } + + return b +} + +// Struct list read Str +func ReadStrList(buf []byte, dest []Str) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Str{} + b += ReadStr(buf[b:], &dest[i]) + } + return pad(b) +} + +// Struct write Str +func (v Str) Bytes() []byte { + buf := make([]byte, (1 + pad((int(v.NameLen) * 1)))) + b := 0 + + buf[b] = v.NameLen + b += 1 + + copy(buf[b:], v.Name[:v.NameLen]) + b += pad(int(v.NameLen)) + + return buf +} + +// Write struct list Str +func StrListBytes(buf []byte, list []Str) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += pad(len(structBytes)) + } + return b +} + +// Struct list size Str +func StrListSize(list []Str) int { + size := 0 + for _, item := range list { + size += (1 + pad((int(item.NameLen) * 1))) + } + return size +} + +// 'Segment' struct definition +// Size: 8 +type Segment struct { + X1 int16 + Y1 int16 + X2 int16 + Y2 int16 +} + +// Struct read Segment +func ReadSegment(buf []byte, v *Segment) int { + b := 0 + + v.X1 = int16(Get16(buf[b:])) + b += 2 + + v.Y1 = int16(Get16(buf[b:])) + b += 2 + + v.X2 = int16(Get16(buf[b:])) + b += 2 + + v.Y2 = int16(Get16(buf[b:])) + b += 2 + + return b +} + +// Struct list read Segment +func ReadSegmentList(buf []byte, dest []Segment) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Segment{} + b += ReadSegment(buf[b:], &dest[i]) + } + return pad(b) +} + +// Struct write Segment +func (v Segment) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + Put16(buf[b:], uint16(v.X1)) + b += 2 + + Put16(buf[b:], uint16(v.Y1)) + b += 2 + + Put16(buf[b:], uint16(v.X2)) + b += 2 + + Put16(buf[b:], uint16(v.Y2)) + b += 2 + + return buf +} + +// Write struct list Segment +func SegmentListBytes(buf []byte, list []Segment) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += pad(len(structBytes)) + } + return b +} + +// 'Coloritem' struct definition +// Size: 12 +type Coloritem struct { + Pixel uint32 + Red uint16 + Green uint16 + Blue uint16 + Flags byte + // padding: 1 bytes +} + +// Struct read Coloritem +func ReadColoritem(buf []byte, v *Coloritem) int { + b := 0 + + v.Pixel = Get32(buf[b:]) + b += 4 + + v.Red = Get16(buf[b:]) + b += 2 + + v.Green = Get16(buf[b:]) + b += 2 + + v.Blue = Get16(buf[b:]) + b += 2 + + v.Flags = buf[b] + b += 1 + + b += 1 // padding + + return b +} + +// Struct list read Coloritem +func ReadColoritemList(buf []byte, dest []Coloritem) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Coloritem{} + b += ReadColoritem(buf[b:], &dest[i]) + } + return pad(b) +} + +// Struct write Coloritem +func (v Coloritem) Bytes() []byte { + buf := make([]byte, 12) + b := 0 + + Put32(buf[b:], v.Pixel) + b += 4 + + Put16(buf[b:], v.Red) + b += 2 + + Put16(buf[b:], v.Green) + b += 2 + + Put16(buf[b:], v.Blue) + b += 2 + + buf[b] = v.Flags + b += 1 + + b += 1 // padding + + return buf +} + +// Write struct list Coloritem +func ColoritemListBytes(buf []byte, list []Coloritem) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += pad(len(structBytes)) + } + return b +} + +// 'Rgb' struct definition +// Size: 8 +type Rgb struct { + Red uint16 + Green uint16 + Blue uint16 + // padding: 2 bytes +} + +// Struct read Rgb +func ReadRgb(buf []byte, v *Rgb) int { + b := 0 + + v.Red = Get16(buf[b:]) + b += 2 + + v.Green = Get16(buf[b:]) + b += 2 + + v.Blue = Get16(buf[b:]) + b += 2 + + b += 2 // padding + + return b +} + +// Struct list read Rgb +func ReadRgbList(buf []byte, dest []Rgb) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Rgb{} + b += ReadRgb(buf[b:], &dest[i]) + } + return pad(b) +} + +// Struct write Rgb +func (v Rgb) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + Put16(buf[b:], v.Red) + b += 2 + + Put16(buf[b:], v.Green) + b += 2 + + Put16(buf[b:], v.Blue) + b += 2 + + b += 2 // padding + + return buf +} + +// Write struct list Rgb +func RgbListBytes(buf []byte, list []Rgb) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += pad(len(structBytes)) + } + return b +} + +// 'Host' struct definition +// Size: (4 + pad((int(AddressLen) * 1))) +type Host struct { + Family byte + // padding: 1 bytes + AddressLen uint16 + Address []byte // size: pad((int(AddressLen) * 1)) +} + +// Struct read Host +func ReadHost(buf []byte, v *Host) int { + b := 0 + + v.Family = buf[b] + b += 1 + + b += 1 // padding + + v.AddressLen = Get16(buf[b:]) + b += 2 + + v.Address = make([]byte, v.AddressLen) + copy(v.Address[:v.AddressLen], buf[b:]) + b += pad(int(v.AddressLen)) + + return b +} + +// Struct list read Host +func ReadHostList(buf []byte, dest []Host) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Host{} + b += ReadHost(buf[b:], &dest[i]) + } + return pad(b) +} + +// Struct write Host +func (v Host) Bytes() []byte { + buf := make([]byte, (4 + pad((int(v.AddressLen) * 1)))) + b := 0 + + buf[b] = v.Family + b += 1 + + b += 1 // padding + + Put16(buf[b:], v.AddressLen) + b += 2 + + copy(buf[b:], v.Address[:v.AddressLen]) + b += pad(int(v.AddressLen)) + + return buf +} + +// Write struct list Host +func HostListBytes(buf []byte, list []Host) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += pad(len(structBytes)) + } + return b +} + +// Struct list size Host +func HostListSize(list []Host) int { + size := 0 + for _, item := range list { + size += (4 + pad((int(item.AddressLen) * 1))) + } + return size +} + +// Union definition ClientMessageDataUnion +// Note that to *create* a Union, you should *never* create +// this struct directly (unless you know what you're doing). +// Instead use one of the following constructors for 'ClientMessageDataUnion': +// NewClientMessageDataUnionData8(Data8 []byte) ClientMessageDataUnion +// NewClientMessageDataUnionData16(Data16 []uint16) ClientMessageDataUnion +// NewClientMessageDataUnionData32(Data32 []uint32) ClientMessageDataUnion +type ClientMessageDataUnion struct { + Data8 []byte // size: pad(20) + Data16 []uint16 // size: pad(20) + Data32 []uint32 // size: pad(20) +} + +// Union constructor for ClientMessageDataUnion for field Data8. +func NewClientMessageDataUnionData8(Data8 []byte) ClientMessageDataUnion { + var b int + buf := make([]byte, pad(20)) + + copy(buf[b:], Data8[:20]) + b += pad(int(20)) + + // Create the Union type + v := ClientMessageDataUnion{} + + // Now copy buf into all fields + + b = 0 // always read the same bytes + v.Data8 = make([]byte, 20) + copy(v.Data8[:20], buf[b:]) + b += pad(int(20)) + + b = 0 // always read the same bytes + v.Data16 = make([]uint16, 10) + for i := 0; i < int(10); i++ { + v.Data16[i] = Get16(buf[b:]) + b += 2 + } + b = pad(b) + + b = 0 // always read the same bytes + v.Data32 = make([]uint32, 5) + for i := 0; i < int(5); i++ { + v.Data32[i] = Get32(buf[b:]) + b += 4 + } + b = pad(b) + + return v +} + +// Union constructor for ClientMessageDataUnion for field Data16. +func NewClientMessageDataUnionData16(Data16 []uint16) ClientMessageDataUnion { + var b int + buf := make([]byte, pad(20)) + + for i := 0; i < int(10); i++ { + Put16(buf[b:], Data16[i]) + b += 2 + } + b = pad(b) + + // Create the Union type + v := ClientMessageDataUnion{} + + // Now copy buf into all fields + + b = 0 // always read the same bytes + v.Data8 = make([]byte, 20) + copy(v.Data8[:20], buf[b:]) + b += pad(int(20)) + + b = 0 // always read the same bytes + v.Data16 = make([]uint16, 10) + for i := 0; i < int(10); i++ { + v.Data16[i] = Get16(buf[b:]) + b += 2 + } + b = pad(b) + + b = 0 // always read the same bytes + v.Data32 = make([]uint32, 5) + for i := 0; i < int(5); i++ { + v.Data32[i] = Get32(buf[b:]) + b += 4 + } + b = pad(b) + + return v +} + +// Union constructor for ClientMessageDataUnion for field Data32. +func NewClientMessageDataUnionData32(Data32 []uint32) ClientMessageDataUnion { + var b int + buf := make([]byte, pad(20)) + + for i := 0; i < int(5); i++ { + Put32(buf[b:], Data32[i]) + b += 4 + } + b = pad(b) + + // Create the Union type + v := ClientMessageDataUnion{} + + // Now copy buf into all fields + + b = 0 // always read the same bytes + v.Data8 = make([]byte, 20) + copy(v.Data8[:20], buf[b:]) + b += pad(int(20)) + + b = 0 // always read the same bytes + v.Data16 = make([]uint16, 10) + for i := 0; i < int(10); i++ { + v.Data16[i] = Get16(buf[b:]) + b += 2 + } + b = pad(b) + + b = 0 // always read the same bytes + v.Data32 = make([]uint32, 5) + for i := 0; i < int(5); i++ { + v.Data32[i] = Get32(buf[b:]) + b += 4 + } + b = pad(b) + + return v +} + +// Union read ClientMessageDataUnion +func ReadClientMessageDataUnion(buf []byte, v *ClientMessageDataUnion) int { + var b int + + b = 0 // re-read the same bytes + v.Data8 = make([]byte, 20) + copy(v.Data8[:20], buf[b:]) + b += pad(int(20)) + + b = 0 // re-read the same bytes + v.Data16 = make([]uint16, 10) + for i := 0; i < int(10); i++ { + v.Data16[i] = Get16(buf[b:]) + b += 2 + } + b = pad(b) + + b = 0 // re-read the same bytes + v.Data32 = make([]uint32, 5) + for i := 0; i < int(5); i++ { + v.Data32[i] = Get32(buf[b:]) + b += 4 + } + b = pad(b) + + return pad(20) +} + +// Union list read ClientMessageDataUnion +func ReadClientMessageDataUnionList(buf []byte, dest []ClientMessageDataUnion) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = ClientMessageDataUnion{} + b += ReadClientMessageDataUnion(buf[b:], &dest[i]) + } + return pad(b) +} + +// Union write ClientMessageDataUnion +// Each field in a union must contain the same data. +// So simply pick the first field and write that to the wire. +func (v ClientMessageDataUnion) Bytes() []byte { + buf := make([]byte, pad(20)) + b := 0 + + copy(buf[b:], v.Data8[:20]) + b += pad(int(20)) + return buf +} + +// Union list write ClientMessageDataUnion +func ClientMessageDataUnionListBytes(buf []byte, list []ClientMessageDataUnion) int { + b := 0 + var unionBytes []byte + for _, item := range list { + unionBytes = item.Bytes() + copy(buf[b:], unionBytes) + b += pad(len(unionBytes)) + } + return b +} + +// Event definition KeyPress (2) +// Size: 32 + +const KeyPress = 2 + +type KeyPressEvent struct { + Sequence uint16 + Detail Keycode + Time Timestamp + Root Id + Event Id + Child Id + RootX int16 + RootY int16 + EventX int16 + EventY int16 + State uint16 + SameScreen bool + // padding: 1 bytes +} + +// Event read KeyPress +func NewKeyPressEvent(buf []byte) Event { + v := KeyPressEvent{} + b := 1 // don't read event number + + v.Detail = Keycode(buf[b]) + b += 1 + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Time = Timestamp(Get32(buf[b:])) + b += 4 + + v.Root = Id(Get32(buf[b:])) + b += 4 + + v.Event = Id(Get32(buf[b:])) + b += 4 + + v.Child = Id(Get32(buf[b:])) + b += 4 + + v.RootX = int16(Get16(buf[b:])) + b += 2 + + v.RootY = int16(Get16(buf[b:])) + b += 2 + + v.EventX = int16(Get16(buf[b:])) + b += 2 + + v.EventY = int16(Get16(buf[b:])) + b += 2 + + v.State = Get16(buf[b:]) + b += 2 + + if buf[b] == 1 { + v.SameScreen = true + } else { + v.SameScreen = false + } + b += 1 + + b += 1 // padding + + return v +} + +// Event write KeyPress +func (v KeyPressEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 2 + b += 1 + + buf[b] = byte(v.Detail) + b += 1 + + b += 2 // skip sequence number + + Put32(buf[b:], uint32(v.Time)) + b += 4 + + Put32(buf[b:], uint32(v.Root)) + b += 4 + + Put32(buf[b:], uint32(v.Event)) + b += 4 + + Put32(buf[b:], uint32(v.Child)) + b += 4 + + Put16(buf[b:], uint16(v.RootX)) + b += 2 + + Put16(buf[b:], uint16(v.RootY)) + b += 2 + + Put16(buf[b:], uint16(v.EventX)) + b += 2 + + Put16(buf[b:], uint16(v.EventY)) + b += 2 + + Put16(buf[b:], v.State) + b += 2 + + if v.SameScreen { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 1 // padding + + return buf +} + +func (v KeyPressEvent) ImplementsEvent() {} + +func init() { + newEventFuncs[2] = NewKeyPressEvent +} + +// Event definition ButtonPress (4) +// Size: 32 + +const ButtonPress = 4 + +type ButtonPressEvent struct { + Sequence uint16 + Detail Button + Time Timestamp + Root Id + Event Id + Child Id + RootX int16 + RootY int16 + EventX int16 + EventY int16 + State uint16 + SameScreen bool + // padding: 1 bytes +} + +// Event read ButtonPress +func NewButtonPressEvent(buf []byte) Event { + v := ButtonPressEvent{} + b := 1 // don't read event number + + v.Detail = Button(buf[b]) + b += 1 + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Time = Timestamp(Get32(buf[b:])) + b += 4 + + v.Root = Id(Get32(buf[b:])) + b += 4 + + v.Event = Id(Get32(buf[b:])) + b += 4 + + v.Child = Id(Get32(buf[b:])) + b += 4 + + v.RootX = int16(Get16(buf[b:])) + b += 2 + + v.RootY = int16(Get16(buf[b:])) + b += 2 + + v.EventX = int16(Get16(buf[b:])) + b += 2 + + v.EventY = int16(Get16(buf[b:])) + b += 2 + + v.State = Get16(buf[b:]) + b += 2 + + if buf[b] == 1 { + v.SameScreen = true + } else { + v.SameScreen = false + } + b += 1 + + b += 1 // padding + + return v +} + +// Event write ButtonPress +func (v ButtonPressEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 4 + b += 1 + + buf[b] = byte(v.Detail) + b += 1 + + b += 2 // skip sequence number + + Put32(buf[b:], uint32(v.Time)) + b += 4 + + Put32(buf[b:], uint32(v.Root)) + b += 4 + + Put32(buf[b:], uint32(v.Event)) + b += 4 + + Put32(buf[b:], uint32(v.Child)) + b += 4 + + Put16(buf[b:], uint16(v.RootX)) + b += 2 + + Put16(buf[b:], uint16(v.RootY)) + b += 2 + + Put16(buf[b:], uint16(v.EventX)) + b += 2 + + Put16(buf[b:], uint16(v.EventY)) + b += 2 + + Put16(buf[b:], v.State) + b += 2 + + if v.SameScreen { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 1 // padding + + return buf +} + +func (v ButtonPressEvent) ImplementsEvent() {} + +func init() { + newEventFuncs[4] = NewButtonPressEvent +} + +// Event definition MotionNotify (6) +// Size: 32 + +const MotionNotify = 6 + +type MotionNotifyEvent struct { + Sequence uint16 + Detail byte + Time Timestamp + Root Id + Event Id + Child Id + RootX int16 + RootY int16 + EventX int16 + EventY int16 + State uint16 + SameScreen bool + // padding: 1 bytes +} + +// Event read MotionNotify +func NewMotionNotifyEvent(buf []byte) Event { + v := MotionNotifyEvent{} + b := 1 // don't read event number + + v.Detail = buf[b] + b += 1 + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Time = Timestamp(Get32(buf[b:])) + b += 4 + + v.Root = Id(Get32(buf[b:])) + b += 4 + + v.Event = Id(Get32(buf[b:])) + b += 4 + + v.Child = Id(Get32(buf[b:])) + b += 4 + + v.RootX = int16(Get16(buf[b:])) + b += 2 + + v.RootY = int16(Get16(buf[b:])) + b += 2 + + v.EventX = int16(Get16(buf[b:])) + b += 2 + + v.EventY = int16(Get16(buf[b:])) + b += 2 + + v.State = Get16(buf[b:]) + b += 2 + + if buf[b] == 1 { + v.SameScreen = true + } else { + v.SameScreen = false + } + b += 1 + + b += 1 // padding + + return v +} + +// Event write MotionNotify +func (v MotionNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 6 + b += 1 + + buf[b] = v.Detail + b += 1 + + b += 2 // skip sequence number + + Put32(buf[b:], uint32(v.Time)) + b += 4 + + Put32(buf[b:], uint32(v.Root)) + b += 4 + + Put32(buf[b:], uint32(v.Event)) + b += 4 + + Put32(buf[b:], uint32(v.Child)) + b += 4 + + Put16(buf[b:], uint16(v.RootX)) + b += 2 + + Put16(buf[b:], uint16(v.RootY)) + b += 2 + + Put16(buf[b:], uint16(v.EventX)) + b += 2 + + Put16(buf[b:], uint16(v.EventY)) + b += 2 + + Put16(buf[b:], v.State) + b += 2 + + if v.SameScreen { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 1 // padding + + return buf +} + +func (v MotionNotifyEvent) ImplementsEvent() {} + +func init() { + newEventFuncs[6] = NewMotionNotifyEvent +} + +// Event definition EnterNotify (7) +// Size: 32 + +const EnterNotify = 7 + +type EnterNotifyEvent struct { + Sequence uint16 + Detail byte + Time Timestamp + Root Id + Event Id + Child Id + RootX int16 + RootY int16 + EventX int16 + EventY int16 + State uint16 + Mode byte + SameScreenFocus byte +} + +// Event read EnterNotify +func NewEnterNotifyEvent(buf []byte) Event { + v := EnterNotifyEvent{} + b := 1 // don't read event number + + v.Detail = buf[b] + b += 1 + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Time = Timestamp(Get32(buf[b:])) + b += 4 + + v.Root = Id(Get32(buf[b:])) + b += 4 + + v.Event = Id(Get32(buf[b:])) + b += 4 + + v.Child = Id(Get32(buf[b:])) + b += 4 + + v.RootX = int16(Get16(buf[b:])) + b += 2 + + v.RootY = int16(Get16(buf[b:])) + b += 2 + + v.EventX = int16(Get16(buf[b:])) + b += 2 + + v.EventY = int16(Get16(buf[b:])) + b += 2 + + v.State = Get16(buf[b:]) + b += 2 + + v.Mode = buf[b] + b += 1 + + v.SameScreenFocus = buf[b] + b += 1 + + return v +} + +// Event write EnterNotify +func (v EnterNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 7 + b += 1 + + buf[b] = v.Detail + b += 1 + + b += 2 // skip sequence number + + Put32(buf[b:], uint32(v.Time)) + b += 4 + + Put32(buf[b:], uint32(v.Root)) + b += 4 + + Put32(buf[b:], uint32(v.Event)) + b += 4 + + Put32(buf[b:], uint32(v.Child)) + b += 4 + + Put16(buf[b:], uint16(v.RootX)) + b += 2 + + Put16(buf[b:], uint16(v.RootY)) + b += 2 + + Put16(buf[b:], uint16(v.EventX)) + b += 2 + + Put16(buf[b:], uint16(v.EventY)) + b += 2 + + Put16(buf[b:], v.State) + b += 2 + + buf[b] = v.Mode + b += 1 + + buf[b] = v.SameScreenFocus + b += 1 + + return buf +} + +func (v EnterNotifyEvent) ImplementsEvent() {} + +func init() { + newEventFuncs[7] = NewEnterNotifyEvent +} + +// Event definition FocusIn (9) +// Size: 32 + +const FocusIn = 9 + +type FocusInEvent struct { + Sequence uint16 + Detail byte + Event Id + Mode byte + // padding: 3 bytes +} + +// Event read FocusIn +func NewFocusInEvent(buf []byte) Event { + v := FocusInEvent{} + b := 1 // don't read event number + + v.Detail = buf[b] + b += 1 + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Event = Id(Get32(buf[b:])) + b += 4 + + v.Mode = buf[b] + b += 1 + + b += 3 // padding + + return v +} + +// Event write FocusIn +func (v FocusInEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 9 + b += 1 + + buf[b] = v.Detail + b += 1 + + b += 2 // skip sequence number + + Put32(buf[b:], uint32(v.Event)) + b += 4 + + buf[b] = v.Mode + b += 1 + + b += 3 // padding + + return buf +} + +func (v FocusInEvent) ImplementsEvent() {} + +func init() { + newEventFuncs[9] = NewFocusInEvent +} + +// Event definition KeymapNotify (11) +// Size: 32 + +const KeymapNotify = 11 + +type KeymapNotifyEvent struct { + Keys []byte // size: pad(31) +} + +// Event read KeymapNotify +func NewKeymapNotifyEvent(buf []byte) Event { + v := KeymapNotifyEvent{} + b := 1 // don't read event number + + v.Keys = make([]byte, 31) + copy(v.Keys[:31], buf[b:]) + b += pad(int(31)) + + return v +} + +// Event write KeymapNotify +func (v KeymapNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 11 + b += 1 + + copy(buf[b:], v.Keys[:31]) + b += pad(int(31)) + + return buf +} + +func (v KeymapNotifyEvent) ImplementsEvent() {} + +func init() { + newEventFuncs[11] = NewKeymapNotifyEvent +} + +// Event definition Expose (12) +// Size: 32 + +const Expose = 12 + +type ExposeEvent struct { + Sequence uint16 + // padding: 1 bytes + Window Id + X uint16 + Y uint16 + Width uint16 + Height uint16 + Count uint16 + // padding: 2 bytes +} + +// Event read Expose +func NewExposeEvent(buf []byte) Event { + v := ExposeEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Window = Id(Get32(buf[b:])) + b += 4 + + v.X = Get16(buf[b:]) + b += 2 + + v.Y = Get16(buf[b:]) + b += 2 + + v.Width = Get16(buf[b:]) + b += 2 + + v.Height = Get16(buf[b:]) + b += 2 + + v.Count = Get16(buf[b:]) + b += 2 + + b += 2 // padding + + return v +} + +// Event write Expose +func (v ExposeEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 12 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + Put32(buf[b:], uint32(v.Window)) + b += 4 + + Put16(buf[b:], v.X) + b += 2 + + Put16(buf[b:], v.Y) + b += 2 + + Put16(buf[b:], v.Width) + b += 2 + + Put16(buf[b:], v.Height) + b += 2 + + Put16(buf[b:], v.Count) + b += 2 + + b += 2 // padding + + return buf +} + +func (v ExposeEvent) ImplementsEvent() {} + +func init() { + newEventFuncs[12] = NewExposeEvent +} + +// Event definition GraphicsExposure (13) +// Size: 32 + +const GraphicsExposure = 13 + +type GraphicsExposureEvent struct { + Sequence uint16 + // padding: 1 bytes + Drawable Id + X uint16 + Y uint16 + Width uint16 + Height uint16 + MinorOpcode uint16 + Count uint16 + MajorOpcode byte + // padding: 3 bytes +} + +// Event read GraphicsExposure +func NewGraphicsExposureEvent(buf []byte) Event { + v := GraphicsExposureEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Drawable = Id(Get32(buf[b:])) + b += 4 + + v.X = Get16(buf[b:]) + b += 2 + + v.Y = Get16(buf[b:]) + b += 2 + + v.Width = Get16(buf[b:]) + b += 2 + + v.Height = Get16(buf[b:]) + b += 2 + + v.MinorOpcode = Get16(buf[b:]) + b += 2 + + v.Count = Get16(buf[b:]) + b += 2 + + v.MajorOpcode = buf[b] + b += 1 + + b += 3 // padding + + return v +} + +// Event write GraphicsExposure +func (v GraphicsExposureEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 13 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + Put32(buf[b:], uint32(v.Drawable)) + b += 4 + + Put16(buf[b:], v.X) + b += 2 + + Put16(buf[b:], v.Y) + b += 2 + + Put16(buf[b:], v.Width) + b += 2 + + Put16(buf[b:], v.Height) + b += 2 + + Put16(buf[b:], v.MinorOpcode) + b += 2 + + Put16(buf[b:], v.Count) + b += 2 + + buf[b] = v.MajorOpcode + b += 1 + + b += 3 // padding + + return buf +} + +func (v GraphicsExposureEvent) ImplementsEvent() {} + +func init() { + newEventFuncs[13] = NewGraphicsExposureEvent +} + +// Event definition NoExposure (14) +// Size: 32 + +const NoExposure = 14 + +type NoExposureEvent struct { + Sequence uint16 + // padding: 1 bytes + Drawable Id + MinorOpcode uint16 + MajorOpcode byte + // padding: 1 bytes +} + +// Event read NoExposure +func NewNoExposureEvent(buf []byte) Event { + v := NoExposureEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Drawable = Id(Get32(buf[b:])) + b += 4 + + v.MinorOpcode = Get16(buf[b:]) + b += 2 + + v.MajorOpcode = buf[b] + b += 1 + + b += 1 // padding + + return v +} + +// Event write NoExposure +func (v NoExposureEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 14 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + Put32(buf[b:], uint32(v.Drawable)) + b += 4 + + Put16(buf[b:], v.MinorOpcode) + b += 2 + + buf[b] = v.MajorOpcode + b += 1 + + b += 1 // padding + + return buf +} + +func (v NoExposureEvent) ImplementsEvent() {} + +func init() { + newEventFuncs[14] = NewNoExposureEvent +} + +// Event definition VisibilityNotify (15) +// Size: 32 + +const VisibilityNotify = 15 + +type VisibilityNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Window Id + State byte + // padding: 3 bytes +} + +// Event read VisibilityNotify +func NewVisibilityNotifyEvent(buf []byte) Event { + v := VisibilityNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Window = Id(Get32(buf[b:])) + b += 4 + + v.State = buf[b] + b += 1 + + b += 3 // padding + + return v +} + +// Event write VisibilityNotify +func (v VisibilityNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 15 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + Put32(buf[b:], uint32(v.Window)) + b += 4 + + buf[b] = v.State + b += 1 + + b += 3 // padding + + return buf +} + +func (v VisibilityNotifyEvent) ImplementsEvent() {} + +func init() { + newEventFuncs[15] = NewVisibilityNotifyEvent +} + +// Event definition CreateNotify (16) +// Size: 32 + +const CreateNotify = 16 + +type CreateNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Parent Id + Window Id + X int16 + Y int16 + Width uint16 + Height uint16 + BorderWidth uint16 + OverrideRedirect bool + // padding: 1 bytes +} + +// Event read CreateNotify +func NewCreateNotifyEvent(buf []byte) Event { + v := CreateNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Parent = Id(Get32(buf[b:])) + b += 4 + + v.Window = Id(Get32(buf[b:])) + b += 4 + + v.X = int16(Get16(buf[b:])) + b += 2 + + v.Y = int16(Get16(buf[b:])) + b += 2 + + v.Width = Get16(buf[b:]) + b += 2 + + v.Height = Get16(buf[b:]) + b += 2 + + v.BorderWidth = Get16(buf[b:]) + b += 2 + + if buf[b] == 1 { + v.OverrideRedirect = true + } else { + v.OverrideRedirect = false + } + b += 1 + + b += 1 // padding + + return v +} + +// Event write CreateNotify +func (v CreateNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 16 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + Put32(buf[b:], uint32(v.Parent)) + b += 4 + + Put32(buf[b:], uint32(v.Window)) + b += 4 + + Put16(buf[b:], uint16(v.X)) + b += 2 + + Put16(buf[b:], uint16(v.Y)) + b += 2 + + Put16(buf[b:], v.Width) + b += 2 + + Put16(buf[b:], v.Height) + b += 2 + + Put16(buf[b:], v.BorderWidth) + b += 2 + + if v.OverrideRedirect { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 1 // padding + + return buf +} + +func (v CreateNotifyEvent) ImplementsEvent() {} + +func init() { + newEventFuncs[16] = NewCreateNotifyEvent +} + +// Event definition DestroyNotify (17) +// Size: 32 + +const DestroyNotify = 17 + +type DestroyNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Event Id + Window Id +} + +// Event read DestroyNotify +func NewDestroyNotifyEvent(buf []byte) Event { + v := DestroyNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Event = Id(Get32(buf[b:])) + b += 4 + + v.Window = Id(Get32(buf[b:])) + b += 4 + + return v +} + +// Event write DestroyNotify +func (v DestroyNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 17 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + Put32(buf[b:], uint32(v.Event)) + b += 4 + + Put32(buf[b:], uint32(v.Window)) + b += 4 + + return buf +} + +func (v DestroyNotifyEvent) ImplementsEvent() {} + +func init() { + newEventFuncs[17] = NewDestroyNotifyEvent +} + +// Event definition UnmapNotify (18) +// Size: 32 + +const UnmapNotify = 18 + +type UnmapNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Event Id + Window Id + FromConfigure bool + // padding: 3 bytes +} + +// Event read UnmapNotify +func NewUnmapNotifyEvent(buf []byte) Event { + v := UnmapNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Event = Id(Get32(buf[b:])) + b += 4 + + v.Window = Id(Get32(buf[b:])) + b += 4 + + if buf[b] == 1 { + v.FromConfigure = true + } else { + v.FromConfigure = false + } + b += 1 + + b += 3 // padding + + return v +} + +// Event write UnmapNotify +func (v UnmapNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 18 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + Put32(buf[b:], uint32(v.Event)) + b += 4 + + Put32(buf[b:], uint32(v.Window)) + b += 4 + + if v.FromConfigure { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding + + return buf +} + +func (v UnmapNotifyEvent) ImplementsEvent() {} + +func init() { + newEventFuncs[18] = NewUnmapNotifyEvent +} + +// Event definition MapNotify (19) +// Size: 32 + +const MapNotify = 19 + +type MapNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Event Id + Window Id + OverrideRedirect bool + // padding: 3 bytes +} + +// Event read MapNotify +func NewMapNotifyEvent(buf []byte) Event { + v := MapNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Event = Id(Get32(buf[b:])) + b += 4 + + v.Window = Id(Get32(buf[b:])) + b += 4 + + if buf[b] == 1 { + v.OverrideRedirect = true + } else { + v.OverrideRedirect = false + } + b += 1 + + b += 3 // padding + + return v +} + +// Event write MapNotify +func (v MapNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 19 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + Put32(buf[b:], uint32(v.Event)) + b += 4 + + Put32(buf[b:], uint32(v.Window)) + b += 4 + + if v.OverrideRedirect { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding + + return buf +} + +func (v MapNotifyEvent) ImplementsEvent() {} + +func init() { + newEventFuncs[19] = NewMapNotifyEvent +} + +// Event definition MapRequest (20) +// Size: 32 + +const MapRequest = 20 + +type MapRequestEvent struct { + Sequence uint16 + // padding: 1 bytes + Parent Id + Window Id +} + +// Event read MapRequest +func NewMapRequestEvent(buf []byte) Event { + v := MapRequestEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Parent = Id(Get32(buf[b:])) + b += 4 + + v.Window = Id(Get32(buf[b:])) + b += 4 + + return v +} + +// Event write MapRequest +func (v MapRequestEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 20 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + Put32(buf[b:], uint32(v.Parent)) + b += 4 + + Put32(buf[b:], uint32(v.Window)) + b += 4 + + return buf +} + +func (v MapRequestEvent) ImplementsEvent() {} + +func init() { + newEventFuncs[20] = NewMapRequestEvent +} + +// Event definition ReparentNotify (21) +// Size: 32 + +const ReparentNotify = 21 + +type ReparentNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Event Id + Window Id + Parent Id + X int16 + Y int16 + OverrideRedirect bool + // padding: 3 bytes +} + +// Event read ReparentNotify +func NewReparentNotifyEvent(buf []byte) Event { + v := ReparentNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Event = Id(Get32(buf[b:])) + b += 4 + + v.Window = Id(Get32(buf[b:])) + b += 4 + + v.Parent = Id(Get32(buf[b:])) + b += 4 + + v.X = int16(Get16(buf[b:])) + b += 2 + + v.Y = int16(Get16(buf[b:])) + b += 2 + + if buf[b] == 1 { + v.OverrideRedirect = true + } else { + v.OverrideRedirect = false + } + b += 1 + + b += 3 // padding + + return v +} + +// Event write ReparentNotify +func (v ReparentNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 21 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + Put32(buf[b:], uint32(v.Event)) + b += 4 + + Put32(buf[b:], uint32(v.Window)) + b += 4 + + Put32(buf[b:], uint32(v.Parent)) + b += 4 + + Put16(buf[b:], uint16(v.X)) + b += 2 + + Put16(buf[b:], uint16(v.Y)) + b += 2 + + if v.OverrideRedirect { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding + + return buf +} + +func (v ReparentNotifyEvent) ImplementsEvent() {} + +func init() { + newEventFuncs[21] = NewReparentNotifyEvent +} + +// Event definition ConfigureNotify (22) +// Size: 32 + +const ConfigureNotify = 22 + +type ConfigureNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Event Id + Window Id + AboveSibling Id + X int16 + Y int16 + Width uint16 + Height uint16 + BorderWidth uint16 + OverrideRedirect bool + // padding: 1 bytes +} + +// Event read ConfigureNotify +func NewConfigureNotifyEvent(buf []byte) Event { + v := ConfigureNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Event = Id(Get32(buf[b:])) + b += 4 + + v.Window = Id(Get32(buf[b:])) + b += 4 + + v.AboveSibling = Id(Get32(buf[b:])) + b += 4 + + v.X = int16(Get16(buf[b:])) + b += 2 + + v.Y = int16(Get16(buf[b:])) + b += 2 + + v.Width = Get16(buf[b:]) + b += 2 + + v.Height = Get16(buf[b:]) + b += 2 + + v.BorderWidth = Get16(buf[b:]) + b += 2 + + if buf[b] == 1 { + v.OverrideRedirect = true + } else { + v.OverrideRedirect = false + } + b += 1 + + b += 1 // padding + + return v +} + +// Event write ConfigureNotify +func (v ConfigureNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 22 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + Put32(buf[b:], uint32(v.Event)) + b += 4 + + Put32(buf[b:], uint32(v.Window)) + b += 4 + + Put32(buf[b:], uint32(v.AboveSibling)) + b += 4 + + Put16(buf[b:], uint16(v.X)) + b += 2 + + Put16(buf[b:], uint16(v.Y)) + b += 2 + + Put16(buf[b:], v.Width) + b += 2 + + Put16(buf[b:], v.Height) + b += 2 + + Put16(buf[b:], v.BorderWidth) + b += 2 + + if v.OverrideRedirect { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 1 // padding + + return buf +} + +func (v ConfigureNotifyEvent) ImplementsEvent() {} + +func init() { + newEventFuncs[22] = NewConfigureNotifyEvent +} + +// Event definition ConfigureRequest (23) +// Size: 32 + +const ConfigureRequest = 23 + +type ConfigureRequestEvent struct { + Sequence uint16 + StackMode byte + Parent Id + Window Id + Sibling Id + X int16 + Y int16 + Width uint16 + Height uint16 + BorderWidth uint16 + ValueMask uint16 +} + +// Event read ConfigureRequest +func NewConfigureRequestEvent(buf []byte) Event { + v := ConfigureRequestEvent{} + b := 1 // don't read event number + + v.StackMode = buf[b] + b += 1 + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Parent = Id(Get32(buf[b:])) + b += 4 + + v.Window = Id(Get32(buf[b:])) + b += 4 + + v.Sibling = Id(Get32(buf[b:])) + b += 4 + + v.X = int16(Get16(buf[b:])) + b += 2 + + v.Y = int16(Get16(buf[b:])) + b += 2 + + v.Width = Get16(buf[b:]) + b += 2 + + v.Height = Get16(buf[b:]) + b += 2 + + v.BorderWidth = Get16(buf[b:]) + b += 2 + + v.ValueMask = Get16(buf[b:]) + b += 2 + + return v +} + +// Event write ConfigureRequest +func (v ConfigureRequestEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 23 + b += 1 + + buf[b] = v.StackMode + b += 1 + + b += 2 // skip sequence number + + Put32(buf[b:], uint32(v.Parent)) + b += 4 + + Put32(buf[b:], uint32(v.Window)) + b += 4 + + Put32(buf[b:], uint32(v.Sibling)) + b += 4 + + Put16(buf[b:], uint16(v.X)) + b += 2 + + Put16(buf[b:], uint16(v.Y)) + b += 2 + + Put16(buf[b:], v.Width) + b += 2 + + Put16(buf[b:], v.Height) + b += 2 + + Put16(buf[b:], v.BorderWidth) + b += 2 + + Put16(buf[b:], v.ValueMask) + b += 2 + + return buf +} + +func (v ConfigureRequestEvent) ImplementsEvent() {} + +func init() { + newEventFuncs[23] = NewConfigureRequestEvent +} + +// Event definition GravityNotify (24) +// Size: 32 + +const GravityNotify = 24 + +type GravityNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Event Id + Window Id + X int16 + Y int16 +} + +// Event read GravityNotify +func NewGravityNotifyEvent(buf []byte) Event { + v := GravityNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Event = Id(Get32(buf[b:])) + b += 4 + + v.Window = Id(Get32(buf[b:])) + b += 4 + + v.X = int16(Get16(buf[b:])) + b += 2 + + v.Y = int16(Get16(buf[b:])) + b += 2 + + return v +} + +// Event write GravityNotify +func (v GravityNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 24 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + Put32(buf[b:], uint32(v.Event)) + b += 4 + + Put32(buf[b:], uint32(v.Window)) + b += 4 + + Put16(buf[b:], uint16(v.X)) + b += 2 + + Put16(buf[b:], uint16(v.Y)) + b += 2 + + return buf +} + +func (v GravityNotifyEvent) ImplementsEvent() {} + +func init() { + newEventFuncs[24] = NewGravityNotifyEvent +} + +// Event definition ResizeRequest (25) +// Size: 32 + +const ResizeRequest = 25 + +type ResizeRequestEvent struct { + Sequence uint16 + // padding: 1 bytes + Window Id + Width uint16 + Height uint16 +} + +// Event read ResizeRequest +func NewResizeRequestEvent(buf []byte) Event { + v := ResizeRequestEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Window = Id(Get32(buf[b:])) + b += 4 + + v.Width = Get16(buf[b:]) + b += 2 + + v.Height = Get16(buf[b:]) + b += 2 + + return v +} + +// Event write ResizeRequest +func (v ResizeRequestEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 25 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + Put32(buf[b:], uint32(v.Window)) + b += 4 + + Put16(buf[b:], v.Width) + b += 2 + + Put16(buf[b:], v.Height) + b += 2 + + return buf +} + +func (v ResizeRequestEvent) ImplementsEvent() {} + +func init() { + newEventFuncs[25] = NewResizeRequestEvent +} + +// Event definition CirculateNotify (26) +// Size: 32 + +const CirculateNotify = 26 + +type CirculateNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Event Id + Window Id + // padding: 4 bytes + Place byte + // padding: 3 bytes +} + +// Event read CirculateNotify +func NewCirculateNotifyEvent(buf []byte) Event { + v := CirculateNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Event = Id(Get32(buf[b:])) + b += 4 + + v.Window = Id(Get32(buf[b:])) + b += 4 + + b += 4 // padding + + v.Place = buf[b] + b += 1 + + b += 3 // padding + + return v +} + +// Event write CirculateNotify +func (v CirculateNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 26 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + Put32(buf[b:], uint32(v.Event)) + b += 4 + + Put32(buf[b:], uint32(v.Window)) + b += 4 + + b += 4 // padding + + buf[b] = v.Place + b += 1 + + b += 3 // padding + + return buf +} + +func (v CirculateNotifyEvent) ImplementsEvent() {} + +func init() { + newEventFuncs[26] = NewCirculateNotifyEvent +} + +// Event definition PropertyNotify (28) +// Size: 32 + +const PropertyNotify = 28 + +type PropertyNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Window Id + Atom Id + Time Timestamp + State byte + // padding: 3 bytes +} + +// Event read PropertyNotify +func NewPropertyNotifyEvent(buf []byte) Event { + v := PropertyNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Window = Id(Get32(buf[b:])) + b += 4 + + v.Atom = Id(Get32(buf[b:])) + b += 4 + + v.Time = Timestamp(Get32(buf[b:])) + b += 4 + + v.State = buf[b] + b += 1 + + b += 3 // padding + + return v +} + +// Event write PropertyNotify +func (v PropertyNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 28 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + Put32(buf[b:], uint32(v.Window)) + b += 4 + + Put32(buf[b:], uint32(v.Atom)) + b += 4 + + Put32(buf[b:], uint32(v.Time)) + b += 4 + + buf[b] = v.State + b += 1 + + b += 3 // padding + + return buf +} + +func (v PropertyNotifyEvent) ImplementsEvent() {} + +func init() { + newEventFuncs[28] = NewPropertyNotifyEvent +} + +// Event definition SelectionClear (29) +// Size: 32 + +const SelectionClear = 29 + +type SelectionClearEvent struct { + Sequence uint16 + // padding: 1 bytes + Time Timestamp + Owner Id + Selection Id +} + +// Event read SelectionClear +func NewSelectionClearEvent(buf []byte) Event { + v := SelectionClearEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Time = Timestamp(Get32(buf[b:])) + b += 4 + + v.Owner = Id(Get32(buf[b:])) + b += 4 + + v.Selection = Id(Get32(buf[b:])) + b += 4 + + return v +} + +// Event write SelectionClear +func (v SelectionClearEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 29 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + Put32(buf[b:], uint32(v.Time)) + b += 4 + + Put32(buf[b:], uint32(v.Owner)) + b += 4 + + Put32(buf[b:], uint32(v.Selection)) + b += 4 + + return buf +} + +func (v SelectionClearEvent) ImplementsEvent() {} + +func init() { + newEventFuncs[29] = NewSelectionClearEvent +} + +// Event definition SelectionRequest (30) +// Size: 32 + +const SelectionRequest = 30 + +type SelectionRequestEvent struct { + Sequence uint16 + // padding: 1 bytes + Time Timestamp + Owner Id + Requestor Id + Selection Id + Target Id + Property Id +} + +// Event read SelectionRequest +func NewSelectionRequestEvent(buf []byte) Event { + v := SelectionRequestEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Time = Timestamp(Get32(buf[b:])) + b += 4 + + v.Owner = Id(Get32(buf[b:])) + b += 4 + + v.Requestor = Id(Get32(buf[b:])) + b += 4 + + v.Selection = Id(Get32(buf[b:])) + b += 4 + + v.Target = Id(Get32(buf[b:])) + b += 4 + + v.Property = Id(Get32(buf[b:])) + b += 4 + + return v +} + +// Event write SelectionRequest +func (v SelectionRequestEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 30 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + Put32(buf[b:], uint32(v.Time)) + b += 4 + + Put32(buf[b:], uint32(v.Owner)) + b += 4 + + Put32(buf[b:], uint32(v.Requestor)) + b += 4 + + Put32(buf[b:], uint32(v.Selection)) + b += 4 + + Put32(buf[b:], uint32(v.Target)) + b += 4 + + Put32(buf[b:], uint32(v.Property)) + b += 4 + + return buf +} + +func (v SelectionRequestEvent) ImplementsEvent() {} + +func init() { + newEventFuncs[30] = NewSelectionRequestEvent +} + +// Event definition SelectionNotify (31) +// Size: 32 + +const SelectionNotify = 31 + +type SelectionNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Time Timestamp + Requestor Id + Selection Id + Target Id + Property Id +} + +// Event read SelectionNotify +func NewSelectionNotifyEvent(buf []byte) Event { + v := SelectionNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Time = Timestamp(Get32(buf[b:])) + b += 4 + + v.Requestor = Id(Get32(buf[b:])) + b += 4 + + v.Selection = Id(Get32(buf[b:])) + b += 4 + + v.Target = Id(Get32(buf[b:])) + b += 4 + + v.Property = Id(Get32(buf[b:])) + b += 4 + + return v +} + +// Event write SelectionNotify +func (v SelectionNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 31 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + Put32(buf[b:], uint32(v.Time)) + b += 4 + + Put32(buf[b:], uint32(v.Requestor)) + b += 4 + + Put32(buf[b:], uint32(v.Selection)) + b += 4 + + Put32(buf[b:], uint32(v.Target)) + b += 4 + + Put32(buf[b:], uint32(v.Property)) + b += 4 + + return buf +} + +func (v SelectionNotifyEvent) ImplementsEvent() {} + +func init() { + newEventFuncs[31] = NewSelectionNotifyEvent +} + +// Event definition ColormapNotify (32) +// Size: 32 + +const ColormapNotify = 32 + +type ColormapNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Window Id + Colormap Id + New bool + State byte + // padding: 2 bytes +} + +// Event read ColormapNotify +func NewColormapNotifyEvent(buf []byte) Event { + v := ColormapNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Window = Id(Get32(buf[b:])) + b += 4 + + v.Colormap = Id(Get32(buf[b:])) + b += 4 + + if buf[b] == 1 { + v.New = true + } else { + v.New = false + } + b += 1 + + v.State = buf[b] + b += 1 + + b += 2 // padding + + return v +} + +// Event write ColormapNotify +func (v ColormapNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 32 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + Put32(buf[b:], uint32(v.Window)) + b += 4 + + Put32(buf[b:], uint32(v.Colormap)) + b += 4 + + if v.New { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + buf[b] = v.State + b += 1 + + b += 2 // padding + + return buf +} + +func (v ColormapNotifyEvent) ImplementsEvent() {} + +func init() { + newEventFuncs[32] = NewColormapNotifyEvent +} + +// Event definition ClientMessage (33) +// Size: 32 + +const ClientMessage = 33 + +type ClientMessageEvent struct { + Sequence uint16 + Format byte + Window Id + Type Id + Data ClientMessageDataUnion +} + +// Event read ClientMessage +func NewClientMessageEvent(buf []byte) Event { + v := ClientMessageEvent{} + b := 1 // don't read event number + + v.Format = buf[b] + b += 1 + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Window = Id(Get32(buf[b:])) + b += 4 + + v.Type = Id(Get32(buf[b:])) + b += 4 + + v.Data = ClientMessageDataUnion{} + b += ReadClientMessageDataUnion(buf[b:], &v.Data) + + return v +} + +// Event write ClientMessage +func (v ClientMessageEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 33 + b += 1 + + buf[b] = v.Format + b += 1 + + b += 2 // skip sequence number + + Put32(buf[b:], uint32(v.Window)) + b += 4 + + Put32(buf[b:], uint32(v.Type)) + b += 4 + + { + unionBytes := v.Data.Bytes() + copy(buf[b:], unionBytes) + b += pad(len(unionBytes)) + } + + return buf +} + +func (v ClientMessageEvent) ImplementsEvent() {} + +func init() { + newEventFuncs[33] = NewClientMessageEvent +} + +// Event definition MappingNotify (34) +// Size: 32 + +const MappingNotify = 34 + +type MappingNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Request byte + FirstKeycode Keycode + Count byte + // padding: 1 bytes +} + +// Event read MappingNotify +func NewMappingNotifyEvent(buf []byte) Event { + v := MappingNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Request = buf[b] + b += 1 + + v.FirstKeycode = Keycode(buf[b]) + b += 1 + + v.Count = buf[b] + b += 1 + + b += 1 // padding + + return v +} + +// Event write MappingNotify +func (v MappingNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 34 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + buf[b] = v.Request + b += 1 + + buf[b] = byte(v.FirstKeycode) + b += 1 + + buf[b] = v.Count + b += 1 + + b += 1 // padding + + return buf +} + +func (v MappingNotifyEvent) ImplementsEvent() {} + +func init() { + newEventFuncs[34] = NewMappingNotifyEvent +} + +// EventCopy definition KeyRelease (3) + +const KeyRelease = 3 + +type KeyReleaseEvent KeyPressEvent + +func NewKeyReleaseEvent(buf []byte) Event { + return KeyReleaseEvent(NewKeyPressEvent(buf).(KeyPressEvent)) +} + +func (v KeyReleaseEvent) Bytes() []byte { + return KeyPressEvent(v).Bytes() +} + +func (v KeyReleaseEvent) ImplementsEvent() {} + +func init() { + newEventFuncs[3] = NewKeyReleaseEvent +} + +// EventCopy definition ButtonRelease (5) + +const ButtonRelease = 5 + +type ButtonReleaseEvent ButtonPressEvent + +func NewButtonReleaseEvent(buf []byte) Event { + return ButtonReleaseEvent(NewButtonPressEvent(buf).(ButtonPressEvent)) +} + +func (v ButtonReleaseEvent) Bytes() []byte { + return ButtonPressEvent(v).Bytes() +} + +func (v ButtonReleaseEvent) ImplementsEvent() {} + +func init() { + newEventFuncs[5] = NewButtonReleaseEvent +} + +// EventCopy definition LeaveNotify (8) + +const LeaveNotify = 8 + +type LeaveNotifyEvent EnterNotifyEvent + +func NewLeaveNotifyEvent(buf []byte) Event { + return LeaveNotifyEvent(NewEnterNotifyEvent(buf).(EnterNotifyEvent)) +} + +func (v LeaveNotifyEvent) Bytes() []byte { + return EnterNotifyEvent(v).Bytes() +} + +func (v LeaveNotifyEvent) ImplementsEvent() {} + +func init() { + newEventFuncs[8] = NewLeaveNotifyEvent +} + +// EventCopy definition FocusOut (10) + +const FocusOut = 10 + +type FocusOutEvent FocusInEvent + +func NewFocusOutEvent(buf []byte) Event { + return FocusOutEvent(NewFocusInEvent(buf).(FocusInEvent)) +} + +func (v FocusOutEvent) Bytes() []byte { + return FocusInEvent(v).Bytes() +} + +func (v FocusOutEvent) ImplementsEvent() {} + +func init() { + newEventFuncs[10] = NewFocusOutEvent +} + +// EventCopy definition CirculateRequest (27) + +const CirculateRequest = 27 + +type CirculateRequestEvent CirculateNotifyEvent + +func NewCirculateRequestEvent(buf []byte) Event { + return CirculateRequestEvent(NewCirculateNotifyEvent(buf).(CirculateNotifyEvent)) +} + +func (v CirculateRequestEvent) Bytes() []byte { + return CirculateNotifyEvent(v).Bytes() +} + +func (v CirculateRequestEvent) ImplementsEvent() {} + +func init() { + newEventFuncs[27] = NewCirculateRequestEvent +} + +// Error definition Request (1) +// Size: 32 + +const BadRequest = 1 + +type RequestError struct { + Sequence uint16 + NiceName string + BadValue uint32 + MinorOpcode uint16 + MajorOpcode byte + // padding: 1 bytes +} + +// Error read Request +func NewRequestError(buf []byte) Error { + v := RequestError{} + v.NiceName = "Request" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.BadValue = Get32(buf[b:]) + b += 4 + + v.MinorOpcode = Get16(buf[b:]) + b += 2 + + v.MajorOpcode = buf[b] + b += 1 + + b += 1 // padding + + return v +} + +func (err RequestError) ImplementsError() {} + +func (err RequestError) SequenceId() uint16 { + return err.Sequence +} + +func (err RequestError) BadId() Id { + return Id(err.BadValue) +} + +func (err RequestError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadRequest {" + stringsJoin(fieldVals, ", ") + "}" +} + +func init() { + newErrorFuncs[1] = NewRequestError +} + +// Error definition Value (2) +// Size: 32 + +const BadValue = 2 + +type ValueError struct { + Sequence uint16 + NiceName string + BadValue uint32 + MinorOpcode uint16 + MajorOpcode byte + // padding: 1 bytes +} + +// Error read Value +func NewValueError(buf []byte) Error { + v := ValueError{} + v.NiceName = "Value" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.BadValue = Get32(buf[b:]) + b += 4 + + v.MinorOpcode = Get16(buf[b:]) + b += 2 + + v.MajorOpcode = buf[b] + b += 1 + + b += 1 // padding + + return v +} + +func (err ValueError) ImplementsError() {} + +func (err ValueError) SequenceId() uint16 { + return err.Sequence +} + +func (err ValueError) BadId() Id { + return Id(err.BadValue) +} + +func (err ValueError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadValue {" + stringsJoin(fieldVals, ", ") + "}" +} + +func init() { + newErrorFuncs[2] = NewValueError +} + +// ErrorCopy definition Window (3) + +const BadWindow = 3 + +type WindowError ValueError + +func NewWindowError(buf []byte) Error { + v := WindowError(NewValueError(buf).(ValueError)) + v.NiceName = "Window" + return v +} + +func (err WindowError) ImplementsError() {} + +func (err WindowError) SequenceId() uint16 { + return err.Sequence +} + +func (err WindowError) BadId() Id { + return Id(err.BadValue) +} + +func (err WindowError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadWindow {" + stringsJoin(fieldVals, ", ") + "}" +} + +func init() { + newErrorFuncs[3] = NewWindowError +} + +// ErrorCopy definition Pixmap (4) + +const BadPixmap = 4 + +type PixmapError ValueError + +func NewPixmapError(buf []byte) Error { + v := PixmapError(NewValueError(buf).(ValueError)) + v.NiceName = "Pixmap" + return v +} + +func (err PixmapError) ImplementsError() {} + +func (err PixmapError) SequenceId() uint16 { + return err.Sequence +} + +func (err PixmapError) BadId() Id { + return Id(err.BadValue) +} + +func (err PixmapError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadPixmap {" + stringsJoin(fieldVals, ", ") + "}" +} + +func init() { + newErrorFuncs[4] = NewPixmapError +} + +// ErrorCopy definition Atom (5) + +const BadAtom = 5 + +type AtomError ValueError + +func NewAtomError(buf []byte) Error { + v := AtomError(NewValueError(buf).(ValueError)) + v.NiceName = "Atom" + return v +} + +func (err AtomError) ImplementsError() {} + +func (err AtomError) SequenceId() uint16 { + return err.Sequence +} + +func (err AtomError) BadId() Id { + return Id(err.BadValue) +} + +func (err AtomError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadAtom {" + stringsJoin(fieldVals, ", ") + "}" +} + +func init() { + newErrorFuncs[5] = NewAtomError +} + +// ErrorCopy definition Cursor (6) + +const BadCursor = 6 + +type CursorError ValueError + +func NewCursorError(buf []byte) Error { + v := CursorError(NewValueError(buf).(ValueError)) + v.NiceName = "Cursor" + return v +} + +func (err CursorError) ImplementsError() {} + +func (err CursorError) SequenceId() uint16 { + return err.Sequence +} + +func (err CursorError) BadId() Id { + return Id(err.BadValue) +} + +func (err CursorError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadCursor {" + stringsJoin(fieldVals, ", ") + "}" +} + +func init() { + newErrorFuncs[6] = NewCursorError +} + +// ErrorCopy definition Font (7) + +const BadFont = 7 + +type FontError ValueError + +func NewFontError(buf []byte) Error { + v := FontError(NewValueError(buf).(ValueError)) + v.NiceName = "Font" + return v +} + +func (err FontError) ImplementsError() {} + +func (err FontError) SequenceId() uint16 { + return err.Sequence +} + +func (err FontError) BadId() Id { + return Id(err.BadValue) +} + +func (err FontError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadFont {" + stringsJoin(fieldVals, ", ") + "}" +} + +func init() { + newErrorFuncs[7] = NewFontError +} + +// ErrorCopy definition Match (8) + +const BadMatch = 8 + +type MatchError RequestError + +func NewMatchError(buf []byte) Error { + v := MatchError(NewRequestError(buf).(RequestError)) + v.NiceName = "Match" + return v +} + +func (err MatchError) ImplementsError() {} + +func (err MatchError) SequenceId() uint16 { + return err.Sequence +} + +func (err MatchError) BadId() Id { + return Id(err.BadValue) +} + +func (err MatchError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadMatch {" + stringsJoin(fieldVals, ", ") + "}" +} + +func init() { + newErrorFuncs[8] = NewMatchError +} + +// ErrorCopy definition Drawable (9) + +const BadDrawable = 9 + +type DrawableError ValueError + +func NewDrawableError(buf []byte) Error { + v := DrawableError(NewValueError(buf).(ValueError)) + v.NiceName = "Drawable" + return v +} + +func (err DrawableError) ImplementsError() {} + +func (err DrawableError) SequenceId() uint16 { + return err.Sequence +} + +func (err DrawableError) BadId() Id { + return Id(err.BadValue) +} + +func (err DrawableError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadDrawable {" + stringsJoin(fieldVals, ", ") + "}" +} + +func init() { + newErrorFuncs[9] = NewDrawableError +} + +// ErrorCopy definition Access (10) + +const BadAccess = 10 + +type AccessError RequestError + +func NewAccessError(buf []byte) Error { + v := AccessError(NewRequestError(buf).(RequestError)) + v.NiceName = "Access" + return v +} + +func (err AccessError) ImplementsError() {} + +func (err AccessError) SequenceId() uint16 { + return err.Sequence +} + +func (err AccessError) BadId() Id { + return Id(err.BadValue) +} + +func (err AccessError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadAccess {" + stringsJoin(fieldVals, ", ") + "}" +} + +func init() { + newErrorFuncs[10] = NewAccessError +} + +// ErrorCopy definition Alloc (11) + +const BadAlloc = 11 + +type AllocError RequestError + +func NewAllocError(buf []byte) Error { + v := AllocError(NewRequestError(buf).(RequestError)) + v.NiceName = "Alloc" + return v +} + +func (err AllocError) ImplementsError() {} + +func (err AllocError) SequenceId() uint16 { + return err.Sequence +} + +func (err AllocError) BadId() Id { + return Id(err.BadValue) +} + +func (err AllocError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadAlloc {" + stringsJoin(fieldVals, ", ") + "}" +} + +func init() { + newErrorFuncs[11] = NewAllocError +} + +// ErrorCopy definition Colormap (12) + +const BadColormap = 12 + +type ColormapError ValueError + +func NewColormapError(buf []byte) Error { + v := ColormapError(NewValueError(buf).(ValueError)) + v.NiceName = "Colormap" + return v +} + +func (err ColormapError) ImplementsError() {} + +func (err ColormapError) SequenceId() uint16 { + return err.Sequence +} + +func (err ColormapError) BadId() Id { + return Id(err.BadValue) +} + +func (err ColormapError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadColormap {" + stringsJoin(fieldVals, ", ") + "}" +} + +func init() { + newErrorFuncs[12] = NewColormapError +} + +// ErrorCopy definition GContext (13) + +const BadGContext = 13 + +type GContextError ValueError + +func NewGContextError(buf []byte) Error { + v := GContextError(NewValueError(buf).(ValueError)) + v.NiceName = "GContext" + return v +} + +func (err GContextError) ImplementsError() {} + +func (err GContextError) SequenceId() uint16 { + return err.Sequence +} + +func (err GContextError) BadId() Id { + return Id(err.BadValue) +} + +func (err GContextError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadGContext {" + stringsJoin(fieldVals, ", ") + "}" +} + +func init() { + newErrorFuncs[13] = NewGContextError +} + +// ErrorCopy definition IDChoice (14) + +const BadIDChoice = 14 + +type IDChoiceError ValueError + +func NewIDChoiceError(buf []byte) Error { + v := IDChoiceError(NewValueError(buf).(ValueError)) + v.NiceName = "IDChoice" + return v +} + +func (err IDChoiceError) ImplementsError() {} + +func (err IDChoiceError) SequenceId() uint16 { + return err.Sequence +} + +func (err IDChoiceError) BadId() Id { + return Id(err.BadValue) +} + +func (err IDChoiceError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadIDChoice {" + stringsJoin(fieldVals, ", ") + "}" +} + +func init() { + newErrorFuncs[14] = NewIDChoiceError +} + +// ErrorCopy definition Name (15) + +const BadName = 15 + +type NameError RequestError + +func NewNameError(buf []byte) Error { + v := NameError(NewRequestError(buf).(RequestError)) + v.NiceName = "Name" + return v +} + +func (err NameError) ImplementsError() {} + +func (err NameError) SequenceId() uint16 { + return err.Sequence +} + +func (err NameError) BadId() Id { + return Id(err.BadValue) +} + +func (err NameError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadName {" + stringsJoin(fieldVals, ", ") + "}" +} + +func init() { + newErrorFuncs[15] = NewNameError +} + +// ErrorCopy definition Length (16) + +const BadLength = 16 + +type LengthError RequestError + +func NewLengthError(buf []byte) Error { + v := LengthError(NewRequestError(buf).(RequestError)) + v.NiceName = "Length" + return v +} + +func (err LengthError) ImplementsError() {} + +func (err LengthError) SequenceId() uint16 { + return err.Sequence +} + +func (err LengthError) BadId() Id { + return Id(err.BadValue) +} + +func (err LengthError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadLength {" + stringsJoin(fieldVals, ", ") + "}" +} + +func init() { + newErrorFuncs[16] = NewLengthError +} + +// ErrorCopy definition Implementation (17) + +const BadImplementation = 17 + +type ImplementationError RequestError + +func NewImplementationError(buf []byte) Error { + v := ImplementationError(NewRequestError(buf).(RequestError)) + v.NiceName = "Implementation" + return v +} + +func (err ImplementationError) ImplementsError() {} + +func (err ImplementationError) SequenceId() uint16 { + return err.Sequence +} + +func (err ImplementationError) BadId() Id { + return Id(err.BadValue) +} + +func (err ImplementationError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadImplementation {" + stringsJoin(fieldVals, ", ") + "}" +} + +func init() { + newErrorFuncs[17] = NewImplementationError +} + +// Request CreateWindow +// size: (28 + (4 + pad((4 * popCount(int(ValueMask)))))) +// Write request to wire for CreateWindow +func (c *Conn) CreateWindow(Depth byte, Wid Id, Parent Id, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class uint16, Visual Visualid, ValueMask uint32, ValueList []uint32) { + size := (28 + (4 + pad((4 * popCount(int(ValueMask)))))) + b := 0 + buf := make([]byte, size) + + buf[b] = 1 // request opcode + b += 1 + + buf[b] = Depth + b += 1 + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Wid)) + b += 4 + + Put32(buf[b:], uint32(Parent)) + b += 4 + + Put16(buf[b:], uint16(X)) + b += 2 + + Put16(buf[b:], uint16(Y)) + b += 2 + + Put16(buf[b:], Width) + b += 2 + + Put16(buf[b:], Height) + b += 2 + + Put16(buf[b:], BorderWidth) + b += 2 + + Put16(buf[b:], Class) + b += 2 + + Put32(buf[b:], uint32(Visual)) + b += 4 + + Put32(buf[b:], ValueMask) + b += 4 + for i := 0; i < popCount(int(ValueMask)); i++ { + Put32(buf[b:], ValueList[i]) + b += 4 + } + b = pad(b) + + c.sendRequest(false, buf) +} + +// Request ChangeWindowAttributes +// size: (8 + (4 + pad((4 * popCount(int(ValueMask)))))) +// Write request to wire for ChangeWindowAttributes +func (c *Conn) ChangeWindowAttributes(Window Id, ValueMask uint32, ValueList []uint32) { + size := (8 + (4 + pad((4 * popCount(int(ValueMask)))))) + b := 0 + buf := make([]byte, size) + + buf[b] = 2 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Window)) + b += 4 + + Put32(buf[b:], ValueMask) + b += 4 + for i := 0; i < popCount(int(ValueMask)); i++ { + Put32(buf[b:], ValueList[i]) + b += 4 + } + b = pad(b) + + c.sendRequest(false, buf) +} + +// Request GetWindowAttributes +// size: 8 +func (c *Conn) GetWindowAttributes(Window Id) (*GetWindowAttributesReply, error) { + return c.GetWindowAttributesReply(c.GetWindowAttributesRequest(Window)) +} + +// Write request to wire for GetWindowAttributes +func (c *Conn) GetWindowAttributesRequest(Window Id) *Cookie { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 3 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Window)) + b += 4 + + return c.sendRequest(true, buf) +} + +// Request reply for GetWindowAttributes +// size: 44 +type GetWindowAttributesReply struct { + Sequence uint16 + Length uint32 + BackingStore byte + Visual Visualid + Class uint16 + BitGravity byte + WinGravity byte + BackingPlanes uint32 + BackingPixel uint32 + SaveUnder bool + MapIsInstalled bool + MapState byte + OverrideRedirect bool + Colormap Id + AllEventMasks uint32 + YourEventMask uint32 + DoNotPropagateMask uint16 + // padding: 2 bytes +} + +// Read reply GetWindowAttributes +func (c *Conn) GetWindowAttributesReply(cook *Cookie) (*GetWindowAttributesReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(GetWindowAttributesReply) + b := 1 // skip reply determinant + + v.BackingStore = buf[b] + b += 1 + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Length = Get32(buf[b:]) // 4-byte units + b += 4 + + v.Visual = Visualid(Get32(buf[b:])) + b += 4 + + v.Class = Get16(buf[b:]) + b += 2 + + v.BitGravity = buf[b] + b += 1 + + v.WinGravity = buf[b] + b += 1 + + v.BackingPlanes = Get32(buf[b:]) + b += 4 + + v.BackingPixel = Get32(buf[b:]) + b += 4 + + if buf[b] == 1 { + v.SaveUnder = true + } else { + v.SaveUnder = false + } + b += 1 + + if buf[b] == 1 { + v.MapIsInstalled = true + } else { + v.MapIsInstalled = false + } + b += 1 + + v.MapState = buf[b] + b += 1 + + if buf[b] == 1 { + v.OverrideRedirect = true + } else { + v.OverrideRedirect = false + } + b += 1 + + v.Colormap = Id(Get32(buf[b:])) + b += 4 + + v.AllEventMasks = Get32(buf[b:]) + b += 4 + + v.YourEventMask = Get32(buf[b:]) + b += 4 + + v.DoNotPropagateMask = Get16(buf[b:]) + b += 2 + + b += 2 // padding + + return v, nil +} + +// Request DestroyWindow +// size: 8 +// Write request to wire for DestroyWindow +func (c *Conn) DestroyWindow(Window Id) { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 4 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Window)) + b += 4 + + c.sendRequest(false, buf) +} + +// Request DestroySubwindows +// size: 8 +// Write request to wire for DestroySubwindows +func (c *Conn) DestroySubwindows(Window Id) { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 5 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Window)) + b += 4 + + c.sendRequest(false, buf) +} + +// Request ChangeSaveSet +// size: 8 +// Write request to wire for ChangeSaveSet +func (c *Conn) ChangeSaveSet(Mode byte, Window Id) { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 6 // request opcode + b += 1 + + buf[b] = Mode + b += 1 + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Window)) + b += 4 + + c.sendRequest(false, buf) +} + +// Request ReparentWindow +// size: 16 +// Write request to wire for ReparentWindow +func (c *Conn) ReparentWindow(Window Id, Parent Id, X int16, Y int16) { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 7 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Window)) + b += 4 + + Put32(buf[b:], uint32(Parent)) + b += 4 + + Put16(buf[b:], uint16(X)) + b += 2 + + Put16(buf[b:], uint16(Y)) + b += 2 + + c.sendRequest(false, buf) +} + +// Request MapWindow +// size: 8 +// Write request to wire for MapWindow +func (c *Conn) MapWindow(Window Id) { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 8 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Window)) + b += 4 + + c.sendRequest(false, buf) +} + +// Request MapSubwindows +// size: 8 +// Write request to wire for MapSubwindows +func (c *Conn) MapSubwindows(Window Id) { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 9 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Window)) + b += 4 + + c.sendRequest(false, buf) +} + +// Request UnmapWindow +// size: 8 +// Write request to wire for UnmapWindow +func (c *Conn) UnmapWindow(Window Id) { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 10 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Window)) + b += 4 + + c.sendRequest(false, buf) +} + +// Request UnmapSubwindows +// size: 8 +// Write request to wire for UnmapSubwindows +func (c *Conn) UnmapSubwindows(Window Id) { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 11 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Window)) + b += 4 + + c.sendRequest(false, buf) +} + +// Request ConfigureWindow +// size: (10 + (2 + pad((4 * popCount(int(ValueMask)))))) +// Write request to wire for ConfigureWindow +func (c *Conn) ConfigureWindow(Window Id, ValueMask uint16, ValueList []uint32) { + size := (10 + (2 + pad((4 * popCount(int(ValueMask)))))) + b := 0 + buf := make([]byte, size) + + buf[b] = 12 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Window)) + b += 4 + + Put16(buf[b:], ValueMask) + b += 2 + + b += 2 // padding + + for i := 0; i < popCount(int(ValueMask)); i++ { + Put32(buf[b:], ValueList[i]) + b += 4 + } + b = pad(b) + + c.sendRequest(false, buf) +} + +// Request CirculateWindow +// size: 8 +// Write request to wire for CirculateWindow +func (c *Conn) CirculateWindow(Direction byte, Window Id) { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 13 // request opcode + b += 1 + + buf[b] = Direction + b += 1 + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Window)) + b += 4 + + c.sendRequest(false, buf) +} + +// Request GetGeometry +// size: 8 +func (c *Conn) GetGeometry(Drawable Id) (*GetGeometryReply, error) { + return c.GetGeometryReply(c.GetGeometryRequest(Drawable)) +} + +// Write request to wire for GetGeometry +func (c *Conn) GetGeometryRequest(Drawable Id) *Cookie { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 14 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Drawable)) + b += 4 + + return c.sendRequest(true, buf) +} + +// Request reply for GetGeometry +// size: 24 +type GetGeometryReply struct { + Sequence uint16 + Length uint32 + Depth byte + Root Id + X int16 + Y int16 + Width uint16 + Height uint16 + BorderWidth uint16 + // padding: 2 bytes +} + +// Read reply GetGeometry +func (c *Conn) GetGeometryReply(cook *Cookie) (*GetGeometryReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(GetGeometryReply) + b := 1 // skip reply determinant + + v.Depth = buf[b] + b += 1 + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Length = Get32(buf[b:]) // 4-byte units + b += 4 + + v.Root = Id(Get32(buf[b:])) + b += 4 + + v.X = int16(Get16(buf[b:])) + b += 2 + + v.Y = int16(Get16(buf[b:])) + b += 2 + + v.Width = Get16(buf[b:]) + b += 2 + + v.Height = Get16(buf[b:]) + b += 2 + + v.BorderWidth = Get16(buf[b:]) + b += 2 + + b += 2 // padding + + return v, nil +} + +// Request QueryTree +// size: 8 +func (c *Conn) QueryTree(Window Id) (*QueryTreeReply, error) { + return c.QueryTreeReply(c.QueryTreeRequest(Window)) +} + +// Write request to wire for QueryTree +func (c *Conn) QueryTreeRequest(Window Id) *Cookie { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 15 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Window)) + b += 4 + + return c.sendRequest(true, buf) +} + +// Request reply for QueryTree +// size: (32 + pad((int(ChildrenLen) * 4))) +type QueryTreeReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Root Id + Parent Id + ChildrenLen uint16 + // padding: 14 bytes + Children []Id // size: pad((int(ChildrenLen) * 4)) +} + +// Read reply QueryTree +func (c *Conn) QueryTreeReply(cook *Cookie) (*QueryTreeReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(QueryTreeReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Length = Get32(buf[b:]) // 4-byte units + b += 4 + + v.Root = Id(Get32(buf[b:])) + b += 4 + + v.Parent = Id(Get32(buf[b:])) + b += 4 + + v.ChildrenLen = Get16(buf[b:]) + b += 2 + + b += 14 // padding + + v.Children = make([]Id, v.ChildrenLen) + for i := 0; i < int(v.ChildrenLen); i++ { + v.Children[i] = Id(Get32(buf[b:])) + b += 4 + } + b = pad(b) + + return v, nil +} + +// Request InternAtom +// size: (8 + pad((int(NameLen) * 1))) +func (c *Conn) InternAtom(OnlyIfExists bool, NameLen uint16, Name string) (*InternAtomReply, error) { + return c.InternAtomReply(c.InternAtomRequest(OnlyIfExists, NameLen, Name)) +} + +// Write request to wire for InternAtom +func (c *Conn) InternAtomRequest(OnlyIfExists bool, NameLen uint16, Name string) *Cookie { + size := (8 + pad((int(NameLen) * 1))) + b := 0 + buf := make([]byte, size) + + buf[b] = 16 // request opcode + b += 1 + + if OnlyIfExists { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put16(buf[b:], NameLen) + b += 2 + + b += 2 // padding + + copy(buf[b:], Name[:NameLen]) + b += pad(int(NameLen)) + + return c.sendRequest(true, buf) +} + +// Request reply for InternAtom +// size: 12 +type InternAtomReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Atom Id +} + +// Read reply InternAtom +func (c *Conn) InternAtomReply(cook *Cookie) (*InternAtomReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(InternAtomReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Length = Get32(buf[b:]) // 4-byte units + b += 4 + + v.Atom = Id(Get32(buf[b:])) + b += 4 + + return v, nil +} + +// Request GetAtomName +// size: 8 +func (c *Conn) GetAtomName(Atom Id) (*GetAtomNameReply, error) { + return c.GetAtomNameReply(c.GetAtomNameRequest(Atom)) +} + +// Write request to wire for GetAtomName +func (c *Conn) GetAtomNameRequest(Atom Id) *Cookie { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 17 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Atom)) + b += 4 + + return c.sendRequest(true, buf) +} + +// Request reply for GetAtomName +// size: (32 + pad((int(NameLen) * 1))) +type GetAtomNameReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NameLen uint16 + // padding: 22 bytes + Name string // size: pad((int(NameLen) * 1)) +} + +// Read reply GetAtomName +func (c *Conn) GetAtomNameReply(cook *Cookie) (*GetAtomNameReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(GetAtomNameReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Length = Get32(buf[b:]) // 4-byte units + b += 4 + + v.NameLen = Get16(buf[b:]) + b += 2 + + b += 22 // padding + + { + byteString := make([]byte, v.NameLen) + copy(byteString[:v.NameLen], buf[b:]) + v.Name = string(byteString) + b += pad(int(v.NameLen)) + } + + return v, nil +} + +// Request ChangeProperty +// size: (24 + pad((((int(DataLen) * int(Format)) / 8) * 1))) +// Write request to wire for ChangeProperty +func (c *Conn) ChangeProperty(Mode byte, Window Id, Property Id, Type Id, Format byte, DataLen uint32, Data []byte) { + size := (24 + pad((((int(DataLen) * int(Format)) / 8) * 1))) + b := 0 + buf := make([]byte, size) + + buf[b] = 18 // request opcode + b += 1 + + buf[b] = Mode + b += 1 + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Window)) + b += 4 + + Put32(buf[b:], uint32(Property)) + b += 4 + + Put32(buf[b:], uint32(Type)) + b += 4 + + buf[b] = Format + b += 1 + + b += 3 // padding + + Put32(buf[b:], DataLen) + b += 4 + + copy(buf[b:], Data[:((int(DataLen)*int(Format))/8)]) + b += pad(int(((int(DataLen) * int(Format)) / 8))) + + c.sendRequest(false, buf) +} + +// Request DeleteProperty +// size: 12 +// Write request to wire for DeleteProperty +func (c *Conn) DeleteProperty(Window Id, Property Id) { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = 19 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Window)) + b += 4 + + Put32(buf[b:], uint32(Property)) + b += 4 + + c.sendRequest(false, buf) +} + +// Request GetProperty +// size: 24 +func (c *Conn) GetProperty(Delete bool, Window Id, Property Id, Type Id, LongOffset uint32, LongLength uint32) (*GetPropertyReply, error) { + return c.GetPropertyReply(c.GetPropertyRequest(Delete, Window, Property, Type, LongOffset, LongLength)) +} + +// Write request to wire for GetProperty +func (c *Conn) GetPropertyRequest(Delete bool, Window Id, Property Id, Type Id, LongOffset uint32, LongLength uint32) *Cookie { + size := 24 + b := 0 + buf := make([]byte, size) + + buf[b] = 20 // request opcode + b += 1 + + if Delete { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Window)) + b += 4 + + Put32(buf[b:], uint32(Property)) + b += 4 + + Put32(buf[b:], uint32(Type)) + b += 4 + + Put32(buf[b:], LongOffset) + b += 4 + + Put32(buf[b:], LongLength) + b += 4 + + return c.sendRequest(true, buf) +} + +// Request reply for GetProperty +// size: (32 + pad(((int(ValueLen) * (int(Format) / 8)) * 1))) +type GetPropertyReply struct { + Sequence uint16 + Length uint32 + Format byte + Type Id + BytesAfter uint32 + ValueLen uint32 + // padding: 12 bytes + Value []byte // size: pad(((int(ValueLen) * (int(Format) / 8)) * 1)) +} + +// Read reply GetProperty +func (c *Conn) GetPropertyReply(cook *Cookie) (*GetPropertyReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(GetPropertyReply) + b := 1 // skip reply determinant + + v.Format = buf[b] + b += 1 + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Length = Get32(buf[b:]) // 4-byte units + b += 4 + + v.Type = Id(Get32(buf[b:])) + b += 4 + + v.BytesAfter = Get32(buf[b:]) + b += 4 + + v.ValueLen = Get32(buf[b:]) + b += 4 + + b += 12 // padding + + v.Value = make([]byte, (int(v.ValueLen) * (int(v.Format) / 8))) + copy(v.Value[:(int(v.ValueLen)*(int(v.Format)/8))], buf[b:]) + b += pad(int((int(v.ValueLen) * (int(v.Format) / 8)))) + + return v, nil +} + +// Request ListProperties +// size: 8 +func (c *Conn) ListProperties(Window Id) (*ListPropertiesReply, error) { + return c.ListPropertiesReply(c.ListPropertiesRequest(Window)) +} + +// Write request to wire for ListProperties +func (c *Conn) ListPropertiesRequest(Window Id) *Cookie { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 21 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Window)) + b += 4 + + return c.sendRequest(true, buf) +} + +// Request reply for ListProperties +// size: (32 + pad((int(AtomsLen) * 4))) +type ListPropertiesReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + AtomsLen uint16 + // padding: 22 bytes + Atoms []Id // size: pad((int(AtomsLen) * 4)) +} + +// Read reply ListProperties +func (c *Conn) ListPropertiesReply(cook *Cookie) (*ListPropertiesReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(ListPropertiesReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Length = Get32(buf[b:]) // 4-byte units + b += 4 + + v.AtomsLen = Get16(buf[b:]) + b += 2 + + b += 22 // padding + + v.Atoms = make([]Id, v.AtomsLen) + for i := 0; i < int(v.AtomsLen); i++ { + v.Atoms[i] = Id(Get32(buf[b:])) + b += 4 + } + b = pad(b) + + return v, nil +} + +// Request SetSelectionOwner +// size: 16 +// Write request to wire for SetSelectionOwner +func (c *Conn) SetSelectionOwner(Owner Id, Selection Id, Time Timestamp) { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 22 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Owner)) + b += 4 + + Put32(buf[b:], uint32(Selection)) + b += 4 + + Put32(buf[b:], uint32(Time)) + b += 4 + + c.sendRequest(false, buf) +} + +// Request GetSelectionOwner +// size: 8 +func (c *Conn) GetSelectionOwner(Selection Id) (*GetSelectionOwnerReply, error) { + return c.GetSelectionOwnerReply(c.GetSelectionOwnerRequest(Selection)) +} + +// Write request to wire for GetSelectionOwner +func (c *Conn) GetSelectionOwnerRequest(Selection Id) *Cookie { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 23 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Selection)) + b += 4 + + return c.sendRequest(true, buf) +} + +// Request reply for GetSelectionOwner +// size: 12 +type GetSelectionOwnerReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Owner Id +} + +// Read reply GetSelectionOwner +func (c *Conn) GetSelectionOwnerReply(cook *Cookie) (*GetSelectionOwnerReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(GetSelectionOwnerReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Length = Get32(buf[b:]) // 4-byte units + b += 4 + + v.Owner = Id(Get32(buf[b:])) + b += 4 + + return v, nil +} + +// Request ConvertSelection +// size: 24 +// Write request to wire for ConvertSelection +func (c *Conn) ConvertSelection(Requestor Id, Selection Id, Target Id, Property Id, Time Timestamp) { + size := 24 + b := 0 + buf := make([]byte, size) + + buf[b] = 24 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Requestor)) + b += 4 + + Put32(buf[b:], uint32(Selection)) + b += 4 + + Put32(buf[b:], uint32(Target)) + b += 4 + + Put32(buf[b:], uint32(Property)) + b += 4 + + Put32(buf[b:], uint32(Time)) + b += 4 + + c.sendRequest(false, buf) +} + +// Request SendEvent +// size: (12 + pad(32)) +// Write request to wire for SendEvent +func (c *Conn) SendEvent(Propagate bool, Destination Id, EventMask uint32, Event string) { + size := (12 + pad(32)) + b := 0 + buf := make([]byte, size) + + buf[b] = 25 // request opcode + b += 1 + + if Propagate { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Destination)) + b += 4 + + Put32(buf[b:], EventMask) + b += 4 + + copy(buf[b:], Event[:32]) + b += pad(int(32)) + + c.sendRequest(false, buf) +} + +// Request GrabPointer +// size: 24 +func (c *Conn) GrabPointer(OwnerEvents bool, GrabWindow Id, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Id, Cursor Id, Time Timestamp) (*GrabPointerReply, error) { + return c.GrabPointerReply(c.GrabPointerRequest(OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Time)) +} + +// Write request to wire for GrabPointer +func (c *Conn) GrabPointerRequest(OwnerEvents bool, GrabWindow Id, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Id, Cursor Id, Time Timestamp) *Cookie { + size := 24 + b := 0 + buf := make([]byte, size) + + buf[b] = 26 // request opcode + b += 1 + + if OwnerEvents { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(GrabWindow)) + b += 4 + + Put16(buf[b:], EventMask) + b += 2 + + buf[b] = PointerMode + b += 1 + + buf[b] = KeyboardMode + b += 1 + + Put32(buf[b:], uint32(ConfineTo)) + b += 4 + + Put32(buf[b:], uint32(Cursor)) + b += 4 + + Put32(buf[b:], uint32(Time)) + b += 4 + + return c.sendRequest(true, buf) +} + +// Request reply for GrabPointer +// size: 8 +type GrabPointerReply struct { + Sequence uint16 + Length uint32 + Status byte +} + +// Read reply GrabPointer +func (c *Conn) GrabPointerReply(cook *Cookie) (*GrabPointerReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(GrabPointerReply) + b := 1 // skip reply determinant + + v.Status = buf[b] + b += 1 + + return v, nil +} + +// Request UngrabPointer +// size: 8 +// Write request to wire for UngrabPointer +func (c *Conn) UngrabPointer(Time Timestamp) { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 27 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Time)) + b += 4 + + c.sendRequest(false, buf) +} + +// Request GrabButton +// size: 24 +// Write request to wire for GrabButton +func (c *Conn) GrabButton(OwnerEvents bool, GrabWindow Id, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Id, Cursor Id, Button byte, Modifiers uint16) { + size := 24 + b := 0 + buf := make([]byte, size) + + buf[b] = 28 // request opcode + b += 1 + + if OwnerEvents { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(GrabWindow)) + b += 4 + + Put16(buf[b:], EventMask) + b += 2 + + buf[b] = PointerMode + b += 1 + + buf[b] = KeyboardMode + b += 1 + + Put32(buf[b:], uint32(ConfineTo)) + b += 4 + + Put32(buf[b:], uint32(Cursor)) + b += 4 + + buf[b] = Button + b += 1 + + b += 1 // padding + + Put16(buf[b:], Modifiers) + b += 2 + + c.sendRequest(false, buf) +} + +// Request UngrabButton +// size: 12 +// Write request to wire for UngrabButton +func (c *Conn) UngrabButton(Button byte, GrabWindow Id, Modifiers uint16) { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = 29 // request opcode + b += 1 + + buf[b] = Button + b += 1 + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(GrabWindow)) + b += 4 + + Put16(buf[b:], Modifiers) + b += 2 + + b += 2 // padding + + c.sendRequest(false, buf) +} + +// Request ChangeActivePointerGrab +// size: 16 +// Write request to wire for ChangeActivePointerGrab +func (c *Conn) ChangeActivePointerGrab(Cursor Id, Time Timestamp, EventMask uint16) { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 30 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Cursor)) + b += 4 + + Put32(buf[b:], uint32(Time)) + b += 4 + + Put16(buf[b:], EventMask) + b += 2 + + b += 2 // padding + + c.sendRequest(false, buf) +} + +// Request GrabKeyboard +// size: 16 +func (c *Conn) GrabKeyboard(OwnerEvents bool, GrabWindow Id, Time Timestamp, PointerMode byte, KeyboardMode byte) (*GrabKeyboardReply, error) { + return c.GrabKeyboardReply(c.GrabKeyboardRequest(OwnerEvents, GrabWindow, Time, PointerMode, KeyboardMode)) +} + +// Write request to wire for GrabKeyboard +func (c *Conn) GrabKeyboardRequest(OwnerEvents bool, GrabWindow Id, Time Timestamp, PointerMode byte, KeyboardMode byte) *Cookie { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 31 // request opcode + b += 1 + + if OwnerEvents { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(GrabWindow)) + b += 4 + + Put32(buf[b:], uint32(Time)) + b += 4 + + buf[b] = PointerMode + b += 1 + + buf[b] = KeyboardMode + b += 1 + + b += 2 // padding + + return c.sendRequest(true, buf) +} + +// Request reply for GrabKeyboard +// size: 8 +type GrabKeyboardReply struct { + Sequence uint16 + Length uint32 + Status byte +} + +// Read reply GrabKeyboard +func (c *Conn) GrabKeyboardReply(cook *Cookie) (*GrabKeyboardReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(GrabKeyboardReply) + b := 1 // skip reply determinant + + v.Status = buf[b] + b += 1 + + return v, nil +} + +// Request UngrabKeyboard +// size: 8 +// Write request to wire for UngrabKeyboard +func (c *Conn) UngrabKeyboard(Time Timestamp) { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 32 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Time)) + b += 4 + + c.sendRequest(false, buf) +} + +// Request GrabKey +// size: 16 +// Write request to wire for GrabKey +func (c *Conn) GrabKey(OwnerEvents bool, GrabWindow Id, Modifiers uint16, Key Keycode, PointerMode byte, KeyboardMode byte) { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 33 // request opcode + b += 1 + + if OwnerEvents { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(GrabWindow)) + b += 4 + + Put16(buf[b:], Modifiers) + b += 2 + + buf[b] = byte(Key) + b += 1 + + buf[b] = PointerMode + b += 1 + + buf[b] = KeyboardMode + b += 1 + + b += 3 // padding + + c.sendRequest(false, buf) +} + +// Request UngrabKey +// size: 12 +// Write request to wire for UngrabKey +func (c *Conn) UngrabKey(Key Keycode, GrabWindow Id, Modifiers uint16) { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = 34 // request opcode + b += 1 + + buf[b] = byte(Key) + b += 1 + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(GrabWindow)) + b += 4 + + Put16(buf[b:], Modifiers) + b += 2 + + b += 2 // padding + + c.sendRequest(false, buf) +} + +// Request AllowEvents +// size: 8 +// Write request to wire for AllowEvents +func (c *Conn) AllowEvents(Mode byte, Time Timestamp) { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 35 // request opcode + b += 1 + + buf[b] = Mode + b += 1 + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Time)) + b += 4 + + c.sendRequest(false, buf) +} + +// Request GrabServer +// size: 3 +// Write request to wire for GrabServer +func (c *Conn) GrabServer() { + size := 3 + b := 0 + buf := make([]byte, size) + + buf[b] = 36 // request opcode + b += 1 + + c.sendRequest(false, buf) +} + +// Request UngrabServer +// size: 3 +// Write request to wire for UngrabServer +func (c *Conn) UngrabServer() { + size := 3 + b := 0 + buf := make([]byte, size) + + buf[b] = 37 // request opcode + b += 1 + + c.sendRequest(false, buf) +} + +// Request QueryPointer +// size: 8 +func (c *Conn) QueryPointer(Window Id) (*QueryPointerReply, error) { + return c.QueryPointerReply(c.QueryPointerRequest(Window)) +} + +// Write request to wire for QueryPointer +func (c *Conn) QueryPointerRequest(Window Id) *Cookie { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 38 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Window)) + b += 4 + + return c.sendRequest(true, buf) +} + +// Request reply for QueryPointer +// size: 28 +type QueryPointerReply struct { + Sequence uint16 + Length uint32 + SameScreen bool + Root Id + Child Id + RootX int16 + RootY int16 + WinX int16 + WinY int16 + Mask uint16 + // padding: 2 bytes +} + +// Read reply QueryPointer +func (c *Conn) QueryPointerReply(cook *Cookie) (*QueryPointerReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(QueryPointerReply) + b := 1 // skip reply determinant + + if buf[b] == 1 { + v.SameScreen = true + } else { + v.SameScreen = false + } + b += 1 + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Length = Get32(buf[b:]) // 4-byte units + b += 4 + + v.Root = Id(Get32(buf[b:])) + b += 4 + + v.Child = Id(Get32(buf[b:])) + b += 4 + + v.RootX = int16(Get16(buf[b:])) + b += 2 + + v.RootY = int16(Get16(buf[b:])) + b += 2 + + v.WinX = int16(Get16(buf[b:])) + b += 2 + + v.WinY = int16(Get16(buf[b:])) + b += 2 + + v.Mask = Get16(buf[b:]) + b += 2 + + b += 2 // padding + + return v, nil +} + +// Request GetMotionEvents +// size: 16 +func (c *Conn) GetMotionEvents(Window Id, Start Timestamp, Stop Timestamp) (*GetMotionEventsReply, error) { + return c.GetMotionEventsReply(c.GetMotionEventsRequest(Window, Start, Stop)) +} + +// Write request to wire for GetMotionEvents +func (c *Conn) GetMotionEventsRequest(Window Id, Start Timestamp, Stop Timestamp) *Cookie { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 39 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Window)) + b += 4 + + Put32(buf[b:], uint32(Start)) + b += 4 + + Put32(buf[b:], uint32(Stop)) + b += 4 + + return c.sendRequest(true, buf) +} + +// Request reply for GetMotionEvents +// size: (32 + pad((int(EventsLen) * 8))) +type GetMotionEventsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + EventsLen uint32 + // padding: 20 bytes + Events []Timecoord // size: pad((int(EventsLen) * 8)) +} + +// Read reply GetMotionEvents +func (c *Conn) GetMotionEventsReply(cook *Cookie) (*GetMotionEventsReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(GetMotionEventsReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Length = Get32(buf[b:]) // 4-byte units + b += 4 + + v.EventsLen = Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Events = make([]Timecoord, v.EventsLen) + b += ReadTimecoordList(buf[b:], v.Events) + + return v, nil +} + +// Request TranslateCoordinates +// size: 16 +func (c *Conn) TranslateCoordinates(SrcWindow Id, DstWindow Id, SrcX int16, SrcY int16) (*TranslateCoordinatesReply, error) { + return c.TranslateCoordinatesReply(c.TranslateCoordinatesRequest(SrcWindow, DstWindow, SrcX, SrcY)) +} + +// Write request to wire for TranslateCoordinates +func (c *Conn) TranslateCoordinatesRequest(SrcWindow Id, DstWindow Id, SrcX int16, SrcY int16) *Cookie { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 40 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(SrcWindow)) + b += 4 + + Put32(buf[b:], uint32(DstWindow)) + b += 4 + + Put16(buf[b:], uint16(SrcX)) + b += 2 + + Put16(buf[b:], uint16(SrcY)) + b += 2 + + return c.sendRequest(true, buf) +} + +// Request reply for TranslateCoordinates +// size: 16 +type TranslateCoordinatesReply struct { + Sequence uint16 + Length uint32 + SameScreen bool + Child Id + DstX int16 + DstY int16 +} + +// Read reply TranslateCoordinates +func (c *Conn) TranslateCoordinatesReply(cook *Cookie) (*TranslateCoordinatesReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(TranslateCoordinatesReply) + b := 1 // skip reply determinant + + if buf[b] == 1 { + v.SameScreen = true + } else { + v.SameScreen = false + } + b += 1 + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Length = Get32(buf[b:]) // 4-byte units + b += 4 + + v.Child = Id(Get32(buf[b:])) + b += 4 + + v.DstX = int16(Get16(buf[b:])) + b += 2 + + v.DstY = int16(Get16(buf[b:])) + b += 2 + + return v, nil +} + +// Request WarpPointer +// size: 24 +// Write request to wire for WarpPointer +func (c *Conn) WarpPointer(SrcWindow Id, DstWindow Id, SrcX int16, SrcY int16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16) { + size := 24 + b := 0 + buf := make([]byte, size) + + buf[b] = 41 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(SrcWindow)) + b += 4 + + Put32(buf[b:], uint32(DstWindow)) + b += 4 + + Put16(buf[b:], uint16(SrcX)) + b += 2 + + Put16(buf[b:], uint16(SrcY)) + b += 2 + + Put16(buf[b:], SrcWidth) + b += 2 + + Put16(buf[b:], SrcHeight) + b += 2 + + Put16(buf[b:], uint16(DstX)) + b += 2 + + Put16(buf[b:], uint16(DstY)) + b += 2 + + c.sendRequest(false, buf) +} + +// Request SetInputFocus +// size: 12 +// Write request to wire for SetInputFocus +func (c *Conn) SetInputFocus(RevertTo byte, Focus Id, Time Timestamp) { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = 42 // request opcode + b += 1 + + buf[b] = RevertTo + b += 1 + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Focus)) + b += 4 + + Put32(buf[b:], uint32(Time)) + b += 4 + + c.sendRequest(false, buf) +} + +// Request GetInputFocus +// size: 3 +func (c *Conn) GetInputFocus() (*GetInputFocusReply, error) { + return c.GetInputFocusReply(c.GetInputFocusRequest()) +} + +// Write request to wire for GetInputFocus +func (c *Conn) GetInputFocusRequest() *Cookie { + size := 3 + b := 0 + buf := make([]byte, size) + + buf[b] = 43 // request opcode + b += 1 + + return c.sendRequest(true, buf) +} + +// Request reply for GetInputFocus +// size: 12 +type GetInputFocusReply struct { + Sequence uint16 + Length uint32 + RevertTo byte + Focus Id +} + +// Read reply GetInputFocus +func (c *Conn) GetInputFocusReply(cook *Cookie) (*GetInputFocusReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(GetInputFocusReply) + b := 1 // skip reply determinant + + v.RevertTo = buf[b] + b += 1 + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Length = Get32(buf[b:]) // 4-byte units + b += 4 + + v.Focus = Id(Get32(buf[b:])) + b += 4 + + return v, nil +} + +// Request QueryKeymap +// size: 3 +func (c *Conn) QueryKeymap() (*QueryKeymapReply, error) { + return c.QueryKeymapReply(c.QueryKeymapRequest()) +} + +// Write request to wire for QueryKeymap +func (c *Conn) QueryKeymapRequest() *Cookie { + size := 3 + b := 0 + buf := make([]byte, size) + + buf[b] = 44 // request opcode + b += 1 + + return c.sendRequest(true, buf) +} + +// Request reply for QueryKeymap +// size: (8 + pad(32)) +type QueryKeymapReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Keys []byte // size: pad(32) +} + +// Read reply QueryKeymap +func (c *Conn) QueryKeymapReply(cook *Cookie) (*QueryKeymapReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(QueryKeymapReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Length = Get32(buf[b:]) // 4-byte units + b += 4 + + v.Keys = make([]byte, 32) + copy(v.Keys[:32], buf[b:]) + b += pad(int(32)) + + return v, nil +} + +// Request OpenFont +// size: (12 + pad((int(NameLen) * 1))) +// Write request to wire for OpenFont +func (c *Conn) OpenFont(Fid Id, NameLen uint16, Name string) { + size := (12 + pad((int(NameLen) * 1))) + b := 0 + buf := make([]byte, size) + + buf[b] = 45 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Fid)) + b += 4 + + Put16(buf[b:], NameLen) + b += 2 + + b += 2 // padding + + copy(buf[b:], Name[:NameLen]) + b += pad(int(NameLen)) + + c.sendRequest(false, buf) +} + +// Request CloseFont +// size: 8 +// Write request to wire for CloseFont +func (c *Conn) CloseFont(Font Id) { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 46 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Font)) + b += 4 + + c.sendRequest(false, buf) +} + +// Request QueryFont +// size: 8 +func (c *Conn) QueryFont(Font Id) (*QueryFontReply, error) { + return c.QueryFontReply(c.QueryFontRequest(Font)) +} + +// Write request to wire for QueryFont +func (c *Conn) QueryFontRequest(Font Id) *Cookie { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 47 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Font)) + b += 4 + + return c.sendRequest(true, buf) +} + +// Request reply for QueryFont +// size: ((60 + pad((int(PropertiesLen) * 8))) + pad((int(CharInfosLen) * 12))) +type QueryFontReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + MinBounds Charinfo + // padding: 4 bytes + MaxBounds Charinfo + // padding: 4 bytes + MinCharOrByte2 uint16 + MaxCharOrByte2 uint16 + DefaultChar uint16 + PropertiesLen uint16 + DrawDirection byte + MinByte1 byte + MaxByte1 byte + AllCharsExist bool + FontAscent int16 + FontDescent int16 + CharInfosLen uint32 + Properties []Fontprop // size: pad((int(PropertiesLen) * 8)) + CharInfos []Charinfo // size: pad((int(CharInfosLen) * 12)) +} + +// Read reply QueryFont +func (c *Conn) QueryFontReply(cook *Cookie) (*QueryFontReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(QueryFontReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Length = Get32(buf[b:]) // 4-byte units + b += 4 + + v.MinBounds = Charinfo{} + b += ReadCharinfo(buf[b:], &v.MinBounds) + + b += 4 // padding + + v.MaxBounds = Charinfo{} + b += ReadCharinfo(buf[b:], &v.MaxBounds) + + b += 4 // padding + + v.MinCharOrByte2 = Get16(buf[b:]) + b += 2 + + v.MaxCharOrByte2 = Get16(buf[b:]) + b += 2 + + v.DefaultChar = Get16(buf[b:]) + b += 2 + + v.PropertiesLen = Get16(buf[b:]) + b += 2 + + v.DrawDirection = buf[b] + b += 1 + + v.MinByte1 = buf[b] + b += 1 + + v.MaxByte1 = buf[b] + b += 1 + + if buf[b] == 1 { + v.AllCharsExist = true + } else { + v.AllCharsExist = false + } + b += 1 + + v.FontAscent = int16(Get16(buf[b:])) + b += 2 + + v.FontDescent = int16(Get16(buf[b:])) + b += 2 + + v.CharInfosLen = Get32(buf[b:]) + b += 4 + + v.Properties = make([]Fontprop, v.PropertiesLen) + b += ReadFontpropList(buf[b:], v.Properties) + + v.CharInfos = make([]Charinfo, v.CharInfosLen) + b += ReadCharinfoList(buf[b:], v.CharInfos) + + return v, nil +} + +// Request QueryTextExtents +// size: (8 + pad((len(String) * 2))) +func (c *Conn) QueryTextExtents(Font Id, String []Char2b, StringLen uint16) (*QueryTextExtentsReply, error) { + return c.QueryTextExtentsReply(c.QueryTextExtentsRequest(Font, String, StringLen)) +} + +// Write request to wire for QueryTextExtents +func (c *Conn) QueryTextExtentsRequest(Font Id, String []Char2b, StringLen uint16) *Cookie { + size := (8 + pad((len(String) * 2))) + b := 0 + buf := make([]byte, size) + + buf[b] = 48 // request opcode + b += 1 + + buf[b] = byte((int(StringLen) & 1)) + b += 1 + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Font)) + b += 4 + + b += Char2bListBytes(buf[b:], String) + + // skip writing local field: StringLen (2) :: uint16 + + return c.sendRequest(true, buf) +} + +// Request reply for QueryTextExtents +// size: 28 +type QueryTextExtentsReply struct { + Sequence uint16 + Length uint32 + DrawDirection byte + FontAscent int16 + FontDescent int16 + OverallAscent int16 + OverallDescent int16 + OverallWidth int32 + OverallLeft int32 + OverallRight int32 +} + +// Read reply QueryTextExtents +func (c *Conn) QueryTextExtentsReply(cook *Cookie) (*QueryTextExtentsReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(QueryTextExtentsReply) + b := 1 // skip reply determinant + + v.DrawDirection = buf[b] + b += 1 + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Length = Get32(buf[b:]) // 4-byte units + b += 4 + + v.FontAscent = int16(Get16(buf[b:])) + b += 2 + + v.FontDescent = int16(Get16(buf[b:])) + b += 2 + + v.OverallAscent = int16(Get16(buf[b:])) + b += 2 + + v.OverallDescent = int16(Get16(buf[b:])) + b += 2 + + v.OverallWidth = int32(Get32(buf[b:])) + b += 4 + + v.OverallLeft = int32(Get32(buf[b:])) + b += 4 + + v.OverallRight = int32(Get32(buf[b:])) + b += 4 + + return v, nil +} + +// Request ListFonts +// size: (8 + pad((int(PatternLen) * 1))) +func (c *Conn) ListFonts(MaxNames uint16, PatternLen uint16, Pattern string) (*ListFontsReply, error) { + return c.ListFontsReply(c.ListFontsRequest(MaxNames, PatternLen, Pattern)) +} + +// Write request to wire for ListFonts +func (c *Conn) ListFontsRequest(MaxNames uint16, PatternLen uint16, Pattern string) *Cookie { + size := (8 + pad((int(PatternLen) * 1))) + b := 0 + buf := make([]byte, size) + + buf[b] = 49 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put16(buf[b:], MaxNames) + b += 2 + + Put16(buf[b:], PatternLen) + b += 2 + + copy(buf[b:], Pattern[:PatternLen]) + b += pad(int(PatternLen)) + + return c.sendRequest(true, buf) +} + +// Request reply for ListFonts +// size: (32 + StrListSize(Names)) +type ListFontsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NamesLen uint16 + // padding: 22 bytes + Names []Str // size: StrListSize(Names) +} + +// Read reply ListFonts +func (c *Conn) ListFontsReply(cook *Cookie) (*ListFontsReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(ListFontsReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Length = Get32(buf[b:]) // 4-byte units + b += 4 + + v.NamesLen = Get16(buf[b:]) + b += 2 + + b += 22 // padding + + v.Names = make([]Str, v.NamesLen) + b += ReadStrList(buf[b:], v.Names) + + return v, nil +} + +// Request ListFontsWithInfo +// size: (8 + pad((int(PatternLen) * 1))) +func (c *Conn) ListFontsWithInfo(MaxNames uint16, PatternLen uint16, Pattern string) (*ListFontsWithInfoReply, error) { + return c.ListFontsWithInfoReply(c.ListFontsWithInfoRequest(MaxNames, PatternLen, Pattern)) +} + +// Write request to wire for ListFontsWithInfo +func (c *Conn) ListFontsWithInfoRequest(MaxNames uint16, PatternLen uint16, Pattern string) *Cookie { + size := (8 + pad((int(PatternLen) * 1))) + b := 0 + buf := make([]byte, size) + + buf[b] = 50 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put16(buf[b:], MaxNames) + b += 2 + + Put16(buf[b:], PatternLen) + b += 2 + + copy(buf[b:], Pattern[:PatternLen]) + b += pad(int(PatternLen)) + + return c.sendRequest(true, buf) +} + +// Request reply for ListFontsWithInfo +// size: ((60 + pad((int(PropertiesLen) * 8))) + pad((int(NameLen) * 1))) +type ListFontsWithInfoReply struct { + Sequence uint16 + Length uint32 + NameLen byte + MinBounds Charinfo + // padding: 4 bytes + MaxBounds Charinfo + // padding: 4 bytes + MinCharOrByte2 uint16 + MaxCharOrByte2 uint16 + DefaultChar uint16 + PropertiesLen uint16 + DrawDirection byte + MinByte1 byte + MaxByte1 byte + AllCharsExist bool + FontAscent int16 + FontDescent int16 + RepliesHint uint32 + Properties []Fontprop // size: pad((int(PropertiesLen) * 8)) + Name string // size: pad((int(NameLen) * 1)) +} + +// Read reply ListFontsWithInfo +func (c *Conn) ListFontsWithInfoReply(cook *Cookie) (*ListFontsWithInfoReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(ListFontsWithInfoReply) + b := 1 // skip reply determinant + + v.NameLen = buf[b] + b += 1 + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Length = Get32(buf[b:]) // 4-byte units + b += 4 + + v.MinBounds = Charinfo{} + b += ReadCharinfo(buf[b:], &v.MinBounds) + + b += 4 // padding + + v.MaxBounds = Charinfo{} + b += ReadCharinfo(buf[b:], &v.MaxBounds) + + b += 4 // padding + + v.MinCharOrByte2 = Get16(buf[b:]) + b += 2 + + v.MaxCharOrByte2 = Get16(buf[b:]) + b += 2 + + v.DefaultChar = Get16(buf[b:]) + b += 2 + + v.PropertiesLen = Get16(buf[b:]) + b += 2 + + v.DrawDirection = buf[b] + b += 1 + + v.MinByte1 = buf[b] + b += 1 + + v.MaxByte1 = buf[b] + b += 1 + + if buf[b] == 1 { + v.AllCharsExist = true + } else { + v.AllCharsExist = false + } + b += 1 + + v.FontAscent = int16(Get16(buf[b:])) + b += 2 + + v.FontDescent = int16(Get16(buf[b:])) + b += 2 + + v.RepliesHint = Get32(buf[b:]) + b += 4 + + v.Properties = make([]Fontprop, v.PropertiesLen) + b += ReadFontpropList(buf[b:], v.Properties) + + { + byteString := make([]byte, v.NameLen) + copy(byteString[:v.NameLen], buf[b:]) + v.Name = string(byteString) + b += pad(int(v.NameLen)) + } + + return v, nil +} + +// Request SetFontPath +// size: (8 + StrListSize(Font)) +// Write request to wire for SetFontPath +func (c *Conn) SetFontPath(FontQty uint16, Font []Str) { + size := (8 + StrListSize(Font)) + b := 0 + buf := make([]byte, size) + + buf[b] = 51 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put16(buf[b:], FontQty) + b += 2 + + b += 2 // padding + + b += StrListBytes(buf[b:], Font) + + c.sendRequest(false, buf) +} + +// Request GetFontPath +// size: 3 +func (c *Conn) GetFontPath() (*GetFontPathReply, error) { + return c.GetFontPathReply(c.GetFontPathRequest()) +} + +// Write request to wire for GetFontPath +func (c *Conn) GetFontPathRequest() *Cookie { + size := 3 + b := 0 + buf := make([]byte, size) + + buf[b] = 52 // request opcode + b += 1 + + return c.sendRequest(true, buf) +} + +// Request reply for GetFontPath +// size: (32 + StrListSize(Path)) +type GetFontPathReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + PathLen uint16 + // padding: 22 bytes + Path []Str // size: StrListSize(Path) +} + +// Read reply GetFontPath +func (c *Conn) GetFontPathReply(cook *Cookie) (*GetFontPathReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(GetFontPathReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Length = Get32(buf[b:]) // 4-byte units + b += 4 + + v.PathLen = Get16(buf[b:]) + b += 2 + + b += 22 // padding + + v.Path = make([]Str, v.PathLen) + b += ReadStrList(buf[b:], v.Path) + + return v, nil +} + +// Request CreatePixmap +// size: 16 +// Write request to wire for CreatePixmap +func (c *Conn) CreatePixmap(Depth byte, Pid Id, Drawable Id, Width uint16, Height uint16) { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 53 // request opcode + b += 1 + + buf[b] = Depth + b += 1 + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Pid)) + b += 4 + + Put32(buf[b:], uint32(Drawable)) + b += 4 + + Put16(buf[b:], Width) + b += 2 + + Put16(buf[b:], Height) + b += 2 + + c.sendRequest(false, buf) +} + +// Request FreePixmap +// size: 8 +// Write request to wire for FreePixmap +func (c *Conn) FreePixmap(Pixmap Id) { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 54 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Pixmap)) + b += 4 + + c.sendRequest(false, buf) +} + +// Request CreateGC +// size: (12 + (4 + pad((4 * popCount(int(ValueMask)))))) +// Write request to wire for CreateGC +func (c *Conn) CreateGC(Cid Id, Drawable Id, ValueMask uint32, ValueList []uint32) { + size := (12 + (4 + pad((4 * popCount(int(ValueMask)))))) + b := 0 + buf := make([]byte, size) + + buf[b] = 55 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Cid)) + b += 4 + + Put32(buf[b:], uint32(Drawable)) + b += 4 + + Put32(buf[b:], ValueMask) + b += 4 + for i := 0; i < popCount(int(ValueMask)); i++ { + Put32(buf[b:], ValueList[i]) + b += 4 + } + b = pad(b) + + c.sendRequest(false, buf) +} + +// Request ChangeGC +// size: (8 + (4 + pad((4 * popCount(int(ValueMask)))))) +// Write request to wire for ChangeGC +func (c *Conn) ChangeGC(Gc Id, ValueMask uint32, ValueList []uint32) { + size := (8 + (4 + pad((4 * popCount(int(ValueMask)))))) + b := 0 + buf := make([]byte, size) + + buf[b] = 56 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Gc)) + b += 4 + + Put32(buf[b:], ValueMask) + b += 4 + for i := 0; i < popCount(int(ValueMask)); i++ { + Put32(buf[b:], ValueList[i]) + b += 4 + } + b = pad(b) + + c.sendRequest(false, buf) +} + +// Request CopyGC +// size: 16 +// Write request to wire for CopyGC +func (c *Conn) CopyGC(SrcGc Id, DstGc Id, ValueMask uint32) { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 57 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(SrcGc)) + b += 4 + + Put32(buf[b:], uint32(DstGc)) + b += 4 + + Put32(buf[b:], ValueMask) + b += 4 + + c.sendRequest(false, buf) +} + +// Request SetDashes +// size: (12 + pad((int(DashesLen) * 1))) +// Write request to wire for SetDashes +func (c *Conn) SetDashes(Gc Id, DashOffset uint16, DashesLen uint16, Dashes []byte) { + size := (12 + pad((int(DashesLen) * 1))) + b := 0 + buf := make([]byte, size) + + buf[b] = 58 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Gc)) + b += 4 + + Put16(buf[b:], DashOffset) + b += 2 + + Put16(buf[b:], DashesLen) + b += 2 + + copy(buf[b:], Dashes[:DashesLen]) + b += pad(int(DashesLen)) + + c.sendRequest(false, buf) +} + +// Request SetClipRectangles +// size: (12 + pad((len(Rectangles) * 8))) +// Write request to wire for SetClipRectangles +func (c *Conn) SetClipRectangles(Ordering byte, Gc Id, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) { + size := (12 + pad((len(Rectangles) * 8))) + b := 0 + buf := make([]byte, size) + + buf[b] = 59 // request opcode + b += 1 + + buf[b] = Ordering + b += 1 + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Gc)) + b += 4 + + Put16(buf[b:], uint16(ClipXOrigin)) + b += 2 + + Put16(buf[b:], uint16(ClipYOrigin)) + b += 2 + + b += RectangleListBytes(buf[b:], Rectangles) + + c.sendRequest(false, buf) +} + +// Request FreeGC +// size: 8 +// Write request to wire for FreeGC +func (c *Conn) FreeGC(Gc Id) { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 60 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Gc)) + b += 4 + + c.sendRequest(false, buf) +} + +// Request ClearArea +// size: 16 +// Write request to wire for ClearArea +func (c *Conn) ClearArea(Exposures bool, Window Id, X int16, Y int16, Width uint16, Height uint16) { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 61 // request opcode + b += 1 + + if Exposures { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Window)) + b += 4 + + Put16(buf[b:], uint16(X)) + b += 2 + + Put16(buf[b:], uint16(Y)) + b += 2 + + Put16(buf[b:], Width) + b += 2 + + Put16(buf[b:], Height) + b += 2 + + c.sendRequest(false, buf) +} + +// Request CopyArea +// size: 28 +// Write request to wire for CopyArea +func (c *Conn) CopyArea(SrcDrawable Id, DstDrawable Id, Gc Id, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16) { + size := 28 + b := 0 + buf := make([]byte, size) + + buf[b] = 62 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(SrcDrawable)) + b += 4 + + Put32(buf[b:], uint32(DstDrawable)) + b += 4 + + Put32(buf[b:], uint32(Gc)) + b += 4 + + Put16(buf[b:], uint16(SrcX)) + b += 2 + + Put16(buf[b:], uint16(SrcY)) + b += 2 + + Put16(buf[b:], uint16(DstX)) + b += 2 + + Put16(buf[b:], uint16(DstY)) + b += 2 + + Put16(buf[b:], Width) + b += 2 + + Put16(buf[b:], Height) + b += 2 + + c.sendRequest(false, buf) +} + +// Request CopyPlane +// size: 32 +// Write request to wire for CopyPlane +func (c *Conn) CopyPlane(SrcDrawable Id, DstDrawable Id, Gc Id, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16, BitPlane uint32) { + size := 32 + b := 0 + buf := make([]byte, size) + + buf[b] = 63 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(SrcDrawable)) + b += 4 + + Put32(buf[b:], uint32(DstDrawable)) + b += 4 + + Put32(buf[b:], uint32(Gc)) + b += 4 + + Put16(buf[b:], uint16(SrcX)) + b += 2 + + Put16(buf[b:], uint16(SrcY)) + b += 2 + + Put16(buf[b:], uint16(DstX)) + b += 2 + + Put16(buf[b:], uint16(DstY)) + b += 2 + + Put16(buf[b:], Width) + b += 2 + + Put16(buf[b:], Height) + b += 2 + + Put32(buf[b:], BitPlane) + b += 4 + + c.sendRequest(false, buf) +} + +// Request PolyPoint +// size: (12 + pad((len(Points) * 4))) +// Write request to wire for PolyPoint +func (c *Conn) PolyPoint(CoordinateMode byte, Drawable Id, Gc Id, Points []Point) { + size := (12 + pad((len(Points) * 4))) + b := 0 + buf := make([]byte, size) + + buf[b] = 64 // request opcode + b += 1 + + buf[b] = CoordinateMode + b += 1 + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Drawable)) + b += 4 + + Put32(buf[b:], uint32(Gc)) + b += 4 + + b += PointListBytes(buf[b:], Points) + + c.sendRequest(false, buf) +} + +// Request PolyLine +// size: (12 + pad((len(Points) * 4))) +// Write request to wire for PolyLine +func (c *Conn) PolyLine(CoordinateMode byte, Drawable Id, Gc Id, Points []Point) { + size := (12 + pad((len(Points) * 4))) + b := 0 + buf := make([]byte, size) + + buf[b] = 65 // request opcode + b += 1 + + buf[b] = CoordinateMode + b += 1 + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Drawable)) + b += 4 + + Put32(buf[b:], uint32(Gc)) + b += 4 + + b += PointListBytes(buf[b:], Points) + + c.sendRequest(false, buf) +} + +// Request PolySegment +// size: (12 + pad((len(Segments) * 8))) +// Write request to wire for PolySegment +func (c *Conn) PolySegment(Drawable Id, Gc Id, Segments []Segment) { + size := (12 + pad((len(Segments) * 8))) + b := 0 + buf := make([]byte, size) + + buf[b] = 66 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Drawable)) + b += 4 + + Put32(buf[b:], uint32(Gc)) + b += 4 + + b += SegmentListBytes(buf[b:], Segments) + + c.sendRequest(false, buf) +} + +// Request PolyRectangle +// size: (12 + pad((len(Rectangles) * 8))) +// Write request to wire for PolyRectangle +func (c *Conn) PolyRectangle(Drawable Id, Gc Id, Rectangles []Rectangle) { + size := (12 + pad((len(Rectangles) * 8))) + b := 0 + buf := make([]byte, size) + + buf[b] = 67 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Drawable)) + b += 4 + + Put32(buf[b:], uint32(Gc)) + b += 4 + + b += RectangleListBytes(buf[b:], Rectangles) + + c.sendRequest(false, buf) +} + +// Request PolyArc +// size: (12 + pad((len(Arcs) * 12))) +// Write request to wire for PolyArc +func (c *Conn) PolyArc(Drawable Id, Gc Id, Arcs []Arc) { + size := (12 + pad((len(Arcs) * 12))) + b := 0 + buf := make([]byte, size) + + buf[b] = 68 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Drawable)) + b += 4 + + Put32(buf[b:], uint32(Gc)) + b += 4 + + b += ArcListBytes(buf[b:], Arcs) + + c.sendRequest(false, buf) +} + +// Request FillPoly +// size: (16 + pad((len(Points) * 4))) +// Write request to wire for FillPoly +func (c *Conn) FillPoly(Drawable Id, Gc Id, Shape byte, CoordinateMode byte, Points []Point) { + size := (16 + pad((len(Points) * 4))) + b := 0 + buf := make([]byte, size) + + buf[b] = 69 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Drawable)) + b += 4 + + Put32(buf[b:], uint32(Gc)) + b += 4 + + buf[b] = Shape + b += 1 + + buf[b] = CoordinateMode + b += 1 + + b += 2 // padding + + b += PointListBytes(buf[b:], Points) + + c.sendRequest(false, buf) +} + +// Request PolyFillRectangle +// size: (12 + pad((len(Rectangles) * 8))) +// Write request to wire for PolyFillRectangle +func (c *Conn) PolyFillRectangle(Drawable Id, Gc Id, Rectangles []Rectangle) { + size := (12 + pad((len(Rectangles) * 8))) + b := 0 + buf := make([]byte, size) + + buf[b] = 70 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Drawable)) + b += 4 + + Put32(buf[b:], uint32(Gc)) + b += 4 + + b += RectangleListBytes(buf[b:], Rectangles) + + c.sendRequest(false, buf) +} + +// Request PolyFillArc +// size: (12 + pad((len(Arcs) * 12))) +// Write request to wire for PolyFillArc +func (c *Conn) PolyFillArc(Drawable Id, Gc Id, Arcs []Arc) { + size := (12 + pad((len(Arcs) * 12))) + b := 0 + buf := make([]byte, size) + + buf[b] = 71 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Drawable)) + b += 4 + + Put32(buf[b:], uint32(Gc)) + b += 4 + + b += ArcListBytes(buf[b:], Arcs) + + c.sendRequest(false, buf) +} + +// Request PutImage +// size: (24 + pad((len(Data) * 1))) +// Write request to wire for PutImage +func (c *Conn) PutImage(Format byte, Drawable Id, Gc Id, Width uint16, Height uint16, DstX int16, DstY int16, LeftPad byte, Depth byte, Data []byte) { + size := (24 + pad((len(Data) * 1))) + b := 0 + buf := make([]byte, size) + + buf[b] = 72 // request opcode + b += 1 + + buf[b] = Format + b += 1 + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Drawable)) + b += 4 + + Put32(buf[b:], uint32(Gc)) + b += 4 + + Put16(buf[b:], Width) + b += 2 + + Put16(buf[b:], Height) + b += 2 + + Put16(buf[b:], uint16(DstX)) + b += 2 + + Put16(buf[b:], uint16(DstY)) + b += 2 + + buf[b] = LeftPad + b += 1 + + buf[b] = Depth + b += 1 + + b += 2 // padding + + copy(buf[b:], Data[:len(Data)]) + b += pad(int(len(Data))) + + c.sendRequest(false, buf) +} + +// Request GetImage +// size: 20 +func (c *Conn) GetImage(Format byte, Drawable Id, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32) (*GetImageReply, error) { + return c.GetImageReply(c.GetImageRequest(Format, Drawable, X, Y, Width, Height, PlaneMask)) +} + +// Write request to wire for GetImage +func (c *Conn) GetImageRequest(Format byte, Drawable Id, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32) *Cookie { + size := 20 + b := 0 + buf := make([]byte, size) + + buf[b] = 73 // request opcode + b += 1 + + buf[b] = Format + b += 1 + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Drawable)) + b += 4 + + Put16(buf[b:], uint16(X)) + b += 2 + + Put16(buf[b:], uint16(Y)) + b += 2 + + Put16(buf[b:], Width) + b += 2 + + Put16(buf[b:], Height) + b += 2 + + Put32(buf[b:], PlaneMask) + b += 4 + + return c.sendRequest(true, buf) +} + +// Request reply for GetImage +// size: (32 + pad(((int(Length) * 4) * 1))) +type GetImageReply struct { + Sequence uint16 + Length uint32 + Depth byte + Visual Visualid + // padding: 20 bytes + Data []byte // size: pad(((int(Length) * 4) * 1)) +} + +// Read reply GetImage +func (c *Conn) GetImageReply(cook *Cookie) (*GetImageReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(GetImageReply) + b := 1 // skip reply determinant + + v.Depth = buf[b] + b += 1 + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Length = Get32(buf[b:]) // 4-byte units + b += 4 + + v.Visual = Visualid(Get32(buf[b:])) + b += 4 + + b += 20 // padding + + v.Data = make([]byte, (int(v.Length) * 4)) + copy(v.Data[:(int(v.Length)*4)], buf[b:]) + b += pad(int((int(v.Length) * 4))) + + return v, nil +} + +// Request PolyText8 +// size: (16 + pad((len(Items) * 1))) +// Write request to wire for PolyText8 +func (c *Conn) PolyText8(Drawable Id, Gc Id, X int16, Y int16, Items []byte) { + size := (16 + pad((len(Items) * 1))) + b := 0 + buf := make([]byte, size) + + buf[b] = 74 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Drawable)) + b += 4 + + Put32(buf[b:], uint32(Gc)) + b += 4 + + Put16(buf[b:], uint16(X)) + b += 2 + + Put16(buf[b:], uint16(Y)) + b += 2 + + copy(buf[b:], Items[:len(Items)]) + b += pad(int(len(Items))) + + c.sendRequest(false, buf) +} + +// Request PolyText16 +// size: (16 + pad((len(Items) * 1))) +// Write request to wire for PolyText16 +func (c *Conn) PolyText16(Drawable Id, Gc Id, X int16, Y int16, Items []byte) { + size := (16 + pad((len(Items) * 1))) + b := 0 + buf := make([]byte, size) + + buf[b] = 75 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Drawable)) + b += 4 + + Put32(buf[b:], uint32(Gc)) + b += 4 + + Put16(buf[b:], uint16(X)) + b += 2 + + Put16(buf[b:], uint16(Y)) + b += 2 + + copy(buf[b:], Items[:len(Items)]) + b += pad(int(len(Items))) + + c.sendRequest(false, buf) +} + +// Request ImageText8 +// size: (16 + pad((int(StringLen) * 1))) +// Write request to wire for ImageText8 +func (c *Conn) ImageText8(StringLen byte, Drawable Id, Gc Id, X int16, Y int16, String string) { + size := (16 + pad((int(StringLen) * 1))) + b := 0 + buf := make([]byte, size) + + buf[b] = 76 // request opcode + b += 1 + + buf[b] = StringLen + b += 1 + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Drawable)) + b += 4 + + Put32(buf[b:], uint32(Gc)) + b += 4 + + Put16(buf[b:], uint16(X)) + b += 2 + + Put16(buf[b:], uint16(Y)) + b += 2 + + copy(buf[b:], String[:StringLen]) + b += pad(int(StringLen)) + + c.sendRequest(false, buf) +} + +// Request ImageText16 +// size: (16 + pad((int(StringLen) * 2))) +// Write request to wire for ImageText16 +func (c *Conn) ImageText16(StringLen byte, Drawable Id, Gc Id, X int16, Y int16, String []Char2b) { + size := (16 + pad((int(StringLen) * 2))) + b := 0 + buf := make([]byte, size) + + buf[b] = 77 // request opcode + b += 1 + + buf[b] = StringLen + b += 1 + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Drawable)) + b += 4 + + Put32(buf[b:], uint32(Gc)) + b += 4 + + Put16(buf[b:], uint16(X)) + b += 2 + + Put16(buf[b:], uint16(Y)) + b += 2 + + b += Char2bListBytes(buf[b:], String) + + c.sendRequest(false, buf) +} + +// Request CreateColormap +// size: 16 +// Write request to wire for CreateColormap +func (c *Conn) CreateColormap(Alloc byte, Mid Id, Window Id, Visual Visualid) { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 78 // request opcode + b += 1 + + buf[b] = Alloc + b += 1 + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Mid)) + b += 4 + + Put32(buf[b:], uint32(Window)) + b += 4 + + Put32(buf[b:], uint32(Visual)) + b += 4 + + c.sendRequest(false, buf) +} + +// Request FreeColormap +// size: 8 +// Write request to wire for FreeColormap +func (c *Conn) FreeColormap(Cmap Id) { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 79 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Cmap)) + b += 4 + + c.sendRequest(false, buf) +} + +// Request CopyColormapAndFree +// size: 12 +// Write request to wire for CopyColormapAndFree +func (c *Conn) CopyColormapAndFree(Mid Id, SrcCmap Id) { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = 80 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Mid)) + b += 4 + + Put32(buf[b:], uint32(SrcCmap)) + b += 4 + + c.sendRequest(false, buf) +} + +// Request InstallColormap +// size: 8 +// Write request to wire for InstallColormap +func (c *Conn) InstallColormap(Cmap Id) { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 81 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Cmap)) + b += 4 + + c.sendRequest(false, buf) +} + +// Request UninstallColormap +// size: 8 +// Write request to wire for UninstallColormap +func (c *Conn) UninstallColormap(Cmap Id) { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 82 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Cmap)) + b += 4 + + c.sendRequest(false, buf) +} + +// Request ListInstalledColormaps +// size: 8 +func (c *Conn) ListInstalledColormaps(Window Id) (*ListInstalledColormapsReply, error) { + return c.ListInstalledColormapsReply(c.ListInstalledColormapsRequest(Window)) +} + +// Write request to wire for ListInstalledColormaps +func (c *Conn) ListInstalledColormapsRequest(Window Id) *Cookie { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 83 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Window)) + b += 4 + + return c.sendRequest(true, buf) +} + +// Request reply for ListInstalledColormaps +// size: (32 + pad((int(CmapsLen) * 4))) +type ListInstalledColormapsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + CmapsLen uint16 + // padding: 22 bytes + Cmaps []Id // size: pad((int(CmapsLen) * 4)) +} + +// Read reply ListInstalledColormaps +func (c *Conn) ListInstalledColormapsReply(cook *Cookie) (*ListInstalledColormapsReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(ListInstalledColormapsReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Length = Get32(buf[b:]) // 4-byte units + b += 4 + + v.CmapsLen = Get16(buf[b:]) + b += 2 + + b += 22 // padding + + v.Cmaps = make([]Id, v.CmapsLen) + for i := 0; i < int(v.CmapsLen); i++ { + v.Cmaps[i] = Id(Get32(buf[b:])) + b += 4 + } + b = pad(b) + + return v, nil +} + +// Request AllocColor +// size: 16 +func (c *Conn) AllocColor(Cmap Id, Red uint16, Green uint16, Blue uint16) (*AllocColorReply, error) { + return c.AllocColorReply(c.AllocColorRequest(Cmap, Red, Green, Blue)) +} + +// Write request to wire for AllocColor +func (c *Conn) AllocColorRequest(Cmap Id, Red uint16, Green uint16, Blue uint16) *Cookie { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 84 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Cmap)) + b += 4 + + Put16(buf[b:], Red) + b += 2 + + Put16(buf[b:], Green) + b += 2 + + Put16(buf[b:], Blue) + b += 2 + + b += 2 // padding + + return c.sendRequest(true, buf) +} + +// Request reply for AllocColor +// size: 20 +type AllocColorReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Red uint16 + Green uint16 + Blue uint16 + // padding: 2 bytes + Pixel uint32 +} + +// Read reply AllocColor +func (c *Conn) AllocColorReply(cook *Cookie) (*AllocColorReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(AllocColorReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Length = Get32(buf[b:]) // 4-byte units + b += 4 + + v.Red = Get16(buf[b:]) + b += 2 + + v.Green = Get16(buf[b:]) + b += 2 + + v.Blue = Get16(buf[b:]) + b += 2 + + b += 2 // padding + + v.Pixel = Get32(buf[b:]) + b += 4 + + return v, nil +} + +// Request AllocNamedColor +// size: (12 + pad((int(NameLen) * 1))) +func (c *Conn) AllocNamedColor(Cmap Id, NameLen uint16, Name string) (*AllocNamedColorReply, error) { + return c.AllocNamedColorReply(c.AllocNamedColorRequest(Cmap, NameLen, Name)) +} + +// Write request to wire for AllocNamedColor +func (c *Conn) AllocNamedColorRequest(Cmap Id, NameLen uint16, Name string) *Cookie { + size := (12 + pad((int(NameLen) * 1))) + b := 0 + buf := make([]byte, size) + + buf[b] = 85 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Cmap)) + b += 4 + + Put16(buf[b:], NameLen) + b += 2 + + b += 2 // padding + + copy(buf[b:], Name[:NameLen]) + b += pad(int(NameLen)) + + return c.sendRequest(true, buf) +} + +// Request reply for AllocNamedColor +// size: 24 +type AllocNamedColorReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Pixel uint32 + ExactRed uint16 + ExactGreen uint16 + ExactBlue uint16 + VisualRed uint16 + VisualGreen uint16 + VisualBlue uint16 +} + +// Read reply AllocNamedColor +func (c *Conn) AllocNamedColorReply(cook *Cookie) (*AllocNamedColorReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(AllocNamedColorReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Length = Get32(buf[b:]) // 4-byte units + b += 4 + + v.Pixel = Get32(buf[b:]) + b += 4 + + v.ExactRed = Get16(buf[b:]) + b += 2 + + v.ExactGreen = Get16(buf[b:]) + b += 2 + + v.ExactBlue = Get16(buf[b:]) + b += 2 + + v.VisualRed = Get16(buf[b:]) + b += 2 + + v.VisualGreen = Get16(buf[b:]) + b += 2 + + v.VisualBlue = Get16(buf[b:]) + b += 2 + + return v, nil +} + +// Request AllocColorCells +// size: 12 +func (c *Conn) AllocColorCells(Contiguous bool, Cmap Id, Colors uint16, Planes uint16) (*AllocColorCellsReply, error) { + return c.AllocColorCellsReply(c.AllocColorCellsRequest(Contiguous, Cmap, Colors, Planes)) +} + +// Write request to wire for AllocColorCells +func (c *Conn) AllocColorCellsRequest(Contiguous bool, Cmap Id, Colors uint16, Planes uint16) *Cookie { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = 86 // request opcode + b += 1 + + if Contiguous { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Cmap)) + b += 4 + + Put16(buf[b:], Colors) + b += 2 + + Put16(buf[b:], Planes) + b += 2 + + return c.sendRequest(true, buf) +} + +// Request reply for AllocColorCells +// size: ((32 + pad((int(PixelsLen) * 4))) + pad((int(MasksLen) * 4))) +type AllocColorCellsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + PixelsLen uint16 + MasksLen uint16 + // padding: 20 bytes + Pixels []uint32 // size: pad((int(PixelsLen) * 4)) + Masks []uint32 // size: pad((int(MasksLen) * 4)) +} + +// Read reply AllocColorCells +func (c *Conn) AllocColorCellsReply(cook *Cookie) (*AllocColorCellsReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(AllocColorCellsReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Length = Get32(buf[b:]) // 4-byte units + b += 4 + + v.PixelsLen = Get16(buf[b:]) + b += 2 + + v.MasksLen = Get16(buf[b:]) + b += 2 + + b += 20 // padding + + v.Pixels = make([]uint32, v.PixelsLen) + for i := 0; i < int(v.PixelsLen); i++ { + v.Pixels[i] = Get32(buf[b:]) + b += 4 + } + b = pad(b) + + v.Masks = make([]uint32, v.MasksLen) + for i := 0; i < int(v.MasksLen); i++ { + v.Masks[i] = Get32(buf[b:]) + b += 4 + } + b = pad(b) + + return v, nil +} + +// Request AllocColorPlanes +// size: 16 +func (c *Conn) AllocColorPlanes(Contiguous bool, Cmap Id, Colors uint16, Reds uint16, Greens uint16, Blues uint16) (*AllocColorPlanesReply, error) { + return c.AllocColorPlanesReply(c.AllocColorPlanesRequest(Contiguous, Cmap, Colors, Reds, Greens, Blues)) +} + +// Write request to wire for AllocColorPlanes +func (c *Conn) AllocColorPlanesRequest(Contiguous bool, Cmap Id, Colors uint16, Reds uint16, Greens uint16, Blues uint16) *Cookie { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 87 // request opcode + b += 1 + + if Contiguous { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Cmap)) + b += 4 + + Put16(buf[b:], Colors) + b += 2 + + Put16(buf[b:], Reds) + b += 2 + + Put16(buf[b:], Greens) + b += 2 + + Put16(buf[b:], Blues) + b += 2 + + return c.sendRequest(true, buf) +} + +// Request reply for AllocColorPlanes +// size: (32 + pad((int(PixelsLen) * 4))) +type AllocColorPlanesReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + PixelsLen uint16 + // padding: 2 bytes + RedMask uint32 + GreenMask uint32 + BlueMask uint32 + // padding: 8 bytes + Pixels []uint32 // size: pad((int(PixelsLen) * 4)) +} + +// Read reply AllocColorPlanes +func (c *Conn) AllocColorPlanesReply(cook *Cookie) (*AllocColorPlanesReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(AllocColorPlanesReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Length = Get32(buf[b:]) // 4-byte units + b += 4 + + v.PixelsLen = Get16(buf[b:]) + b += 2 + + b += 2 // padding + + v.RedMask = Get32(buf[b:]) + b += 4 + + v.GreenMask = Get32(buf[b:]) + b += 4 + + v.BlueMask = Get32(buf[b:]) + b += 4 + + b += 8 // padding + + v.Pixels = make([]uint32, v.PixelsLen) + for i := 0; i < int(v.PixelsLen); i++ { + v.Pixels[i] = Get32(buf[b:]) + b += 4 + } + b = pad(b) + + return v, nil +} + +// Request FreeColors +// size: (12 + pad((len(Pixels) * 4))) +// Write request to wire for FreeColors +func (c *Conn) FreeColors(Cmap Id, PlaneMask uint32, Pixels []uint32) { + size := (12 + pad((len(Pixels) * 4))) + b := 0 + buf := make([]byte, size) + + buf[b] = 88 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Cmap)) + b += 4 + + Put32(buf[b:], PlaneMask) + b += 4 + + for i := 0; i < int(len(Pixels)); i++ { + Put32(buf[b:], Pixels[i]) + b += 4 + } + b = pad(b) + + c.sendRequest(false, buf) +} + +// Request StoreColors +// size: (8 + pad((len(Items) * 12))) +// Write request to wire for StoreColors +func (c *Conn) StoreColors(Cmap Id, Items []Coloritem) { + size := (8 + pad((len(Items) * 12))) + b := 0 + buf := make([]byte, size) + + buf[b] = 89 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Cmap)) + b += 4 + + b += ColoritemListBytes(buf[b:], Items) + + c.sendRequest(false, buf) +} + +// Request StoreNamedColor +// size: (16 + pad((int(NameLen) * 1))) +// Write request to wire for StoreNamedColor +func (c *Conn) StoreNamedColor(Flags byte, Cmap Id, Pixel uint32, NameLen uint16, Name string) { + size := (16 + pad((int(NameLen) * 1))) + b := 0 + buf := make([]byte, size) + + buf[b] = 90 // request opcode + b += 1 + + buf[b] = Flags + b += 1 + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Cmap)) + b += 4 + + Put32(buf[b:], Pixel) + b += 4 + + Put16(buf[b:], NameLen) + b += 2 + + b += 2 // padding + + copy(buf[b:], Name[:NameLen]) + b += pad(int(NameLen)) + + c.sendRequest(false, buf) +} + +// Request QueryColors +// size: (8 + pad((len(Pixels) * 4))) +func (c *Conn) QueryColors(Cmap Id, Pixels []uint32) (*QueryColorsReply, error) { + return c.QueryColorsReply(c.QueryColorsRequest(Cmap, Pixels)) +} + +// Write request to wire for QueryColors +func (c *Conn) QueryColorsRequest(Cmap Id, Pixels []uint32) *Cookie { + size := (8 + pad((len(Pixels) * 4))) + b := 0 + buf := make([]byte, size) + + buf[b] = 91 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Cmap)) + b += 4 + + for i := 0; i < int(len(Pixels)); i++ { + Put32(buf[b:], Pixels[i]) + b += 4 + } + b = pad(b) + + return c.sendRequest(true, buf) +} + +// Request reply for QueryColors +// size: (32 + pad((int(ColorsLen) * 8))) +type QueryColorsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ColorsLen uint16 + // padding: 22 bytes + Colors []Rgb // size: pad((int(ColorsLen) * 8)) +} + +// Read reply QueryColors +func (c *Conn) QueryColorsReply(cook *Cookie) (*QueryColorsReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(QueryColorsReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Length = Get32(buf[b:]) // 4-byte units + b += 4 + + v.ColorsLen = Get16(buf[b:]) + b += 2 + + b += 22 // padding + + v.Colors = make([]Rgb, v.ColorsLen) + b += ReadRgbList(buf[b:], v.Colors) + + return v, nil +} + +// Request LookupColor +// size: (12 + pad((int(NameLen) * 1))) +func (c *Conn) LookupColor(Cmap Id, NameLen uint16, Name string) (*LookupColorReply, error) { + return c.LookupColorReply(c.LookupColorRequest(Cmap, NameLen, Name)) +} + +// Write request to wire for LookupColor +func (c *Conn) LookupColorRequest(Cmap Id, NameLen uint16, Name string) *Cookie { + size := (12 + pad((int(NameLen) * 1))) + b := 0 + buf := make([]byte, size) + + buf[b] = 92 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Cmap)) + b += 4 + + Put16(buf[b:], NameLen) + b += 2 + + b += 2 // padding + + copy(buf[b:], Name[:NameLen]) + b += pad(int(NameLen)) + + return c.sendRequest(true, buf) +} + +// Request reply for LookupColor +// size: 20 +type LookupColorReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ExactRed uint16 + ExactGreen uint16 + ExactBlue uint16 + VisualRed uint16 + VisualGreen uint16 + VisualBlue uint16 +} + +// Read reply LookupColor +func (c *Conn) LookupColorReply(cook *Cookie) (*LookupColorReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(LookupColorReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Length = Get32(buf[b:]) // 4-byte units + b += 4 + + v.ExactRed = Get16(buf[b:]) + b += 2 + + v.ExactGreen = Get16(buf[b:]) + b += 2 + + v.ExactBlue = Get16(buf[b:]) + b += 2 + + v.VisualRed = Get16(buf[b:]) + b += 2 + + v.VisualGreen = Get16(buf[b:]) + b += 2 + + v.VisualBlue = Get16(buf[b:]) + b += 2 + + return v, nil +} + +// Request CreateCursor +// size: 32 +// Write request to wire for CreateCursor +func (c *Conn) CreateCursor(Cid Id, Source Id, Mask Id, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16, X uint16, Y uint16) { + size := 32 + b := 0 + buf := make([]byte, size) + + buf[b] = 93 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Cid)) + b += 4 + + Put32(buf[b:], uint32(Source)) + b += 4 + + Put32(buf[b:], uint32(Mask)) + b += 4 + + Put16(buf[b:], ForeRed) + b += 2 + + Put16(buf[b:], ForeGreen) + b += 2 + + Put16(buf[b:], ForeBlue) + b += 2 + + Put16(buf[b:], BackRed) + b += 2 + + Put16(buf[b:], BackGreen) + b += 2 + + Put16(buf[b:], BackBlue) + b += 2 + + Put16(buf[b:], X) + b += 2 + + Put16(buf[b:], Y) + b += 2 + + c.sendRequest(false, buf) +} + +// Request CreateGlyphCursor +// size: 32 +// Write request to wire for CreateGlyphCursor +func (c *Conn) CreateGlyphCursor(Cid Id, SourceFont Id, MaskFont Id, SourceChar uint16, MaskChar uint16, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) { + size := 32 + b := 0 + buf := make([]byte, size) + + buf[b] = 94 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Cid)) + b += 4 + + Put32(buf[b:], uint32(SourceFont)) + b += 4 + + Put32(buf[b:], uint32(MaskFont)) + b += 4 + + Put16(buf[b:], SourceChar) + b += 2 + + Put16(buf[b:], MaskChar) + b += 2 + + Put16(buf[b:], ForeRed) + b += 2 + + Put16(buf[b:], ForeGreen) + b += 2 + + Put16(buf[b:], ForeBlue) + b += 2 + + Put16(buf[b:], BackRed) + b += 2 + + Put16(buf[b:], BackGreen) + b += 2 + + Put16(buf[b:], BackBlue) + b += 2 + + c.sendRequest(false, buf) +} + +// Request FreeCursor +// size: 8 +// Write request to wire for FreeCursor +func (c *Conn) FreeCursor(Cursor Id) { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 95 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Cursor)) + b += 4 + + c.sendRequest(false, buf) +} + +// Request RecolorCursor +// size: 20 +// Write request to wire for RecolorCursor +func (c *Conn) RecolorCursor(Cursor Id, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) { + size := 20 + b := 0 + buf := make([]byte, size) + + buf[b] = 96 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Cursor)) + b += 4 + + Put16(buf[b:], ForeRed) + b += 2 + + Put16(buf[b:], ForeGreen) + b += 2 + + Put16(buf[b:], ForeBlue) + b += 2 + + Put16(buf[b:], BackRed) + b += 2 + + Put16(buf[b:], BackGreen) + b += 2 + + Put16(buf[b:], BackBlue) + b += 2 + + c.sendRequest(false, buf) +} + +// Request QueryBestSize +// size: 12 +func (c *Conn) QueryBestSize(Class byte, Drawable Id, Width uint16, Height uint16) (*QueryBestSizeReply, error) { + return c.QueryBestSizeReply(c.QueryBestSizeRequest(Class, Drawable, Width, Height)) +} + +// Write request to wire for QueryBestSize +func (c *Conn) QueryBestSizeRequest(Class byte, Drawable Id, Width uint16, Height uint16) *Cookie { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = 97 // request opcode + b += 1 + + buf[b] = Class + b += 1 + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Drawable)) + b += 4 + + Put16(buf[b:], Width) + b += 2 + + Put16(buf[b:], Height) + b += 2 + + return c.sendRequest(true, buf) +} + +// Request reply for QueryBestSize +// size: 12 +type QueryBestSizeReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Width uint16 + Height uint16 +} + +// Read reply QueryBestSize +func (c *Conn) QueryBestSizeReply(cook *Cookie) (*QueryBestSizeReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(QueryBestSizeReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Length = Get32(buf[b:]) // 4-byte units + b += 4 + + v.Width = Get16(buf[b:]) + b += 2 + + v.Height = Get16(buf[b:]) + b += 2 + + return v, nil +} + +// Request QueryExtension +// size: (8 + pad((int(NameLen) * 1))) +func (c *Conn) QueryExtension(NameLen uint16, Name string) (*QueryExtensionReply, error) { + return c.QueryExtensionReply(c.QueryExtensionRequest(NameLen, Name)) +} + +// Write request to wire for QueryExtension +func (c *Conn) QueryExtensionRequest(NameLen uint16, Name string) *Cookie { + size := (8 + pad((int(NameLen) * 1))) + b := 0 + buf := make([]byte, size) + + buf[b] = 98 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put16(buf[b:], NameLen) + b += 2 + + b += 2 // padding + + copy(buf[b:], Name[:NameLen]) + b += pad(int(NameLen)) + + return c.sendRequest(true, buf) +} + +// Request reply for QueryExtension +// size: 12 +type QueryExtensionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Present bool + MajorOpcode byte + FirstEvent byte + FirstError byte +} + +// Read reply QueryExtension +func (c *Conn) QueryExtensionReply(cook *Cookie) (*QueryExtensionReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(QueryExtensionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Length = Get32(buf[b:]) // 4-byte units + b += 4 + + if buf[b] == 1 { + v.Present = true + } else { + v.Present = false + } + b += 1 + + v.MajorOpcode = buf[b] + b += 1 + + v.FirstEvent = buf[b] + b += 1 + + v.FirstError = buf[b] + b += 1 + + return v, nil +} + +// Request ListExtensions +// size: 3 +func (c *Conn) ListExtensions() (*ListExtensionsReply, error) { + return c.ListExtensionsReply(c.ListExtensionsRequest()) +} + +// Write request to wire for ListExtensions +func (c *Conn) ListExtensionsRequest() *Cookie { + size := 3 + b := 0 + buf := make([]byte, size) + + buf[b] = 99 // request opcode + b += 1 + + return c.sendRequest(true, buf) +} + +// Request reply for ListExtensions +// size: (32 + StrListSize(Names)) +type ListExtensionsReply struct { + Sequence uint16 + Length uint32 + NamesLen byte + // padding: 24 bytes + Names []Str // size: StrListSize(Names) +} + +// Read reply ListExtensions +func (c *Conn) ListExtensionsReply(cook *Cookie) (*ListExtensionsReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(ListExtensionsReply) + b := 1 // skip reply determinant + + v.NamesLen = buf[b] + b += 1 + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Length = Get32(buf[b:]) // 4-byte units + b += 4 + + b += 24 // padding + + v.Names = make([]Str, v.NamesLen) + b += ReadStrList(buf[b:], v.Names) + + return v, nil +} + +// Request ChangeKeyboardMapping +// size: (8 + pad(((int(KeycodeCount) * int(KeysymsPerKeycode)) * 4))) +// Write request to wire for ChangeKeyboardMapping +func (c *Conn) ChangeKeyboardMapping(KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) { + size := (8 + pad(((int(KeycodeCount) * int(KeysymsPerKeycode)) * 4))) + b := 0 + buf := make([]byte, size) + + buf[b] = 100 // request opcode + b += 1 + + buf[b] = KeycodeCount + b += 1 + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = byte(FirstKeycode) + b += 1 + + buf[b] = KeysymsPerKeycode + b += 1 + + b += 2 // padding + + for i := 0; i < int((int(KeycodeCount) * int(KeysymsPerKeycode))); i++ { + Put32(buf[b:], uint32(Keysyms[i])) + b += 4 + } + b = pad(b) + + c.sendRequest(false, buf) +} + +// Request GetKeyboardMapping +// size: 6 +func (c *Conn) GetKeyboardMapping(FirstKeycode Keycode, Count byte) (*GetKeyboardMappingReply, error) { + return c.GetKeyboardMappingReply(c.GetKeyboardMappingRequest(FirstKeycode, Count)) +} + +// Write request to wire for GetKeyboardMapping +func (c *Conn) GetKeyboardMappingRequest(FirstKeycode Keycode, Count byte) *Cookie { + size := 6 + b := 0 + buf := make([]byte, size) + + buf[b] = 101 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = byte(FirstKeycode) + b += 1 + + buf[b] = Count + b += 1 + + return c.sendRequest(true, buf) +} + +// Request reply for GetKeyboardMapping +// size: (32 + pad((int(Length) * 4))) +type GetKeyboardMappingReply struct { + Sequence uint16 + Length uint32 + KeysymsPerKeycode byte + // padding: 24 bytes + Keysyms []Keysym // size: pad((int(Length) * 4)) +} + +// Read reply GetKeyboardMapping +func (c *Conn) GetKeyboardMappingReply(cook *Cookie) (*GetKeyboardMappingReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(GetKeyboardMappingReply) + b := 1 // skip reply determinant + + v.KeysymsPerKeycode = buf[b] + b += 1 + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Length = Get32(buf[b:]) // 4-byte units + b += 4 + + b += 24 // padding + + v.Keysyms = make([]Keysym, v.Length) + for i := 0; i < int(v.Length); i++ { + v.Keysyms[i] = Keysym(Get32(buf[b:])) + b += 4 + } + b = pad(b) + + return v, nil +} + +// Request ChangeKeyboardControl +// size: (4 + (4 + pad((4 * popCount(int(ValueMask)))))) +// Write request to wire for ChangeKeyboardControl +func (c *Conn) ChangeKeyboardControl(ValueMask uint32, ValueList []uint32) { + size := (4 + (4 + pad((4 * popCount(int(ValueMask)))))) + b := 0 + buf := make([]byte, size) + + buf[b] = 102 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], ValueMask) + b += 4 + for i := 0; i < popCount(int(ValueMask)); i++ { + Put32(buf[b:], ValueList[i]) + b += 4 + } + b = pad(b) + + c.sendRequest(false, buf) +} + +// Request GetKeyboardControl +// size: 3 +func (c *Conn) GetKeyboardControl() (*GetKeyboardControlReply, error) { + return c.GetKeyboardControlReply(c.GetKeyboardControlRequest()) +} + +// Write request to wire for GetKeyboardControl +func (c *Conn) GetKeyboardControlRequest() *Cookie { + size := 3 + b := 0 + buf := make([]byte, size) + + buf[b] = 103 // request opcode + b += 1 + + return c.sendRequest(true, buf) +} + +// Request reply for GetKeyboardControl +// size: (20 + pad(32)) +type GetKeyboardControlReply struct { + Sequence uint16 + Length uint32 + GlobalAutoRepeat byte + LedMask uint32 + KeyClickPercent byte + BellPercent byte + BellPitch uint16 + BellDuration uint16 + // padding: 2 bytes + AutoRepeats []byte // size: pad(32) +} + +// Read reply GetKeyboardControl +func (c *Conn) GetKeyboardControlReply(cook *Cookie) (*GetKeyboardControlReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(GetKeyboardControlReply) + b := 1 // skip reply determinant + + v.GlobalAutoRepeat = buf[b] + b += 1 + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Length = Get32(buf[b:]) // 4-byte units + b += 4 + + v.LedMask = Get32(buf[b:]) + b += 4 + + v.KeyClickPercent = buf[b] + b += 1 + + v.BellPercent = buf[b] + b += 1 + + v.BellPitch = Get16(buf[b:]) + b += 2 + + v.BellDuration = Get16(buf[b:]) + b += 2 + + b += 2 // padding + + v.AutoRepeats = make([]byte, 32) + copy(v.AutoRepeats[:32], buf[b:]) + b += pad(int(32)) + + return v, nil +} + +// Request Bell +// size: 4 +// Write request to wire for Bell +func (c *Conn) Bell(Percent int8) { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 104 // request opcode + b += 1 + + buf[b] = byte(Percent) + b += 1 + + c.sendRequest(false, buf) +} + +// Request ChangePointerControl +// size: 12 +// Write request to wire for ChangePointerControl +func (c *Conn) ChangePointerControl(AccelerationNumerator int16, AccelerationDenominator int16, Threshold int16, DoAcceleration bool, DoThreshold bool) { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = 105 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put16(buf[b:], uint16(AccelerationNumerator)) + b += 2 + + Put16(buf[b:], uint16(AccelerationDenominator)) + b += 2 + + Put16(buf[b:], uint16(Threshold)) + b += 2 + + if DoAcceleration { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + if DoThreshold { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + c.sendRequest(false, buf) +} + +// Request GetPointerControl +// size: 3 +func (c *Conn) GetPointerControl() (*GetPointerControlReply, error) { + return c.GetPointerControlReply(c.GetPointerControlRequest()) +} + +// Write request to wire for GetPointerControl +func (c *Conn) GetPointerControlRequest() *Cookie { + size := 3 + b := 0 + buf := make([]byte, size) + + buf[b] = 106 // request opcode + b += 1 + + return c.sendRequest(true, buf) +} + +// Request reply for GetPointerControl +// size: 32 +type GetPointerControlReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + AccelerationNumerator uint16 + AccelerationDenominator uint16 + Threshold uint16 + // padding: 18 bytes +} + +// Read reply GetPointerControl +func (c *Conn) GetPointerControlReply(cook *Cookie) (*GetPointerControlReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(GetPointerControlReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Length = Get32(buf[b:]) // 4-byte units + b += 4 + + v.AccelerationNumerator = Get16(buf[b:]) + b += 2 + + v.AccelerationDenominator = Get16(buf[b:]) + b += 2 + + v.Threshold = Get16(buf[b:]) + b += 2 + + b += 18 // padding + + return v, nil +} + +// Request SetScreenSaver +// size: 10 +// Write request to wire for SetScreenSaver +func (c *Conn) SetScreenSaver(Timeout int16, Interval int16, PreferBlanking byte, AllowExposures byte) { + size := 10 + b := 0 + buf := make([]byte, size) + + buf[b] = 107 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put16(buf[b:], uint16(Timeout)) + b += 2 + + Put16(buf[b:], uint16(Interval)) + b += 2 + + buf[b] = PreferBlanking + b += 1 + + buf[b] = AllowExposures + b += 1 + + c.sendRequest(false, buf) +} + +// Request GetScreenSaver +// size: 3 +func (c *Conn) GetScreenSaver() (*GetScreenSaverReply, error) { + return c.GetScreenSaverReply(c.GetScreenSaverRequest()) +} + +// Write request to wire for GetScreenSaver +func (c *Conn) GetScreenSaverRequest() *Cookie { + size := 3 + b := 0 + buf := make([]byte, size) + + buf[b] = 108 // request opcode + b += 1 + + return c.sendRequest(true, buf) +} + +// Request reply for GetScreenSaver +// size: 32 +type GetScreenSaverReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Timeout uint16 + Interval uint16 + PreferBlanking byte + AllowExposures byte + // padding: 18 bytes +} + +// Read reply GetScreenSaver +func (c *Conn) GetScreenSaverReply(cook *Cookie) (*GetScreenSaverReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(GetScreenSaverReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Length = Get32(buf[b:]) // 4-byte units + b += 4 + + v.Timeout = Get16(buf[b:]) + b += 2 + + v.Interval = Get16(buf[b:]) + b += 2 + + v.PreferBlanking = buf[b] + b += 1 + + v.AllowExposures = buf[b] + b += 1 + + b += 18 // padding + + return v, nil +} + +// Request ChangeHosts +// size: (8 + pad((int(AddressLen) * 1))) +// Write request to wire for ChangeHosts +func (c *Conn) ChangeHosts(Mode byte, Family byte, AddressLen uint16, Address []byte) { + size := (8 + pad((int(AddressLen) * 1))) + b := 0 + buf := make([]byte, size) + + buf[b] = 109 // request opcode + b += 1 + + buf[b] = Mode + b += 1 + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = Family + b += 1 + + b += 1 // padding + + Put16(buf[b:], AddressLen) + b += 2 + + copy(buf[b:], Address[:AddressLen]) + b += pad(int(AddressLen)) + + c.sendRequest(false, buf) +} + +// Request ListHosts +// size: 3 +func (c *Conn) ListHosts() (*ListHostsReply, error) { + return c.ListHostsReply(c.ListHostsRequest()) +} + +// Write request to wire for ListHosts +func (c *Conn) ListHostsRequest() *Cookie { + size := 3 + b := 0 + buf := make([]byte, size) + + buf[b] = 110 // request opcode + b += 1 + + return c.sendRequest(true, buf) +} + +// Request reply for ListHosts +// size: (32 + HostListSize(Hosts)) +type ListHostsReply struct { + Sequence uint16 + Length uint32 + Mode byte + HostsLen uint16 + // padding: 22 bytes + Hosts []Host // size: HostListSize(Hosts) +} + +// Read reply ListHosts +func (c *Conn) ListHostsReply(cook *Cookie) (*ListHostsReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(ListHostsReply) + b := 1 // skip reply determinant + + v.Mode = buf[b] + b += 1 + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Length = Get32(buf[b:]) // 4-byte units + b += 4 + + v.HostsLen = Get16(buf[b:]) + b += 2 + + b += 22 // padding + + v.Hosts = make([]Host, v.HostsLen) + b += ReadHostList(buf[b:], v.Hosts) + + return v, nil +} + +// Request SetAccessControl +// size: 4 +// Write request to wire for SetAccessControl +func (c *Conn) SetAccessControl(Mode byte) { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 111 // request opcode + b += 1 + + buf[b] = Mode + b += 1 + + c.sendRequest(false, buf) +} + +// Request SetCloseDownMode +// size: 4 +// Write request to wire for SetCloseDownMode +func (c *Conn) SetCloseDownMode(Mode byte) { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 112 // request opcode + b += 1 + + buf[b] = Mode + b += 1 + + c.sendRequest(false, buf) +} + +// Request KillClient +// size: 8 +// Write request to wire for KillClient +func (c *Conn) KillClient(Resource uint32) { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 113 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], Resource) + b += 4 + + c.sendRequest(false, buf) +} + +// Request RotateProperties +// size: (12 + pad((int(AtomsLen) * 4))) +// Write request to wire for RotateProperties +func (c *Conn) RotateProperties(Window Id, AtomsLen uint16, Delta int16, Atoms []Id) { + size := (12 + pad((int(AtomsLen) * 4))) + b := 0 + buf := make([]byte, size) + + buf[b] = 114 // request opcode + b += 1 + + b += 1 // padding + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + Put32(buf[b:], uint32(Window)) + b += 4 + + Put16(buf[b:], AtomsLen) + b += 2 + + Put16(buf[b:], uint16(Delta)) + b += 2 + + for i := 0; i < int(AtomsLen); i++ { + Put32(buf[b:], uint32(Atoms[i])) + b += 4 + } + b = pad(b) + + c.sendRequest(false, buf) +} + +// Request ForceScreenSaver +// size: 4 +// Write request to wire for ForceScreenSaver +func (c *Conn) ForceScreenSaver(Mode byte) { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 115 // request opcode + b += 1 + + buf[b] = Mode + b += 1 + + c.sendRequest(false, buf) +} + +// Request SetPointerMapping +// size: (4 + pad((int(MapLen) * 1))) +func (c *Conn) SetPointerMapping(MapLen byte, Map []byte) (*SetPointerMappingReply, error) { + return c.SetPointerMappingReply(c.SetPointerMappingRequest(MapLen, Map)) +} + +// Write request to wire for SetPointerMapping +func (c *Conn) SetPointerMappingRequest(MapLen byte, Map []byte) *Cookie { + size := (4 + pad((int(MapLen) * 1))) + b := 0 + buf := make([]byte, size) + + buf[b] = 116 // request opcode + b += 1 + + buf[b] = MapLen + b += 1 + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + copy(buf[b:], Map[:MapLen]) + b += pad(int(MapLen)) + + return c.sendRequest(true, buf) +} + +// Request reply for SetPointerMapping +// size: 8 +type SetPointerMappingReply struct { + Sequence uint16 + Length uint32 + Status byte +} + +// Read reply SetPointerMapping +func (c *Conn) SetPointerMappingReply(cook *Cookie) (*SetPointerMappingReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(SetPointerMappingReply) + b := 1 // skip reply determinant + + v.Status = buf[b] + b += 1 + + return v, nil +} + +// Request GetPointerMapping +// size: 3 +func (c *Conn) GetPointerMapping() (*GetPointerMappingReply, error) { + return c.GetPointerMappingReply(c.GetPointerMappingRequest()) +} + +// Write request to wire for GetPointerMapping +func (c *Conn) GetPointerMappingRequest() *Cookie { + size := 3 + b := 0 + buf := make([]byte, size) + + buf[b] = 117 // request opcode + b += 1 + + return c.sendRequest(true, buf) +} + +// Request reply for GetPointerMapping +// size: (32 + pad((int(MapLen) * 1))) +type GetPointerMappingReply struct { + Sequence uint16 + Length uint32 + MapLen byte + // padding: 24 bytes + Map []byte // size: pad((int(MapLen) * 1)) +} + +// Read reply GetPointerMapping +func (c *Conn) GetPointerMappingReply(cook *Cookie) (*GetPointerMappingReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(GetPointerMappingReply) + b := 1 // skip reply determinant + + v.MapLen = buf[b] + b += 1 + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Length = Get32(buf[b:]) // 4-byte units + b += 4 + + b += 24 // padding + + v.Map = make([]byte, v.MapLen) + copy(v.Map[:v.MapLen], buf[b:]) + b += pad(int(v.MapLen)) + + return v, nil +} + +// Request SetModifierMapping +// size: (4 + pad(((int(KeycodesPerModifier) * 8) * 1))) +func (c *Conn) SetModifierMapping(KeycodesPerModifier byte, Keycodes []Keycode) (*SetModifierMappingReply, error) { + return c.SetModifierMappingReply(c.SetModifierMappingRequest(KeycodesPerModifier, Keycodes)) +} + +// Write request to wire for SetModifierMapping +func (c *Conn) SetModifierMappingRequest(KeycodesPerModifier byte, Keycodes []Keycode) *Cookie { + size := (4 + pad(((int(KeycodesPerModifier) * 8) * 1))) + b := 0 + buf := make([]byte, size) + + buf[b] = 118 // request opcode + b += 1 + + buf[b] = KeycodesPerModifier + b += 1 + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + for i := 0; i < int((int(KeycodesPerModifier) * 8)); i++ { + buf[b] = byte(Keycodes[i]) + b += 1 + } + b = pad(b) + + return c.sendRequest(true, buf) +} + +// Request reply for SetModifierMapping +// size: 8 +type SetModifierMappingReply struct { + Sequence uint16 + Length uint32 + Status byte +} + +// Read reply SetModifierMapping +func (c *Conn) SetModifierMappingReply(cook *Cookie) (*SetModifierMappingReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(SetModifierMappingReply) + b := 1 // skip reply determinant + + v.Status = buf[b] + b += 1 + + return v, nil +} + +// Request GetModifierMapping +// size: 3 +func (c *Conn) GetModifierMapping() (*GetModifierMappingReply, error) { + return c.GetModifierMappingReply(c.GetModifierMappingRequest()) +} + +// Write request to wire for GetModifierMapping +func (c *Conn) GetModifierMappingRequest() *Cookie { + size := 3 + b := 0 + buf := make([]byte, size) + + buf[b] = 119 // request opcode + b += 1 + + return c.sendRequest(true, buf) +} + +// Request reply for GetModifierMapping +// size: (32 + pad(((int(KeycodesPerModifier) * 8) * 1))) +type GetModifierMappingReply struct { + Sequence uint16 + Length uint32 + KeycodesPerModifier byte + // padding: 24 bytes + Keycodes []Keycode // size: pad(((int(KeycodesPerModifier) * 8) * 1)) +} + +// Read reply GetModifierMapping +func (c *Conn) GetModifierMappingReply(cook *Cookie) (*GetModifierMappingReply, error) { + buf, err := c.waitForReply(cook) + if err != nil { + return nil, err + } + + v := new(GetModifierMappingReply) + b := 1 // skip reply determinant + + v.KeycodesPerModifier = buf[b] + b += 1 + + v.Sequence = Get16(buf[b:]) + b += 2 + + v.Length = Get32(buf[b:]) // 4-byte units + b += 4 + + b += 24 // padding + + v.Keycodes = make([]Keycode, (int(v.KeycodesPerModifier) * 8)) + for i := 0; i < int((int(v.KeycodesPerModifier) * 8)); i++ { + v.Keycodes[i] = Keycode(buf[b]) + b += 1 + } + b = pad(b) + + return v, nil +} + +// Request NoOperation +// size: 3 +// Write request to wire for NoOperation +func (c *Conn) NoOperation() { + size := 3 + b := 0 + buf := make([]byte, size) + + buf[b] = 127 // request opcode + b += 1 + + c.sendRequest(false, buf) +} -- cgit v1.2.3-70-g09d2 From c222d406b09de529388fcd248476e9ae258895b8 Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Sat, 5 May 2012 02:55:38 -0400 Subject: converting to new reply/cookie scheme --- nexgb/xgbgen/expression.go | 27 +++++++++++++ nexgb/xgbgen/go_event.go | 16 ++++++++ nexgb/xgbgen/go_request_reply.go | 84 +++++++++++++++++++++++++++------------- nexgb/xgbgen/representation.go | 23 ++++++++++- 4 files changed, 122 insertions(+), 28 deletions(-) (limited to 'nexgb/xgbgen/go_event.go') diff --git a/nexgb/xgbgen/expression.go b/nexgb/xgbgen/expression.go index 12bcb19..6a8aa52 100644 --- a/nexgb/xgbgen/expression.go +++ b/nexgb/xgbgen/expression.go @@ -158,6 +158,33 @@ func (e *UnaryOp) Initialize(p *Protocol) { e.Expr.Initialize(p) } +type Padding struct { + Expr Expression +} + +func (e *Padding) Concrete() bool { + return e.Expr.Concrete() +} + +func (e *Padding) Eval() uint { + return uint(pad(int(e.Expr.Eval()))) +} + +func (e *Padding) Reduce(prefix string) string { + if e.Concrete() { + return fmt.Sprintf("%d", e.Eval()) + } + return fmt.Sprintf("pad(%s)", e.Expr.Reduce(prefix)) +} + +func (e *Padding) String() string { + return e.Reduce("") +} + +func (e *Padding) Initialize(p *Protocol) { + e.Expr.Initialize(p) +} + type PopCount struct { Expr Expression } diff --git a/nexgb/xgbgen/go_event.go b/nexgb/xgbgen/go_event.go index 71252a7..41f9320 100644 --- a/nexgb/xgbgen/go_event.go +++ b/nexgb/xgbgen/go_event.go @@ -28,6 +28,14 @@ func (e *Event) Define(c *Context) { // Makes sure that this event type is an Event interface. c.Putln("func (v %s) ImplementsEvent() { }", e.EvType()) c.Putln("") + c.Putln("func (v %s) SequenceId() uint16 {", e.EvType()) + if e.NoSequence { + c.Putln("return uint16(0)") + } else { + c.Putln("return v.Sequence") + } + c.Putln("}") + c.Putln("") // Let's the XGB event loop read this event. c.Putln("func init() {") @@ -99,6 +107,14 @@ func (e *EventCopy) Define(c *Context) { // Makes sure that this event type is an Event interface. c.Putln("func (v %s) ImplementsEvent() { }", e.EvType()) c.Putln("") + c.Putln("func (v %s) SequenceId() uint16 {", e.EvType()) + if e.Old.(*Event).NoSequence { + c.Putln("return uint16(0)") + } else { + c.Putln("return v.Sequence") + } + c.Putln("}") + c.Putln("") // Let's the XGB event loop read this event. c.Putln("func init() {") diff --git a/nexgb/xgbgen/go_request_reply.go b/nexgb/xgbgen/go_request_reply.go index e6180a1..00c48f9 100644 --- a/nexgb/xgbgen/go_request_reply.go +++ b/nexgb/xgbgen/go_request_reply.go @@ -8,30 +8,51 @@ import ( func (r *Request) Define(c *Context) { c.Putln("// Request %s", r.SrcName()) c.Putln("// size: %s", r.Size(c)) + c.Putln("type %s cookie", r.CookieName()) if r.Reply != nil { - c.Putln("func (c *Conn) %s(%s) (*%s, error) {", - r.SrcName(), r.ParamNameTypes(), r.ReplyName()) - c.Putln("return c.%s(c.%s(%s))", - r.ReplyName(), r.ReqName(), r.ParamNames()) + c.Putln("func (c *Conn) %s(%s) %s {", + r.SrcName(), r.ParamNameTypes(), r.CookieName()) + c.Putln("cookie := c.newCookie(true, true)") + c.Putln("c.newRequest(%s(%s), cookie)", r.ReqName(), r.ParamNames()) + c.Putln("return %s(cookie)", r.CookieName()) + c.Putln("}") + c.Putln("") + + c.Putln("func (c *Conn) %sUnchecked(%s) %s {", + r.SrcName(), r.ParamNameTypes(), r.CookieName()) + c.Putln("cookie := c.newCookie(false, true)") + c.Putln("c.newRequest(%s(%s), cookie)", r.ReqName(), r.ParamNames()) + c.Putln("return %s(cookie)", r.CookieName()) c.Putln("}") c.Putln("") - r.WriteRequest(c) r.ReadReply(c) } else { c.Putln("// Write request to wire for %s", r.SrcName()) - c.Putln("func (c *Conn) %s(%s) {", r.SrcName(), r.ParamNameTypes()) - r.WriteRequestFields(c) - c.Putln("c.sendRequest(false, buf)") + c.Putln("func (c *Conn) %s(%s) %s {", + r.SrcName(), r.ParamNameTypes(), r.CookieName()) + c.Putln("cookie := c.newCookie(false, false)") + c.Putln("c.newRequest(%s(%s), cookie)", r.ReqName(), r.ParamNames()) + c.Putln("return %s(cookie)", r.CookieName()) + c.Putln("}") + c.Putln("") + + c.Putln("func (c *Conn) %sChecked(%s) %s {", + r.SrcName(), r.ParamNameTypes(), r.CookieName()) + c.Putln("cookie := c.newCookie(true, false)") + c.Putln("c.newRequest(%s(%s), cookie)", r.ReqName(), r.ParamNames()) + c.Putln("return %s(cookie)", r.CookieName()) c.Putln("}") c.Putln("") } + + r.WriteRequest(c) } func (r *Request) ReadReply(c *Context) { c.Putln("// Request reply for %s", r.SrcName()) c.Putln("// size: %s", r.Reply.Size()) - c.Putln("type %s struct {", r.ReplyName()) + c.Putln("type %s struct {", r.ReplyTypeName()) c.Putln("Sequence uint16") c.Putln("Length uint32") for _, field := range r.Reply.Fields { @@ -40,15 +61,21 @@ func (r *Request) ReadReply(c *Context) { c.Putln("}") c.Putln("") - c.Putln("// Read reply %s", r.SrcName()) - c.Putln("func (c *Conn) %s(cook *Cookie) (*%s, error) {", - r.ReplyName(), r.ReplyName()) - c.Putln("buf, err := c.waitForReply(cook)") - c.Putln("if err != nil {") - c.Putln("return nil, err") + c.Putln("// Waits and reads reply data from request %s", r.SrcName()) + c.Putln("func (cook %s) Reply() (*%s, error) {", + r.CookieName(), r.ReplyTypeName()) + c.Putln("buf, err := cookie(cook).reply()") + c.Putln("if err != nil {") + c.Putln("return nil, err") + c.Putln("}") + c.Putln("return %s(buf), nil", r.ReplyName()) c.Putln("}") c.Putln("") - c.Putln("v := new(%s)", r.ReplyName()) + + c.Putln("// Read reply into structure from buffer for %s", r.SrcName()) + c.Putln("func %s(buf []byte) *%s {", + r.ReplyName(), r.ReplyTypeName()) + c.Putln("v := new(%s)", r.ReplyTypeName()) c.Putln("b := 1 // skip reply determinant") c.Putln("") for i, field := range r.Reply.Fields { @@ -63,21 +90,14 @@ func (r *Request) ReadReply(c *Context) { field.Read(c, "v.") c.Putln("") } - c.Putln("return v, nil") + c.Putln("return v") c.Putln("}") c.Putln("") } func (r *Request) WriteRequest(c *Context) { c.Putln("// Write request to wire for %s", r.SrcName()) - c.Putln("func (c *Conn) %s(%s) *Cookie {", r.ReqName(), r.ParamNameTypes()) - r.WriteRequestFields(c) - c.Putln("return c.sendRequest(true, buf)") - c.Putln("}") - c.Putln("") -} - -func (r *Request) WriteRequestFields(c *Context) { + c.Putln("func %s(%s) []byte {", r.ReqName(), r.ParamNameTypes()) c.Putln("size := %s", r.Size(c)) c.Putln("b := 0") c.Putln("buf := make([]byte, size)") @@ -85,6 +105,12 @@ func (r *Request) WriteRequestFields(c *Context) { c.Putln("buf[b] = %d // request opcode", r.Opcode) c.Putln("b += 1") c.Putln("") + if strings.ToLower(c.protocol.Name) != "xproto" { + c.Putln("buf[b] = c.extensions[\"%s\"]", + strings.ToUpper(c.protocol.ExtXName)) + c.Putln("b += 1") + c.Putln("") + } for i, field := range r.Fields { if i == 1 { c.Putln("Put16(buf[b:], uint16(size / 4)) "+ @@ -95,6 +121,9 @@ func (r *Request) WriteRequestFields(c *Context) { field.Write(c, "") c.Putln("") } + c.Putln("return buf") + c.Putln("}") + c.Putln("") } func (r *Request) ParamNames() string { @@ -102,7 +131,10 @@ func (r *Request) ParamNames() string { for _, field := range r.Fields { switch f := field.(type) { case *ValueField: - names = append(names, f.MaskName) + // mofos... + if r.SrcName() != "ConfigureWindow" { + names = append(names, f.MaskName) + } names = append(names, f.ListName) case *PadField: continue diff --git a/nexgb/xgbgen/representation.go b/nexgb/xgbgen/representation.go index ef62157..be7accd 100644 --- a/nexgb/xgbgen/representation.go +++ b/nexgb/xgbgen/representation.go @@ -3,6 +3,7 @@ package main import ( "fmt" "log" + "unicode" ) type Protocol struct { @@ -58,6 +59,16 @@ func (r *Request) XmlName() string { } func (r *Request) ReplyName() string { + if r.Reply == nil { + log.Panicf("Cannot call 'ReplyName' on request %s, which has no reply.", + r.SrcName()) + } + name := r.SrcName() + lower := string(unicode.ToLower(rune(name[0]))) + name[1:] + return fmt.Sprintf("%sReply", lower) +} + +func (r *Request) ReplyTypeName() string { if r.Reply == nil { log.Panicf("Cannot call 'ReplyName' on request %s, which has no reply.", r.SrcName()) @@ -66,7 +77,13 @@ func (r *Request) ReplyName() string { } func (r *Request) ReqName() string { - return fmt.Sprintf("%sRequest", r.SrcName()) + name := r.SrcName() + lower := string(unicode.ToLower(rune(name[0]))) + name[1:] + return fmt.Sprintf("%sRequest", lower) +} + +func (r *Request) CookieName() string { + return fmt.Sprintf("%sCookie", r.SrcName()) } // Size for Request needs a context. @@ -99,7 +116,9 @@ func (r *Request) Size(c *Context) Size { size = size.Add(field.Size()) } } - return size + return newExpressionSize(&Padding{ + Expr: size.Expression, + }) } type Reply struct { -- cgit v1.2.3-70-g09d2 From b6715f376f5ea3efb58146c58924dcc7b1536181 Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Sat, 5 May 2012 18:21:48 -0400 Subject: fixing bugs related mostly to extension handling --- nexgb/xgbgen/expression.go | 6 ++-- nexgb/xgbgen/field.go | 12 +++---- nexgb/xgbgen/go.go | 6 ++-- nexgb/xgbgen/go_error.go | 14 ++++++--- nexgb/xgbgen/go_event.go | 51 ++++++++++++++++++++++++++++++ nexgb/xgbgen/go_request_reply.go | 67 ++++++++++++++++++++++++++-------------- nexgb/xgbgen/representation.go | 7 ++++- nexgb/xgbgen/translation.go | 2 +- nexgb/xgbgen/type.go | 2 +- 9 files changed, 125 insertions(+), 42 deletions(-) (limited to 'nexgb/xgbgen/go_event.go') diff --git a/nexgb/xgbgen/expression.go b/nexgb/xgbgen/expression.go index 6a8aa52..2350979 100644 --- a/nexgb/xgbgen/expression.go +++ b/nexgb/xgbgen/expression.go @@ -282,7 +282,7 @@ func (e *FieldRef) String() string { } func (e *FieldRef) Initialize(p *Protocol) { - e.Name = SrcName(e.Name) + e.Name = SrcName(p, e.Name) } type EnumRef struct { @@ -309,7 +309,7 @@ func (e *EnumRef) String() string { func (e *EnumRef) Initialize(p *Protocol) { e.EnumKind = e.EnumKind.(*Translation).RealType(p) - e.EnumItem = SrcName(e.EnumItem) + e.EnumItem = SrcName(p, e.EnumItem) } type SumOf struct { @@ -337,5 +337,5 @@ func (e *SumOf) String() string { } func (e *SumOf) Initialize(p *Protocol) { - e.Name = SrcName(e.Name) + e.Name = SrcName(p, e.Name) } diff --git a/nexgb/xgbgen/field.go b/nexgb/xgbgen/field.go index ddc2028..5041f77 100644 --- a/nexgb/xgbgen/field.go +++ b/nexgb/xgbgen/field.go @@ -47,7 +47,7 @@ type SingleField struct { } func (f *SingleField) Initialize(p *Protocol) { - f.srcName = SrcName(f.XmlName()) + f.srcName = SrcName(p, f.XmlName()) f.Type = f.Type.(*Translation).RealType(p) } @@ -138,7 +138,7 @@ func (f *ListField) Size() Size { } func (f *ListField) Initialize(p *Protocol) { - f.srcName = SrcName(f.XmlName()) + f.srcName = SrcName(p, f.XmlName()) f.Type = f.Type.(*Translation).RealType(p) if f.LengthExpr != nil { f.LengthExpr.Initialize(p) @@ -173,7 +173,7 @@ func (f *ExprField) Size() Size { } func (f *ExprField) Initialize(p *Protocol) { - f.srcName = SrcName(f.XmlName()) + f.srcName = SrcName(p, f.XmlName()) f.Type = f.Type.(*Translation).RealType(p) f.Expr.Initialize(p) } @@ -230,8 +230,8 @@ func (f *ValueField) ListLength() Size { func (f *ValueField) Initialize(p *Protocol) { f.MaskType = f.MaskType.(*Translation).RealType(p) - f.MaskName = SrcName(f.MaskName) - f.ListName = SrcName(f.ListName) + f.MaskName = SrcName(p, f.MaskName) + f.ListName = SrcName(p, f.ListName) } type SwitchField struct { @@ -260,7 +260,7 @@ func (f *SwitchField) Size() Size { } func (f *SwitchField) Initialize(p *Protocol) { - f.Name = SrcName(f.Name) + f.Name = SrcName(p, f.Name) f.Expr.Initialize(p) for _, bitcase := range f.Bitcases { bitcase.Expr.Initialize(p) diff --git a/nexgb/xgbgen/go.go b/nexgb/xgbgen/go.go index 771cfcf..df12e69 100644 --- a/nexgb/xgbgen/go.go +++ b/nexgb/xgbgen/go.go @@ -65,7 +65,8 @@ var NameMap = map[string]string{} // Base types func (b *Base) Define(c *Context) { - c.Putln("// Skipping definition for base type '%s'", SrcName(b.XmlName())) + c.Putln("// Skipping definition for base type '%s'", + SrcName(c.protocol, b.XmlName())) c.Putln("") } @@ -81,7 +82,8 @@ func (enum *Enum) Define(c *Context) { // Resource types func (res *Resource) Define(c *Context) { - c.Putln("// Skipping resource definition of '%s'", SrcName(res.XmlName())) + c.Putln("// Skipping resource definition of '%s'", + SrcName(c.protocol, res.XmlName())) c.Putln("") } diff --git a/nexgb/xgbgen/go_error.go b/nexgb/xgbgen/go_error.go index 5a51064..152db8b 100644 --- a/nexgb/xgbgen/go_error.go +++ b/nexgb/xgbgen/go_error.go @@ -64,11 +64,15 @@ func (e *Error) ImplementsError(c *Context) { c.Putln("}") c.Putln("") c.Putln("func (err %s) BadId() Id {", e.ErrType()) - c.Putln("return Id(err.BadValue)") + if c.protocol.Name == "xproto" { + c.Putln("return Id(err.BadValue)") + } else { + c.Putln("return 0") + } c.Putln("}") c.Putln("") c.Putln("func (err %s) Error() string {", e.ErrType()) - FieldString(c, e.Fields, e.ErrConst()) + ErrorFieldString(c, e.Fields, e.ErrConst()) c.Putln("}") c.Putln("") } @@ -119,14 +123,14 @@ func (e *ErrorCopy) ImplementsError(c *Context) { c.Putln("}") c.Putln("") c.Putln("func (err %s) Error() string {", e.ErrType()) - FieldString(c, e.Old.(*Error).Fields, e.ErrConst()) + ErrorFieldString(c, e.Old.(*Error).Fields, e.ErrConst()) c.Putln("}") c.Putln("") } -// FieldString works for both Error and ErrorCopy. It assembles all of the +// ErrorFieldString works for both Error and ErrorCopy. It assembles all of the // fields in an error and formats them into a single string. -func FieldString(c *Context, fields []Field, errName string) { +func ErrorFieldString(c *Context, fields []Field, errName string) { c.Putln("fieldVals := make([]string, 0, %d)", len(fields)) c.Putln("fieldVals = append(fieldVals, \"NiceName: \" + err.NiceName)") c.Putln("fieldVals = append(fieldVals, " + diff --git a/nexgb/xgbgen/go_event.go b/nexgb/xgbgen/go_event.go index 41f9320..9bc6dfe 100644 --- a/nexgb/xgbgen/go_event.go +++ b/nexgb/xgbgen/go_event.go @@ -1,5 +1,9 @@ package main +import ( + "fmt" +) + // Event types func (e *Event) Define(c *Context) { c.Putln("// Event definition %s (%d)", e.SrcName(), e.Number) @@ -36,6 +40,10 @@ func (e *Event) Define(c *Context) { } c.Putln("}") c.Putln("") + c.Putln("func (v %s) String() string {", e.EvType()) + EventFieldString(c, e.Fields, e.SrcName()) + c.Putln("}") + c.Putln("") // Let's the XGB event loop read this event. c.Putln("func init() {") @@ -115,6 +123,10 @@ func (e *EventCopy) Define(c *Context) { } c.Putln("}") c.Putln("") + c.Putln("func (v %s) String() string {", e.EvType()) + EventFieldString(c, e.Old.(*Event).Fields, e.SrcName()) + c.Putln("}") + c.Putln("") // Let's the XGB event loop read this event. c.Putln("func init() {") @@ -137,3 +149,42 @@ func (e *EventCopy) Write(c *Context) { c.Putln("}") c.Putln("") } + +// EventFieldString works for both Event and EventCopy. It assembles all of the +// fields in an event and formats them into a single string. +func EventFieldString(c *Context, fields []Field, evName string) { + c.Putln("fieldVals := make([]string, 0, %d)", len(fields)) + if evName != "KeymapNotify" { + c.Putln("fieldVals = append(fieldVals, " + + "sprintf(\"Sequence: %s\", v.Sequence))", "%d") + } + for _, field := range fields { + switch f := field.(type) { + case *PadField: + continue + case *SingleField: + switch f.Type.(type) { + case *Base: + case *Resource: + case *TypeDef: + default: continue + } + + switch field.SrcType() { + case "string": + format := fmt.Sprintf("sprintf(\"%s: %s\", v.%s)", + field.SrcName(), "%s", field.SrcName()) + c.Putln("fieldVals = append(fieldVals, %s)", format) + case "bool": + format := fmt.Sprintf("sprintf(\"%s: %s\", v.%s)", + field.SrcName(), "%t", field.SrcName()) + c.Putln("fieldVals = append(fieldVals, %s)", format) + default: + format := fmt.Sprintf("sprintf(\"%s: %s\", v.%s)", + field.SrcName(), "%d", field.SrcName()) + c.Putln("fieldVals = append(fieldVals, %s)", format) + } + } + } + c.Putln("return \"%s {\" + stringsJoin(fieldVals, \", \") + \"}\"", evName) +} diff --git a/nexgb/xgbgen/go_request_reply.go b/nexgb/xgbgen/go_request_reply.go index 00c48f9..e64e2a2 100644 --- a/nexgb/xgbgen/go_request_reply.go +++ b/nexgb/xgbgen/go_request_reply.go @@ -8,21 +8,24 @@ import ( func (r *Request) Define(c *Context) { c.Putln("// Request %s", r.SrcName()) c.Putln("// size: %s", r.Size(c)) - c.Putln("type %s cookie", r.CookieName()) + c.Putln("type %s struct {", r.CookieName()) + c.Putln("*cookie") + c.Putln("}") + c.Putln("") if r.Reply != nil { c.Putln("func (c *Conn) %s(%s) %s {", r.SrcName(), r.ParamNameTypes(), r.CookieName()) c.Putln("cookie := c.newCookie(true, true)") - c.Putln("c.newRequest(%s(%s), cookie)", r.ReqName(), r.ParamNames()) - c.Putln("return %s(cookie)", r.CookieName()) + c.Putln("c.newRequest(c.%s(%s), cookie)", r.ReqName(), r.ParamNames()) + c.Putln("return %s{cookie}", r.CookieName()) c.Putln("}") c.Putln("") c.Putln("func (c *Conn) %sUnchecked(%s) %s {", r.SrcName(), r.ParamNameTypes(), r.CookieName()) c.Putln("cookie := c.newCookie(false, true)") - c.Putln("c.newRequest(%s(%s), cookie)", r.ReqName(), r.ParamNames()) - c.Putln("return %s(cookie)", r.CookieName()) + c.Putln("c.newRequest(c.%s(%s), cookie)", r.ReqName(), r.ParamNames()) + c.Putln("return %s{cookie}", r.CookieName()) c.Putln("}") c.Putln("") @@ -32,20 +35,24 @@ func (r *Request) Define(c *Context) { c.Putln("func (c *Conn) %s(%s) %s {", r.SrcName(), r.ParamNameTypes(), r.CookieName()) c.Putln("cookie := c.newCookie(false, false)") - c.Putln("c.newRequest(%s(%s), cookie)", r.ReqName(), r.ParamNames()) - c.Putln("return %s(cookie)", r.CookieName()) + c.Putln("c.newRequest(c.%s(%s), cookie)", r.ReqName(), r.ParamNames()) + c.Putln("return %s{cookie}", r.CookieName()) c.Putln("}") c.Putln("") c.Putln("func (c *Conn) %sChecked(%s) %s {", r.SrcName(), r.ParamNameTypes(), r.CookieName()) c.Putln("cookie := c.newCookie(true, false)") - c.Putln("c.newRequest(%s(%s), cookie)", r.ReqName(), r.ParamNames()) - c.Putln("return %s(cookie)", r.CookieName()) + c.Putln("c.newRequest(c.%s(%s), cookie)", r.ReqName(), r.ParamNames()) + c.Putln("return %s{cookie}", r.CookieName()) c.Putln("}") c.Putln("") } + c.Putln("func (cook %s) Check() error {", r.CookieName()) + c.Putln("return cook.check()") + c.Putln("}") + c.Putln("") r.WriteRequest(c) } @@ -64,10 +71,13 @@ func (r *Request) ReadReply(c *Context) { c.Putln("// Waits and reads reply data from request %s", r.SrcName()) c.Putln("func (cook %s) Reply() (*%s, error) {", r.CookieName(), r.ReplyTypeName()) - c.Putln("buf, err := cookie(cook).reply()") + c.Putln("buf, err := cook.reply()") c.Putln("if err != nil {") c.Putln("return nil, err") c.Putln("}") + c.Putln("if buf == nil {") + c.Putln("return nil, nil") + c.Putln("}") c.Putln("return %s(buf), nil", r.ReplyName()) c.Putln("}") c.Putln("") @@ -79,7 +89,9 @@ func (r *Request) ReadReply(c *Context) { c.Putln("b := 1 // skip reply determinant") c.Putln("") for i, field := range r.Reply.Fields { - if i == 1 { + field.Read(c, "v.") + c.Putln("") + if i == 0 { c.Putln("v.Sequence = Get16(buf[b:])") c.Putln("b += 2") c.Putln("") @@ -87,8 +99,6 @@ func (r *Request) ReadReply(c *Context) { c.Putln("b += 4") c.Putln("") } - field.Read(c, "v.") - c.Putln("") } c.Putln("return v") c.Putln("}") @@ -96,30 +106,41 @@ func (r *Request) ReadReply(c *Context) { } func (r *Request) WriteRequest(c *Context) { + writeSize := func() { + c.Putln("Put16(buf[b:], uint16(size / 4)) "+ + "// write request size in 4-byte units") + c.Putln("b += 2") + c.Putln("") + } c.Putln("// Write request to wire for %s", r.SrcName()) - c.Putln("func %s(%s) []byte {", r.ReqName(), r.ParamNameTypes()) + c.Putln("func (c *Conn) %s(%s) []byte {", r.ReqName(), r.ParamNameTypes()) c.Putln("size := %s", r.Size(c)) c.Putln("b := 0") c.Putln("buf := make([]byte, size)") c.Putln("") - c.Putln("buf[b] = %d // request opcode", r.Opcode) - c.Putln("b += 1") - c.Putln("") if strings.ToLower(c.protocol.Name) != "xproto" { c.Putln("buf[b] = c.extensions[\"%s\"]", strings.ToUpper(c.protocol.ExtXName)) c.Putln("b += 1") c.Putln("") } - for i, field := range r.Fields { - if i == 1 { - c.Putln("Put16(buf[b:], uint16(size / 4)) "+ - "// write request size in 4-byte units") - c.Putln("b += 2") - c.Putln("") + c.Putln("buf[b] = %d // request opcode", r.Opcode) + c.Putln("b += 1") + c.Putln("") + if len(r.Fields) == 0 { + if strings.ToLower(c.protocol.Name) == "xproto" { + c.Putln("b += 1 // padding") } + writeSize() + } else if strings.ToLower(c.protocol.Name) != "xproto" { + writeSize() + } + for i, field := range r.Fields { field.Write(c, "") c.Putln("") + if i == 0 && strings.ToLower(c.protocol.Name) == "xproto" { + writeSize() + } } c.Putln("return buf") c.Putln("}") diff --git a/nexgb/xgbgen/representation.go b/nexgb/xgbgen/representation.go index be7accd..62a3eb2 100644 --- a/nexgb/xgbgen/representation.go +++ b/nexgb/xgbgen/representation.go @@ -3,6 +3,7 @@ package main import ( "fmt" "log" + "strings" "unicode" ) @@ -41,7 +42,11 @@ type Request struct { } func (r *Request) Initialize(p *Protocol) { - r.srcName = SrcName(r.xmlName) + r.srcName = SrcName(p, r.xmlName) + if p.Name != "xproto" { + r.srcName = strings.Title(strings.ToLower(p.Name)) + r.srcName + } + if r.Reply != nil { r.Reply.Initialize(p) } diff --git a/nexgb/xgbgen/translation.go b/nexgb/xgbgen/translation.go index fe5a52b..b650bc4 100644 --- a/nexgb/xgbgen/translation.go +++ b/nexgb/xgbgen/translation.go @@ -373,7 +373,7 @@ func (x *XMLBitcase) Translate() *Bitcase { // SrcName is used to translate any identifier into a Go name. // Mostly used for fields, but used in a couple other places too (enum items). -func SrcName(name string) string { +func SrcName(p *Protocol, name string) string { // If it's in the name map, use that translation. if newn, ok := NameMap[name]; ok { return newn diff --git a/nexgb/xgbgen/type.go b/nexgb/xgbgen/type.go index 3498463..521f67e 100644 --- a/nexgb/xgbgen/type.go +++ b/nexgb/xgbgen/type.go @@ -123,7 +123,7 @@ func (enum *Enum) Size() Size { func (enum *Enum) Initialize(p *Protocol) { enum.srcName = TypeSrcName(p, enum) for _, item := range enum.Items { - item.srcName = SrcName(item.xmlName) + item.srcName = SrcName(p, item.xmlName) if item.Expr != nil { item.Expr.Initialize(p) } -- cgit v1.2.3-70-g09d2 From 6d545e723a7e972998a0e77adcf2219a31a9b800 Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Sun, 6 May 2012 17:48:40 -0400 Subject: add more extension cruft. make extension checking more uniform. --- nexgb/xgbgen/context.go | 38 ++++++++++++++++++++++++++++++++++++++ nexgb/xgbgen/go_error.go | 2 +- nexgb/xgbgen/go_event.go | 14 ++++++++++++-- nexgb/xgbgen/go_request_reply.go | 8 ++++---- nexgb/xgbgen/protocol.go | 2 +- nexgb/xgbgen/request_reply.go | 4 ++-- nexgb/xgbgen/translation.go | 2 +- 7 files changed, 59 insertions(+), 11 deletions(-) (limited to 'nexgb/xgbgen/go_event.go') diff --git a/nexgb/xgbgen/context.go b/nexgb/xgbgen/context.go index d433531..35dd37e 100644 --- a/nexgb/xgbgen/context.go +++ b/nexgb/xgbgen/context.go @@ -5,6 +5,7 @@ import ( "encoding/xml" "fmt" "log" + "strings" "time" ) @@ -70,6 +71,43 @@ func (c *Context) Morph(xmlBytes []byte) { c.Putln("") } + // If this is an extension, create a function to initialize the extension + // before it can be used. + if c.protocol.isExt() { + name := strings.Title(c.protocol.Name) + "Init" + xname := c.protocol.ExtXName + + c.Putln("// %s must be called before using the %s extension.", + name, xname) + c.Putln("func (c *Conn) %s() error {", name) + c.Putln("reply, err := c.QueryExtension(%d, \"%s\").Reply()", + len(xname), xname) + c.Putln("switch {") + c.Putln("case err != nil:") + c.Putln("return err") + c.Putln("case !reply.Present:") + c.Putln("return newError(\"No extension named %s could be found on " + + "on the server.\")", xname) + c.Putln("}") + c.Putln("") + c.Putln("c.extLock.Lock()") + c.Putln("c.extensions[\"%s\"] = reply.MajorOpcode", xname) + c.Putln("for evNum, fun := range newExtEventFuncs[\"%s\"] {", xname) + c.Putln("newEventFuncs[int(reply.FirstEvent) + evNum] = fun") + c.Putln("}") + c.Putln("c.extLock.Unlock()") + c.Putln("") + c.Putln("return nil") + c.Putln("}") + c.Putln("") + + // Make sure newExtEventFuncs["EXT_NAME"] map is initialized. + c.Putln("func init() {") + c.Putln("newExtEventFuncs[\"%s\"] = make(map[int]newEventFun)", xname) + c.Putln("}") + c.Putln("") + } + // Now write Go source code for _, typ := range c.protocol.Types { typ.Define(c) diff --git a/nexgb/xgbgen/go_error.go b/nexgb/xgbgen/go_error.go index 152db8b..0222289 100644 --- a/nexgb/xgbgen/go_error.go +++ b/nexgb/xgbgen/go_error.go @@ -64,7 +64,7 @@ func (e *Error) ImplementsError(c *Context) { c.Putln("}") c.Putln("") c.Putln("func (err %s) BadId() Id {", e.ErrType()) - if c.protocol.Name == "xproto" { + if !c.protocol.isExt() { c.Putln("return Id(err.BadValue)") } else { c.Putln("return 0") diff --git a/nexgb/xgbgen/go_event.go b/nexgb/xgbgen/go_event.go index 9bc6dfe..ce54e19 100644 --- a/nexgb/xgbgen/go_event.go +++ b/nexgb/xgbgen/go_event.go @@ -47,7 +47,12 @@ func (e *Event) Define(c *Context) { // Let's the XGB event loop read this event. c.Putln("func init() {") - c.Putln("newEventFuncs[%d] = New%s", e.Number, e.EvType()) + if c.protocol.isExt() { + c.Putln("newExtEventFuncs[\"%s\"][%d] = New%s", + c.protocol.ExtXName, e.Number, e.EvType()) + } else { + c.Putln("newEventFuncs[%d] = New%s", e.Number, e.EvType()) + } c.Putln("}") c.Putln("") } @@ -130,7 +135,12 @@ func (e *EventCopy) Define(c *Context) { // Let's the XGB event loop read this event. c.Putln("func init() {") - c.Putln("newEventFuncs[%d] = New%s", e.Number, e.EvType()) + if c.protocol.isExt() { + c.Putln("newExtEventFuncs[\"%s\"][%d] = New%s", + c.protocol.ExtXName, e.Number, e.EvType()) + } else { + c.Putln("newEventFuncs[%d] = New%s", e.Number, e.EvType()) + } c.Putln("}") c.Putln("") } diff --git a/nexgb/xgbgen/go_request_reply.go b/nexgb/xgbgen/go_request_reply.go index e64e2a2..451667f 100644 --- a/nexgb/xgbgen/go_request_reply.go +++ b/nexgb/xgbgen/go_request_reply.go @@ -118,7 +118,7 @@ func (r *Request) WriteRequest(c *Context) { c.Putln("b := 0") c.Putln("buf := make([]byte, size)") c.Putln("") - if strings.ToLower(c.protocol.Name) != "xproto" { + if c.protocol.isExt() { c.Putln("buf[b] = c.extensions[\"%s\"]", strings.ToUpper(c.protocol.ExtXName)) c.Putln("b += 1") @@ -128,17 +128,17 @@ func (r *Request) WriteRequest(c *Context) { c.Putln("b += 1") c.Putln("") if len(r.Fields) == 0 { - if strings.ToLower(c.protocol.Name) == "xproto" { + if !c.protocol.isExt() { c.Putln("b += 1 // padding") } writeSize() - } else if strings.ToLower(c.protocol.Name) != "xproto" { + } else if c.protocol.isExt() { writeSize() } for i, field := range r.Fields { field.Write(c, "") c.Putln("") - if i == 0 && strings.ToLower(c.protocol.Name) == "xproto" { + if i == 0 && !c.protocol.isExt() { writeSize() } } diff --git a/nexgb/xgbgen/protocol.go b/nexgb/xgbgen/protocol.go index 505b400..e01bc17 100644 --- a/nexgb/xgbgen/protocol.go +++ b/nexgb/xgbgen/protocol.go @@ -36,6 +36,6 @@ func (p *Protocol) Initialize() { // isExt returns true if this protocol is an extension. // i.e., it's name isn't "xproto". func (p *Protocol) isExt() bool { - return strings.ToLower(p.Name) == "xproto" + return strings.ToLower(p.Name) != "xproto" } diff --git a/nexgb/xgbgen/request_reply.go b/nexgb/xgbgen/request_reply.go index 7cd2859..c7a4cf8 100644 --- a/nexgb/xgbgen/request_reply.go +++ b/nexgb/xgbgen/request_reply.go @@ -22,7 +22,7 @@ type Request struct { // It also initializes the reply if one exists, and all fields in this request. func (r *Request) Initialize(p *Protocol) { r.srcName = SrcName(p, r.xmlName) - if p.Name != "xproto" { + if p.isExt() { r.srcName = strings.Title(strings.ToLower(p.Name)) + r.srcName } @@ -93,7 +93,7 @@ func (r *Request) Size(c *Context) Size { // request. In an extension request, this byte is always occupied // by the opcode of the request (while the first byte is always occupied // by the opcode of the extension). - if c.protocol.Name == "xproto" { + if !c.protocol.isExt() { size = size.Add(newFixedSize(3)) } else { size = size.Add(newFixedSize(4)) diff --git a/nexgb/xgbgen/translation.go b/nexgb/xgbgen/translation.go index 90cd0f3..592c152 100644 --- a/nexgb/xgbgen/translation.go +++ b/nexgb/xgbgen/translation.go @@ -410,7 +410,7 @@ func TypeSrcName(p *Protocol, typ Type) string { // Since there is no namespace, we need to look for a namespace // in the current context. niceType := splitAndTitle(t) - if p.Name != "xproto" { + if p.isExt() { for _, typ2 := range p.Types { if t == typ2.XmlName() { return strings.Title(p.Name) + niceType -- cgit v1.2.3-70-g09d2 From dc48249e1acea54b391f53b95f16e515dead7c97 Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Mon, 7 May 2012 04:09:19 -0400 Subject: lots of docs and examples --- nexgb/Makefile | 6 ++ nexgb/doc.go | 152 +++++++++++++++++++++++++++++++ nexgb/examples/atom.go | 27 ------ nexgb/examples/create-window/main.go | 98 ++++++++++++++++++++ nexgb/examples/doc.go | 21 +++++ nexgb/examples/get-active-window/main.go | 57 ++++++++++++ nexgb/examples/property.go | 41 --------- nexgb/examples/randr.go | 48 ---------- nexgb/examples/randr/main.go | 84 +++++++++++++++++ nexgb/examples/seq-nowrap.go | 29 ------ nexgb/examples/seq-wrap.go | 24 ----- nexgb/examples/window.go | 61 ------------- nexgb/examples/xinerama.go | 29 ------ nexgb/examples/xinerama/main.go | 39 ++++++++ nexgb/xgb.go | 6 -- nexgb/xgb_test.go | 6 +- nexgb/xgbgen/context.go | 2 +- nexgb/xgbgen/field.go | 4 +- nexgb/xgbgen/go_error.go | 2 +- nexgb/xgbgen/go_event.go | 5 +- nexgb/xgbgen/go_list.go | 1 - nexgb/xgbgen/go_request_reply.go | 18 ++-- nexgb/xgbgen/go_union.go | 1 - nexgb/xgbgen/protocol.go | 1 - nexgb/xgbgen/request_reply.go | 4 +- nexgb/xgbgen/translation.go | 2 +- nexgb/xgbgen/xml.go | 32 +++---- 27 files changed, 495 insertions(+), 305 deletions(-) create mode 100644 nexgb/doc.go delete mode 100644 nexgb/examples/atom.go create mode 100644 nexgb/examples/create-window/main.go create mode 100644 nexgb/examples/doc.go create mode 100644 nexgb/examples/get-active-window/main.go delete mode 100644 nexgb/examples/property.go delete mode 100644 nexgb/examples/randr.go create mode 100644 nexgb/examples/randr/main.go delete mode 100644 nexgb/examples/seq-nowrap.go delete mode 100644 nexgb/examples/seq-wrap.go delete mode 100644 nexgb/examples/window.go delete mode 100644 nexgb/examples/xinerama.go create mode 100644 nexgb/examples/xinerama/main.go (limited to 'nexgb/xgbgen/go_event.go') diff --git a/nexgb/Makefile b/nexgb/Makefile index c70b01c..7ba1cb4 100644 --- a/nexgb/Makefile +++ b/nexgb/Makefile @@ -1,5 +1,6 @@ # This Makefile is used by the developer. It is not needed in any way to build # a checkout of the XGB repository. +# It will be useful, however, if you are hacking at the code generator. XPROTO=/usr/share/xcb @@ -20,3 +21,8 @@ test: bench: go test -run 'nomatch' -bench '.*' -cpu 1,2,6 +gofmt: + gofmt -w *.go xgbgen/*.go examples/*.go examples/*/*.go + colcheck xgbgen/*.go examples/*.go examples/*/*.go \ + auth.go conn.go cookie.go doc.go xgb.go xgb_help.go xgb_test.go + diff --git a/nexgb/doc.go b/nexgb/doc.go new file mode 100644 index 0000000..b6c956f --- /dev/null +++ b/nexgb/doc.go @@ -0,0 +1,152 @@ +/* +Package XGB provides the X Go Binding, which is a low-level API to communicate +with the core X protocol and many of the X extensions. + +It is *very* closely modeled on XCB, so that experience with XCB (or xpyb) is +easily translatable to XGB. That is, it uses the same cookie/reply model +and is thread safe. There are otherwise no major differences (in the API). + +Most uses of XGB typically fall under the realm of window manager and GUI kit +development, but other applications (like pagers, panels, tilers, etc.) may +also require XGB. Moreover, it is a near certainty that if you need to work +with X, xgbutil will be of great use to you as well: +https://github.com/BurntSushi/xgbutil + +Example + +This is an extremely terse example that demonstrates how to connect to X, +create a window, listen to StructureNotify events and Key{Press,Release} +events, map the window, and print out all events received. An example with +accompanying documentation can be found in examples/create-window. + + package main + + import ( + "fmt" + "github.com/BurntSushi/xgb" + ) + + func main() { + X, err := xgb.NewConn() + if err != nil { + fmt.Println(err) + return + } + + wid, _ := X.NewId() + X.CreateWindow(X.DefaultScreen().RootDepth, wid, X.DefaultScreen().Root, + 0, 0, 500, 500, 0, + xgb.WindowClassInputOutput, X.DefaultScreen().RootVisual, + xgb.CwBackPixel | xgb.CwEventMask, + []uint32{ // values must be in the order defined by the protocol + 0xffffffff, + xgb.EventMaskStructureNotify | + xgb.EventMaskKeyPress | + xgb.EventMaskKeyRelease}) + + X.MapWindow(wid) + for { + ev, xerr := X.WaitForEvent() + if ev == nil && xerr == nil { + fmt.Println("Both event and error are nil. Exiting...") + return + } + + if ev != nil { + fmt.Printf("Event: %s\n", ev) + } + if xerr != nil { + fmt.Printf("Error: %s\n", xerr) + } + } + } + +Xinerama Example + +This is another small example that shows how to query Xinerama for geometry +information of each active head. Accompanying documentation for this example +can be found in examples/xinerama. + + package main + + import ( + "fmt" + "log" + "github.com/BurntSushi/xgb" + ) + + func main() { + X, err := xgb.NewConn() + if err != nil { + log.Fatal(err) + } + + // Initialize the Xinerama extension. + // The appropriate 'Init' function must be run for *every* + // extension before any of its requests can be used. + err = X.XineramaInit() + if err != nil { + log.Fatal(err) + } + + reply, err := X.XineramaQueryScreens().Reply() + if err != nil { + log.Fatal(err) + } + + fmt.Printf("Number of heads: %d\n", reply.Number) + for i, screen := range reply.ScreenInfo { + fmt.Printf("%d :: X: %d, Y: %d, Width: %d, Height: %d\n", + i, screen.XOrg, screen.YOrg, screen.Width, screen.Height) + } + } + +Parallelism + +XGB can benefit greatly from parallelism due to its concurrent design. For +evidence of this claim, please see the benchmarks in xgb_test.go. + +Tests + +xgb_test.go contains a number of contrived tests that stress particular corners +of XGB that I presume could be problem areas. Namely: requests with no replies, +requests with replies, checked errors, unchecked errors, sequence number +wrapping, cookie buffer flushing (i.e., forcing a round trip every N requests +made that don't have a reply), getting/setting properties and creating a window +and listening to StructureNotify events. + +Code Generator + +Both XCB and xpyb use the same Python module (xcbgen) for a code generator. XGB +(before this fork) used the same code generator as well, but in my attempt to +add support for more extensions, I found the code generator extremely difficult +to work with. Therefore, I re-wrote the code generator in Go. It can be found +in its own sub-package, xgbgen, of xgb. My design of xgbgen includes a rough +consideration that it could be used for other languages. + +What works + +I am reasonably confident that the core X protocol is in full working form. I've +also tested the Xinerama and RandR extensions sparingly. Many of the other +existing extensions have Go source generated (and are compilable) and are +included in this package, but I am currently unsure of their status. They +*should* work. + +What does not work + +XKB is the only extension that intentionally does not work, although I suspect +that GLX also does not work (however, there is Go source code for GLX that +compiles, unlike XKB). I don't currently have any intention of getting XKB +working, due to its complexity and my current mental incapacity to test it. + +There are so many functions + +Indeed. Everything below this initial overview is useful insomuch as your +browser's "Find" feature is useful. The following list of types and functions +should act as a reference to the Go representation of a request, type or reply +of something you *already know about*. To search the following list in hopes +of attaining understanding is a quest in folly. For understanding, please see +the X Protocol Reference Manual: http://goo.gl/aMd2e + +*/ +package xgb diff --git a/nexgb/examples/atom.go b/nexgb/examples/atom.go deleted file mode 100644 index 2cb7132..0000000 --- a/nexgb/examples/atom.go +++ /dev/null @@ -1,27 +0,0 @@ -package main - -import ( - // "fmt" - "log" - - "github.com/BurntSushi/xgb" -) - -func init() { - log.SetFlags(0) -} - -func main() { - X, err := xgb.NewConn() - if err != nil { - log.Fatal(err) - } - - aname := "_NET_ACTIVE_WINDOW" - atom, err := X.InternAtom(true, uint16(len(aname)), aname).Reply() - if err != nil { - log.Fatal(err) - } - log.Printf("%d", atom.Atom) -} - diff --git a/nexgb/examples/create-window/main.go b/nexgb/examples/create-window/main.go new file mode 100644 index 0000000..6996f37 --- /dev/null +++ b/nexgb/examples/create-window/main.go @@ -0,0 +1,98 @@ +// Example create-window shows how to create a window, map it, resize it, +// and listen to structure and key events (i.e., when the window is resized +// by the window manager, or when key presses/releases are made when the +// window has focus). The events are printed to stdout. +package main + +import ( + "fmt" + + "github.com/BurntSushi/xgb" +) + +func main() { + X, err := xgb.NewConn() + if err != nil { + fmt.Println(err) + return + } + + // Any time a new resource (i.e., a window, pixmap, graphics context, etc.) + // is created, we need to generate a resource identifier with NewId. + wid, _ := X.NewId() + + // CreateWindow takes a boatload of parameters. + X.CreateWindow(X.DefaultScreen().RootDepth, wid, X.DefaultScreen().Root, + 0, 0, 500, 500, 0, + xgb.WindowClassInputOutput, X.DefaultScreen().RootVisual, + 0, []uint32{}) + + // This call to ChangeWindowAttributes could be factored out and + // included with the above CreateWindow call, but it is left here for + // instructive purposes. It tells X to send us events when the 'structure' + // of the window is changed (i.e., when it is resized, mapped, unmapped, + // etc.) and when a key press or a key release has been made when the + // window has focus. + // We also set the 'BackPixel' to white so that the window isn't butt ugly. + X.ChangeWindowAttributes(wid, + xgb.CwBackPixel|xgb.CwEventMask, + []uint32{ // values must be in the order defined by the protocol + 0xffffffff, + xgb.EventMaskStructureNotify | + xgb.EventMaskKeyPress | + xgb.EventMaskKeyRelease}) + + // MapWindow makes the window we've created appear on the screen. + // We demonstrated the use of a 'checked' request here. + // A checked request is a fancy way of saying, "do error handling + // synchronously." Namely, if there is a problem with the MapWindow request, + // we'll get the error *here*. If we were to do a normal unchecked + // request (like the above CreateWindow and ChangeWindowAttributes + // requests), then we would only see the error arrive in the main event + // loop. + // + // Typically, checked requests are useful when you need to make sure they + // succeed. Since they are synchronous, they incur a round trip cost before + // the program can continue, but this is only going to be noticeable if + // you're issuing tons of requests in succession. + // + // Note that requests without replies are by default unchecked while + // requests *with* replies are checked by default. + err = X.MapWindowChecked(wid).Check() + if err != nil { + fmt.Printf("Checked Error for mapping window %d: %s\n", wid, err) + } else { + fmt.Printf("Map window %d successful!\n", wid) + } + + // This is an example of an invalid MapWindow request and what an error + // looks like. + err = X.MapWindowChecked(0).Check() + if err != nil { + fmt.Printf("Checked Error for mapping window 0x1: %s\n", err) + } else { // neva + fmt.Printf("Map window 0x1 successful!\n") + } + + // Start the main event loop. + for { + // WaitForEvent either returns an event or an error and never both. + // If both are nil, then something went wrong and the loop should be + // halted. + // + // An error can only be seen here as a response to an unchecked + // request. + ev, xerr := X.WaitForEvent() + if ev == nil && xerr == nil { + fmt.Println("Both event and error are nil. Exiting...") + return + } + + if ev != nil { + fmt.Printf("Event: %s\n", ev) + } + if xerr != nil { + fmt.Printf("Error: %s\n", xerr) + } + } +} diff --git a/nexgb/examples/doc.go b/nexgb/examples/doc.go new file mode 100644 index 0000000..80ea5b7 --- /dev/null +++ b/nexgb/examples/doc.go @@ -0,0 +1,21 @@ +/* +Package examples contains a few different use cases of XGB, like creating +a window, reading properties, and querying for information about multiple +heads using the Xinerama or RandR extensions. + +If you're looking to get started quickly, I recommend checking out the +create-window example first. It is the most documented and probably covers +some of the more common bare bones cases of creating windows and responding +to events. + +If you're looking to query information about your window manager, +get-active-window is a start. However, to do anything extensive requires +a lot of boiler plate. To that end, I'd recommend use of my higher level +library, xgbutil: https://github.com/BurntSushi/xgbutil + +There are also examples of using the Xinerama and RandR extensions, if you're +interested in querying information about your active heads. In RandR's case, +you can also reconfigure your heads, but the example doesn't cover that. + +*/ +package documentation diff --git a/nexgb/examples/get-active-window/main.go b/nexgb/examples/get-active-window/main.go new file mode 100644 index 0000000..e90563c --- /dev/null +++ b/nexgb/examples/get-active-window/main.go @@ -0,0 +1,57 @@ +// Example get-active-window reads the _NET_ACTIVE_WINDOW property of the root +// window and uses the result (a window id) to get the name of the window. +package main + +import ( + "fmt" + "log" + + "github.com/BurntSushi/xgb" +) + +func main() { + X, err := xgb.NewConn() + if err != nil { + log.Fatal(err) + } + + // Get the window id of the root window. + root := X.DefaultScreen().Root + + // Get the atom id (i.e., intern an atom) of "_NET_ACTIVE_WINDOW". + aname := "_NET_ACTIVE_WINDOW" + activeAtom, err := X.InternAtom(true, uint16(len(aname)), aname).Reply() + if err != nil { + log.Fatal(err) + } + + // Get the atom id (i.e., intern an atom) of "_NET_WM_NAME". + aname = "_NET_WM_NAME" + nameAtom, err := X.InternAtom(true, uint16(len(aname)), aname).Reply() + if err != nil { + log.Fatal(err) + } + + // Get the actual value of _NET_ACTIVE_WINDOW. + // Note that 'reply.Value' is just a slice of bytes, so we use an + // XGB helper function, 'Get32', to pull an unsigned 32-bit integer out + // of the byte slice. We then convert it to an X resource id so it can + // be used to get the name of the window in the next GetProperty request. + reply, err := X.GetProperty(false, root, activeAtom.Atom, + xgb.GetPropertyTypeAny, 0, (1<<32)-1).Reply() + if err != nil { + log.Fatal(err) + } + windowId := xgb.Id(xgb.Get32(reply.Value)) + fmt.Printf("Active window id: %X\n", windowId) + + // Now get the value of _NET_WM_NAME for the active window. + // Note that this time, we simply convert the resulting byte slice, + // reply.Value, to a string. + reply, err = X.GetProperty(false, windowId, nameAtom.Atom, + xgb.GetPropertyTypeAny, 0, (1<<32)-1).Reply() + if err != nil { + log.Fatal(err) + } + fmt.Printf("Active window name: %s\n", string(reply.Value)) +} diff --git a/nexgb/examples/property.go b/nexgb/examples/property.go deleted file mode 100644 index 45144c7..0000000 --- a/nexgb/examples/property.go +++ /dev/null @@ -1,41 +0,0 @@ -package main - -import ( - "log" - - "github.com/BurntSushi/xgb" -) - -func init() { - log.SetFlags(0) -} - -func get32(buf []byte) uint32 { - v := uint32(buf[0]) - v |= uint32(buf[1]) << 8 - v |= uint32(buf[2]) << 16 - v |= uint32(buf[3]) << 24 - return v -} - -func main() { - X, err := xgb.NewConn() - if err != nil { - log.Fatal(err) - } - - root := X.DefaultScreen().Root - - aname := "_NET_ACTIVE_WINDOW" - atom, err := X.InternAtom(true, uint16(len(aname)), aname).Reply() - if err != nil { - log.Fatal(err) - } - - reply, err := X.GetProperty(false, root, atom.Atom, - xgb.GetPropertyTypeAny, 0, (1<<32)-1).Reply() - if err != nil { - log.Fatal(err) - } - log.Printf("%X", get32(reply.Value)) -} diff --git a/nexgb/examples/randr.go b/nexgb/examples/randr.go deleted file mode 100644 index 064856d..0000000 --- a/nexgb/examples/randr.go +++ /dev/null @@ -1,48 +0,0 @@ -package main - -import ( - "fmt" - "log" - - "github.com/BurntSushi/xgb" -) - -func main() { - X, _ := xgb.NewConn() - - err := X.RegisterExtension("randr") - if err != nil { - log.Fatal(err) - } - - resources, err := X.RandrGetScreenResources(X.DefaultScreen().Root).Reply() - if err != nil { - log.Fatal(err) - } - - for _, output := range resources.Outputs { - info, err := X.RandrGetOutputInfo(output, 0).Reply() - if err != nil { - log.Fatal(err) - } - - bestMode := info.Modes[0] - for _, mode := range resources.Modes { - if mode.Id == uint32(bestMode) { - fmt.Printf("Width: %d, Height: %d\n", mode.Width, mode.Height) - } - } - } - - fmt.Println("\n") - - for _, crtc := range resources.Crtcs { - info, err := X.RandrGetCrtcInfo(crtc, 0).Reply() - if err != nil { - log.Fatal(err) - } - fmt.Printf("X: %d, Y: %d, Width: %d, Height: %d\n", - info.X, info.Y, info.Width, info.Height) - } -} - diff --git a/nexgb/examples/randr/main.go b/nexgb/examples/randr/main.go new file mode 100644 index 0000000..5c56609 --- /dev/null +++ b/nexgb/examples/randr/main.go @@ -0,0 +1,84 @@ +// Example randr uses the randr protocol to get information about the active +// heads. It also listens for events that are sent when the head configuration +// changes. Since it listens to events, you'll have to manually kill this +// process when you're done (i.e., ctrl+c.) +// +// While this program is running, if you use 'xrandr' to reconfigure your +// heads, you should see event information dumped to standard out. +// +// For more information, please see the RandR protocol spec: +// http://www.x.org/releases/X11R7.6/doc/randrproto/randrproto.txt +package main + +import ( + "fmt" + "log" + + "github.com/BurntSushi/xgb" +) + +func main() { + X, _ := xgb.NewConn() + + // Every extension must be initialized before it can be used. + err := X.RandrInit() + if err != nil { + log.Fatal(err) + } + + // Gets the current screen resources. Screen resources contains a list + // of names, crtcs, outputs and modes, among other things. + resources, err := X.RandrGetScreenResources(X.DefaultScreen().Root).Reply() + if err != nil { + log.Fatal(err) + } + + // Iterate through all of the outputs and show some of their info. + for _, output := range resources.Outputs { + info, err := X.RandrGetOutputInfo(output, 0).Reply() + if err != nil { + log.Fatal(err) + } + + bestMode := info.Modes[0] + for _, mode := range resources.Modes { + if mode.Id == uint32(bestMode) { + fmt.Printf("Width: %d, Height: %d\n", mode.Width, mode.Height) + } + } + } + + fmt.Println("\n") + + // Iterate through all of the crtcs and show some of their info. + for _, crtc := range resources.Crtcs { + info, err := X.RandrGetCrtcInfo(crtc, 0).Reply() + if err != nil { + log.Fatal(err) + } + fmt.Printf("X: %d, Y: %d, Width: %d, Height: %d\n", + info.X, info.Y, info.Width, info.Height) + } + + // Tell RandR to send us events. (I think these are all of them, as of 1.3.) + err = X.RandrSelectInputChecked(X.DefaultScreen().Root, + xgb.RandrNotifyMaskScreenChange| + xgb.RandrNotifyMaskCrtcChange| + xgb.RandrNotifyMaskOutputChange| + xgb.RandrNotifyMaskOutputProperty).Check() + if err != nil { + log.Fatal(err) + } + + // Listen to events and just dump them to standard out. + // A more involved approach will have to read the 'U' field of + // RandrNotifyEvent, which is a union (really a struct) of type + // RanrNotifyDataUnion. + for { + ev, err := X.WaitForEvent() + if err != nil { + log.Fatal(err) + } + fmt.Println(ev) + } +} diff --git a/nexgb/examples/seq-nowrap.go b/nexgb/examples/seq-nowrap.go deleted file mode 100644 index 994a07b..0000000 --- a/nexgb/examples/seq-nowrap.go +++ /dev/null @@ -1,29 +0,0 @@ -package main - -import ( - "fmt" - - "github.com/BurntSushi/xgb" -) - -func main() { - X, _ := xgb.NewConn() - - for i := 1; i <= 1<<16 + 10; i++ { - X.NoOperation() - // fmt.Printf("%d. No-Op\n", i) - } - - aname := "_NET_ACTIVE_WINDOW" - - for i := 1; i <= 10; i++ { - atom, err := X.InternAtom(true, uint16(len(aname)), aname).Reply() - if err != nil { - fmt.Println(err) - } else { - fmt.Printf("%d. Sequence: %d, Atom: %d\n", - i, atom.Sequence, atom.Atom) - } - } -} - diff --git a/nexgb/examples/seq-wrap.go b/nexgb/examples/seq-wrap.go deleted file mode 100644 index b5bc834..0000000 --- a/nexgb/examples/seq-wrap.go +++ /dev/null @@ -1,24 +0,0 @@ -package main - -import ( - "fmt" - - "github.com/BurntSushi/xgb" -) - -func main() { - X, _ := xgb.NewConn() - - aname := "_NET_ACTIVE_WINDOW" - - for i := 1; i <= 1<<16 + 10; i++ { - atom, err := X.InternAtom(true, uint16(len(aname)), aname).Reply() - if err != nil { - fmt.Println(err) - } else { - fmt.Printf("%d. Sequence: %d, Atom: %d\n", - i, atom.Sequence, atom.Atom) - } - } -} - diff --git a/nexgb/examples/window.go b/nexgb/examples/window.go deleted file mode 100644 index 68fe27b..0000000 --- a/nexgb/examples/window.go +++ /dev/null @@ -1,61 +0,0 @@ -package main - -import ( - "fmt" - "log" - - "github.com/BurntSushi/xgb" -) - -func main() { - X, err := xgb.NewConn() - if err != nil { - log.Fatal(err) - } - - wid, _ := X.NewId() - X.CreateWindow(X.DefaultScreen().RootDepth, wid, X.DefaultScreen().Root, - 0, 0, 500, 500, 0, - xgb.WindowClassInputOutput, X.DefaultScreen().RootVisual, - 0, []uint32{}) - X.ChangeWindowAttributes(wid, xgb.CwEventMask | xgb.CwBackPixel, - []uint32{0xffffffff, xgb.EventMaskKeyPress | xgb.EventMaskKeyRelease}) - - err = X.MapWindowChecked(wid).Check() - if err != nil { - fmt.Printf("Checked Error for mapping window %d: %s\n", wid, err) - } else { - fmt.Printf("Map window %d successful!\n", wid) - } - - err = X.MapWindowChecked(0x1).Check() - if err != nil { - fmt.Printf("Checked Error for mapping window 0x1: %s\n", err) - } else { - fmt.Printf("Map window 0x1 successful!\n") - } - - for { - ev, xerr := X.WaitForEvent() - if ev == nil && xerr == nil { - log.Fatal("Both event and error are nil. Exiting...") - } - - if ev != nil { - fmt.Printf("Event: %s\n", ev) - } - if xerr != nil { - fmt.Printf("Error: %s\n", xerr) - } - - if xerr == nil { - geom, err := X.GetGeometry(0x1).Reply() - if err != nil { - fmt.Printf("Geom Error: %#v\n", err) - } else { - fmt.Printf("Geometry: %#v\n", geom) - } - } - } -} - diff --git a/nexgb/examples/xinerama.go b/nexgb/examples/xinerama.go deleted file mode 100644 index 7fe9984..0000000 --- a/nexgb/examples/xinerama.go +++ /dev/null @@ -1,29 +0,0 @@ -package main - -import ( - "fmt" - "log" - - "github.com/BurntSushi/xgb" -) - -func main() { - X, _ := xgb.NewConn() - - err := X.RegisterExtension("xinerama") - if err != nil { - log.Fatal(err) - } - - reply, err := X.XineramaQueryScreens().Reply() - if err != nil { - log.Fatal(err) - } - - fmt.Printf("Xinerama number: %d\n", reply.Number) - for i, screen := range reply.ScreenInfo { - fmt.Printf("%d :: X: %d, Y: %d, Width: %d, Height: %d\n", - i, screen.XOrg, screen.YOrg, screen.Width, screen.Height) - } -} - diff --git a/nexgb/examples/xinerama/main.go b/nexgb/examples/xinerama/main.go new file mode 100644 index 0000000..ec7f46a --- /dev/null +++ b/nexgb/examples/xinerama/main.go @@ -0,0 +1,39 @@ +// Example xinerama shows how to query the geometry of all active heads. +package main + +import ( + "fmt" + "log" + + "github.com/BurntSushi/xgb" +) + +func main() { + X, err := xgb.NewConn() + if err != nil { + log.Fatal(err) + } + + // Initialize the Xinerama extension. + // The appropriate 'Init' function must be run for *every* + // extension before any of its requests can be used. + err = X.XineramaInit() + if err != nil { + log.Fatal(err) + } + + // Issue a request to get the screen information. + reply, err := X.XineramaQueryScreens().Reply() + if err != nil { + log.Fatal(err) + } + + // reply.Number is the number of active heads, while reply.ScreenInfo + // is a slice of XineramaScreenInfo containing the rectangle geometry + // of each head. + fmt.Printf("Number of heads: %d\n", reply.Number) + for i, screen := range reply.ScreenInfo { + fmt.Printf("%d :: X: %d, Y: %d, Width: %d, Height: %d\n", + i, screen.XOrg, screen.YOrg, screen.Width, screen.Height) + } +} diff --git a/nexgb/xgb.go b/nexgb/xgb.go index 581b8fa..c9a265f 100644 --- a/nexgb/xgb.go +++ b/nexgb/xgb.go @@ -1,9 +1,3 @@ -// Copyright 2009 The XGB Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// The XGB package implements the X11 core protocol. -// It is based on XCB: http://xcb.freedesktop.org/ package xgb import ( diff --git a/nexgb/xgb_test.go b/nexgb/xgb_test.go index 9665164..b70ff5e 100644 --- a/nexgb/xgb_test.go +++ b/nexgb/xgb_test.go @@ -45,8 +45,8 @@ func init() { // Tests /******************************************************************************/ -// TestSynchronousError purposefully causes a BadLength error in an -// InternAtom request, and checks it synchronously. +// TestSynchronousError purposefully causes a BadWindow error in a +// MapWindow request, and checks it synchronously. func TestSynchronousError(t *testing.T) { err := X.MapWindowChecked(0).Check() // resource id 0 is always invalid if err == nil { @@ -205,7 +205,7 @@ func TestWindowEvents(t *testing.T) { // BenchmarkInternAtomsGood shows how many requests with replies // *should* be sent and gathered from the server. Namely, send as many // requests as you can at once, then go back and gather up all the replies. -// More importantly, this approach can exploit parallelism better when +// More importantly, this approach can exploit parallelism when // GOMAXPROCS > 1. // Run with `go test -run 'nomatch' -bench '.*' -cpu 1,2,6` if you have // multiple cores to see the improvement that parallelism brings. diff --git a/nexgb/xgbgen/context.go b/nexgb/xgbgen/context.go index 35dd37e..f1762d3 100644 --- a/nexgb/xgbgen/context.go +++ b/nexgb/xgbgen/context.go @@ -86,7 +86,7 @@ func (c *Context) Morph(xmlBytes []byte) { c.Putln("case err != nil:") c.Putln("return err") c.Putln("case !reply.Present:") - c.Putln("return newError(\"No extension named %s could be found on " + + c.Putln("return newError(\"No extension named %s could be found on "+ "on the server.\")", xname) c.Putln("}") c.Putln("") diff --git a/nexgb/xgbgen/field.go b/nexgb/xgbgen/field.go index 4452408..7c83f1a 100644 --- a/nexgb/xgbgen/field.go +++ b/nexgb/xgbgen/field.go @@ -220,7 +220,7 @@ func (f *ExprField) Initialize(p *Protocol) { // integers. The mask specifies which kinds of values are in the list. // (i.e., See ConfigureWindow, CreateWindow, ChangeWindowAttributes, etc.) type ValueField struct { - Parent interface{} + Parent interface{} MaskType Type MaskName string ListName string @@ -247,7 +247,7 @@ func (f *ValueField) Size() Size { listSize := newExpressionSize(&Function{ Name: "pad", Expr: &BinaryOp{ - Op: "*", + Op: "*", Expr1: &Value{v: 4}, Expr2: &PopCount{ Expr: &Function{ diff --git a/nexgb/xgbgen/go_error.go b/nexgb/xgbgen/go_error.go index 0222289..9e01042 100644 --- a/nexgb/xgbgen/go_error.go +++ b/nexgb/xgbgen/go_error.go @@ -133,7 +133,7 @@ func (e *ErrorCopy) ImplementsError(c *Context) { func ErrorFieldString(c *Context, fields []Field, errName string) { c.Putln("fieldVals := make([]string, 0, %d)", len(fields)) c.Putln("fieldVals = append(fieldVals, \"NiceName: \" + err.NiceName)") - c.Putln("fieldVals = append(fieldVals, " + + c.Putln("fieldVals = append(fieldVals, "+ "sprintf(\"Sequence: %s\", err.Sequence))", "%d") for _, field := range fields { switch field.(type) { diff --git a/nexgb/xgbgen/go_event.go b/nexgb/xgbgen/go_event.go index ce54e19..f55e26f 100644 --- a/nexgb/xgbgen/go_event.go +++ b/nexgb/xgbgen/go_event.go @@ -165,7 +165,7 @@ func (e *EventCopy) Write(c *Context) { func EventFieldString(c *Context, fields []Field, evName string) { c.Putln("fieldVals := make([]string, 0, %d)", len(fields)) if evName != "KeymapNotify" { - c.Putln("fieldVals = append(fieldVals, " + + c.Putln("fieldVals = append(fieldVals, "+ "sprintf(\"Sequence: %s\", v.Sequence))", "%d") } for _, field := range fields { @@ -177,7 +177,8 @@ func EventFieldString(c *Context, fields []Field, evName string) { case *Base: case *Resource: case *TypeDef: - default: continue + default: + continue } switch field.SrcType() { diff --git a/nexgb/xgbgen/go_list.go b/nexgb/xgbgen/go_list.go index 41cfb76..ad859bb 100644 --- a/nexgb/xgbgen/go_list.go +++ b/nexgb/xgbgen/go_list.go @@ -107,4 +107,3 @@ func (f *ListField) Write(c *Context, prefix string) { f.XmlName(), f.Type) } } - diff --git a/nexgb/xgbgen/go_request_reply.go b/nexgb/xgbgen/go_request_reply.go index 451667f..a9e624d 100644 --- a/nexgb/xgbgen/go_request_reply.go +++ b/nexgb/xgbgen/go_request_reply.go @@ -71,14 +71,14 @@ func (r *Request) ReadReply(c *Context) { c.Putln("// Waits and reads reply data from request %s", r.SrcName()) c.Putln("func (cook %s) Reply() (*%s, error) {", r.CookieName(), r.ReplyTypeName()) - c.Putln("buf, err := cook.reply()") - c.Putln("if err != nil {") - c.Putln("return nil, err") - c.Putln("}") - c.Putln("if buf == nil {") - c.Putln("return nil, nil") - c.Putln("}") - c.Putln("return %s(buf), nil", r.ReplyName()) + c.Putln("buf, err := cook.reply()") + c.Putln("if err != nil {") + c.Putln("return nil, err") + c.Putln("}") + c.Putln("if buf == nil {") + c.Putln("return nil, nil") + c.Putln("}") + c.Putln("return %s(buf), nil", r.ReplyName()) c.Putln("}") c.Putln("") @@ -107,7 +107,7 @@ func (r *Request) ReadReply(c *Context) { func (r *Request) WriteRequest(c *Context) { writeSize := func() { - c.Putln("Put16(buf[b:], uint16(size / 4)) "+ + c.Putln("Put16(buf[b:], uint16(size / 4)) " + "// write request size in 4-byte units") c.Putln("b += 2") c.Putln("") diff --git a/nexgb/xgbgen/go_union.go b/nexgb/xgbgen/go_union.go index 9f339af..73e85f7 100644 --- a/nexgb/xgbgen/go_union.go +++ b/nexgb/xgbgen/go_union.go @@ -139,4 +139,3 @@ func (u *Union) WriteListSize(c *Context) { c.Putln("}") c.Putln("") } - diff --git a/nexgb/xgbgen/protocol.go b/nexgb/xgbgen/protocol.go index e01bc17..83dde14 100644 --- a/nexgb/xgbgen/protocol.go +++ b/nexgb/xgbgen/protocol.go @@ -38,4 +38,3 @@ func (p *Protocol) Initialize() { func (p *Protocol) isExt() bool { return strings.ToLower(p.Name) != "xproto" } - diff --git a/nexgb/xgbgen/request_reply.go b/nexgb/xgbgen/request_reply.go index c7a4cf8..4daa4ac 100644 --- a/nexgb/xgbgen/request_reply.go +++ b/nexgb/xgbgen/request_reply.go @@ -13,9 +13,9 @@ type Request struct { srcName string // The Go name of this request. xmlName string // The XML name of this request. Opcode int - Combine bool // Not currently used. + Combine bool // Not currently used. Fields []Field // All fields in the request. - Reply *Reply // A reply, if one exists for this request. + Reply *Reply // A reply, if one exists for this request. } // Initialize creates the proper Go source name for this request. diff --git a/nexgb/xgbgen/translation.go b/nexgb/xgbgen/translation.go index 592c152..e4d81bc 100644 --- a/nexgb/xgbgen/translation.go +++ b/nexgb/xgbgen/translation.go @@ -339,7 +339,7 @@ func (x *XMLField) Translate(parent interface{}) Field { } case "valueparam": return &ValueField{ - Parent: parent, + Parent: parent, MaskType: newTranslation(x.ValueMaskType), MaskName: x.ValueMaskName, ListName: x.ValueListName, diff --git a/nexgb/xgbgen/xml.go b/nexgb/xgbgen/xml.go index df21433..440d0a8 100644 --- a/nexgb/xgbgen/xml.go +++ b/nexgb/xgbgen/xml.go @@ -17,11 +17,11 @@ type XML struct { // Types for all top-level elements. // First are the simple ones. - Imports XMLImports `xml:"import"` - Enums []*XMLEnum `xml:"enum"` - Xids []*XMLXid `xml:"xidtype"` - XidUnions []*XMLXid `xml:"xidunion"` - TypeDefs []*XMLTypeDef `xml:"typedef"` + Imports XMLImports `xml:"import"` + Enums []*XMLEnum `xml:"enum"` + Xids []*XMLXid `xml:"xidtype"` + XidUnions []*XMLXid `xml:"xidunion"` + TypeDefs []*XMLTypeDef `xml:"typedef"` EventCopies []*XMLEventCopy `xml:"eventcopy"` ErrorCopies []*XMLErrorCopy `xml:"errorcopy"` @@ -93,21 +93,21 @@ type XMLErrorCopy struct { } type XMLStruct struct { - Name string `xml:"name,attr"` + Name string `xml:"name,attr"` Fields []*XMLField `xml:",any"` } type XMLUnion struct { - Name string `xml:"name,attr"` + Name string `xml:"name,attr"` Fields []*XMLField `xml:",any"` } type XMLRequest struct { - Name string `xml:"name,attr"` - Opcode int `xml:"opcode,attr"` - Combine bool `xml:"combine-adjacent,attr"` + Name string `xml:"name,attr"` + Opcode int `xml:"opcode,attr"` + Combine bool `xml:"combine-adjacent,attr"` Fields []*XMLField `xml:",any"` - Reply *XMLReply `xml:"reply"` + Reply *XMLReply `xml:"reply"` } type XMLReply struct { @@ -115,15 +115,15 @@ type XMLReply struct { } type XMLEvent struct { - Name string `xml:"name,attr"` - Number int `xml:"number,attr"` - NoSequence bool `xml:"no-sequence-number,attr"` + Name string `xml:"name,attr"` + Number int `xml:"number,attr"` + NoSequence bool `xml:"no-sequence-number,attr"` Fields []*XMLField `xml:",any"` } type XMLError struct { - Name string `xml:"name,attr"` - Number int `xml:"number,attr"` + Name string `xml:"name,attr"` + Number int `xml:"number,attr"` Fields []*XMLField `xml:",any"` } -- cgit v1.2.3-70-g09d2 From 0c50dc6241fa21712e041cfa2bfb9db4ccaef10a Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Thu, 10 May 2012 17:01:42 -0400 Subject: a huge commit. splitting extensions into their own sub-packages. --- nexgb/Makefile | 25 +- nexgb/auto_bigreq.go | 138 - nexgb/auto_composite.go | 581 -- nexgb/auto_damage.go | 513 - nexgb/auto_dpms.go | 600 -- nexgb/auto_dri2.go | 1560 ---- nexgb/auto_ge.go | 151 - nexgb/auto_glx.go | 9430 ------------------- nexgb/auto_randr.go | 4038 -------- nexgb/auto_record.go | 1095 --- nexgb/auto_render.go | 3556 ------- nexgb/auto_res.go | 528 -- nexgb/auto_screensaver.go | 627 -- nexgb/auto_shape.go | 897 -- nexgb/auto_shm.go | 678 -- nexgb/auto_sync.go | 1949 ---- nexgb/auto_xc_misc.go | 326 - nexgb/auto_xevie.go | 539 -- nexgb/auto_xf86dri.go | 1151 --- nexgb/auto_xf86vidmode.go | 2398 ----- nexgb/auto_xfixes.go | 2173 ----- nexgb/auto_xinerama.go | 655 -- nexgb/auto_xinput.go | 7297 --------------- nexgb/auto_xprint.go | 2210 ----- nexgb/auto_xproto.go | 14490 ----------------------------- nexgb/auto_xselinux.go | 1965 ---- nexgb/auto_xtest.go | 361 - nexgb/auto_xv.go | 2780 ------ nexgb/auto_xvmc.go | 929 -- nexgb/bigreq/bigreq.go | 140 + nexgb/composite/composite.go | 575 ++ nexgb/conn.go | 17 +- nexgb/cookie.go | 36 +- nexgb/damage/damage.go | 511 + nexgb/doc.go | 23 +- nexgb/dpms/dpms.go | 590 ++ nexgb/dri2/dri2.go | 1522 +++ nexgb/examples/create-window/main.go | 33 +- nexgb/examples/get-active-window/main.go | 20 +- nexgb/examples/randr/main.go | 23 +- nexgb/examples/xinerama/main.go | 5 +- nexgb/ge/ge.go | 153 + nexgb/glx/glx.go | 9168 ++++++++++++++++++ nexgb/randr/randr.go | 3964 ++++++++ nexgb/record/record.go | 1089 +++ nexgb/render/render.go | 3542 +++++++ nexgb/res/res.go | 514 + nexgb/screensaver/screensaver.go | 621 ++ nexgb/shape/shape.go | 883 ++ nexgb/shm/shm.go | 672 ++ nexgb/sync.go | 29 + nexgb/sync/sync.go | 1927 ++++ nexgb/xcmisc/xcmisc.go | 320 + nexgb/xevie/xevie.go | 525 ++ nexgb/xf86dri/xf86dri.go | 1121 +++ nexgb/xf86vidmode/xf86vidmode.go | 2360 +++++ nexgb/xfixes/xfixes.go | 2155 +++++ nexgb/xgb.go | 89 +- nexgb/xgb_help.go | 16 +- nexgb/xgb_test.go | 376 - nexgb/xgbgen/context.go | 76 +- nexgb/xgbgen/expression.go | 4 +- nexgb/xgbgen/field.go | 2 +- nexgb/xgbgen/go.go | 10 +- nexgb/xgbgen/go_error.go | 23 +- nexgb/xgbgen/go_event.go | 27 +- nexgb/xgbgen/go_list.go | 22 +- nexgb/xgbgen/go_request_reply.go | 53 +- nexgb/xgbgen/go_single_field.go | 42 +- nexgb/xgbgen/go_struct.go | 10 +- nexgb/xgbgen/go_union.go | 14 +- nexgb/xgbgen/protocol.go | 24 + nexgb/xgbgen/request_reply.go | 3 +- nexgb/xgbgen/translation.go | 36 +- nexgb/xinerama/xinerama.go | 633 ++ nexgb/xinput/xinput.go | 7219 ++++++++++++++ nexgb/xprint/xprint.go | 2164 +++++ nexgb/xproto/xproto.go | 14347 ++++++++++++++++++++++++++++ nexgb/xproto/xproto_test.go | 365 + nexgb/xselinux/xselinux.go | 1903 ++++ nexgb/xtest/xtest.go | 355 + nexgb/xv/xv.go | 2746 ++++++ nexgb/xvmc/xvmc.go | 908 ++ 83 files changed, 63387 insertions(+), 64258 deletions(-) delete mode 100644 nexgb/auto_bigreq.go delete mode 100644 nexgb/auto_composite.go delete mode 100644 nexgb/auto_damage.go delete mode 100644 nexgb/auto_dpms.go delete mode 100644 nexgb/auto_dri2.go delete mode 100644 nexgb/auto_ge.go delete mode 100644 nexgb/auto_glx.go delete mode 100644 nexgb/auto_randr.go delete mode 100644 nexgb/auto_record.go delete mode 100644 nexgb/auto_render.go delete mode 100644 nexgb/auto_res.go delete mode 100644 nexgb/auto_screensaver.go delete mode 100644 nexgb/auto_shape.go delete mode 100644 nexgb/auto_shm.go delete mode 100644 nexgb/auto_sync.go delete mode 100644 nexgb/auto_xc_misc.go delete mode 100644 nexgb/auto_xevie.go delete mode 100644 nexgb/auto_xf86dri.go delete mode 100644 nexgb/auto_xf86vidmode.go delete mode 100644 nexgb/auto_xfixes.go delete mode 100644 nexgb/auto_xinerama.go delete mode 100644 nexgb/auto_xinput.go delete mode 100644 nexgb/auto_xprint.go delete mode 100644 nexgb/auto_xproto.go delete mode 100644 nexgb/auto_xselinux.go delete mode 100644 nexgb/auto_xtest.go delete mode 100644 nexgb/auto_xv.go delete mode 100644 nexgb/auto_xvmc.go create mode 100644 nexgb/bigreq/bigreq.go create mode 100644 nexgb/composite/composite.go create mode 100644 nexgb/damage/damage.go create mode 100644 nexgb/dpms/dpms.go create mode 100644 nexgb/dri2/dri2.go create mode 100644 nexgb/ge/ge.go create mode 100644 nexgb/glx/glx.go create mode 100644 nexgb/randr/randr.go create mode 100644 nexgb/record/record.go create mode 100644 nexgb/render/render.go create mode 100644 nexgb/res/res.go create mode 100644 nexgb/screensaver/screensaver.go create mode 100644 nexgb/shape/shape.go create mode 100644 nexgb/shm/shm.go create mode 100644 nexgb/sync.go create mode 100644 nexgb/sync/sync.go create mode 100644 nexgb/xcmisc/xcmisc.go create mode 100644 nexgb/xevie/xevie.go create mode 100644 nexgb/xf86dri/xf86dri.go create mode 100644 nexgb/xf86vidmode/xf86vidmode.go create mode 100644 nexgb/xfixes/xfixes.go delete mode 100644 nexgb/xgb_test.go create mode 100644 nexgb/xinerama/xinerama.go create mode 100644 nexgb/xinput/xinput.go create mode 100644 nexgb/xprint/xprint.go create mode 100644 nexgb/xproto/xproto.go create mode 100644 nexgb/xproto/xproto_test.go create mode 100644 nexgb/xselinux/xselinux.go create mode 100644 nexgb/xtest/xtest.go create mode 100644 nexgb/xv/xv.go create mode 100644 nexgb/xvmc/xvmc.go (limited to 'nexgb/xgbgen/go_event.go') diff --git a/nexgb/Makefile b/nexgb/Makefile index 56738f4..7fa8b9b 100644 --- a/nexgb/Makefile +++ b/nexgb/Makefile @@ -16,17 +16,30 @@ all: build-xgbgen \ build-xgbgen: (cd xgbgen && go build) -%.xml: - xgbgen/xgbgen --proto-path $(XPROTO) $(XPROTO)/$*.xml > auto_$*.go +build-all: bigreq.b composite.b damage.b dpms.b dri2.b ge.b glx.b randr.b \ + record.b render.b res.b screensaver.b shape.b shm.b sync.b xcmisc.b \ + xevie.b xf86dri.b xf86vidmode.b xfixes.b xinerama.b xinput.b \ + xprint.b xproto.b xselinux.b xtest.b xv.b xvmc.b + +%.b: + (cd $* ; go build) + +xc_misc.xml: build-xgbgen + mkdir -p xcmisc + xgbgen/xgbgen --proto-path $(XPROTO) $(XPROTO)/xc_misc.xml > xcmisc/xcmisc.go + +%.xml: build-xgbgen + mkdir -p $* + xgbgen/xgbgen --proto-path $(XPROTO) $(XPROTO)/$*.xml > $*/$*.go test: - go test + (cd xproto ; go test) bench: - go test -run 'nomatch' -bench '.*' -cpu 1,2,6 + (cd xproto ; go test -run 'nomatch' -bench '.*' -cpu 1,2,6) gofmt: gofmt -w *.go xgbgen/*.go examples/*.go examples/*/*.go - colcheck xgbgen/*.go examples/*.go examples/*/*.go \ - auth.go conn.go cookie.go doc.go xgb.go xgb_help.go xgb_test.go + colcheck xgbgen/*.go examples/*.go examples/*/*.go xproto/xproto_test.go \ + auth.go conn.go cookie.go doc.go xgb.go xgb_help.go diff --git a/nexgb/auto_bigreq.go b/nexgb/auto_bigreq.go deleted file mode 100644 index e8bbaef..0000000 --- a/nexgb/auto_bigreq.go +++ /dev/null @@ -1,138 +0,0 @@ -package xgb - -/* - This file was generated by bigreq.xml on May 10 2012 12:39:33pm EDT. - This file is automatically generated. Edit at your peril! -*/ - -// BigreqInit must be called before using the BIG-REQUESTS extension. -func (c *Conn) BigreqInit() error { - reply, err := c.QueryExtension(12, "BIG-REQUESTS").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named BIG-REQUESTS could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["BIG-REQUESTS"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["BIG-REQUESTS"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["BIG-REQUESTS"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["BIG-REQUESTS"] = make(map[int]newEventFun) - newExtErrorFuncs["BIG-REQUESTS"] = make(map[int]newErrorFun) -} - -// Skipping definition for base type 'Card16' - -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - -// Skipping definition for base type 'Float' - -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - -// Skipping definition for base type 'Int8' - -// Request BigreqEnable -// size: 4 -type BigreqEnableCookie struct { - *cookie -} - -func (c *Conn) BigreqEnable() BigreqEnableCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.bigreqEnableRequest(), cookie) - return BigreqEnableCookie{cookie} -} - -func (c *Conn) BigreqEnableUnchecked() BigreqEnableCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.bigreqEnableRequest(), cookie) - return BigreqEnableCookie{cookie} -} - -// Request reply for BigreqEnable -// size: 12 -type BigreqEnableReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - MaximumRequestLength uint32 -} - -// Waits and reads reply data from request BigreqEnable -func (cook BigreqEnableCookie) Reply() (*BigreqEnableReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return bigreqEnableReply(buf), nil -} - -// Read reply into structure from buffer for BigreqEnable -func bigreqEnableReply(buf []byte) *BigreqEnableReply { - v := new(BigreqEnableReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.MaximumRequestLength = Get32(buf[b:]) - b += 4 - - return v -} - -func (cook BigreqEnableCookie) Check() error { - return cook.check() -} - -// Write request to wire for BigreqEnable -func (c *Conn) bigreqEnableRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["BIG-REQUESTS"] - b += 1 - - buf[b] = 0 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} diff --git a/nexgb/auto_composite.go b/nexgb/auto_composite.go deleted file mode 100644 index 836436f..0000000 --- a/nexgb/auto_composite.go +++ /dev/null @@ -1,581 +0,0 @@ -package xgb - -/* - This file was generated by composite.xml on May 10 2012 12:39:33pm EDT. - This file is automatically generated. Edit at your peril! -*/ - -// Imports are not necessary for XGB because everything is -// in one package. They are still listed here for reference. -// import "xproto" -// import "xfixes" - -// CompositeInit must be called before using the Composite extension. -func (c *Conn) CompositeInit() error { - reply, err := c.QueryExtension(9, "Composite").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named Composite could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["Composite"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["Composite"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["Composite"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["Composite"] = make(map[int]newEventFun) - newExtErrorFuncs["Composite"] = make(map[int]newErrorFun) -} - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - -// Skipping definition for base type 'Int8' - -// Skipping definition for base type 'Card16' - -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - -// Skipping definition for base type 'Float' - -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -const ( - CompositeRedirectAutomatic = 0 - CompositeRedirectManual = 1 -) - -// Request CompositeQueryVersion -// size: 12 -type CompositeQueryVersionCookie struct { - *cookie -} - -func (c *Conn) CompositeQueryVersion(ClientMajorVersion uint32, ClientMinorVersion uint32) CompositeQueryVersionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.compositeQueryVersionRequest(ClientMajorVersion, ClientMinorVersion), cookie) - return CompositeQueryVersionCookie{cookie} -} - -func (c *Conn) CompositeQueryVersionUnchecked(ClientMajorVersion uint32, ClientMinorVersion uint32) CompositeQueryVersionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.compositeQueryVersionRequest(ClientMajorVersion, ClientMinorVersion), cookie) - return CompositeQueryVersionCookie{cookie} -} - -// Request reply for CompositeQueryVersion -// size: 32 -type CompositeQueryVersionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - MajorVersion uint32 - MinorVersion uint32 - // padding: 16 bytes -} - -// Waits and reads reply data from request CompositeQueryVersion -func (cook CompositeQueryVersionCookie) Reply() (*CompositeQueryVersionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return compositeQueryVersionReply(buf), nil -} - -// Read reply into structure from buffer for CompositeQueryVersion -func compositeQueryVersionReply(buf []byte) *CompositeQueryVersionReply { - v := new(CompositeQueryVersionReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.MajorVersion = Get32(buf[b:]) - b += 4 - - v.MinorVersion = Get32(buf[b:]) - b += 4 - - b += 16 // padding - - return v -} - -func (cook CompositeQueryVersionCookie) Check() error { - return cook.check() -} - -// Write request to wire for CompositeQueryVersion -func (c *Conn) compositeQueryVersionRequest(ClientMajorVersion uint32, ClientMinorVersion uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["COMPOSITE"] - b += 1 - - buf[b] = 0 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], ClientMajorVersion) - b += 4 - - Put32(buf[b:], ClientMinorVersion) - b += 4 - - return buf -} - -// Request CompositeRedirectWindow -// size: 12 -type CompositeRedirectWindowCookie struct { - *cookie -} - -// Write request to wire for CompositeRedirectWindow -func (c *Conn) CompositeRedirectWindow(Window Window, Update byte) CompositeRedirectWindowCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.compositeRedirectWindowRequest(Window, Update), cookie) - return CompositeRedirectWindowCookie{cookie} -} - -func (c *Conn) CompositeRedirectWindowChecked(Window Window, Update byte) CompositeRedirectWindowCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.compositeRedirectWindowRequest(Window, Update), cookie) - return CompositeRedirectWindowCookie{cookie} -} - -func (cook CompositeRedirectWindowCookie) Check() error { - return cook.check() -} - -// Write request to wire for CompositeRedirectWindow -func (c *Conn) compositeRedirectWindowRequest(Window Window, Update byte) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["COMPOSITE"] - b += 1 - - buf[b] = 1 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - buf[b] = Update - b += 1 - - b += 3 // padding - - return buf -} - -// Request CompositeRedirectSubwindows -// size: 12 -type CompositeRedirectSubwindowsCookie struct { - *cookie -} - -// Write request to wire for CompositeRedirectSubwindows -func (c *Conn) CompositeRedirectSubwindows(Window Window, Update byte) CompositeRedirectSubwindowsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.compositeRedirectSubwindowsRequest(Window, Update), cookie) - return CompositeRedirectSubwindowsCookie{cookie} -} - -func (c *Conn) CompositeRedirectSubwindowsChecked(Window Window, Update byte) CompositeRedirectSubwindowsCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.compositeRedirectSubwindowsRequest(Window, Update), cookie) - return CompositeRedirectSubwindowsCookie{cookie} -} - -func (cook CompositeRedirectSubwindowsCookie) Check() error { - return cook.check() -} - -// Write request to wire for CompositeRedirectSubwindows -func (c *Conn) compositeRedirectSubwindowsRequest(Window Window, Update byte) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["COMPOSITE"] - b += 1 - - buf[b] = 2 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - buf[b] = Update - b += 1 - - b += 3 // padding - - return buf -} - -// Request CompositeUnredirectWindow -// size: 12 -type CompositeUnredirectWindowCookie struct { - *cookie -} - -// Write request to wire for CompositeUnredirectWindow -func (c *Conn) CompositeUnredirectWindow(Window Window, Update byte) CompositeUnredirectWindowCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.compositeUnredirectWindowRequest(Window, Update), cookie) - return CompositeUnredirectWindowCookie{cookie} -} - -func (c *Conn) CompositeUnredirectWindowChecked(Window Window, Update byte) CompositeUnredirectWindowCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.compositeUnredirectWindowRequest(Window, Update), cookie) - return CompositeUnredirectWindowCookie{cookie} -} - -func (cook CompositeUnredirectWindowCookie) Check() error { - return cook.check() -} - -// Write request to wire for CompositeUnredirectWindow -func (c *Conn) compositeUnredirectWindowRequest(Window Window, Update byte) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["COMPOSITE"] - b += 1 - - buf[b] = 3 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - buf[b] = Update - b += 1 - - b += 3 // padding - - return buf -} - -// Request CompositeUnredirectSubwindows -// size: 12 -type CompositeUnredirectSubwindowsCookie struct { - *cookie -} - -// Write request to wire for CompositeUnredirectSubwindows -func (c *Conn) CompositeUnredirectSubwindows(Window Window, Update byte) CompositeUnredirectSubwindowsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.compositeUnredirectSubwindowsRequest(Window, Update), cookie) - return CompositeUnredirectSubwindowsCookie{cookie} -} - -func (c *Conn) CompositeUnredirectSubwindowsChecked(Window Window, Update byte) CompositeUnredirectSubwindowsCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.compositeUnredirectSubwindowsRequest(Window, Update), cookie) - return CompositeUnredirectSubwindowsCookie{cookie} -} - -func (cook CompositeUnredirectSubwindowsCookie) Check() error { - return cook.check() -} - -// Write request to wire for CompositeUnredirectSubwindows -func (c *Conn) compositeUnredirectSubwindowsRequest(Window Window, Update byte) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["COMPOSITE"] - b += 1 - - buf[b] = 4 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - buf[b] = Update - b += 1 - - b += 3 // padding - - return buf -} - -// Request CompositeCreateRegionFromBorderClip -// size: 12 -type CompositeCreateRegionFromBorderClipCookie struct { - *cookie -} - -// Write request to wire for CompositeCreateRegionFromBorderClip -func (c *Conn) CompositeCreateRegionFromBorderClip(Region XfixesRegion, Window Window) CompositeCreateRegionFromBorderClipCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.compositeCreateRegionFromBorderClipRequest(Region, Window), cookie) - return CompositeCreateRegionFromBorderClipCookie{cookie} -} - -func (c *Conn) CompositeCreateRegionFromBorderClipChecked(Region XfixesRegion, Window Window) CompositeCreateRegionFromBorderClipCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.compositeCreateRegionFromBorderClipRequest(Region, Window), cookie) - return CompositeCreateRegionFromBorderClipCookie{cookie} -} - -func (cook CompositeCreateRegionFromBorderClipCookie) Check() error { - return cook.check() -} - -// Write request to wire for CompositeCreateRegionFromBorderClip -func (c *Conn) compositeCreateRegionFromBorderClipRequest(Region XfixesRegion, Window Window) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["COMPOSITE"] - b += 1 - - buf[b] = 5 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Region)) - b += 4 - - Put32(buf[b:], uint32(Window)) - b += 4 - - return buf -} - -// Request CompositeNameWindowPixmap -// size: 12 -type CompositeNameWindowPixmapCookie struct { - *cookie -} - -// Write request to wire for CompositeNameWindowPixmap -func (c *Conn) CompositeNameWindowPixmap(Window Window, Pixmap Pixmap) CompositeNameWindowPixmapCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.compositeNameWindowPixmapRequest(Window, Pixmap), cookie) - return CompositeNameWindowPixmapCookie{cookie} -} - -func (c *Conn) CompositeNameWindowPixmapChecked(Window Window, Pixmap Pixmap) CompositeNameWindowPixmapCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.compositeNameWindowPixmapRequest(Window, Pixmap), cookie) - return CompositeNameWindowPixmapCookie{cookie} -} - -func (cook CompositeNameWindowPixmapCookie) Check() error { - return cook.check() -} - -// Write request to wire for CompositeNameWindowPixmap -func (c *Conn) compositeNameWindowPixmapRequest(Window Window, Pixmap Pixmap) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["COMPOSITE"] - b += 1 - - buf[b] = 6 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - Put32(buf[b:], uint32(Pixmap)) - b += 4 - - return buf -} - -// Request CompositeGetOverlayWindow -// size: 8 -type CompositeGetOverlayWindowCookie struct { - *cookie -} - -func (c *Conn) CompositeGetOverlayWindow(Window Window) CompositeGetOverlayWindowCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.compositeGetOverlayWindowRequest(Window), cookie) - return CompositeGetOverlayWindowCookie{cookie} -} - -func (c *Conn) CompositeGetOverlayWindowUnchecked(Window Window) CompositeGetOverlayWindowCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.compositeGetOverlayWindowRequest(Window), cookie) - return CompositeGetOverlayWindowCookie{cookie} -} - -// Request reply for CompositeGetOverlayWindow -// size: 32 -type CompositeGetOverlayWindowReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - OverlayWin Window - // padding: 20 bytes -} - -// Waits and reads reply data from request CompositeGetOverlayWindow -func (cook CompositeGetOverlayWindowCookie) Reply() (*CompositeGetOverlayWindowReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return compositeGetOverlayWindowReply(buf), nil -} - -// Read reply into structure from buffer for CompositeGetOverlayWindow -func compositeGetOverlayWindowReply(buf []byte) *CompositeGetOverlayWindowReply { - v := new(CompositeGetOverlayWindowReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.OverlayWin = Window(Get32(buf[b:])) - b += 4 - - b += 20 // padding - - return v -} - -func (cook CompositeGetOverlayWindowCookie) Check() error { - return cook.check() -} - -// Write request to wire for CompositeGetOverlayWindow -func (c *Conn) compositeGetOverlayWindowRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["COMPOSITE"] - b += 1 - - buf[b] = 7 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - return buf -} - -// Request CompositeReleaseOverlayWindow -// size: 8 -type CompositeReleaseOverlayWindowCookie struct { - *cookie -} - -// Write request to wire for CompositeReleaseOverlayWindow -func (c *Conn) CompositeReleaseOverlayWindow(Window Window) CompositeReleaseOverlayWindowCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.compositeReleaseOverlayWindowRequest(Window), cookie) - return CompositeReleaseOverlayWindowCookie{cookie} -} - -func (c *Conn) CompositeReleaseOverlayWindowChecked(Window Window) CompositeReleaseOverlayWindowCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.compositeReleaseOverlayWindowRequest(Window), cookie) - return CompositeReleaseOverlayWindowCookie{cookie} -} - -func (cook CompositeReleaseOverlayWindowCookie) Check() error { - return cook.check() -} - -// Write request to wire for CompositeReleaseOverlayWindow -func (c *Conn) compositeReleaseOverlayWindowRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["COMPOSITE"] - b += 1 - - buf[b] = 8 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - return buf -} diff --git a/nexgb/auto_damage.go b/nexgb/auto_damage.go deleted file mode 100644 index 97c76b4..0000000 --- a/nexgb/auto_damage.go +++ /dev/null @@ -1,513 +0,0 @@ -package xgb - -/* - This file was generated by damage.xml on May 10 2012 12:39:33pm EDT. - This file is automatically generated. Edit at your peril! -*/ - -// Imports are not necessary for XGB because everything is -// in one package. They are still listed here for reference. -// import "xproto" -// import "xfixes" - -// DamageInit must be called before using the DAMAGE extension. -func (c *Conn) DamageInit() error { - reply, err := c.QueryExtension(6, "DAMAGE").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named DAMAGE could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["DAMAGE"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["DAMAGE"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["DAMAGE"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["DAMAGE"] = make(map[int]newEventFun) - newExtErrorFuncs["DAMAGE"] = make(map[int]newErrorFun) -} - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - -// Skipping definition for base type 'Int8' - -// Skipping definition for base type 'Card16' - -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - -// Skipping definition for base type 'Float' - -// Skipping definition for base type 'Card8' - -const ( - DamageReportLevelRawRectangles = 0 - DamageReportLevelDeltaRectangles = 1 - DamageReportLevelBoundingBox = 2 - DamageReportLevelNonEmpty = 3 -) - -type DamageDamage uint32 - -func (c *Conn) NewDamageDamageId() (DamageDamage, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return DamageDamage(id), nil -} - -// Event definition DamageNotify (0) -// Size: 32 - -const DamageNotify = 0 - -type DamageNotifyEvent struct { - Sequence uint16 - Level byte - Drawable Drawable - Damage DamageDamage - Timestamp Timestamp - Area Rectangle - Geometry Rectangle -} - -// Event read DamageNotify -func NewDamageNotifyEvent(buf []byte) Event { - v := DamageNotifyEvent{} - b := 1 // don't read event number - - v.Level = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Drawable = Drawable(Get32(buf[b:])) - b += 4 - - v.Damage = DamageDamage(Get32(buf[b:])) - b += 4 - - v.Timestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.Area = Rectangle{} - b += ReadRectangle(buf[b:], &v.Area) - - v.Geometry = Rectangle{} - b += ReadRectangle(buf[b:], &v.Geometry) - - return v -} - -// Event write DamageNotify -func (v DamageNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 0 - b += 1 - - buf[b] = v.Level - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Drawable)) - b += 4 - - Put32(buf[b:], uint32(v.Damage)) - b += 4 - - Put32(buf[b:], uint32(v.Timestamp)) - b += 4 - - { - structBytes := v.Area.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - { - structBytes := v.Geometry.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - return buf -} - -func (v DamageNotifyEvent) ImplementsEvent() {} - -func (v DamageNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v DamageNotifyEvent) String() string { - fieldVals := make([]string, 0, 6) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Level: %d", v.Level)) - fieldVals = append(fieldVals, sprintf("Drawable: %d", v.Drawable)) - fieldVals = append(fieldVals, sprintf("Damage: %d", v.Damage)) - fieldVals = append(fieldVals, sprintf("Timestamp: %d", v.Timestamp)) - return "DamageNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["DAMAGE"][0] = NewDamageNotifyEvent -} - -// Error definition DamageBadDamage (0) -// Size: 32 - -const BadDamageBadDamage = 0 - -type DamageBadDamageError struct { - Sequence uint16 - NiceName string -} - -// Error read DamageBadDamage -func NewDamageBadDamageError(buf []byte) Error { - v := DamageBadDamageError{} - v.NiceName = "DamageBadDamage" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err DamageBadDamageError) ImplementsError() {} - -func (err DamageBadDamageError) SequenceId() uint16 { - return err.Sequence -} - -func (err DamageBadDamageError) BadId() uint32 { - return 0 -} - -func (err DamageBadDamageError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadDamageBadDamage {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["DAMAGE"][0] = NewDamageBadDamageError -} - -// Request DamageQueryVersion -// size: 12 -type DamageQueryVersionCookie struct { - *cookie -} - -func (c *Conn) DamageQueryVersion(ClientMajorVersion uint32, ClientMinorVersion uint32) DamageQueryVersionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.damageQueryVersionRequest(ClientMajorVersion, ClientMinorVersion), cookie) - return DamageQueryVersionCookie{cookie} -} - -func (c *Conn) DamageQueryVersionUnchecked(ClientMajorVersion uint32, ClientMinorVersion uint32) DamageQueryVersionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.damageQueryVersionRequest(ClientMajorVersion, ClientMinorVersion), cookie) - return DamageQueryVersionCookie{cookie} -} - -// Request reply for DamageQueryVersion -// size: 32 -type DamageQueryVersionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - MajorVersion uint32 - MinorVersion uint32 - // padding: 16 bytes -} - -// Waits and reads reply data from request DamageQueryVersion -func (cook DamageQueryVersionCookie) Reply() (*DamageQueryVersionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return damageQueryVersionReply(buf), nil -} - -// Read reply into structure from buffer for DamageQueryVersion -func damageQueryVersionReply(buf []byte) *DamageQueryVersionReply { - v := new(DamageQueryVersionReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.MajorVersion = Get32(buf[b:]) - b += 4 - - v.MinorVersion = Get32(buf[b:]) - b += 4 - - b += 16 // padding - - return v -} - -func (cook DamageQueryVersionCookie) Check() error { - return cook.check() -} - -// Write request to wire for DamageQueryVersion -func (c *Conn) damageQueryVersionRequest(ClientMajorVersion uint32, ClientMinorVersion uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["DAMAGE"] - b += 1 - - buf[b] = 0 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], ClientMajorVersion) - b += 4 - - Put32(buf[b:], ClientMinorVersion) - b += 4 - - return buf -} - -// Request DamageCreate -// size: 16 -type DamageCreateCookie struct { - *cookie -} - -// Write request to wire for DamageCreate -func (c *Conn) DamageCreate(Damage DamageDamage, Drawable Drawable, Level byte) DamageCreateCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.damageCreateRequest(Damage, Drawable, Level), cookie) - return DamageCreateCookie{cookie} -} - -func (c *Conn) DamageCreateChecked(Damage DamageDamage, Drawable Drawable, Level byte) DamageCreateCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.damageCreateRequest(Damage, Drawable, Level), cookie) - return DamageCreateCookie{cookie} -} - -func (cook DamageCreateCookie) Check() error { - return cook.check() -} - -// Write request to wire for DamageCreate -func (c *Conn) damageCreateRequest(Damage DamageDamage, Drawable Drawable, Level byte) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["DAMAGE"] - b += 1 - - buf[b] = 1 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Damage)) - b += 4 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - buf[b] = Level - b += 1 - - b += 3 // padding - - return buf -} - -// Request DamageDestroy -// size: 8 -type DamageDestroyCookie struct { - *cookie -} - -// Write request to wire for DamageDestroy -func (c *Conn) DamageDestroy(Damage DamageDamage) DamageDestroyCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.damageDestroyRequest(Damage), cookie) - return DamageDestroyCookie{cookie} -} - -func (c *Conn) DamageDestroyChecked(Damage DamageDamage) DamageDestroyCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.damageDestroyRequest(Damage), cookie) - return DamageDestroyCookie{cookie} -} - -func (cook DamageDestroyCookie) Check() error { - return cook.check() -} - -// Write request to wire for DamageDestroy -func (c *Conn) damageDestroyRequest(Damage DamageDamage) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["DAMAGE"] - b += 1 - - buf[b] = 2 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Damage)) - b += 4 - - return buf -} - -// Request DamageSubtract -// size: 16 -type DamageSubtractCookie struct { - *cookie -} - -// Write request to wire for DamageSubtract -func (c *Conn) DamageSubtract(Damage DamageDamage, Repair XfixesRegion, Parts XfixesRegion) DamageSubtractCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.damageSubtractRequest(Damage, Repair, Parts), cookie) - return DamageSubtractCookie{cookie} -} - -func (c *Conn) DamageSubtractChecked(Damage DamageDamage, Repair XfixesRegion, Parts XfixesRegion) DamageSubtractCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.damageSubtractRequest(Damage, Repair, Parts), cookie) - return DamageSubtractCookie{cookie} -} - -func (cook DamageSubtractCookie) Check() error { - return cook.check() -} - -// Write request to wire for DamageSubtract -func (c *Conn) damageSubtractRequest(Damage DamageDamage, Repair XfixesRegion, Parts XfixesRegion) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["DAMAGE"] - b += 1 - - buf[b] = 3 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Damage)) - b += 4 - - Put32(buf[b:], uint32(Repair)) - b += 4 - - Put32(buf[b:], uint32(Parts)) - b += 4 - - return buf -} - -// Request DamageAdd -// size: 12 -type DamageAddCookie struct { - *cookie -} - -// Write request to wire for DamageAdd -func (c *Conn) DamageAdd(Drawable Drawable, Region XfixesRegion) DamageAddCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.damageAddRequest(Drawable, Region), cookie) - return DamageAddCookie{cookie} -} - -func (c *Conn) DamageAddChecked(Drawable Drawable, Region XfixesRegion) DamageAddCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.damageAddRequest(Drawable, Region), cookie) - return DamageAddCookie{cookie} -} - -func (cook DamageAddCookie) Check() error { - return cook.check() -} - -// Write request to wire for DamageAdd -func (c *Conn) damageAddRequest(Drawable Drawable, Region XfixesRegion) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["DAMAGE"] - b += 1 - - buf[b] = 4 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], uint32(Region)) - b += 4 - - return buf -} diff --git a/nexgb/auto_dpms.go b/nexgb/auto_dpms.go deleted file mode 100644 index 8ceab58..0000000 --- a/nexgb/auto_dpms.go +++ /dev/null @@ -1,600 +0,0 @@ -package xgb - -/* - This file was generated by dpms.xml on May 10 2012 12:39:33pm EDT. - This file is automatically generated. Edit at your peril! -*/ - -// DpmsInit must be called before using the DPMS extension. -func (c *Conn) DpmsInit() error { - reply, err := c.QueryExtension(4, "DPMS").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named DPMS could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["DPMS"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["DPMS"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["DPMS"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["DPMS"] = make(map[int]newEventFun) - newExtErrorFuncs["DPMS"] = make(map[int]newErrorFun) -} - -// Skipping definition for base type 'Float' - -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - -// Skipping definition for base type 'Int8' - -// Skipping definition for base type 'Card16' - -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - -const ( - DpmsDPMSModeOn = 0 - DpmsDPMSModeStandby = 1 - DpmsDPMSModeSuspend = 2 - DpmsDPMSModeOff = 3 -) - -// Request DpmsGetVersion -// size: 8 -type DpmsGetVersionCookie struct { - *cookie -} - -func (c *Conn) DpmsGetVersion(ClientMajorVersion uint16, ClientMinorVersion uint16) DpmsGetVersionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.dpmsGetVersionRequest(ClientMajorVersion, ClientMinorVersion), cookie) - return DpmsGetVersionCookie{cookie} -} - -func (c *Conn) DpmsGetVersionUnchecked(ClientMajorVersion uint16, ClientMinorVersion uint16) DpmsGetVersionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.dpmsGetVersionRequest(ClientMajorVersion, ClientMinorVersion), cookie) - return DpmsGetVersionCookie{cookie} -} - -// Request reply for DpmsGetVersion -// size: 12 -type DpmsGetVersionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ServerMajorVersion uint16 - ServerMinorVersion uint16 -} - -// Waits and reads reply data from request DpmsGetVersion -func (cook DpmsGetVersionCookie) Reply() (*DpmsGetVersionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return dpmsGetVersionReply(buf), nil -} - -// Read reply into structure from buffer for DpmsGetVersion -func dpmsGetVersionReply(buf []byte) *DpmsGetVersionReply { - v := new(DpmsGetVersionReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.ServerMajorVersion = Get16(buf[b:]) - b += 2 - - v.ServerMinorVersion = Get16(buf[b:]) - b += 2 - - return v -} - -func (cook DpmsGetVersionCookie) Check() error { - return cook.check() -} - -// Write request to wire for DpmsGetVersion -func (c *Conn) dpmsGetVersionRequest(ClientMajorVersion uint16, ClientMinorVersion uint16) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["DPMS"] - b += 1 - - buf[b] = 0 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], ClientMajorVersion) - b += 2 - - Put16(buf[b:], ClientMinorVersion) - b += 2 - - return buf -} - -// Request DpmsCapable -// size: 4 -type DpmsCapableCookie struct { - *cookie -} - -func (c *Conn) DpmsCapable() DpmsCapableCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.dpmsCapableRequest(), cookie) - return DpmsCapableCookie{cookie} -} - -func (c *Conn) DpmsCapableUnchecked() DpmsCapableCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.dpmsCapableRequest(), cookie) - return DpmsCapableCookie{cookie} -} - -// Request reply for DpmsCapable -// size: 32 -type DpmsCapableReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Capable bool - // padding: 23 bytes -} - -// Waits and reads reply data from request DpmsCapable -func (cook DpmsCapableCookie) Reply() (*DpmsCapableReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return dpmsCapableReply(buf), nil -} - -// Read reply into structure from buffer for DpmsCapable -func dpmsCapableReply(buf []byte) *DpmsCapableReply { - v := new(DpmsCapableReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - if buf[b] == 1 { - v.Capable = true - } else { - v.Capable = false - } - b += 1 - - b += 23 // padding - - return v -} - -func (cook DpmsCapableCookie) Check() error { - return cook.check() -} - -// Write request to wire for DpmsCapable -func (c *Conn) dpmsCapableRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["DPMS"] - b += 1 - - buf[b] = 1 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request DpmsGetTimeouts -// size: 4 -type DpmsGetTimeoutsCookie struct { - *cookie -} - -func (c *Conn) DpmsGetTimeouts() DpmsGetTimeoutsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.dpmsGetTimeoutsRequest(), cookie) - return DpmsGetTimeoutsCookie{cookie} -} - -func (c *Conn) DpmsGetTimeoutsUnchecked() DpmsGetTimeoutsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.dpmsGetTimeoutsRequest(), cookie) - return DpmsGetTimeoutsCookie{cookie} -} - -// Request reply for DpmsGetTimeouts -// size: 32 -type DpmsGetTimeoutsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - StandbyTimeout uint16 - SuspendTimeout uint16 - OffTimeout uint16 - // padding: 18 bytes -} - -// Waits and reads reply data from request DpmsGetTimeouts -func (cook DpmsGetTimeoutsCookie) Reply() (*DpmsGetTimeoutsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return dpmsGetTimeoutsReply(buf), nil -} - -// Read reply into structure from buffer for DpmsGetTimeouts -func dpmsGetTimeoutsReply(buf []byte) *DpmsGetTimeoutsReply { - v := new(DpmsGetTimeoutsReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.StandbyTimeout = Get16(buf[b:]) - b += 2 - - v.SuspendTimeout = Get16(buf[b:]) - b += 2 - - v.OffTimeout = Get16(buf[b:]) - b += 2 - - b += 18 // padding - - return v -} - -func (cook DpmsGetTimeoutsCookie) Check() error { - return cook.check() -} - -// Write request to wire for DpmsGetTimeouts -func (c *Conn) dpmsGetTimeoutsRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["DPMS"] - b += 1 - - buf[b] = 2 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request DpmsSetTimeouts -// size: 12 -type DpmsSetTimeoutsCookie struct { - *cookie -} - -// Write request to wire for DpmsSetTimeouts -func (c *Conn) DpmsSetTimeouts(StandbyTimeout uint16, SuspendTimeout uint16, OffTimeout uint16) DpmsSetTimeoutsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.dpmsSetTimeoutsRequest(StandbyTimeout, SuspendTimeout, OffTimeout), cookie) - return DpmsSetTimeoutsCookie{cookie} -} - -func (c *Conn) DpmsSetTimeoutsChecked(StandbyTimeout uint16, SuspendTimeout uint16, OffTimeout uint16) DpmsSetTimeoutsCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.dpmsSetTimeoutsRequest(StandbyTimeout, SuspendTimeout, OffTimeout), cookie) - return DpmsSetTimeoutsCookie{cookie} -} - -func (cook DpmsSetTimeoutsCookie) Check() error { - return cook.check() -} - -// Write request to wire for DpmsSetTimeouts -func (c *Conn) dpmsSetTimeoutsRequest(StandbyTimeout uint16, SuspendTimeout uint16, OffTimeout uint16) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["DPMS"] - b += 1 - - buf[b] = 3 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], StandbyTimeout) - b += 2 - - Put16(buf[b:], SuspendTimeout) - b += 2 - - Put16(buf[b:], OffTimeout) - b += 2 - - return buf -} - -// Request DpmsEnable -// size: 4 -type DpmsEnableCookie struct { - *cookie -} - -// Write request to wire for DpmsEnable -func (c *Conn) DpmsEnable() DpmsEnableCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.dpmsEnableRequest(), cookie) - return DpmsEnableCookie{cookie} -} - -func (c *Conn) DpmsEnableChecked() DpmsEnableCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.dpmsEnableRequest(), cookie) - return DpmsEnableCookie{cookie} -} - -func (cook DpmsEnableCookie) Check() error { - return cook.check() -} - -// Write request to wire for DpmsEnable -func (c *Conn) dpmsEnableRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["DPMS"] - b += 1 - - buf[b] = 4 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request DpmsDisable -// size: 4 -type DpmsDisableCookie struct { - *cookie -} - -// Write request to wire for DpmsDisable -func (c *Conn) DpmsDisable() DpmsDisableCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.dpmsDisableRequest(), cookie) - return DpmsDisableCookie{cookie} -} - -func (c *Conn) DpmsDisableChecked() DpmsDisableCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.dpmsDisableRequest(), cookie) - return DpmsDisableCookie{cookie} -} - -func (cook DpmsDisableCookie) Check() error { - return cook.check() -} - -// Write request to wire for DpmsDisable -func (c *Conn) dpmsDisableRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["DPMS"] - b += 1 - - buf[b] = 5 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request DpmsForceLevel -// size: 8 -type DpmsForceLevelCookie struct { - *cookie -} - -// Write request to wire for DpmsForceLevel -func (c *Conn) DpmsForceLevel(PowerLevel uint16) DpmsForceLevelCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.dpmsForceLevelRequest(PowerLevel), cookie) - return DpmsForceLevelCookie{cookie} -} - -func (c *Conn) DpmsForceLevelChecked(PowerLevel uint16) DpmsForceLevelCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.dpmsForceLevelRequest(PowerLevel), cookie) - return DpmsForceLevelCookie{cookie} -} - -func (cook DpmsForceLevelCookie) Check() error { - return cook.check() -} - -// Write request to wire for DpmsForceLevel -func (c *Conn) dpmsForceLevelRequest(PowerLevel uint16) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["DPMS"] - b += 1 - - buf[b] = 6 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], PowerLevel) - b += 2 - - return buf -} - -// Request DpmsInfo -// size: 4 -type DpmsInfoCookie struct { - *cookie -} - -func (c *Conn) DpmsInfo() DpmsInfoCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.dpmsInfoRequest(), cookie) - return DpmsInfoCookie{cookie} -} - -func (c *Conn) DpmsInfoUnchecked() DpmsInfoCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.dpmsInfoRequest(), cookie) - return DpmsInfoCookie{cookie} -} - -// Request reply for DpmsInfo -// size: 32 -type DpmsInfoReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - PowerLevel uint16 - State bool - // padding: 21 bytes -} - -// Waits and reads reply data from request DpmsInfo -func (cook DpmsInfoCookie) Reply() (*DpmsInfoReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return dpmsInfoReply(buf), nil -} - -// Read reply into structure from buffer for DpmsInfo -func dpmsInfoReply(buf []byte) *DpmsInfoReply { - v := new(DpmsInfoReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.PowerLevel = Get16(buf[b:]) - b += 2 - - if buf[b] == 1 { - v.State = true - } else { - v.State = false - } - b += 1 - - b += 21 // padding - - return v -} - -func (cook DpmsInfoCookie) Check() error { - return cook.check() -} - -// Write request to wire for DpmsInfo -func (c *Conn) dpmsInfoRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["DPMS"] - b += 1 - - buf[b] = 7 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} diff --git a/nexgb/auto_dri2.go b/nexgb/auto_dri2.go deleted file mode 100644 index 09baef5..0000000 --- a/nexgb/auto_dri2.go +++ /dev/null @@ -1,1560 +0,0 @@ -package xgb - -/* - This file was generated by dri2.xml on May 10 2012 12:39:33pm EDT. - This file is automatically generated. Edit at your peril! -*/ - -// Imports are not necessary for XGB because everything is -// in one package. They are still listed here for reference. -// import "xproto" - -// Dri2Init must be called before using the DRI2 extension. -func (c *Conn) Dri2Init() error { - reply, err := c.QueryExtension(4, "DRI2").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named DRI2 could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["DRI2"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["DRI2"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["DRI2"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["DRI2"] = make(map[int]newEventFun) - newExtErrorFuncs["DRI2"] = make(map[int]newErrorFun) -} - -// Skipping definition for base type 'Int8' - -// Skipping definition for base type 'Card16' - -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - -// Skipping definition for base type 'Float' - -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - -const ( - Dri2AttachmentBufferFrontLeft = 0 - Dri2AttachmentBufferBackLeft = 1 - Dri2AttachmentBufferFrontRight = 2 - Dri2AttachmentBufferBackRight = 3 - Dri2AttachmentBufferDepth = 4 - Dri2AttachmentBufferStencil = 5 - Dri2AttachmentBufferAccum = 6 - Dri2AttachmentBufferFakeFrontLeft = 7 - Dri2AttachmentBufferFakeFrontRight = 8 - Dri2AttachmentBufferDepthStencil = 9 - Dri2AttachmentBufferHiz = 10 -) - -const ( - Dri2DriverTypeDri = 0 - Dri2DriverTypeVdpau = 1 -) - -const ( - Dri2EventTypeExchangeComplete = 1 - Dri2EventTypeBlitComplete = 2 - Dri2EventTypeFlipComplete = 3 -) - -// 'Dri2DRI2Buffer' struct definition -// Size: 20 -type Dri2DRI2Buffer struct { - Attachment uint32 - Name uint32 - Pitch uint32 - Cpp uint32 - Flags uint32 -} - -// Struct read Dri2DRI2Buffer -func ReadDri2DRI2Buffer(buf []byte, v *Dri2DRI2Buffer) int { - b := 0 - - v.Attachment = Get32(buf[b:]) - b += 4 - - v.Name = Get32(buf[b:]) - b += 4 - - v.Pitch = Get32(buf[b:]) - b += 4 - - v.Cpp = Get32(buf[b:]) - b += 4 - - v.Flags = Get32(buf[b:]) - b += 4 - - return b -} - -// Struct list read Dri2DRI2Buffer -func ReadDri2DRI2BufferList(buf []byte, dest []Dri2DRI2Buffer) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Dri2DRI2Buffer{} - b += ReadDri2DRI2Buffer(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write Dri2DRI2Buffer -func (v Dri2DRI2Buffer) Bytes() []byte { - buf := make([]byte, 20) - b := 0 - - Put32(buf[b:], v.Attachment) - b += 4 - - Put32(buf[b:], v.Name) - b += 4 - - Put32(buf[b:], v.Pitch) - b += 4 - - Put32(buf[b:], v.Cpp) - b += 4 - - Put32(buf[b:], v.Flags) - b += 4 - - return buf -} - -// Write struct list Dri2DRI2Buffer -func Dri2DRI2BufferListBytes(buf []byte, list []Dri2DRI2Buffer) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'Dri2AttachFormat' struct definition -// Size: 8 -type Dri2AttachFormat struct { - Attachment uint32 - Format uint32 -} - -// Struct read Dri2AttachFormat -func ReadDri2AttachFormat(buf []byte, v *Dri2AttachFormat) int { - b := 0 - - v.Attachment = Get32(buf[b:]) - b += 4 - - v.Format = Get32(buf[b:]) - b += 4 - - return b -} - -// Struct list read Dri2AttachFormat -func ReadDri2AttachFormatList(buf []byte, dest []Dri2AttachFormat) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Dri2AttachFormat{} - b += ReadDri2AttachFormat(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write Dri2AttachFormat -func (v Dri2AttachFormat) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put32(buf[b:], v.Attachment) - b += 4 - - Put32(buf[b:], v.Format) - b += 4 - - return buf -} - -// Write struct list Dri2AttachFormat -func Dri2AttachFormatListBytes(buf []byte, list []Dri2AttachFormat) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Event definition Dri2BufferSwapComplete (0) -// Size: 32 - -const Dri2BufferSwapComplete = 0 - -type Dri2BufferSwapCompleteEvent struct { - Sequence uint16 - // padding: 1 bytes - EventType uint16 - // padding: 2 bytes - Drawable Drawable - UstHi uint32 - UstLo uint32 - MscHi uint32 - MscLo uint32 - Sbc uint32 -} - -// Event read Dri2BufferSwapComplete -func NewDri2BufferSwapCompleteEvent(buf []byte) Event { - v := Dri2BufferSwapCompleteEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.EventType = Get16(buf[b:]) - b += 2 - - b += 2 // padding - - v.Drawable = Drawable(Get32(buf[b:])) - b += 4 - - v.UstHi = Get32(buf[b:]) - b += 4 - - v.UstLo = Get32(buf[b:]) - b += 4 - - v.MscHi = Get32(buf[b:]) - b += 4 - - v.MscLo = Get32(buf[b:]) - b += 4 - - v.Sbc = Get32(buf[b:]) - b += 4 - - return v -} - -// Event write Dri2BufferSwapComplete -func (v Dri2BufferSwapCompleteEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 0 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put16(buf[b:], v.EventType) - b += 2 - - b += 2 // padding - - Put32(buf[b:], uint32(v.Drawable)) - b += 4 - - Put32(buf[b:], v.UstHi) - b += 4 - - Put32(buf[b:], v.UstLo) - b += 4 - - Put32(buf[b:], v.MscHi) - b += 4 - - Put32(buf[b:], v.MscLo) - b += 4 - - Put32(buf[b:], v.Sbc) - b += 4 - - return buf -} - -func (v Dri2BufferSwapCompleteEvent) ImplementsEvent() {} - -func (v Dri2BufferSwapCompleteEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v Dri2BufferSwapCompleteEvent) String() string { - fieldVals := make([]string, 0, 9) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("EventType: %d", v.EventType)) - fieldVals = append(fieldVals, sprintf("Drawable: %d", v.Drawable)) - fieldVals = append(fieldVals, sprintf("UstHi: %d", v.UstHi)) - fieldVals = append(fieldVals, sprintf("UstLo: %d", v.UstLo)) - fieldVals = append(fieldVals, sprintf("MscHi: %d", v.MscHi)) - fieldVals = append(fieldVals, sprintf("MscLo: %d", v.MscLo)) - fieldVals = append(fieldVals, sprintf("Sbc: %d", v.Sbc)) - return "Dri2BufferSwapComplete {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["DRI2"][0] = NewDri2BufferSwapCompleteEvent -} - -// Event definition Dri2InvalidateBuffers (1) -// Size: 32 - -const Dri2InvalidateBuffers = 1 - -type Dri2InvalidateBuffersEvent struct { - Sequence uint16 - // padding: 1 bytes - Drawable Drawable -} - -// Event read Dri2InvalidateBuffers -func NewDri2InvalidateBuffersEvent(buf []byte) Event { - v := Dri2InvalidateBuffersEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Drawable = Drawable(Get32(buf[b:])) - b += 4 - - return v -} - -// Event write Dri2InvalidateBuffers -func (v Dri2InvalidateBuffersEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 1 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Drawable)) - b += 4 - - return buf -} - -func (v Dri2InvalidateBuffersEvent) ImplementsEvent() {} - -func (v Dri2InvalidateBuffersEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v Dri2InvalidateBuffersEvent) String() string { - fieldVals := make([]string, 0, 2) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Drawable: %d", v.Drawable)) - return "Dri2InvalidateBuffers {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["DRI2"][1] = NewDri2InvalidateBuffersEvent -} - -// Request Dri2QueryVersion -// size: 12 -type Dri2QueryVersionCookie struct { - *cookie -} - -func (c *Conn) Dri2QueryVersion(MajorVersion uint32, MinorVersion uint32) Dri2QueryVersionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.dri2QueryVersionRequest(MajorVersion, MinorVersion), cookie) - return Dri2QueryVersionCookie{cookie} -} - -func (c *Conn) Dri2QueryVersionUnchecked(MajorVersion uint32, MinorVersion uint32) Dri2QueryVersionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.dri2QueryVersionRequest(MajorVersion, MinorVersion), cookie) - return Dri2QueryVersionCookie{cookie} -} - -// Request reply for Dri2QueryVersion -// size: 16 -type Dri2QueryVersionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - MajorVersion uint32 - MinorVersion uint32 -} - -// Waits and reads reply data from request Dri2QueryVersion -func (cook Dri2QueryVersionCookie) Reply() (*Dri2QueryVersionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return dri2QueryVersionReply(buf), nil -} - -// Read reply into structure from buffer for Dri2QueryVersion -func dri2QueryVersionReply(buf []byte) *Dri2QueryVersionReply { - v := new(Dri2QueryVersionReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.MajorVersion = Get32(buf[b:]) - b += 4 - - v.MinorVersion = Get32(buf[b:]) - b += 4 - - return v -} - -func (cook Dri2QueryVersionCookie) Check() error { - return cook.check() -} - -// Write request to wire for Dri2QueryVersion -func (c *Conn) dri2QueryVersionRequest(MajorVersion uint32, MinorVersion uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["DRI2"] - b += 1 - - buf[b] = 0 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], MajorVersion) - b += 4 - - Put32(buf[b:], MinorVersion) - b += 4 - - return buf -} - -// Request Dri2Connect -// size: 12 -type Dri2ConnectCookie struct { - *cookie -} - -func (c *Conn) Dri2Connect(Window Window, DriverType uint32) Dri2ConnectCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.dri2ConnectRequest(Window, DriverType), cookie) - return Dri2ConnectCookie{cookie} -} - -func (c *Conn) Dri2ConnectUnchecked(Window Window, DriverType uint32) Dri2ConnectCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.dri2ConnectRequest(Window, DriverType), cookie) - return Dri2ConnectCookie{cookie} -} - -// Request reply for Dri2Connect -// size: (((32 + pad((int(DriverNameLength) * 1))) + pad(((((int(DriverNameLength) + 3) & -4) - int(DriverNameLength)) * 1))) + pad((int(DeviceNameLength) * 1))) -type Dri2ConnectReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - DriverNameLength uint32 - DeviceNameLength uint32 - // padding: 16 bytes - DriverName string // size: pad((int(DriverNameLength) * 1)) - AlignmentPad []byte // size: pad(((((int(DriverNameLength) + 3) & -4) - int(DriverNameLength)) * 1)) - DeviceName string // size: pad((int(DeviceNameLength) * 1)) -} - -// Waits and reads reply data from request Dri2Connect -func (cook Dri2ConnectCookie) Reply() (*Dri2ConnectReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return dri2ConnectReply(buf), nil -} - -// Read reply into structure from buffer for Dri2Connect -func dri2ConnectReply(buf []byte) *Dri2ConnectReply { - v := new(Dri2ConnectReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.DriverNameLength = Get32(buf[b:]) - b += 4 - - v.DeviceNameLength = Get32(buf[b:]) - b += 4 - - b += 16 // padding - - { - byteString := make([]byte, v.DriverNameLength) - copy(byteString[:v.DriverNameLength], buf[b:]) - v.DriverName = string(byteString) - b += pad(int(v.DriverNameLength)) - } - - v.AlignmentPad = make([]byte, (((int(v.DriverNameLength) + 3) & -4) - int(v.DriverNameLength))) - copy(v.AlignmentPad[:(((int(v.DriverNameLength)+3)&-4)-int(v.DriverNameLength))], buf[b:]) - b += pad(int((((int(v.DriverNameLength) + 3) & -4) - int(v.DriverNameLength)))) - - { - byteString := make([]byte, v.DeviceNameLength) - copy(byteString[:v.DeviceNameLength], buf[b:]) - v.DeviceName = string(byteString) - b += pad(int(v.DeviceNameLength)) - } - - return v -} - -func (cook Dri2ConnectCookie) Check() error { - return cook.check() -} - -// Write request to wire for Dri2Connect -func (c *Conn) dri2ConnectRequest(Window Window, DriverType uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["DRI2"] - b += 1 - - buf[b] = 1 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - Put32(buf[b:], DriverType) - b += 4 - - return buf -} - -// Request Dri2Authenticate -// size: 12 -type Dri2AuthenticateCookie struct { - *cookie -} - -func (c *Conn) Dri2Authenticate(Window Window, Magic uint32) Dri2AuthenticateCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.dri2AuthenticateRequest(Window, Magic), cookie) - return Dri2AuthenticateCookie{cookie} -} - -func (c *Conn) Dri2AuthenticateUnchecked(Window Window, Magic uint32) Dri2AuthenticateCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.dri2AuthenticateRequest(Window, Magic), cookie) - return Dri2AuthenticateCookie{cookie} -} - -// Request reply for Dri2Authenticate -// size: 12 -type Dri2AuthenticateReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Authenticated uint32 -} - -// Waits and reads reply data from request Dri2Authenticate -func (cook Dri2AuthenticateCookie) Reply() (*Dri2AuthenticateReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return dri2AuthenticateReply(buf), nil -} - -// Read reply into structure from buffer for Dri2Authenticate -func dri2AuthenticateReply(buf []byte) *Dri2AuthenticateReply { - v := new(Dri2AuthenticateReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Authenticated = Get32(buf[b:]) - b += 4 - - return v -} - -func (cook Dri2AuthenticateCookie) Check() error { - return cook.check() -} - -// Write request to wire for Dri2Authenticate -func (c *Conn) dri2AuthenticateRequest(Window Window, Magic uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["DRI2"] - b += 1 - - buf[b] = 2 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - Put32(buf[b:], Magic) - b += 4 - - return buf -} - -// Request Dri2CreateDrawable -// size: 8 -type Dri2CreateDrawableCookie struct { - *cookie -} - -// Write request to wire for Dri2CreateDrawable -func (c *Conn) Dri2CreateDrawable(Drawable Drawable) Dri2CreateDrawableCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.dri2CreateDrawableRequest(Drawable), cookie) - return Dri2CreateDrawableCookie{cookie} -} - -func (c *Conn) Dri2CreateDrawableChecked(Drawable Drawable) Dri2CreateDrawableCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.dri2CreateDrawableRequest(Drawable), cookie) - return Dri2CreateDrawableCookie{cookie} -} - -func (cook Dri2CreateDrawableCookie) Check() error { - return cook.check() -} - -// Write request to wire for Dri2CreateDrawable -func (c *Conn) dri2CreateDrawableRequest(Drawable Drawable) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["DRI2"] - b += 1 - - buf[b] = 3 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - return buf -} - -// Request Dri2DestroyDrawable -// size: 8 -type Dri2DestroyDrawableCookie struct { - *cookie -} - -// Write request to wire for Dri2DestroyDrawable -func (c *Conn) Dri2DestroyDrawable(Drawable Drawable) Dri2DestroyDrawableCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.dri2DestroyDrawableRequest(Drawable), cookie) - return Dri2DestroyDrawableCookie{cookie} -} - -func (c *Conn) Dri2DestroyDrawableChecked(Drawable Drawable) Dri2DestroyDrawableCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.dri2DestroyDrawableRequest(Drawable), cookie) - return Dri2DestroyDrawableCookie{cookie} -} - -func (cook Dri2DestroyDrawableCookie) Check() error { - return cook.check() -} - -// Write request to wire for Dri2DestroyDrawable -func (c *Conn) dri2DestroyDrawableRequest(Drawable Drawable) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["DRI2"] - b += 1 - - buf[b] = 4 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - return buf -} - -// Request Dri2GetBuffers -// size: pad((12 + pad((len(Attachments) * 4)))) -type Dri2GetBuffersCookie struct { - *cookie -} - -func (c *Conn) Dri2GetBuffers(Drawable Drawable, Count uint32, Attachments []uint32) Dri2GetBuffersCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.dri2GetBuffersRequest(Drawable, Count, Attachments), cookie) - return Dri2GetBuffersCookie{cookie} -} - -func (c *Conn) Dri2GetBuffersUnchecked(Drawable Drawable, Count uint32, Attachments []uint32) Dri2GetBuffersCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.dri2GetBuffersRequest(Drawable, Count, Attachments), cookie) - return Dri2GetBuffersCookie{cookie} -} - -// Request reply for Dri2GetBuffers -// size: (32 + pad((int(Count) * 20))) -type Dri2GetBuffersReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Width uint32 - Height uint32 - Count uint32 - // padding: 12 bytes - Buffers []Dri2DRI2Buffer // size: pad((int(Count) * 20)) -} - -// Waits and reads reply data from request Dri2GetBuffers -func (cook Dri2GetBuffersCookie) Reply() (*Dri2GetBuffersReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return dri2GetBuffersReply(buf), nil -} - -// Read reply into structure from buffer for Dri2GetBuffers -func dri2GetBuffersReply(buf []byte) *Dri2GetBuffersReply { - v := new(Dri2GetBuffersReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Width = Get32(buf[b:]) - b += 4 - - v.Height = Get32(buf[b:]) - b += 4 - - v.Count = Get32(buf[b:]) - b += 4 - - b += 12 // padding - - v.Buffers = make([]Dri2DRI2Buffer, v.Count) - b += ReadDri2DRI2BufferList(buf[b:], v.Buffers) - - return v -} - -func (cook Dri2GetBuffersCookie) Check() error { - return cook.check() -} - -// Write request to wire for Dri2GetBuffers -func (c *Conn) dri2GetBuffersRequest(Drawable Drawable, Count uint32, Attachments []uint32) []byte { - size := pad((12 + pad((len(Attachments) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["DRI2"] - b += 1 - - buf[b] = 5 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], Count) - b += 4 - - for i := 0; i < int(len(Attachments)); i++ { - Put32(buf[b:], Attachments[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Request Dri2CopyRegion -// size: 20 -type Dri2CopyRegionCookie struct { - *cookie -} - -func (c *Conn) Dri2CopyRegion(Drawable Drawable, Region uint32, Dest uint32, Src uint32) Dri2CopyRegionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.dri2CopyRegionRequest(Drawable, Region, Dest, Src), cookie) - return Dri2CopyRegionCookie{cookie} -} - -func (c *Conn) Dri2CopyRegionUnchecked(Drawable Drawable, Region uint32, Dest uint32, Src uint32) Dri2CopyRegionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.dri2CopyRegionRequest(Drawable, Region, Dest, Src), cookie) - return Dri2CopyRegionCookie{cookie} -} - -// Request reply for Dri2CopyRegion -// size: 8 -type Dri2CopyRegionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes -} - -// Waits and reads reply data from request Dri2CopyRegion -func (cook Dri2CopyRegionCookie) Reply() (*Dri2CopyRegionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return dri2CopyRegionReply(buf), nil -} - -// Read reply into structure from buffer for Dri2CopyRegion -func dri2CopyRegionReply(buf []byte) *Dri2CopyRegionReply { - v := new(Dri2CopyRegionReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - return v -} - -func (cook Dri2CopyRegionCookie) Check() error { - return cook.check() -} - -// Write request to wire for Dri2CopyRegion -func (c *Conn) dri2CopyRegionRequest(Drawable Drawable, Region uint32, Dest uint32, Src uint32) []byte { - size := 20 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["DRI2"] - b += 1 - - buf[b] = 6 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], Region) - b += 4 - - Put32(buf[b:], Dest) - b += 4 - - Put32(buf[b:], Src) - b += 4 - - return buf -} - -// Request Dri2GetBuffersWithFormat -// size: pad((12 + pad((len(Attachments) * 8)))) -type Dri2GetBuffersWithFormatCookie struct { - *cookie -} - -func (c *Conn) Dri2GetBuffersWithFormat(Drawable Drawable, Count uint32, Attachments []Dri2AttachFormat) Dri2GetBuffersWithFormatCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.dri2GetBuffersWithFormatRequest(Drawable, Count, Attachments), cookie) - return Dri2GetBuffersWithFormatCookie{cookie} -} - -func (c *Conn) Dri2GetBuffersWithFormatUnchecked(Drawable Drawable, Count uint32, Attachments []Dri2AttachFormat) Dri2GetBuffersWithFormatCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.dri2GetBuffersWithFormatRequest(Drawable, Count, Attachments), cookie) - return Dri2GetBuffersWithFormatCookie{cookie} -} - -// Request reply for Dri2GetBuffersWithFormat -// size: (32 + pad((int(Count) * 20))) -type Dri2GetBuffersWithFormatReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Width uint32 - Height uint32 - Count uint32 - // padding: 12 bytes - Buffers []Dri2DRI2Buffer // size: pad((int(Count) * 20)) -} - -// Waits and reads reply data from request Dri2GetBuffersWithFormat -func (cook Dri2GetBuffersWithFormatCookie) Reply() (*Dri2GetBuffersWithFormatReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return dri2GetBuffersWithFormatReply(buf), nil -} - -// Read reply into structure from buffer for Dri2GetBuffersWithFormat -func dri2GetBuffersWithFormatReply(buf []byte) *Dri2GetBuffersWithFormatReply { - v := new(Dri2GetBuffersWithFormatReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Width = Get32(buf[b:]) - b += 4 - - v.Height = Get32(buf[b:]) - b += 4 - - v.Count = Get32(buf[b:]) - b += 4 - - b += 12 // padding - - v.Buffers = make([]Dri2DRI2Buffer, v.Count) - b += ReadDri2DRI2BufferList(buf[b:], v.Buffers) - - return v -} - -func (cook Dri2GetBuffersWithFormatCookie) Check() error { - return cook.check() -} - -// Write request to wire for Dri2GetBuffersWithFormat -func (c *Conn) dri2GetBuffersWithFormatRequest(Drawable Drawable, Count uint32, Attachments []Dri2AttachFormat) []byte { - size := pad((12 + pad((len(Attachments) * 8)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["DRI2"] - b += 1 - - buf[b] = 7 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], Count) - b += 4 - - b += Dri2AttachFormatListBytes(buf[b:], Attachments) - - return buf -} - -// Request Dri2SwapBuffers -// size: 32 -type Dri2SwapBuffersCookie struct { - *cookie -} - -func (c *Conn) Dri2SwapBuffers(Drawable Drawable, TargetMscHi uint32, TargetMscLo uint32, DivisorHi uint32, DivisorLo uint32, RemainderHi uint32, RemainderLo uint32) Dri2SwapBuffersCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.dri2SwapBuffersRequest(Drawable, TargetMscHi, TargetMscLo, DivisorHi, DivisorLo, RemainderHi, RemainderLo), cookie) - return Dri2SwapBuffersCookie{cookie} -} - -func (c *Conn) Dri2SwapBuffersUnchecked(Drawable Drawable, TargetMscHi uint32, TargetMscLo uint32, DivisorHi uint32, DivisorLo uint32, RemainderHi uint32, RemainderLo uint32) Dri2SwapBuffersCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.dri2SwapBuffersRequest(Drawable, TargetMscHi, TargetMscLo, DivisorHi, DivisorLo, RemainderHi, RemainderLo), cookie) - return Dri2SwapBuffersCookie{cookie} -} - -// Request reply for Dri2SwapBuffers -// size: 16 -type Dri2SwapBuffersReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - SwapHi uint32 - SwapLo uint32 -} - -// Waits and reads reply data from request Dri2SwapBuffers -func (cook Dri2SwapBuffersCookie) Reply() (*Dri2SwapBuffersReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return dri2SwapBuffersReply(buf), nil -} - -// Read reply into structure from buffer for Dri2SwapBuffers -func dri2SwapBuffersReply(buf []byte) *Dri2SwapBuffersReply { - v := new(Dri2SwapBuffersReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.SwapHi = Get32(buf[b:]) - b += 4 - - v.SwapLo = Get32(buf[b:]) - b += 4 - - return v -} - -func (cook Dri2SwapBuffersCookie) Check() error { - return cook.check() -} - -// Write request to wire for Dri2SwapBuffers -func (c *Conn) dri2SwapBuffersRequest(Drawable Drawable, TargetMscHi uint32, TargetMscLo uint32, DivisorHi uint32, DivisorLo uint32, RemainderHi uint32, RemainderLo uint32) []byte { - size := 32 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["DRI2"] - b += 1 - - buf[b] = 8 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], TargetMscHi) - b += 4 - - Put32(buf[b:], TargetMscLo) - b += 4 - - Put32(buf[b:], DivisorHi) - b += 4 - - Put32(buf[b:], DivisorLo) - b += 4 - - Put32(buf[b:], RemainderHi) - b += 4 - - Put32(buf[b:], RemainderLo) - b += 4 - - return buf -} - -// Request Dri2GetMSC -// size: 8 -type Dri2GetMSCCookie struct { - *cookie -} - -func (c *Conn) Dri2GetMSC(Drawable Drawable) Dri2GetMSCCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.dri2GetMSCRequest(Drawable), cookie) - return Dri2GetMSCCookie{cookie} -} - -func (c *Conn) Dri2GetMSCUnchecked(Drawable Drawable) Dri2GetMSCCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.dri2GetMSCRequest(Drawable), cookie) - return Dri2GetMSCCookie{cookie} -} - -// Request reply for Dri2GetMSC -// size: 32 -type Dri2GetMSCReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - UstHi uint32 - UstLo uint32 - MscHi uint32 - MscLo uint32 - SbcHi uint32 - SbcLo uint32 -} - -// Waits and reads reply data from request Dri2GetMSC -func (cook Dri2GetMSCCookie) Reply() (*Dri2GetMSCReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return dri2GetMSCReply(buf), nil -} - -// Read reply into structure from buffer for Dri2GetMSC -func dri2GetMSCReply(buf []byte) *Dri2GetMSCReply { - v := new(Dri2GetMSCReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.UstHi = Get32(buf[b:]) - b += 4 - - v.UstLo = Get32(buf[b:]) - b += 4 - - v.MscHi = Get32(buf[b:]) - b += 4 - - v.MscLo = Get32(buf[b:]) - b += 4 - - v.SbcHi = Get32(buf[b:]) - b += 4 - - v.SbcLo = Get32(buf[b:]) - b += 4 - - return v -} - -func (cook Dri2GetMSCCookie) Check() error { - return cook.check() -} - -// Write request to wire for Dri2GetMSC -func (c *Conn) dri2GetMSCRequest(Drawable Drawable) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["DRI2"] - b += 1 - - buf[b] = 9 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - return buf -} - -// Request Dri2WaitMSC -// size: 32 -type Dri2WaitMSCCookie struct { - *cookie -} - -func (c *Conn) Dri2WaitMSC(Drawable Drawable, TargetMscHi uint32, TargetMscLo uint32, DivisorHi uint32, DivisorLo uint32, RemainderHi uint32, RemainderLo uint32) Dri2WaitMSCCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.dri2WaitMSCRequest(Drawable, TargetMscHi, TargetMscLo, DivisorHi, DivisorLo, RemainderHi, RemainderLo), cookie) - return Dri2WaitMSCCookie{cookie} -} - -func (c *Conn) Dri2WaitMSCUnchecked(Drawable Drawable, TargetMscHi uint32, TargetMscLo uint32, DivisorHi uint32, DivisorLo uint32, RemainderHi uint32, RemainderLo uint32) Dri2WaitMSCCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.dri2WaitMSCRequest(Drawable, TargetMscHi, TargetMscLo, DivisorHi, DivisorLo, RemainderHi, RemainderLo), cookie) - return Dri2WaitMSCCookie{cookie} -} - -// Request reply for Dri2WaitMSC -// size: 32 -type Dri2WaitMSCReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - UstHi uint32 - UstLo uint32 - MscHi uint32 - MscLo uint32 - SbcHi uint32 - SbcLo uint32 -} - -// Waits and reads reply data from request Dri2WaitMSC -func (cook Dri2WaitMSCCookie) Reply() (*Dri2WaitMSCReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return dri2WaitMSCReply(buf), nil -} - -// Read reply into structure from buffer for Dri2WaitMSC -func dri2WaitMSCReply(buf []byte) *Dri2WaitMSCReply { - v := new(Dri2WaitMSCReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.UstHi = Get32(buf[b:]) - b += 4 - - v.UstLo = Get32(buf[b:]) - b += 4 - - v.MscHi = Get32(buf[b:]) - b += 4 - - v.MscLo = Get32(buf[b:]) - b += 4 - - v.SbcHi = Get32(buf[b:]) - b += 4 - - v.SbcLo = Get32(buf[b:]) - b += 4 - - return v -} - -func (cook Dri2WaitMSCCookie) Check() error { - return cook.check() -} - -// Write request to wire for Dri2WaitMSC -func (c *Conn) dri2WaitMSCRequest(Drawable Drawable, TargetMscHi uint32, TargetMscLo uint32, DivisorHi uint32, DivisorLo uint32, RemainderHi uint32, RemainderLo uint32) []byte { - size := 32 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["DRI2"] - b += 1 - - buf[b] = 10 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], TargetMscHi) - b += 4 - - Put32(buf[b:], TargetMscLo) - b += 4 - - Put32(buf[b:], DivisorHi) - b += 4 - - Put32(buf[b:], DivisorLo) - b += 4 - - Put32(buf[b:], RemainderHi) - b += 4 - - Put32(buf[b:], RemainderLo) - b += 4 - - return buf -} - -// Request Dri2WaitSBC -// size: 16 -type Dri2WaitSBCCookie struct { - *cookie -} - -func (c *Conn) Dri2WaitSBC(Drawable Drawable, TargetSbcHi uint32, TargetSbcLo uint32) Dri2WaitSBCCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.dri2WaitSBCRequest(Drawable, TargetSbcHi, TargetSbcLo), cookie) - return Dri2WaitSBCCookie{cookie} -} - -func (c *Conn) Dri2WaitSBCUnchecked(Drawable Drawable, TargetSbcHi uint32, TargetSbcLo uint32) Dri2WaitSBCCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.dri2WaitSBCRequest(Drawable, TargetSbcHi, TargetSbcLo), cookie) - return Dri2WaitSBCCookie{cookie} -} - -// Request reply for Dri2WaitSBC -// size: 32 -type Dri2WaitSBCReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - UstHi uint32 - UstLo uint32 - MscHi uint32 - MscLo uint32 - SbcHi uint32 - SbcLo uint32 -} - -// Waits and reads reply data from request Dri2WaitSBC -func (cook Dri2WaitSBCCookie) Reply() (*Dri2WaitSBCReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return dri2WaitSBCReply(buf), nil -} - -// Read reply into structure from buffer for Dri2WaitSBC -func dri2WaitSBCReply(buf []byte) *Dri2WaitSBCReply { - v := new(Dri2WaitSBCReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.UstHi = Get32(buf[b:]) - b += 4 - - v.UstLo = Get32(buf[b:]) - b += 4 - - v.MscHi = Get32(buf[b:]) - b += 4 - - v.MscLo = Get32(buf[b:]) - b += 4 - - v.SbcHi = Get32(buf[b:]) - b += 4 - - v.SbcLo = Get32(buf[b:]) - b += 4 - - return v -} - -func (cook Dri2WaitSBCCookie) Check() error { - return cook.check() -} - -// Write request to wire for Dri2WaitSBC -func (c *Conn) dri2WaitSBCRequest(Drawable Drawable, TargetSbcHi uint32, TargetSbcLo uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["DRI2"] - b += 1 - - buf[b] = 11 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], TargetSbcHi) - b += 4 - - Put32(buf[b:], TargetSbcLo) - b += 4 - - return buf -} - -// Request Dri2SwapInterval -// size: 12 -type Dri2SwapIntervalCookie struct { - *cookie -} - -// Write request to wire for Dri2SwapInterval -func (c *Conn) Dri2SwapInterval(Drawable Drawable, Interval uint32) Dri2SwapIntervalCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.dri2SwapIntervalRequest(Drawable, Interval), cookie) - return Dri2SwapIntervalCookie{cookie} -} - -func (c *Conn) Dri2SwapIntervalChecked(Drawable Drawable, Interval uint32) Dri2SwapIntervalCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.dri2SwapIntervalRequest(Drawable, Interval), cookie) - return Dri2SwapIntervalCookie{cookie} -} - -func (cook Dri2SwapIntervalCookie) Check() error { - return cook.check() -} - -// Write request to wire for Dri2SwapInterval -func (c *Conn) dri2SwapIntervalRequest(Drawable Drawable, Interval uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["DRI2"] - b += 1 - - buf[b] = 12 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], Interval) - b += 4 - - return buf -} diff --git a/nexgb/auto_ge.go b/nexgb/auto_ge.go deleted file mode 100644 index 3d1b00c..0000000 --- a/nexgb/auto_ge.go +++ /dev/null @@ -1,151 +0,0 @@ -package xgb - -/* - This file was generated by ge.xml on May 10 2012 12:39:33pm EDT. - This file is automatically generated. Edit at your peril! -*/ - -// GeInit must be called before using the Generic Event Extension extension. -func (c *Conn) GeInit() error { - reply, err := c.QueryExtension(23, "Generic Event Extension").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named Generic Event Extension could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["Generic Event Extension"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["Generic Event Extension"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["Generic Event Extension"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["Generic Event Extension"] = make(map[int]newEventFun) - newExtErrorFuncs["Generic Event Extension"] = make(map[int]newErrorFun) -} - -// Skipping definition for base type 'Int8' - -// Skipping definition for base type 'Card16' - -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - -// Skipping definition for base type 'Float' - -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - -// Request GeQueryVersion -// size: 8 -type GeQueryVersionCookie struct { - *cookie -} - -func (c *Conn) GeQueryVersion(ClientMajorVersion uint16, ClientMinorVersion uint16) GeQueryVersionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.geQueryVersionRequest(ClientMajorVersion, ClientMinorVersion), cookie) - return GeQueryVersionCookie{cookie} -} - -func (c *Conn) GeQueryVersionUnchecked(ClientMajorVersion uint16, ClientMinorVersion uint16) GeQueryVersionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.geQueryVersionRequest(ClientMajorVersion, ClientMinorVersion), cookie) - return GeQueryVersionCookie{cookie} -} - -// Request reply for GeQueryVersion -// size: 32 -type GeQueryVersionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - MajorVersion uint16 - MinorVersion uint16 - // padding: 20 bytes -} - -// Waits and reads reply data from request GeQueryVersion -func (cook GeQueryVersionCookie) Reply() (*GeQueryVersionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return geQueryVersionReply(buf), nil -} - -// Read reply into structure from buffer for GeQueryVersion -func geQueryVersionReply(buf []byte) *GeQueryVersionReply { - v := new(GeQueryVersionReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.MajorVersion = Get16(buf[b:]) - b += 2 - - v.MinorVersion = Get16(buf[b:]) - b += 2 - - b += 20 // padding - - return v -} - -func (cook GeQueryVersionCookie) Check() error { - return cook.check() -} - -// Write request to wire for GeQueryVersion -func (c *Conn) geQueryVersionRequest(ClientMajorVersion uint16, ClientMinorVersion uint16) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GENERIC EVENT EXTENSION"] - b += 1 - - buf[b] = 0 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], ClientMajorVersion) - b += 2 - - Put16(buf[b:], ClientMinorVersion) - b += 2 - - return buf -} diff --git a/nexgb/auto_glx.go b/nexgb/auto_glx.go deleted file mode 100644 index 0fe0f61..0000000 --- a/nexgb/auto_glx.go +++ /dev/null @@ -1,9430 +0,0 @@ -package xgb - -/* - This file was generated by glx.xml on May 10 2012 12:39:33pm EDT. - This file is automatically generated. Edit at your peril! -*/ - -// Imports are not necessary for XGB because everything is -// in one package. They are still listed here for reference. -// import "xproto" - -// GlxInit must be called before using the GLX extension. -func (c *Conn) GlxInit() error { - reply, err := c.QueryExtension(3, "GLX").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named GLX could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["GLX"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["GLX"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["GLX"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["GLX"] = make(map[int]newEventFun) - newExtErrorFuncs["GLX"] = make(map[int]newErrorFun) -} - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - -// Skipping definition for base type 'Int8' - -// Skipping definition for base type 'Card16' - -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - -// Skipping definition for base type 'Float' - -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -const ( - GlxPbcetDamaged = 32791 - GlxPbcetSaved = 32792 -) - -const ( - GlxPbcdtWindow = 32793 - GlxPbcdtPbuffer = 32794 -) - -const ( - GlxGcGlCurrentBit = 1 - GlxGcGlPointBit = 2 - GlxGcGlLineBit = 4 - GlxGcGlPolygonBit = 8 - GlxGcGlPolygonStippleBit = 16 - GlxGcGlPixelModeBit = 32 - GlxGcGlLightingBit = 64 - GlxGcGlFogBit = 128 - GlxGcGlDepthBufferBit = 256 - GlxGcGlAccumBufferBit = 512 - GlxGcGlStencilBufferBit = 1024 - GlxGcGlViewportBit = 2048 - GlxGcGlTransformBit = 4096 - GlxGcGlEnableBit = 8192 - GlxGcGlColorBufferBit = 16384 - GlxGcGlHintBit = 32768 - GlxGcGlEvalBit = 65536 - GlxGcGlListBit = 131072 - GlxGcGlTextureBit = 262144 - GlxGcGlScissorBit = 524288 - GlxGcGlAllAttribBits = 16777215 -) - -const ( - GlxRmGlRender = 7168 - GlxRmGlFeedback = 7169 - GlxRmGlSelect = 7170 -) - -type GlxPixmap uint32 - -func (c *Conn) NewGlxPixmapId() (GlxPixmap, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return GlxPixmap(id), nil -} - -type GlxContext uint32 - -func (c *Conn) NewGlxContextId() (GlxContext, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return GlxContext(id), nil -} - -type GlxPbuffer uint32 - -func (c *Conn) NewGlxPbufferId() (GlxPbuffer, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return GlxPbuffer(id), nil -} - -type GlxWindow uint32 - -func (c *Conn) NewGlxWindowId() (GlxWindow, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return GlxWindow(id), nil -} - -type GlxFbconfig uint32 - -func (c *Conn) NewGlxFbconfigId() (GlxFbconfig, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return GlxFbconfig(id), nil -} - -type GlxDrawable uint32 - -func (c *Conn) NewGlxDrawableId() (GlxDrawable, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return GlxDrawable(id), nil -} - -type GlxFloat32 float64 - -type GlxFloat64 float64 - -type GlxBool32 uint32 - -type GlxContextTag uint32 - -// Event definition GlxPbufferClobber (0) -// Size: 32 - -const GlxPbufferClobber = 0 - -type GlxPbufferClobberEvent struct { - Sequence uint16 - // padding: 1 bytes - EventType uint16 - DrawType uint16 - Drawable GlxDrawable - BMask uint32 - AuxBuffer uint16 - X uint16 - Y uint16 - Width uint16 - Height uint16 - Count uint16 - // padding: 4 bytes -} - -// Event read GlxPbufferClobber -func NewGlxPbufferClobberEvent(buf []byte) Event { - v := GlxPbufferClobberEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.EventType = Get16(buf[b:]) - b += 2 - - v.DrawType = Get16(buf[b:]) - b += 2 - - v.Drawable = GlxDrawable(Get32(buf[b:])) - b += 4 - - v.BMask = Get32(buf[b:]) - b += 4 - - v.AuxBuffer = Get16(buf[b:]) - b += 2 - - v.X = Get16(buf[b:]) - b += 2 - - v.Y = Get16(buf[b:]) - b += 2 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - v.Count = Get16(buf[b:]) - b += 2 - - b += 4 // padding - - return v -} - -// Event write GlxPbufferClobber -func (v GlxPbufferClobberEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 0 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put16(buf[b:], v.EventType) - b += 2 - - Put16(buf[b:], v.DrawType) - b += 2 - - Put32(buf[b:], uint32(v.Drawable)) - b += 4 - - Put32(buf[b:], v.BMask) - b += 4 - - Put16(buf[b:], v.AuxBuffer) - b += 2 - - Put16(buf[b:], v.X) - b += 2 - - Put16(buf[b:], v.Y) - b += 2 - - Put16(buf[b:], v.Width) - b += 2 - - Put16(buf[b:], v.Height) - b += 2 - - Put16(buf[b:], v.Count) - b += 2 - - b += 4 // padding - - return buf -} - -func (v GlxPbufferClobberEvent) ImplementsEvent() {} - -func (v GlxPbufferClobberEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v GlxPbufferClobberEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("EventType: %d", v.EventType)) - fieldVals = append(fieldVals, sprintf("DrawType: %d", v.DrawType)) - fieldVals = append(fieldVals, sprintf("Drawable: %d", v.Drawable)) - fieldVals = append(fieldVals, sprintf("BMask: %d", v.BMask)) - fieldVals = append(fieldVals, sprintf("AuxBuffer: %d", v.AuxBuffer)) - fieldVals = append(fieldVals, sprintf("X: %d", v.X)) - fieldVals = append(fieldVals, sprintf("Y: %d", v.Y)) - fieldVals = append(fieldVals, sprintf("Width: %d", v.Width)) - fieldVals = append(fieldVals, sprintf("Height: %d", v.Height)) - fieldVals = append(fieldVals, sprintf("Count: %d", v.Count)) - return "GlxPbufferClobber {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["GLX"][0] = NewGlxPbufferClobberEvent -} - -// Error definition GlxGeneric (-1) -// Size: 32 - -const BadGlxGeneric = -1 - -type GlxGenericError struct { - Sequence uint16 - NiceName string - BadValue uint32 - MinorOpcode uint16 - MajorOpcode byte - // padding: 21 bytes -} - -// Error read GlxGeneric -func NewGlxGenericError(buf []byte) Error { - v := GlxGenericError{} - v.NiceName = "GlxGeneric" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.BadValue = Get32(buf[b:]) - b += 4 - - v.MinorOpcode = Get16(buf[b:]) - b += 2 - - v.MajorOpcode = buf[b] - b += 1 - - b += 21 // padding - - return v -} - -func (err GlxGenericError) ImplementsError() {} - -func (err GlxGenericError) SequenceId() uint16 { - return err.Sequence -} - -func (err GlxGenericError) BadId() uint32 { - return 0 -} - -func (err GlxGenericError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadGlxGeneric {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["GLX"][-1] = NewGlxGenericError -} - -// ErrorCopy definition GlxBadContext (0) - -const BadGlxBadContext = 0 - -type GlxBadContextError GlxGenericError - -func NewGlxBadContextError(buf []byte) Error { - v := GlxBadContextError(NewGlxGenericError(buf).(GlxGenericError)) - v.NiceName = "GlxBadContext" - return v -} - -func (err GlxBadContextError) ImplementsError() {} - -func (err GlxBadContextError) SequenceId() uint16 { - return err.Sequence -} - -func (err GlxBadContextError) BadId() uint32 { - return 0 -} - -func (err GlxBadContextError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadGlxBadContext {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["GLX"][0] = NewGlxBadContextError -} - -// ErrorCopy definition GlxBadContextState (1) - -const BadGlxBadContextState = 1 - -type GlxBadContextStateError GlxGenericError - -func NewGlxBadContextStateError(buf []byte) Error { - v := GlxBadContextStateError(NewGlxGenericError(buf).(GlxGenericError)) - v.NiceName = "GlxBadContextState" - return v -} - -func (err GlxBadContextStateError) ImplementsError() {} - -func (err GlxBadContextStateError) SequenceId() uint16 { - return err.Sequence -} - -func (err GlxBadContextStateError) BadId() uint32 { - return 0 -} - -func (err GlxBadContextStateError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadGlxBadContextState {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["GLX"][1] = NewGlxBadContextStateError -} - -// ErrorCopy definition GlxBadDrawable (2) - -const BadGlxBadDrawable = 2 - -type GlxBadDrawableError GlxGenericError - -func NewGlxBadDrawableError(buf []byte) Error { - v := GlxBadDrawableError(NewGlxGenericError(buf).(GlxGenericError)) - v.NiceName = "GlxBadDrawable" - return v -} - -func (err GlxBadDrawableError) ImplementsError() {} - -func (err GlxBadDrawableError) SequenceId() uint16 { - return err.Sequence -} - -func (err GlxBadDrawableError) BadId() uint32 { - return 0 -} - -func (err GlxBadDrawableError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadGlxBadDrawable {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["GLX"][2] = NewGlxBadDrawableError -} - -// ErrorCopy definition GlxBadPixmap (3) - -const BadGlxBadPixmap = 3 - -type GlxBadPixmapError GlxGenericError - -func NewGlxBadPixmapError(buf []byte) Error { - v := GlxBadPixmapError(NewGlxGenericError(buf).(GlxGenericError)) - v.NiceName = "GlxBadPixmap" - return v -} - -func (err GlxBadPixmapError) ImplementsError() {} - -func (err GlxBadPixmapError) SequenceId() uint16 { - return err.Sequence -} - -func (err GlxBadPixmapError) BadId() uint32 { - return 0 -} - -func (err GlxBadPixmapError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadGlxBadPixmap {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["GLX"][3] = NewGlxBadPixmapError -} - -// ErrorCopy definition GlxBadContextTag (4) - -const BadGlxBadContextTag = 4 - -type GlxBadContextTagError GlxGenericError - -func NewGlxBadContextTagError(buf []byte) Error { - v := GlxBadContextTagError(NewGlxGenericError(buf).(GlxGenericError)) - v.NiceName = "GlxBadContextTag" - return v -} - -func (err GlxBadContextTagError) ImplementsError() {} - -func (err GlxBadContextTagError) SequenceId() uint16 { - return err.Sequence -} - -func (err GlxBadContextTagError) BadId() uint32 { - return 0 -} - -func (err GlxBadContextTagError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadGlxBadContextTag {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["GLX"][4] = NewGlxBadContextTagError -} - -// ErrorCopy definition GlxBadCurrentWindow (5) - -const BadGlxBadCurrentWindow = 5 - -type GlxBadCurrentWindowError GlxGenericError - -func NewGlxBadCurrentWindowError(buf []byte) Error { - v := GlxBadCurrentWindowError(NewGlxGenericError(buf).(GlxGenericError)) - v.NiceName = "GlxBadCurrentWindow" - return v -} - -func (err GlxBadCurrentWindowError) ImplementsError() {} - -func (err GlxBadCurrentWindowError) SequenceId() uint16 { - return err.Sequence -} - -func (err GlxBadCurrentWindowError) BadId() uint32 { - return 0 -} - -func (err GlxBadCurrentWindowError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadGlxBadCurrentWindow {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["GLX"][5] = NewGlxBadCurrentWindowError -} - -// ErrorCopy definition GlxBadRenderRequest (6) - -const BadGlxBadRenderRequest = 6 - -type GlxBadRenderRequestError GlxGenericError - -func NewGlxBadRenderRequestError(buf []byte) Error { - v := GlxBadRenderRequestError(NewGlxGenericError(buf).(GlxGenericError)) - v.NiceName = "GlxBadRenderRequest" - return v -} - -func (err GlxBadRenderRequestError) ImplementsError() {} - -func (err GlxBadRenderRequestError) SequenceId() uint16 { - return err.Sequence -} - -func (err GlxBadRenderRequestError) BadId() uint32 { - return 0 -} - -func (err GlxBadRenderRequestError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadGlxBadRenderRequest {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["GLX"][6] = NewGlxBadRenderRequestError -} - -// ErrorCopy definition GlxBadLargeRequest (7) - -const BadGlxBadLargeRequest = 7 - -type GlxBadLargeRequestError GlxGenericError - -func NewGlxBadLargeRequestError(buf []byte) Error { - v := GlxBadLargeRequestError(NewGlxGenericError(buf).(GlxGenericError)) - v.NiceName = "GlxBadLargeRequest" - return v -} - -func (err GlxBadLargeRequestError) ImplementsError() {} - -func (err GlxBadLargeRequestError) SequenceId() uint16 { - return err.Sequence -} - -func (err GlxBadLargeRequestError) BadId() uint32 { - return 0 -} - -func (err GlxBadLargeRequestError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadGlxBadLargeRequest {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["GLX"][7] = NewGlxBadLargeRequestError -} - -// ErrorCopy definition GlxUnsupportedPrivateRequest (8) - -const BadGlxUnsupportedPrivateRequest = 8 - -type GlxUnsupportedPrivateRequestError GlxGenericError - -func NewGlxUnsupportedPrivateRequestError(buf []byte) Error { - v := GlxUnsupportedPrivateRequestError(NewGlxGenericError(buf).(GlxGenericError)) - v.NiceName = "GlxUnsupportedPrivateRequest" - return v -} - -func (err GlxUnsupportedPrivateRequestError) ImplementsError() {} - -func (err GlxUnsupportedPrivateRequestError) SequenceId() uint16 { - return err.Sequence -} - -func (err GlxUnsupportedPrivateRequestError) BadId() uint32 { - return 0 -} - -func (err GlxUnsupportedPrivateRequestError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadGlxUnsupportedPrivateRequest {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["GLX"][8] = NewGlxUnsupportedPrivateRequestError -} - -// ErrorCopy definition GlxBadFBConfig (9) - -const BadGlxBadFBConfig = 9 - -type GlxBadFBConfigError GlxGenericError - -func NewGlxBadFBConfigError(buf []byte) Error { - v := GlxBadFBConfigError(NewGlxGenericError(buf).(GlxGenericError)) - v.NiceName = "GlxBadFBConfig" - return v -} - -func (err GlxBadFBConfigError) ImplementsError() {} - -func (err GlxBadFBConfigError) SequenceId() uint16 { - return err.Sequence -} - -func (err GlxBadFBConfigError) BadId() uint32 { - return 0 -} - -func (err GlxBadFBConfigError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadGlxBadFBConfig {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["GLX"][9] = NewGlxBadFBConfigError -} - -// ErrorCopy definition GlxBadPbuffer (10) - -const BadGlxBadPbuffer = 10 - -type GlxBadPbufferError GlxGenericError - -func NewGlxBadPbufferError(buf []byte) Error { - v := GlxBadPbufferError(NewGlxGenericError(buf).(GlxGenericError)) - v.NiceName = "GlxBadPbuffer" - return v -} - -func (err GlxBadPbufferError) ImplementsError() {} - -func (err GlxBadPbufferError) SequenceId() uint16 { - return err.Sequence -} - -func (err GlxBadPbufferError) BadId() uint32 { - return 0 -} - -func (err GlxBadPbufferError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadGlxBadPbuffer {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["GLX"][10] = NewGlxBadPbufferError -} - -// ErrorCopy definition GlxBadCurrentDrawable (11) - -const BadGlxBadCurrentDrawable = 11 - -type GlxBadCurrentDrawableError GlxGenericError - -func NewGlxBadCurrentDrawableError(buf []byte) Error { - v := GlxBadCurrentDrawableError(NewGlxGenericError(buf).(GlxGenericError)) - v.NiceName = "GlxBadCurrentDrawable" - return v -} - -func (err GlxBadCurrentDrawableError) ImplementsError() {} - -func (err GlxBadCurrentDrawableError) SequenceId() uint16 { - return err.Sequence -} - -func (err GlxBadCurrentDrawableError) BadId() uint32 { - return 0 -} - -func (err GlxBadCurrentDrawableError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadGlxBadCurrentDrawable {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["GLX"][11] = NewGlxBadCurrentDrawableError -} - -// ErrorCopy definition GlxBadWindow (12) - -const BadGlxBadWindow = 12 - -type GlxBadWindowError GlxGenericError - -func NewGlxBadWindowError(buf []byte) Error { - v := GlxBadWindowError(NewGlxGenericError(buf).(GlxGenericError)) - v.NiceName = "GlxBadWindow" - return v -} - -func (err GlxBadWindowError) ImplementsError() {} - -func (err GlxBadWindowError) SequenceId() uint16 { - return err.Sequence -} - -func (err GlxBadWindowError) BadId() uint32 { - return 0 -} - -func (err GlxBadWindowError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadGlxBadWindow {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["GLX"][12] = NewGlxBadWindowError -} - -// ErrorCopy definition GlxGLXBadProfileARB (13) - -const BadGlxGLXBadProfileARB = 13 - -type GlxGLXBadProfileARBError GlxGenericError - -func NewGlxGLXBadProfileARBError(buf []byte) Error { - v := GlxGLXBadProfileARBError(NewGlxGenericError(buf).(GlxGenericError)) - v.NiceName = "GlxGLXBadProfileARB" - return v -} - -func (err GlxGLXBadProfileARBError) ImplementsError() {} - -func (err GlxGLXBadProfileARBError) SequenceId() uint16 { - return err.Sequence -} - -func (err GlxGLXBadProfileARBError) BadId() uint32 { - return 0 -} - -func (err GlxGLXBadProfileARBError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadGlxGLXBadProfileARB {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["GLX"][13] = NewGlxGLXBadProfileARBError -} - -// Request GlxRender -// size: pad((8 + pad((len(Data) * 1)))) -type GlxRenderCookie struct { - *cookie -} - -// Write request to wire for GlxRender -func (c *Conn) GlxRender(ContextTag GlxContextTag, Data []byte) GlxRenderCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxRenderRequest(ContextTag, Data), cookie) - return GlxRenderCookie{cookie} -} - -func (c *Conn) GlxRenderChecked(ContextTag GlxContextTag, Data []byte) GlxRenderCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxRenderRequest(ContextTag, Data), cookie) - return GlxRenderCookie{cookie} -} - -func (cook GlxRenderCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxRender -func (c *Conn) glxRenderRequest(ContextTag GlxContextTag, Data []byte) []byte { - size := pad((8 + pad((len(Data) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 1 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - copy(buf[b:], Data[:len(Data)]) - b += pad(int(len(Data))) - - return buf -} - -// Request GlxRenderLarge -// size: pad((16 + pad((int(DataLen) * 1)))) -type GlxRenderLargeCookie struct { - *cookie -} - -// Write request to wire for GlxRenderLarge -func (c *Conn) GlxRenderLarge(ContextTag GlxContextTag, RequestNum uint16, RequestTotal uint16, DataLen uint32, Data []byte) GlxRenderLargeCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxRenderLargeRequest(ContextTag, RequestNum, RequestTotal, DataLen, Data), cookie) - return GlxRenderLargeCookie{cookie} -} - -func (c *Conn) GlxRenderLargeChecked(ContextTag GlxContextTag, RequestNum uint16, RequestTotal uint16, DataLen uint32, Data []byte) GlxRenderLargeCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxRenderLargeRequest(ContextTag, RequestNum, RequestTotal, DataLen, Data), cookie) - return GlxRenderLargeCookie{cookie} -} - -func (cook GlxRenderLargeCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxRenderLarge -func (c *Conn) glxRenderLargeRequest(ContextTag GlxContextTag, RequestNum uint16, RequestTotal uint16, DataLen uint32, Data []byte) []byte { - size := pad((16 + pad((int(DataLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 2 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put16(buf[b:], RequestNum) - b += 2 - - Put16(buf[b:], RequestTotal) - b += 2 - - Put32(buf[b:], DataLen) - b += 4 - - copy(buf[b:], Data[:DataLen]) - b += pad(int(DataLen)) - - return buf -} - -// Request GlxCreateContext -// size: 24 -type GlxCreateContextCookie struct { - *cookie -} - -// Write request to wire for GlxCreateContext -func (c *Conn) GlxCreateContext(Context GlxContext, Visual Visualid, Screen uint32, ShareList GlxContext, IsDirect bool) GlxCreateContextCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxCreateContextRequest(Context, Visual, Screen, ShareList, IsDirect), cookie) - return GlxCreateContextCookie{cookie} -} - -func (c *Conn) GlxCreateContextChecked(Context GlxContext, Visual Visualid, Screen uint32, ShareList GlxContext, IsDirect bool) GlxCreateContextCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxCreateContextRequest(Context, Visual, Screen, ShareList, IsDirect), cookie) - return GlxCreateContextCookie{cookie} -} - -func (cook GlxCreateContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxCreateContext -func (c *Conn) glxCreateContextRequest(Context GlxContext, Visual Visualid, Screen uint32, ShareList GlxContext, IsDirect bool) []byte { - size := 24 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 3 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Context)) - b += 4 - - Put32(buf[b:], uint32(Visual)) - b += 4 - - Put32(buf[b:], Screen) - b += 4 - - Put32(buf[b:], uint32(ShareList)) - b += 4 - - if IsDirect { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 3 // padding - - return buf -} - -// Request GlxDestroyContext -// size: 8 -type GlxDestroyContextCookie struct { - *cookie -} - -// Write request to wire for GlxDestroyContext -func (c *Conn) GlxDestroyContext(Context GlxContext) GlxDestroyContextCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxDestroyContextRequest(Context), cookie) - return GlxDestroyContextCookie{cookie} -} - -func (c *Conn) GlxDestroyContextChecked(Context GlxContext) GlxDestroyContextCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxDestroyContextRequest(Context), cookie) - return GlxDestroyContextCookie{cookie} -} - -func (cook GlxDestroyContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxDestroyContext -func (c *Conn) glxDestroyContextRequest(Context GlxContext) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 4 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Context)) - b += 4 - - return buf -} - -// Request GlxMakeCurrent -// size: 16 -type GlxMakeCurrentCookie struct { - *cookie -} - -func (c *Conn) GlxMakeCurrent(Drawable GlxDrawable, Context GlxContext, OldContextTag GlxContextTag) GlxMakeCurrentCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxMakeCurrentRequest(Drawable, Context, OldContextTag), cookie) - return GlxMakeCurrentCookie{cookie} -} - -func (c *Conn) GlxMakeCurrentUnchecked(Drawable GlxDrawable, Context GlxContext, OldContextTag GlxContextTag) GlxMakeCurrentCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxMakeCurrentRequest(Drawable, Context, OldContextTag), cookie) - return GlxMakeCurrentCookie{cookie} -} - -// Request reply for GlxMakeCurrent -// size: 32 -type GlxMakeCurrentReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ContextTag GlxContextTag - // padding: 20 bytes -} - -// Waits and reads reply data from request GlxMakeCurrent -func (cook GlxMakeCurrentCookie) Reply() (*GlxMakeCurrentReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxMakeCurrentReply(buf), nil -} - -// Read reply into structure from buffer for GlxMakeCurrent -func glxMakeCurrentReply(buf []byte) *GlxMakeCurrentReply { - v := new(GlxMakeCurrentReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.ContextTag = GlxContextTag(Get32(buf[b:])) - b += 4 - - b += 20 // padding - - return v -} - -func (cook GlxMakeCurrentCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxMakeCurrent -func (c *Conn) glxMakeCurrentRequest(Drawable GlxDrawable, Context GlxContext, OldContextTag GlxContextTag) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 5 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], uint32(Context)) - b += 4 - - Put32(buf[b:], uint32(OldContextTag)) - b += 4 - - return buf -} - -// Request GlxIsDirect -// size: 8 -type GlxIsDirectCookie struct { - *cookie -} - -func (c *Conn) GlxIsDirect(Context GlxContext) GlxIsDirectCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxIsDirectRequest(Context), cookie) - return GlxIsDirectCookie{cookie} -} - -func (c *Conn) GlxIsDirectUnchecked(Context GlxContext) GlxIsDirectCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxIsDirectRequest(Context), cookie) - return GlxIsDirectCookie{cookie} -} - -// Request reply for GlxIsDirect -// size: 32 -type GlxIsDirectReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - IsDirect bool - // padding: 23 bytes -} - -// Waits and reads reply data from request GlxIsDirect -func (cook GlxIsDirectCookie) Reply() (*GlxIsDirectReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxIsDirectReply(buf), nil -} - -// Read reply into structure from buffer for GlxIsDirect -func glxIsDirectReply(buf []byte) *GlxIsDirectReply { - v := new(GlxIsDirectReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - if buf[b] == 1 { - v.IsDirect = true - } else { - v.IsDirect = false - } - b += 1 - - b += 23 // padding - - return v -} - -func (cook GlxIsDirectCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxIsDirect -func (c *Conn) glxIsDirectRequest(Context GlxContext) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 6 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Context)) - b += 4 - - return buf -} - -// Request GlxQueryVersion -// size: 12 -type GlxQueryVersionCookie struct { - *cookie -} - -func (c *Conn) GlxQueryVersion(MajorVersion uint32, MinorVersion uint32) GlxQueryVersionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxQueryVersionRequest(MajorVersion, MinorVersion), cookie) - return GlxQueryVersionCookie{cookie} -} - -func (c *Conn) GlxQueryVersionUnchecked(MajorVersion uint32, MinorVersion uint32) GlxQueryVersionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxQueryVersionRequest(MajorVersion, MinorVersion), cookie) - return GlxQueryVersionCookie{cookie} -} - -// Request reply for GlxQueryVersion -// size: 32 -type GlxQueryVersionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - MajorVersion uint32 - MinorVersion uint32 - // padding: 16 bytes -} - -// Waits and reads reply data from request GlxQueryVersion -func (cook GlxQueryVersionCookie) Reply() (*GlxQueryVersionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxQueryVersionReply(buf), nil -} - -// Read reply into structure from buffer for GlxQueryVersion -func glxQueryVersionReply(buf []byte) *GlxQueryVersionReply { - v := new(GlxQueryVersionReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.MajorVersion = Get32(buf[b:]) - b += 4 - - v.MinorVersion = Get32(buf[b:]) - b += 4 - - b += 16 // padding - - return v -} - -func (cook GlxQueryVersionCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxQueryVersion -func (c *Conn) glxQueryVersionRequest(MajorVersion uint32, MinorVersion uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 7 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], MajorVersion) - b += 4 - - Put32(buf[b:], MinorVersion) - b += 4 - - return buf -} - -// Request GlxWaitGL -// size: 8 -type GlxWaitGLCookie struct { - *cookie -} - -// Write request to wire for GlxWaitGL -func (c *Conn) GlxWaitGL(ContextTag GlxContextTag) GlxWaitGLCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxWaitGLRequest(ContextTag), cookie) - return GlxWaitGLCookie{cookie} -} - -func (c *Conn) GlxWaitGLChecked(ContextTag GlxContextTag) GlxWaitGLCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxWaitGLRequest(ContextTag), cookie) - return GlxWaitGLCookie{cookie} -} - -func (cook GlxWaitGLCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxWaitGL -func (c *Conn) glxWaitGLRequest(ContextTag GlxContextTag) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 8 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - return buf -} - -// Request GlxWaitX -// size: 8 -type GlxWaitXCookie struct { - *cookie -} - -// Write request to wire for GlxWaitX -func (c *Conn) GlxWaitX(ContextTag GlxContextTag) GlxWaitXCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxWaitXRequest(ContextTag), cookie) - return GlxWaitXCookie{cookie} -} - -func (c *Conn) GlxWaitXChecked(ContextTag GlxContextTag) GlxWaitXCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxWaitXRequest(ContextTag), cookie) - return GlxWaitXCookie{cookie} -} - -func (cook GlxWaitXCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxWaitX -func (c *Conn) glxWaitXRequest(ContextTag GlxContextTag) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 9 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - return buf -} - -// Request GlxCopyContext -// size: 20 -type GlxCopyContextCookie struct { - *cookie -} - -// Write request to wire for GlxCopyContext -func (c *Conn) GlxCopyContext(Src GlxContext, Dest GlxContext, Mask uint32, SrcContextTag GlxContextTag) GlxCopyContextCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxCopyContextRequest(Src, Dest, Mask, SrcContextTag), cookie) - return GlxCopyContextCookie{cookie} -} - -func (c *Conn) GlxCopyContextChecked(Src GlxContext, Dest GlxContext, Mask uint32, SrcContextTag GlxContextTag) GlxCopyContextCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxCopyContextRequest(Src, Dest, Mask, SrcContextTag), cookie) - return GlxCopyContextCookie{cookie} -} - -func (cook GlxCopyContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxCopyContext -func (c *Conn) glxCopyContextRequest(Src GlxContext, Dest GlxContext, Mask uint32, SrcContextTag GlxContextTag) []byte { - size := 20 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 10 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Src)) - b += 4 - - Put32(buf[b:], uint32(Dest)) - b += 4 - - Put32(buf[b:], Mask) - b += 4 - - Put32(buf[b:], uint32(SrcContextTag)) - b += 4 - - return buf -} - -// Request GlxSwapBuffers -// size: 12 -type GlxSwapBuffersCookie struct { - *cookie -} - -// Write request to wire for GlxSwapBuffers -func (c *Conn) GlxSwapBuffers(ContextTag GlxContextTag, Drawable GlxDrawable) GlxSwapBuffersCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxSwapBuffersRequest(ContextTag, Drawable), cookie) - return GlxSwapBuffersCookie{cookie} -} - -func (c *Conn) GlxSwapBuffersChecked(ContextTag GlxContextTag, Drawable GlxDrawable) GlxSwapBuffersCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxSwapBuffersRequest(ContextTag, Drawable), cookie) - return GlxSwapBuffersCookie{cookie} -} - -func (cook GlxSwapBuffersCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxSwapBuffers -func (c *Conn) glxSwapBuffersRequest(ContextTag GlxContextTag, Drawable GlxDrawable) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 11 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - return buf -} - -// Request GlxUseXFont -// size: 24 -type GlxUseXFontCookie struct { - *cookie -} - -// Write request to wire for GlxUseXFont -func (c *Conn) GlxUseXFont(ContextTag GlxContextTag, Font Font, First uint32, Count uint32, ListBase uint32) GlxUseXFontCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxUseXFontRequest(ContextTag, Font, First, Count, ListBase), cookie) - return GlxUseXFontCookie{cookie} -} - -func (c *Conn) GlxUseXFontChecked(ContextTag GlxContextTag, Font Font, First uint32, Count uint32, ListBase uint32) GlxUseXFontCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxUseXFontRequest(ContextTag, Font, First, Count, ListBase), cookie) - return GlxUseXFontCookie{cookie} -} - -func (cook GlxUseXFontCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxUseXFont -func (c *Conn) glxUseXFontRequest(ContextTag GlxContextTag, Font Font, First uint32, Count uint32, ListBase uint32) []byte { - size := 24 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 12 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], uint32(Font)) - b += 4 - - Put32(buf[b:], First) - b += 4 - - Put32(buf[b:], Count) - b += 4 - - Put32(buf[b:], ListBase) - b += 4 - - return buf -} - -// Request GlxCreateGLXPixmap -// size: 20 -type GlxCreateGLXPixmapCookie struct { - *cookie -} - -// Write request to wire for GlxCreateGLXPixmap -func (c *Conn) GlxCreateGLXPixmap(Screen uint32, Visual Visualid, Pixmap Pixmap, GlxPixmap GlxPixmap) GlxCreateGLXPixmapCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxCreateGLXPixmapRequest(Screen, Visual, Pixmap, GlxPixmap), cookie) - return GlxCreateGLXPixmapCookie{cookie} -} - -func (c *Conn) GlxCreateGLXPixmapChecked(Screen uint32, Visual Visualid, Pixmap Pixmap, GlxPixmap GlxPixmap) GlxCreateGLXPixmapCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxCreateGLXPixmapRequest(Screen, Visual, Pixmap, GlxPixmap), cookie) - return GlxCreateGLXPixmapCookie{cookie} -} - -func (cook GlxCreateGLXPixmapCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxCreateGLXPixmap -func (c *Conn) glxCreateGLXPixmapRequest(Screen uint32, Visual Visualid, Pixmap Pixmap, GlxPixmap GlxPixmap) []byte { - size := 20 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 13 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Screen) - b += 4 - - Put32(buf[b:], uint32(Visual)) - b += 4 - - Put32(buf[b:], uint32(Pixmap)) - b += 4 - - Put32(buf[b:], uint32(GlxPixmap)) - b += 4 - - return buf -} - -// Request GlxGetVisualConfigs -// size: 8 -type GlxGetVisualConfigsCookie struct { - *cookie -} - -func (c *Conn) GlxGetVisualConfigs(Screen uint32) GlxGetVisualConfigsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetVisualConfigsRequest(Screen), cookie) - return GlxGetVisualConfigsCookie{cookie} -} - -func (c *Conn) GlxGetVisualConfigsUnchecked(Screen uint32) GlxGetVisualConfigsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetVisualConfigsRequest(Screen), cookie) - return GlxGetVisualConfigsCookie{cookie} -} - -// Request reply for GlxGetVisualConfigs -// size: (32 + pad((int(Length) * 4))) -type GlxGetVisualConfigsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumVisuals uint32 - NumProperties uint32 - // padding: 16 bytes - PropertyList []uint32 // size: pad((int(Length) * 4)) -} - -// Waits and reads reply data from request GlxGetVisualConfigs -func (cook GlxGetVisualConfigsCookie) Reply() (*GlxGetVisualConfigsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetVisualConfigsReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetVisualConfigs -func glxGetVisualConfigsReply(buf []byte) *GlxGetVisualConfigsReply { - v := new(GlxGetVisualConfigsReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.NumVisuals = Get32(buf[b:]) - b += 4 - - v.NumProperties = Get32(buf[b:]) - b += 4 - - b += 16 // padding - - v.PropertyList = make([]uint32, v.Length) - for i := 0; i < int(v.Length); i++ { - v.PropertyList[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetVisualConfigsCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetVisualConfigs -func (c *Conn) glxGetVisualConfigsRequest(Screen uint32) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 14 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Screen) - b += 4 - - return buf -} - -// Request GlxDestroyGLXPixmap -// size: 8 -type GlxDestroyGLXPixmapCookie struct { - *cookie -} - -// Write request to wire for GlxDestroyGLXPixmap -func (c *Conn) GlxDestroyGLXPixmap(GlxPixmap GlxPixmap) GlxDestroyGLXPixmapCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxDestroyGLXPixmapRequest(GlxPixmap), cookie) - return GlxDestroyGLXPixmapCookie{cookie} -} - -func (c *Conn) GlxDestroyGLXPixmapChecked(GlxPixmap GlxPixmap) GlxDestroyGLXPixmapCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxDestroyGLXPixmapRequest(GlxPixmap), cookie) - return GlxDestroyGLXPixmapCookie{cookie} -} - -func (cook GlxDestroyGLXPixmapCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxDestroyGLXPixmap -func (c *Conn) glxDestroyGLXPixmapRequest(GlxPixmap GlxPixmap) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 15 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(GlxPixmap)) - b += 4 - - return buf -} - -// Request GlxVendorPrivate -// size: pad((12 + pad((len(Data) * 1)))) -type GlxVendorPrivateCookie struct { - *cookie -} - -// Write request to wire for GlxVendorPrivate -func (c *Conn) GlxVendorPrivate(VendorCode uint32, ContextTag GlxContextTag, Data []byte) GlxVendorPrivateCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxVendorPrivateRequest(VendorCode, ContextTag, Data), cookie) - return GlxVendorPrivateCookie{cookie} -} - -func (c *Conn) GlxVendorPrivateChecked(VendorCode uint32, ContextTag GlxContextTag, Data []byte) GlxVendorPrivateCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxVendorPrivateRequest(VendorCode, ContextTag, Data), cookie) - return GlxVendorPrivateCookie{cookie} -} - -func (cook GlxVendorPrivateCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxVendorPrivate -func (c *Conn) glxVendorPrivateRequest(VendorCode uint32, ContextTag GlxContextTag, Data []byte) []byte { - size := pad((12 + pad((len(Data) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 16 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], VendorCode) - b += 4 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - copy(buf[b:], Data[:len(Data)]) - b += pad(int(len(Data))) - - return buf -} - -// Request GlxVendorPrivateWithReply -// size: pad((12 + pad((len(Data) * 1)))) -type GlxVendorPrivateWithReplyCookie struct { - *cookie -} - -func (c *Conn) GlxVendorPrivateWithReply(VendorCode uint32, ContextTag GlxContextTag, Data []byte) GlxVendorPrivateWithReplyCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxVendorPrivateWithReplyRequest(VendorCode, ContextTag, Data), cookie) - return GlxVendorPrivateWithReplyCookie{cookie} -} - -func (c *Conn) GlxVendorPrivateWithReplyUnchecked(VendorCode uint32, ContextTag GlxContextTag, Data []byte) GlxVendorPrivateWithReplyCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxVendorPrivateWithReplyRequest(VendorCode, ContextTag, Data), cookie) - return GlxVendorPrivateWithReplyCookie{cookie} -} - -// Request reply for GlxVendorPrivateWithReply -// size: (36 + pad(((int(Length) * 4) * 1))) -type GlxVendorPrivateWithReplyReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Retval uint32 - Data1 []byte // size: 24 - Data2 []byte // size: pad(((int(Length) * 4) * 1)) -} - -// Waits and reads reply data from request GlxVendorPrivateWithReply -func (cook GlxVendorPrivateWithReplyCookie) Reply() (*GlxVendorPrivateWithReplyReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxVendorPrivateWithReplyReply(buf), nil -} - -// Read reply into structure from buffer for GlxVendorPrivateWithReply -func glxVendorPrivateWithReplyReply(buf []byte) *GlxVendorPrivateWithReplyReply { - v := new(GlxVendorPrivateWithReplyReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Retval = Get32(buf[b:]) - b += 4 - - v.Data1 = make([]byte, 24) - copy(v.Data1[:24], buf[b:]) - b += pad(int(24)) - - v.Data2 = make([]byte, (int(v.Length) * 4)) - copy(v.Data2[:(int(v.Length)*4)], buf[b:]) - b += pad(int((int(v.Length) * 4))) - - return v -} - -func (cook GlxVendorPrivateWithReplyCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxVendorPrivateWithReply -func (c *Conn) glxVendorPrivateWithReplyRequest(VendorCode uint32, ContextTag GlxContextTag, Data []byte) []byte { - size := pad((12 + pad((len(Data) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 17 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], VendorCode) - b += 4 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - copy(buf[b:], Data[:len(Data)]) - b += pad(int(len(Data))) - - return buf -} - -// Request GlxQueryExtensionsString -// size: 8 -type GlxQueryExtensionsStringCookie struct { - *cookie -} - -func (c *Conn) GlxQueryExtensionsString(Screen uint32) GlxQueryExtensionsStringCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxQueryExtensionsStringRequest(Screen), cookie) - return GlxQueryExtensionsStringCookie{cookie} -} - -func (c *Conn) GlxQueryExtensionsStringUnchecked(Screen uint32) GlxQueryExtensionsStringCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxQueryExtensionsStringRequest(Screen), cookie) - return GlxQueryExtensionsStringCookie{cookie} -} - -// Request reply for GlxQueryExtensionsString -// size: 32 -type GlxQueryExtensionsStringReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - // padding: 16 bytes -} - -// Waits and reads reply data from request GlxQueryExtensionsString -func (cook GlxQueryExtensionsStringCookie) Reply() (*GlxQueryExtensionsStringReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxQueryExtensionsStringReply(buf), nil -} - -// Read reply into structure from buffer for GlxQueryExtensionsString -func glxQueryExtensionsStringReply(buf []byte) *GlxQueryExtensionsStringReply { - v := new(GlxQueryExtensionsStringReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - b += 16 // padding - - return v -} - -func (cook GlxQueryExtensionsStringCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxQueryExtensionsString -func (c *Conn) glxQueryExtensionsStringRequest(Screen uint32) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 18 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Screen) - b += 4 - - return buf -} - -// Request GlxQueryServerString -// size: 12 -type GlxQueryServerStringCookie struct { - *cookie -} - -func (c *Conn) GlxQueryServerString(Screen uint32, Name uint32) GlxQueryServerStringCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxQueryServerStringRequest(Screen, Name), cookie) - return GlxQueryServerStringCookie{cookie} -} - -func (c *Conn) GlxQueryServerStringUnchecked(Screen uint32, Name uint32) GlxQueryServerStringCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxQueryServerStringRequest(Screen, Name), cookie) - return GlxQueryServerStringCookie{cookie} -} - -// Request reply for GlxQueryServerString -// size: (32 + pad((int(StrLen) * 1))) -type GlxQueryServerStringReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - StrLen uint32 - // padding: 16 bytes - String string // size: pad((int(StrLen) * 1)) -} - -// Waits and reads reply data from request GlxQueryServerString -func (cook GlxQueryServerStringCookie) Reply() (*GlxQueryServerStringReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxQueryServerStringReply(buf), nil -} - -// Read reply into structure from buffer for GlxQueryServerString -func glxQueryServerStringReply(buf []byte) *GlxQueryServerStringReply { - v := new(GlxQueryServerStringReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.StrLen = Get32(buf[b:]) - b += 4 - - b += 16 // padding - - { - byteString := make([]byte, v.StrLen) - copy(byteString[:v.StrLen], buf[b:]) - v.String = string(byteString) - b += pad(int(v.StrLen)) - } - - return v -} - -func (cook GlxQueryServerStringCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxQueryServerString -func (c *Conn) glxQueryServerStringRequest(Screen uint32, Name uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 19 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Screen) - b += 4 - - Put32(buf[b:], Name) - b += 4 - - return buf -} - -// Request GlxClientInfo -// size: pad((16 + pad((int(StrLen) * 1)))) -type GlxClientInfoCookie struct { - *cookie -} - -// Write request to wire for GlxClientInfo -func (c *Conn) GlxClientInfo(MajorVersion uint32, MinorVersion uint32, StrLen uint32, String string) GlxClientInfoCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxClientInfoRequest(MajorVersion, MinorVersion, StrLen, String), cookie) - return GlxClientInfoCookie{cookie} -} - -func (c *Conn) GlxClientInfoChecked(MajorVersion uint32, MinorVersion uint32, StrLen uint32, String string) GlxClientInfoCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxClientInfoRequest(MajorVersion, MinorVersion, StrLen, String), cookie) - return GlxClientInfoCookie{cookie} -} - -func (cook GlxClientInfoCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxClientInfo -func (c *Conn) glxClientInfoRequest(MajorVersion uint32, MinorVersion uint32, StrLen uint32, String string) []byte { - size := pad((16 + pad((int(StrLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 20 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], MajorVersion) - b += 4 - - Put32(buf[b:], MinorVersion) - b += 4 - - Put32(buf[b:], StrLen) - b += 4 - - copy(buf[b:], String[:StrLen]) - b += pad(int(StrLen)) - - return buf -} - -// Request GlxGetFBConfigs -// size: 8 -type GlxGetFBConfigsCookie struct { - *cookie -} - -func (c *Conn) GlxGetFBConfigs(Screen uint32) GlxGetFBConfigsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetFBConfigsRequest(Screen), cookie) - return GlxGetFBConfigsCookie{cookie} -} - -func (c *Conn) GlxGetFBConfigsUnchecked(Screen uint32) GlxGetFBConfigsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetFBConfigsRequest(Screen), cookie) - return GlxGetFBConfigsCookie{cookie} -} - -// Request reply for GlxGetFBConfigs -// size: (32 + pad((int(Length) * 4))) -type GlxGetFBConfigsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumFbConfigs uint32 - NumProperties uint32 - // padding: 16 bytes - PropertyList []uint32 // size: pad((int(Length) * 4)) -} - -// Waits and reads reply data from request GlxGetFBConfigs -func (cook GlxGetFBConfigsCookie) Reply() (*GlxGetFBConfigsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetFBConfigsReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetFBConfigs -func glxGetFBConfigsReply(buf []byte) *GlxGetFBConfigsReply { - v := new(GlxGetFBConfigsReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.NumFbConfigs = Get32(buf[b:]) - b += 4 - - v.NumProperties = Get32(buf[b:]) - b += 4 - - b += 16 // padding - - v.PropertyList = make([]uint32, v.Length) - for i := 0; i < int(v.Length); i++ { - v.PropertyList[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetFBConfigsCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetFBConfigs -func (c *Conn) glxGetFBConfigsRequest(Screen uint32) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 21 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Screen) - b += 4 - - return buf -} - -// Request GlxCreatePixmap -// size: pad((24 + pad(((int(NumAttribs) * 2) * 4)))) -type GlxCreatePixmapCookie struct { - *cookie -} - -// Write request to wire for GlxCreatePixmap -func (c *Conn) GlxCreatePixmap(Screen uint32, Fbconfig GlxFbconfig, Pixmap Pixmap, GlxPixmap GlxPixmap, NumAttribs uint32, Attribs []uint32) GlxCreatePixmapCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxCreatePixmapRequest(Screen, Fbconfig, Pixmap, GlxPixmap, NumAttribs, Attribs), cookie) - return GlxCreatePixmapCookie{cookie} -} - -func (c *Conn) GlxCreatePixmapChecked(Screen uint32, Fbconfig GlxFbconfig, Pixmap Pixmap, GlxPixmap GlxPixmap, NumAttribs uint32, Attribs []uint32) GlxCreatePixmapCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxCreatePixmapRequest(Screen, Fbconfig, Pixmap, GlxPixmap, NumAttribs, Attribs), cookie) - return GlxCreatePixmapCookie{cookie} -} - -func (cook GlxCreatePixmapCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxCreatePixmap -func (c *Conn) glxCreatePixmapRequest(Screen uint32, Fbconfig GlxFbconfig, Pixmap Pixmap, GlxPixmap GlxPixmap, NumAttribs uint32, Attribs []uint32) []byte { - size := pad((24 + pad(((int(NumAttribs) * 2) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 22 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Screen) - b += 4 - - Put32(buf[b:], uint32(Fbconfig)) - b += 4 - - Put32(buf[b:], uint32(Pixmap)) - b += 4 - - Put32(buf[b:], uint32(GlxPixmap)) - b += 4 - - Put32(buf[b:], NumAttribs) - b += 4 - - for i := 0; i < int((int(NumAttribs) * 2)); i++ { - Put32(buf[b:], Attribs[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Request GlxDestroyPixmap -// size: 8 -type GlxDestroyPixmapCookie struct { - *cookie -} - -// Write request to wire for GlxDestroyPixmap -func (c *Conn) GlxDestroyPixmap(GlxPixmap GlxPixmap) GlxDestroyPixmapCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxDestroyPixmapRequest(GlxPixmap), cookie) - return GlxDestroyPixmapCookie{cookie} -} - -func (c *Conn) GlxDestroyPixmapChecked(GlxPixmap GlxPixmap) GlxDestroyPixmapCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxDestroyPixmapRequest(GlxPixmap), cookie) - return GlxDestroyPixmapCookie{cookie} -} - -func (cook GlxDestroyPixmapCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxDestroyPixmap -func (c *Conn) glxDestroyPixmapRequest(GlxPixmap GlxPixmap) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 23 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(GlxPixmap)) - b += 4 - - return buf -} - -// Request GlxCreateNewContext -// size: 28 -type GlxCreateNewContextCookie struct { - *cookie -} - -// Write request to wire for GlxCreateNewContext -func (c *Conn) GlxCreateNewContext(Context GlxContext, Fbconfig GlxFbconfig, Screen uint32, RenderType uint32, ShareList GlxContext, IsDirect bool) GlxCreateNewContextCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxCreateNewContextRequest(Context, Fbconfig, Screen, RenderType, ShareList, IsDirect), cookie) - return GlxCreateNewContextCookie{cookie} -} - -func (c *Conn) GlxCreateNewContextChecked(Context GlxContext, Fbconfig GlxFbconfig, Screen uint32, RenderType uint32, ShareList GlxContext, IsDirect bool) GlxCreateNewContextCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxCreateNewContextRequest(Context, Fbconfig, Screen, RenderType, ShareList, IsDirect), cookie) - return GlxCreateNewContextCookie{cookie} -} - -func (cook GlxCreateNewContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxCreateNewContext -func (c *Conn) glxCreateNewContextRequest(Context GlxContext, Fbconfig GlxFbconfig, Screen uint32, RenderType uint32, ShareList GlxContext, IsDirect bool) []byte { - size := 28 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 24 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Context)) - b += 4 - - Put32(buf[b:], uint32(Fbconfig)) - b += 4 - - Put32(buf[b:], Screen) - b += 4 - - Put32(buf[b:], RenderType) - b += 4 - - Put32(buf[b:], uint32(ShareList)) - b += 4 - - if IsDirect { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 3 // padding - - return buf -} - -// Request GlxQueryContext -// size: 8 -type GlxQueryContextCookie struct { - *cookie -} - -func (c *Conn) GlxQueryContext(Context GlxContext) GlxQueryContextCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxQueryContextRequest(Context), cookie) - return GlxQueryContextCookie{cookie} -} - -func (c *Conn) GlxQueryContextUnchecked(Context GlxContext) GlxQueryContextCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxQueryContextRequest(Context), cookie) - return GlxQueryContextCookie{cookie} -} - -// Request reply for GlxQueryContext -// size: (32 + pad(((int(NumAttribs) * 2) * 4))) -type GlxQueryContextReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumAttribs uint32 - // padding: 20 bytes - Attribs []uint32 // size: pad(((int(NumAttribs) * 2) * 4)) -} - -// Waits and reads reply data from request GlxQueryContext -func (cook GlxQueryContextCookie) Reply() (*GlxQueryContextReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxQueryContextReply(buf), nil -} - -// Read reply into structure from buffer for GlxQueryContext -func glxQueryContextReply(buf []byte) *GlxQueryContextReply { - v := new(GlxQueryContextReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.NumAttribs = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Attribs = make([]uint32, (int(v.NumAttribs) * 2)) - for i := 0; i < int((int(v.NumAttribs) * 2)); i++ { - v.Attribs[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxQueryContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxQueryContext -func (c *Conn) glxQueryContextRequest(Context GlxContext) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 25 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Context)) - b += 4 - - return buf -} - -// Request GlxMakeContextCurrent -// size: 20 -type GlxMakeContextCurrentCookie struct { - *cookie -} - -func (c *Conn) GlxMakeContextCurrent(OldContextTag GlxContextTag, Drawable GlxDrawable, ReadDrawable GlxDrawable, Context GlxContext) GlxMakeContextCurrentCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxMakeContextCurrentRequest(OldContextTag, Drawable, ReadDrawable, Context), cookie) - return GlxMakeContextCurrentCookie{cookie} -} - -func (c *Conn) GlxMakeContextCurrentUnchecked(OldContextTag GlxContextTag, Drawable GlxDrawable, ReadDrawable GlxDrawable, Context GlxContext) GlxMakeContextCurrentCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxMakeContextCurrentRequest(OldContextTag, Drawable, ReadDrawable, Context), cookie) - return GlxMakeContextCurrentCookie{cookie} -} - -// Request reply for GlxMakeContextCurrent -// size: 32 -type GlxMakeContextCurrentReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ContextTag GlxContextTag - // padding: 20 bytes -} - -// Waits and reads reply data from request GlxMakeContextCurrent -func (cook GlxMakeContextCurrentCookie) Reply() (*GlxMakeContextCurrentReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxMakeContextCurrentReply(buf), nil -} - -// Read reply into structure from buffer for GlxMakeContextCurrent -func glxMakeContextCurrentReply(buf []byte) *GlxMakeContextCurrentReply { - v := new(GlxMakeContextCurrentReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.ContextTag = GlxContextTag(Get32(buf[b:])) - b += 4 - - b += 20 // padding - - return v -} - -func (cook GlxMakeContextCurrentCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxMakeContextCurrent -func (c *Conn) glxMakeContextCurrentRequest(OldContextTag GlxContextTag, Drawable GlxDrawable, ReadDrawable GlxDrawable, Context GlxContext) []byte { - size := 20 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 26 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(OldContextTag)) - b += 4 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], uint32(ReadDrawable)) - b += 4 - - Put32(buf[b:], uint32(Context)) - b += 4 - - return buf -} - -// Request GlxCreatePbuffer -// size: pad((20 + pad(((int(NumAttribs) * 2) * 4)))) -type GlxCreatePbufferCookie struct { - *cookie -} - -// Write request to wire for GlxCreatePbuffer -func (c *Conn) GlxCreatePbuffer(Screen uint32, Fbconfig GlxFbconfig, Pbuffer GlxPbuffer, NumAttribs uint32, Attribs []uint32) GlxCreatePbufferCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxCreatePbufferRequest(Screen, Fbconfig, Pbuffer, NumAttribs, Attribs), cookie) - return GlxCreatePbufferCookie{cookie} -} - -func (c *Conn) GlxCreatePbufferChecked(Screen uint32, Fbconfig GlxFbconfig, Pbuffer GlxPbuffer, NumAttribs uint32, Attribs []uint32) GlxCreatePbufferCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxCreatePbufferRequest(Screen, Fbconfig, Pbuffer, NumAttribs, Attribs), cookie) - return GlxCreatePbufferCookie{cookie} -} - -func (cook GlxCreatePbufferCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxCreatePbuffer -func (c *Conn) glxCreatePbufferRequest(Screen uint32, Fbconfig GlxFbconfig, Pbuffer GlxPbuffer, NumAttribs uint32, Attribs []uint32) []byte { - size := pad((20 + pad(((int(NumAttribs) * 2) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 27 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Screen) - b += 4 - - Put32(buf[b:], uint32(Fbconfig)) - b += 4 - - Put32(buf[b:], uint32(Pbuffer)) - b += 4 - - Put32(buf[b:], NumAttribs) - b += 4 - - for i := 0; i < int((int(NumAttribs) * 2)); i++ { - Put32(buf[b:], Attribs[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Request GlxDestroyPbuffer -// size: 8 -type GlxDestroyPbufferCookie struct { - *cookie -} - -// Write request to wire for GlxDestroyPbuffer -func (c *Conn) GlxDestroyPbuffer(Pbuffer GlxPbuffer) GlxDestroyPbufferCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxDestroyPbufferRequest(Pbuffer), cookie) - return GlxDestroyPbufferCookie{cookie} -} - -func (c *Conn) GlxDestroyPbufferChecked(Pbuffer GlxPbuffer) GlxDestroyPbufferCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxDestroyPbufferRequest(Pbuffer), cookie) - return GlxDestroyPbufferCookie{cookie} -} - -func (cook GlxDestroyPbufferCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxDestroyPbuffer -func (c *Conn) glxDestroyPbufferRequest(Pbuffer GlxPbuffer) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 28 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Pbuffer)) - b += 4 - - return buf -} - -// Request GlxGetDrawableAttributes -// size: 8 -type GlxGetDrawableAttributesCookie struct { - *cookie -} - -func (c *Conn) GlxGetDrawableAttributes(Drawable GlxDrawable) GlxGetDrawableAttributesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetDrawableAttributesRequest(Drawable), cookie) - return GlxGetDrawableAttributesCookie{cookie} -} - -func (c *Conn) GlxGetDrawableAttributesUnchecked(Drawable GlxDrawable) GlxGetDrawableAttributesCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetDrawableAttributesRequest(Drawable), cookie) - return GlxGetDrawableAttributesCookie{cookie} -} - -// Request reply for GlxGetDrawableAttributes -// size: (32 + pad(((int(NumAttribs) * 2) * 4))) -type GlxGetDrawableAttributesReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumAttribs uint32 - // padding: 20 bytes - Attribs []uint32 // size: pad(((int(NumAttribs) * 2) * 4)) -} - -// Waits and reads reply data from request GlxGetDrawableAttributes -func (cook GlxGetDrawableAttributesCookie) Reply() (*GlxGetDrawableAttributesReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetDrawableAttributesReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetDrawableAttributes -func glxGetDrawableAttributesReply(buf []byte) *GlxGetDrawableAttributesReply { - v := new(GlxGetDrawableAttributesReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.NumAttribs = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Attribs = make([]uint32, (int(v.NumAttribs) * 2)) - for i := 0; i < int((int(v.NumAttribs) * 2)); i++ { - v.Attribs[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetDrawableAttributesCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetDrawableAttributes -func (c *Conn) glxGetDrawableAttributesRequest(Drawable GlxDrawable) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 29 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - return buf -} - -// Request GlxChangeDrawableAttributes -// size: pad((12 + pad(((int(NumAttribs) * 2) * 4)))) -type GlxChangeDrawableAttributesCookie struct { - *cookie -} - -// Write request to wire for GlxChangeDrawableAttributes -func (c *Conn) GlxChangeDrawableAttributes(Drawable GlxDrawable, NumAttribs uint32, Attribs []uint32) GlxChangeDrawableAttributesCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxChangeDrawableAttributesRequest(Drawable, NumAttribs, Attribs), cookie) - return GlxChangeDrawableAttributesCookie{cookie} -} - -func (c *Conn) GlxChangeDrawableAttributesChecked(Drawable GlxDrawable, NumAttribs uint32, Attribs []uint32) GlxChangeDrawableAttributesCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxChangeDrawableAttributesRequest(Drawable, NumAttribs, Attribs), cookie) - return GlxChangeDrawableAttributesCookie{cookie} -} - -func (cook GlxChangeDrawableAttributesCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxChangeDrawableAttributes -func (c *Conn) glxChangeDrawableAttributesRequest(Drawable GlxDrawable, NumAttribs uint32, Attribs []uint32) []byte { - size := pad((12 + pad(((int(NumAttribs) * 2) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 30 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], NumAttribs) - b += 4 - - for i := 0; i < int((int(NumAttribs) * 2)); i++ { - Put32(buf[b:], Attribs[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Request GlxCreateWindow -// size: pad((24 + pad(((int(NumAttribs) * 2) * 4)))) -type GlxCreateWindowCookie struct { - *cookie -} - -// Write request to wire for GlxCreateWindow -func (c *Conn) GlxCreateWindow(Screen uint32, Fbconfig GlxFbconfig, Window Window, GlxWindow GlxWindow, NumAttribs uint32, Attribs []uint32) GlxCreateWindowCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxCreateWindowRequest(Screen, Fbconfig, Window, GlxWindow, NumAttribs, Attribs), cookie) - return GlxCreateWindowCookie{cookie} -} - -func (c *Conn) GlxCreateWindowChecked(Screen uint32, Fbconfig GlxFbconfig, Window Window, GlxWindow GlxWindow, NumAttribs uint32, Attribs []uint32) GlxCreateWindowCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxCreateWindowRequest(Screen, Fbconfig, Window, GlxWindow, NumAttribs, Attribs), cookie) - return GlxCreateWindowCookie{cookie} -} - -func (cook GlxCreateWindowCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxCreateWindow -func (c *Conn) glxCreateWindowRequest(Screen uint32, Fbconfig GlxFbconfig, Window Window, GlxWindow GlxWindow, NumAttribs uint32, Attribs []uint32) []byte { - size := pad((24 + pad(((int(NumAttribs) * 2) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 31 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Screen) - b += 4 - - Put32(buf[b:], uint32(Fbconfig)) - b += 4 - - Put32(buf[b:], uint32(Window)) - b += 4 - - Put32(buf[b:], uint32(GlxWindow)) - b += 4 - - Put32(buf[b:], NumAttribs) - b += 4 - - for i := 0; i < int((int(NumAttribs) * 2)); i++ { - Put32(buf[b:], Attribs[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Request GlxDeleteWindow -// size: 8 -type GlxDeleteWindowCookie struct { - *cookie -} - -// Write request to wire for GlxDeleteWindow -func (c *Conn) GlxDeleteWindow(Glxwindow GlxWindow) GlxDeleteWindowCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxDeleteWindowRequest(Glxwindow), cookie) - return GlxDeleteWindowCookie{cookie} -} - -func (c *Conn) GlxDeleteWindowChecked(Glxwindow GlxWindow) GlxDeleteWindowCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxDeleteWindowRequest(Glxwindow), cookie) - return GlxDeleteWindowCookie{cookie} -} - -func (cook GlxDeleteWindowCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxDeleteWindow -func (c *Conn) glxDeleteWindowRequest(Glxwindow GlxWindow) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 32 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Glxwindow)) - b += 4 - - return buf -} - -// Request GlxSetClientInfoARB -// size: pad((((24 + pad(((int(NumVersions) * 2) * 4))) + pad((int(GlStrLen) * 1))) + pad((int(GlxStrLen) * 1)))) -type GlxSetClientInfoARBCookie struct { - *cookie -} - -// Write request to wire for GlxSetClientInfoARB -func (c *Conn) GlxSetClientInfoARB(MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) GlxSetClientInfoARBCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxSetClientInfoARBRequest(MajorVersion, MinorVersion, NumVersions, GlStrLen, GlxStrLen, GlVersions, GlExtensionString, GlxExtensionString), cookie) - return GlxSetClientInfoARBCookie{cookie} -} - -func (c *Conn) GlxSetClientInfoARBChecked(MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) GlxSetClientInfoARBCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxSetClientInfoARBRequest(MajorVersion, MinorVersion, NumVersions, GlStrLen, GlxStrLen, GlVersions, GlExtensionString, GlxExtensionString), cookie) - return GlxSetClientInfoARBCookie{cookie} -} - -func (cook GlxSetClientInfoARBCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxSetClientInfoARB -func (c *Conn) glxSetClientInfoARBRequest(MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) []byte { - size := pad((((24 + pad(((int(NumVersions) * 2) * 4))) + pad((int(GlStrLen) * 1))) + pad((int(GlxStrLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 33 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], MajorVersion) - b += 4 - - Put32(buf[b:], MinorVersion) - b += 4 - - Put32(buf[b:], NumVersions) - b += 4 - - Put32(buf[b:], GlStrLen) - b += 4 - - Put32(buf[b:], GlxStrLen) - b += 4 - - for i := 0; i < int((int(NumVersions) * 2)); i++ { - Put32(buf[b:], GlVersions[i]) - b += 4 - } - b = pad(b) - - copy(buf[b:], GlExtensionString[:GlStrLen]) - b += pad(int(GlStrLen)) - - copy(buf[b:], GlxExtensionString[:GlxStrLen]) - b += pad(int(GlxStrLen)) - - return buf -} - -// Request GlxCreateContextAttribsARB -// size: pad((28 + pad(((int(NumAttribs) * 2) * 4)))) -type GlxCreateContextAttribsARBCookie struct { - *cookie -} - -// Write request to wire for GlxCreateContextAttribsARB -func (c *Conn) GlxCreateContextAttribsARB(Context GlxContext, Fbconfig GlxFbconfig, Screen uint32, ShareList GlxContext, IsDirect bool, NumAttribs uint32, Attribs []uint32) GlxCreateContextAttribsARBCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxCreateContextAttribsARBRequest(Context, Fbconfig, Screen, ShareList, IsDirect, NumAttribs, Attribs), cookie) - return GlxCreateContextAttribsARBCookie{cookie} -} - -func (c *Conn) GlxCreateContextAttribsARBChecked(Context GlxContext, Fbconfig GlxFbconfig, Screen uint32, ShareList GlxContext, IsDirect bool, NumAttribs uint32, Attribs []uint32) GlxCreateContextAttribsARBCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxCreateContextAttribsARBRequest(Context, Fbconfig, Screen, ShareList, IsDirect, NumAttribs, Attribs), cookie) - return GlxCreateContextAttribsARBCookie{cookie} -} - -func (cook GlxCreateContextAttribsARBCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxCreateContextAttribsARB -func (c *Conn) glxCreateContextAttribsARBRequest(Context GlxContext, Fbconfig GlxFbconfig, Screen uint32, ShareList GlxContext, IsDirect bool, NumAttribs uint32, Attribs []uint32) []byte { - size := pad((28 + pad(((int(NumAttribs) * 2) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 34 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Context)) - b += 4 - - Put32(buf[b:], uint32(Fbconfig)) - b += 4 - - Put32(buf[b:], Screen) - b += 4 - - Put32(buf[b:], uint32(ShareList)) - b += 4 - - if IsDirect { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 3 // padding - - Put32(buf[b:], NumAttribs) - b += 4 - - for i := 0; i < int((int(NumAttribs) * 2)); i++ { - Put32(buf[b:], Attribs[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Request GlxSetClientInfo2ARB -// size: pad((((24 + pad(((int(NumVersions) * 3) * 4))) + pad((int(GlStrLen) * 1))) + pad((int(GlxStrLen) * 1)))) -type GlxSetClientInfo2ARBCookie struct { - *cookie -} - -// Write request to wire for GlxSetClientInfo2ARB -func (c *Conn) GlxSetClientInfo2ARB(MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) GlxSetClientInfo2ARBCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxSetClientInfo2ARBRequest(MajorVersion, MinorVersion, NumVersions, GlStrLen, GlxStrLen, GlVersions, GlExtensionString, GlxExtensionString), cookie) - return GlxSetClientInfo2ARBCookie{cookie} -} - -func (c *Conn) GlxSetClientInfo2ARBChecked(MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) GlxSetClientInfo2ARBCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxSetClientInfo2ARBRequest(MajorVersion, MinorVersion, NumVersions, GlStrLen, GlxStrLen, GlVersions, GlExtensionString, GlxExtensionString), cookie) - return GlxSetClientInfo2ARBCookie{cookie} -} - -func (cook GlxSetClientInfo2ARBCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxSetClientInfo2ARB -func (c *Conn) glxSetClientInfo2ARBRequest(MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) []byte { - size := pad((((24 + pad(((int(NumVersions) * 3) * 4))) + pad((int(GlStrLen) * 1))) + pad((int(GlxStrLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 35 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], MajorVersion) - b += 4 - - Put32(buf[b:], MinorVersion) - b += 4 - - Put32(buf[b:], NumVersions) - b += 4 - - Put32(buf[b:], GlStrLen) - b += 4 - - Put32(buf[b:], GlxStrLen) - b += 4 - - for i := 0; i < int((int(NumVersions) * 3)); i++ { - Put32(buf[b:], GlVersions[i]) - b += 4 - } - b = pad(b) - - copy(buf[b:], GlExtensionString[:GlStrLen]) - b += pad(int(GlStrLen)) - - copy(buf[b:], GlxExtensionString[:GlxStrLen]) - b += pad(int(GlxStrLen)) - - return buf -} - -// Request GlxNewList -// size: 16 -type GlxNewListCookie struct { - *cookie -} - -// Write request to wire for GlxNewList -func (c *Conn) GlxNewList(ContextTag GlxContextTag, List uint32, Mode uint32) GlxNewListCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxNewListRequest(ContextTag, List, Mode), cookie) - return GlxNewListCookie{cookie} -} - -func (c *Conn) GlxNewListChecked(ContextTag GlxContextTag, List uint32, Mode uint32) GlxNewListCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxNewListRequest(ContextTag, List, Mode), cookie) - return GlxNewListCookie{cookie} -} - -func (cook GlxNewListCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxNewList -func (c *Conn) glxNewListRequest(ContextTag GlxContextTag, List uint32, Mode uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 101 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], List) - b += 4 - - Put32(buf[b:], Mode) - b += 4 - - return buf -} - -// Request GlxEndList -// size: 8 -type GlxEndListCookie struct { - *cookie -} - -// Write request to wire for GlxEndList -func (c *Conn) GlxEndList(ContextTag GlxContextTag) GlxEndListCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxEndListRequest(ContextTag), cookie) - return GlxEndListCookie{cookie} -} - -func (c *Conn) GlxEndListChecked(ContextTag GlxContextTag) GlxEndListCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxEndListRequest(ContextTag), cookie) - return GlxEndListCookie{cookie} -} - -func (cook GlxEndListCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxEndList -func (c *Conn) glxEndListRequest(ContextTag GlxContextTag) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 102 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - return buf -} - -// Request GlxDeleteLists -// size: 16 -type GlxDeleteListsCookie struct { - *cookie -} - -// Write request to wire for GlxDeleteLists -func (c *Conn) GlxDeleteLists(ContextTag GlxContextTag, List uint32, Range int32) GlxDeleteListsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxDeleteListsRequest(ContextTag, List, Range), cookie) - return GlxDeleteListsCookie{cookie} -} - -func (c *Conn) GlxDeleteListsChecked(ContextTag GlxContextTag, List uint32, Range int32) GlxDeleteListsCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxDeleteListsRequest(ContextTag, List, Range), cookie) - return GlxDeleteListsCookie{cookie} -} - -func (cook GlxDeleteListsCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxDeleteLists -func (c *Conn) glxDeleteListsRequest(ContextTag GlxContextTag, List uint32, Range int32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 103 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], List) - b += 4 - - Put32(buf[b:], uint32(Range)) - b += 4 - - return buf -} - -// Request GlxGenLists -// size: 12 -type GlxGenListsCookie struct { - *cookie -} - -func (c *Conn) GlxGenLists(ContextTag GlxContextTag, Range int32) GlxGenListsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGenListsRequest(ContextTag, Range), cookie) - return GlxGenListsCookie{cookie} -} - -func (c *Conn) GlxGenListsUnchecked(ContextTag GlxContextTag, Range int32) GlxGenListsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGenListsRequest(ContextTag, Range), cookie) - return GlxGenListsCookie{cookie} -} - -// Request reply for GlxGenLists -// size: 12 -type GlxGenListsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - RetVal uint32 -} - -// Waits and reads reply data from request GlxGenLists -func (cook GlxGenListsCookie) Reply() (*GlxGenListsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGenListsReply(buf), nil -} - -// Read reply into structure from buffer for GlxGenLists -func glxGenListsReply(buf []byte) *GlxGenListsReply { - v := new(GlxGenListsReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.RetVal = Get32(buf[b:]) - b += 4 - - return v -} - -func (cook GlxGenListsCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGenLists -func (c *Conn) glxGenListsRequest(ContextTag GlxContextTag, Range int32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 104 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], uint32(Range)) - b += 4 - - return buf -} - -// Request GlxFeedbackBuffer -// size: 16 -type GlxFeedbackBufferCookie struct { - *cookie -} - -// Write request to wire for GlxFeedbackBuffer -func (c *Conn) GlxFeedbackBuffer(ContextTag GlxContextTag, Size int32, Type int32) GlxFeedbackBufferCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxFeedbackBufferRequest(ContextTag, Size, Type), cookie) - return GlxFeedbackBufferCookie{cookie} -} - -func (c *Conn) GlxFeedbackBufferChecked(ContextTag GlxContextTag, Size int32, Type int32) GlxFeedbackBufferCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxFeedbackBufferRequest(ContextTag, Size, Type), cookie) - return GlxFeedbackBufferCookie{cookie} -} - -func (cook GlxFeedbackBufferCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxFeedbackBuffer -func (c *Conn) glxFeedbackBufferRequest(ContextTag GlxContextTag, Size int32, Type int32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 105 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], uint32(Size)) - b += 4 - - Put32(buf[b:], uint32(Type)) - b += 4 - - return buf -} - -// Request GlxSelectBuffer -// size: 12 -type GlxSelectBufferCookie struct { - *cookie -} - -// Write request to wire for GlxSelectBuffer -func (c *Conn) GlxSelectBuffer(ContextTag GlxContextTag, Size int32) GlxSelectBufferCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxSelectBufferRequest(ContextTag, Size), cookie) - return GlxSelectBufferCookie{cookie} -} - -func (c *Conn) GlxSelectBufferChecked(ContextTag GlxContextTag, Size int32) GlxSelectBufferCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxSelectBufferRequest(ContextTag, Size), cookie) - return GlxSelectBufferCookie{cookie} -} - -func (cook GlxSelectBufferCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxSelectBuffer -func (c *Conn) glxSelectBufferRequest(ContextTag GlxContextTag, Size int32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 106 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], uint32(Size)) - b += 4 - - return buf -} - -// Request GlxRenderMode -// size: 12 -type GlxRenderModeCookie struct { - *cookie -} - -func (c *Conn) GlxRenderMode(ContextTag GlxContextTag, Mode uint32) GlxRenderModeCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxRenderModeRequest(ContextTag, Mode), cookie) - return GlxRenderModeCookie{cookie} -} - -func (c *Conn) GlxRenderModeUnchecked(ContextTag GlxContextTag, Mode uint32) GlxRenderModeCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxRenderModeRequest(ContextTag, Mode), cookie) - return GlxRenderModeCookie{cookie} -} - -// Request reply for GlxRenderMode -// size: (32 + pad((int(N) * 4))) -type GlxRenderModeReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - RetVal uint32 - N uint32 - NewMode uint32 - // padding: 12 bytes - Data []uint32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxRenderMode -func (cook GlxRenderModeCookie) Reply() (*GlxRenderModeReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxRenderModeReply(buf), nil -} - -// Read reply into structure from buffer for GlxRenderMode -func glxRenderModeReply(buf []byte) *GlxRenderModeReply { - v := new(GlxRenderModeReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.RetVal = Get32(buf[b:]) - b += 4 - - v.N = Get32(buf[b:]) - b += 4 - - v.NewMode = Get32(buf[b:]) - b += 4 - - b += 12 // padding - - v.Data = make([]uint32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxRenderModeCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxRenderMode -func (c *Conn) glxRenderModeRequest(ContextTag GlxContextTag, Mode uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 107 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Mode) - b += 4 - - return buf -} - -// Request GlxFinish -// size: 8 -type GlxFinishCookie struct { - *cookie -} - -func (c *Conn) GlxFinish(ContextTag GlxContextTag) GlxFinishCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxFinishRequest(ContextTag), cookie) - return GlxFinishCookie{cookie} -} - -func (c *Conn) GlxFinishUnchecked(ContextTag GlxContextTag) GlxFinishCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxFinishRequest(ContextTag), cookie) - return GlxFinishCookie{cookie} -} - -// Request reply for GlxFinish -// size: 8 -type GlxFinishReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes -} - -// Waits and reads reply data from request GlxFinish -func (cook GlxFinishCookie) Reply() (*GlxFinishReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxFinishReply(buf), nil -} - -// Read reply into structure from buffer for GlxFinish -func glxFinishReply(buf []byte) *GlxFinishReply { - v := new(GlxFinishReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - return v -} - -func (cook GlxFinishCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxFinish -func (c *Conn) glxFinishRequest(ContextTag GlxContextTag) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 108 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - return buf -} - -// Request GlxPixelStoref -// size: 16 -type GlxPixelStorefCookie struct { - *cookie -} - -// Write request to wire for GlxPixelStoref -func (c *Conn) GlxPixelStoref(ContextTag GlxContextTag, Pname uint32, Datum GlxFloat32) GlxPixelStorefCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxPixelStorefRequest(ContextTag, Pname, Datum), cookie) - return GlxPixelStorefCookie{cookie} -} - -func (c *Conn) GlxPixelStorefChecked(ContextTag GlxContextTag, Pname uint32, Datum GlxFloat32) GlxPixelStorefCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxPixelStorefRequest(ContextTag, Pname, Datum), cookie) - return GlxPixelStorefCookie{cookie} -} - -func (cook GlxPixelStorefCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxPixelStoref -func (c *Conn) glxPixelStorefRequest(ContextTag GlxContextTag, Pname uint32, Datum GlxFloat32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 109 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - Put32(buf[b:], uint32(Datum)) - b += 4 - - return buf -} - -// Request GlxPixelStorei -// size: 16 -type GlxPixelStoreiCookie struct { - *cookie -} - -// Write request to wire for GlxPixelStorei -func (c *Conn) GlxPixelStorei(ContextTag GlxContextTag, Pname uint32, Datum int32) GlxPixelStoreiCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxPixelStoreiRequest(ContextTag, Pname, Datum), cookie) - return GlxPixelStoreiCookie{cookie} -} - -func (c *Conn) GlxPixelStoreiChecked(ContextTag GlxContextTag, Pname uint32, Datum int32) GlxPixelStoreiCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxPixelStoreiRequest(ContextTag, Pname, Datum), cookie) - return GlxPixelStoreiCookie{cookie} -} - -func (cook GlxPixelStoreiCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxPixelStorei -func (c *Conn) glxPixelStoreiRequest(ContextTag GlxContextTag, Pname uint32, Datum int32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 110 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - Put32(buf[b:], uint32(Datum)) - b += 4 - - return buf -} - -// Request GlxReadPixels -// size: 36 -type GlxReadPixelsCookie struct { - *cookie -} - -func (c *Conn) GlxReadPixels(ContextTag GlxContextTag, X int32, Y int32, Width int32, Height int32, Format uint32, Type uint32, SwapBytes bool, LsbFirst bool) GlxReadPixelsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxReadPixelsRequest(ContextTag, X, Y, Width, Height, Format, Type, SwapBytes, LsbFirst), cookie) - return GlxReadPixelsCookie{cookie} -} - -func (c *Conn) GlxReadPixelsUnchecked(ContextTag GlxContextTag, X int32, Y int32, Width int32, Height int32, Format uint32, Type uint32, SwapBytes bool, LsbFirst bool) GlxReadPixelsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxReadPixelsRequest(ContextTag, X, Y, Width, Height, Format, Type, SwapBytes, LsbFirst), cookie) - return GlxReadPixelsCookie{cookie} -} - -// Request reply for GlxReadPixels -// size: (32 + pad(((int(Length) * 4) * 1))) -type GlxReadPixelsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 24 bytes - Data []byte // size: pad(((int(Length) * 4) * 1)) -} - -// Waits and reads reply data from request GlxReadPixels -func (cook GlxReadPixelsCookie) Reply() (*GlxReadPixelsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxReadPixelsReply(buf), nil -} - -// Read reply into structure from buffer for GlxReadPixels -func glxReadPixelsReply(buf []byte) *GlxReadPixelsReply { - v := new(GlxReadPixelsReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 24 // padding - - v.Data = make([]byte, (int(v.Length) * 4)) - copy(v.Data[:(int(v.Length)*4)], buf[b:]) - b += pad(int((int(v.Length) * 4))) - - return v -} - -func (cook GlxReadPixelsCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxReadPixels -func (c *Conn) glxReadPixelsRequest(ContextTag GlxContextTag, X int32, Y int32, Width int32, Height int32, Format uint32, Type uint32, SwapBytes bool, LsbFirst bool) []byte { - size := 36 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 111 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], uint32(X)) - b += 4 - - Put32(buf[b:], uint32(Y)) - b += 4 - - Put32(buf[b:], uint32(Width)) - b += 4 - - Put32(buf[b:], uint32(Height)) - b += 4 - - Put32(buf[b:], Format) - b += 4 - - Put32(buf[b:], Type) - b += 4 - - if SwapBytes { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - if LsbFirst { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - return buf -} - -// Request GlxGetBooleanv -// size: 12 -type GlxGetBooleanvCookie struct { - *cookie -} - -func (c *Conn) GlxGetBooleanv(ContextTag GlxContextTag, Pname int32) GlxGetBooleanvCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetBooleanvRequest(ContextTag, Pname), cookie) - return GlxGetBooleanvCookie{cookie} -} - -func (c *Conn) GlxGetBooleanvUnchecked(ContextTag GlxContextTag, Pname int32) GlxGetBooleanvCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetBooleanvRequest(ContextTag, Pname), cookie) - return GlxGetBooleanvCookie{cookie} -} - -// Request reply for GlxGetBooleanv -// size: (32 + pad((int(N) * 1))) -type GlxGetBooleanvReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum bool - // padding: 15 bytes - Data []bool // size: pad((int(N) * 1)) -} - -// Waits and reads reply data from request GlxGetBooleanv -func (cook GlxGetBooleanvCookie) Reply() (*GlxGetBooleanvReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetBooleanvReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetBooleanv -func glxGetBooleanvReply(buf []byte) *GlxGetBooleanvReply { - v := new(GlxGetBooleanvReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - if buf[b] == 1 { - v.Datum = true - } else { - v.Datum = false - } - b += 1 - - b += 15 // padding - - v.Data = make([]bool, v.N) - for i := 0; i < int(v.N); i++ { - if buf[b] == 1 { - v.Data[i] = true - } else { - v.Data[i] = false - } - b += 1 - } - b = pad(b) - - return v -} - -func (cook GlxGetBooleanvCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetBooleanv -func (c *Conn) glxGetBooleanvRequest(ContextTag GlxContextTag, Pname int32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 112 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], uint32(Pname)) - b += 4 - - return buf -} - -// Request GlxGetClipPlane -// size: 12 -type GlxGetClipPlaneCookie struct { - *cookie -} - -func (c *Conn) GlxGetClipPlane(ContextTag GlxContextTag, Plane int32) GlxGetClipPlaneCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetClipPlaneRequest(ContextTag, Plane), cookie) - return GlxGetClipPlaneCookie{cookie} -} - -func (c *Conn) GlxGetClipPlaneUnchecked(ContextTag GlxContextTag, Plane int32) GlxGetClipPlaneCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetClipPlaneRequest(ContextTag, Plane), cookie) - return GlxGetClipPlaneCookie{cookie} -} - -// Request reply for GlxGetClipPlane -// size: (32 + pad(((int(Length) / 2) * 8))) -type GlxGetClipPlaneReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 24 bytes - Data []GlxFloat64 // size: pad(((int(Length) / 2) * 8)) -} - -// Waits and reads reply data from request GlxGetClipPlane -func (cook GlxGetClipPlaneCookie) Reply() (*GlxGetClipPlaneReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetClipPlaneReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetClipPlane -func glxGetClipPlaneReply(buf []byte) *GlxGetClipPlaneReply { - v := new(GlxGetClipPlaneReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 24 // padding - - v.Data = make([]GlxFloat64, (int(v.Length) / 2)) - for i := 0; i < int((int(v.Length) / 2)); i++ { - v.Data[i] = GlxFloat64(Get64(buf[b:])) - b += 8 - } - b = pad(b) - - return v -} - -func (cook GlxGetClipPlaneCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetClipPlane -func (c *Conn) glxGetClipPlaneRequest(ContextTag GlxContextTag, Plane int32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 113 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], uint32(Plane)) - b += 4 - - return buf -} - -// Request GlxGetDoublev -// size: 12 -type GlxGetDoublevCookie struct { - *cookie -} - -func (c *Conn) GlxGetDoublev(ContextTag GlxContextTag, Pname uint32) GlxGetDoublevCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetDoublevRequest(ContextTag, Pname), cookie) - return GlxGetDoublevCookie{cookie} -} - -func (c *Conn) GlxGetDoublevUnchecked(ContextTag GlxContextTag, Pname uint32) GlxGetDoublevCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetDoublevRequest(ContextTag, Pname), cookie) - return GlxGetDoublevCookie{cookie} -} - -// Request reply for GlxGetDoublev -// size: (32 + pad((int(N) * 8))) -type GlxGetDoublevReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum GlxFloat64 - // padding: 8 bytes - Data []GlxFloat64 // size: pad((int(N) * 8)) -} - -// Waits and reads reply data from request GlxGetDoublev -func (cook GlxGetDoublevCookie) Reply() (*GlxGetDoublevReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetDoublevReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetDoublev -func glxGetDoublevReply(buf []byte) *GlxGetDoublevReply { - v := new(GlxGetDoublevReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = GlxFloat64(Get64(buf[b:])) - b += 8 - - b += 8 // padding - - v.Data = make([]GlxFloat64, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = GlxFloat64(Get64(buf[b:])) - b += 8 - } - b = pad(b) - - return v -} - -func (cook GlxGetDoublevCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetDoublev -func (c *Conn) glxGetDoublevRequest(ContextTag GlxContextTag, Pname uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 114 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetError -// size: 8 -type GlxGetErrorCookie struct { - *cookie -} - -func (c *Conn) GlxGetError(ContextTag GlxContextTag) GlxGetErrorCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetErrorRequest(ContextTag), cookie) - return GlxGetErrorCookie{cookie} -} - -func (c *Conn) GlxGetErrorUnchecked(ContextTag GlxContextTag) GlxGetErrorCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetErrorRequest(ContextTag), cookie) - return GlxGetErrorCookie{cookie} -} - -// Request reply for GlxGetError -// size: 12 -type GlxGetErrorReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Error int32 -} - -// Waits and reads reply data from request GlxGetError -func (cook GlxGetErrorCookie) Reply() (*GlxGetErrorReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetErrorReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetError -func glxGetErrorReply(buf []byte) *GlxGetErrorReply { - v := new(GlxGetErrorReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Error = int32(Get32(buf[b:])) - b += 4 - - return v -} - -func (cook GlxGetErrorCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetError -func (c *Conn) glxGetErrorRequest(ContextTag GlxContextTag) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 115 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - return buf -} - -// Request GlxGetFloatv -// size: 12 -type GlxGetFloatvCookie struct { - *cookie -} - -func (c *Conn) GlxGetFloatv(ContextTag GlxContextTag, Pname uint32) GlxGetFloatvCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetFloatvRequest(ContextTag, Pname), cookie) - return GlxGetFloatvCookie{cookie} -} - -func (c *Conn) GlxGetFloatvUnchecked(ContextTag GlxContextTag, Pname uint32) GlxGetFloatvCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetFloatvRequest(ContextTag, Pname), cookie) - return GlxGetFloatvCookie{cookie} -} - -// Request reply for GlxGetFloatv -// size: (32 + pad((int(N) * 4))) -type GlxGetFloatvReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum GlxFloat32 - // padding: 12 bytes - Data []GlxFloat32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetFloatv -func (cook GlxGetFloatvCookie) Reply() (*GlxGetFloatvReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetFloatvReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetFloatv -func glxGetFloatvReply(buf []byte) *GlxGetFloatvReply { - v := new(GlxGetFloatvReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = GlxFloat32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]GlxFloat32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = GlxFloat32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetFloatvCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetFloatv -func (c *Conn) glxGetFloatvRequest(ContextTag GlxContextTag, Pname uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 116 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetIntegerv -// size: 12 -type GlxGetIntegervCookie struct { - *cookie -} - -func (c *Conn) GlxGetIntegerv(ContextTag GlxContextTag, Pname uint32) GlxGetIntegervCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetIntegervRequest(ContextTag, Pname), cookie) - return GlxGetIntegervCookie{cookie} -} - -func (c *Conn) GlxGetIntegervUnchecked(ContextTag GlxContextTag, Pname uint32) GlxGetIntegervCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetIntegervRequest(ContextTag, Pname), cookie) - return GlxGetIntegervCookie{cookie} -} - -// Request reply for GlxGetIntegerv -// size: (32 + pad((int(N) * 4))) -type GlxGetIntegervReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum int32 - // padding: 12 bytes - Data []int32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetIntegerv -func (cook GlxGetIntegervCookie) Reply() (*GlxGetIntegervReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetIntegervReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetIntegerv -func glxGetIntegervReply(buf []byte) *GlxGetIntegervReply { - v := new(GlxGetIntegervReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = int32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]int32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = int32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetIntegervCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetIntegerv -func (c *Conn) glxGetIntegervRequest(ContextTag GlxContextTag, Pname uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 117 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetLightfv -// size: 16 -type GlxGetLightfvCookie struct { - *cookie -} - -func (c *Conn) GlxGetLightfv(ContextTag GlxContextTag, Light uint32, Pname uint32) GlxGetLightfvCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetLightfvRequest(ContextTag, Light, Pname), cookie) - return GlxGetLightfvCookie{cookie} -} - -func (c *Conn) GlxGetLightfvUnchecked(ContextTag GlxContextTag, Light uint32, Pname uint32) GlxGetLightfvCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetLightfvRequest(ContextTag, Light, Pname), cookie) - return GlxGetLightfvCookie{cookie} -} - -// Request reply for GlxGetLightfv -// size: (32 + pad((int(N) * 4))) -type GlxGetLightfvReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum GlxFloat32 - // padding: 12 bytes - Data []GlxFloat32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetLightfv -func (cook GlxGetLightfvCookie) Reply() (*GlxGetLightfvReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetLightfvReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetLightfv -func glxGetLightfvReply(buf []byte) *GlxGetLightfvReply { - v := new(GlxGetLightfvReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = GlxFloat32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]GlxFloat32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = GlxFloat32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetLightfvCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetLightfv -func (c *Conn) glxGetLightfvRequest(ContextTag GlxContextTag, Light uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 118 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Light) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetLightiv -// size: 16 -type GlxGetLightivCookie struct { - *cookie -} - -func (c *Conn) GlxGetLightiv(ContextTag GlxContextTag, Light uint32, Pname uint32) GlxGetLightivCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetLightivRequest(ContextTag, Light, Pname), cookie) - return GlxGetLightivCookie{cookie} -} - -func (c *Conn) GlxGetLightivUnchecked(ContextTag GlxContextTag, Light uint32, Pname uint32) GlxGetLightivCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetLightivRequest(ContextTag, Light, Pname), cookie) - return GlxGetLightivCookie{cookie} -} - -// Request reply for GlxGetLightiv -// size: (32 + pad((int(N) * 4))) -type GlxGetLightivReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum int32 - // padding: 12 bytes - Data []int32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetLightiv -func (cook GlxGetLightivCookie) Reply() (*GlxGetLightivReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetLightivReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetLightiv -func glxGetLightivReply(buf []byte) *GlxGetLightivReply { - v := new(GlxGetLightivReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = int32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]int32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = int32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetLightivCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetLightiv -func (c *Conn) glxGetLightivRequest(ContextTag GlxContextTag, Light uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 119 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Light) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetMapdv -// size: 16 -type GlxGetMapdvCookie struct { - *cookie -} - -func (c *Conn) GlxGetMapdv(ContextTag GlxContextTag, Target uint32, Query uint32) GlxGetMapdvCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetMapdvRequest(ContextTag, Target, Query), cookie) - return GlxGetMapdvCookie{cookie} -} - -func (c *Conn) GlxGetMapdvUnchecked(ContextTag GlxContextTag, Target uint32, Query uint32) GlxGetMapdvCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetMapdvRequest(ContextTag, Target, Query), cookie) - return GlxGetMapdvCookie{cookie} -} - -// Request reply for GlxGetMapdv -// size: (32 + pad((int(N) * 8))) -type GlxGetMapdvReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum GlxFloat64 - // padding: 8 bytes - Data []GlxFloat64 // size: pad((int(N) * 8)) -} - -// Waits and reads reply data from request GlxGetMapdv -func (cook GlxGetMapdvCookie) Reply() (*GlxGetMapdvReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetMapdvReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetMapdv -func glxGetMapdvReply(buf []byte) *GlxGetMapdvReply { - v := new(GlxGetMapdvReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = GlxFloat64(Get64(buf[b:])) - b += 8 - - b += 8 // padding - - v.Data = make([]GlxFloat64, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = GlxFloat64(Get64(buf[b:])) - b += 8 - } - b = pad(b) - - return v -} - -func (cook GlxGetMapdvCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetMapdv -func (c *Conn) glxGetMapdvRequest(ContextTag GlxContextTag, Target uint32, Query uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 120 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Query) - b += 4 - - return buf -} - -// Request GlxGetMapfv -// size: 16 -type GlxGetMapfvCookie struct { - *cookie -} - -func (c *Conn) GlxGetMapfv(ContextTag GlxContextTag, Target uint32, Query uint32) GlxGetMapfvCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetMapfvRequest(ContextTag, Target, Query), cookie) - return GlxGetMapfvCookie{cookie} -} - -func (c *Conn) GlxGetMapfvUnchecked(ContextTag GlxContextTag, Target uint32, Query uint32) GlxGetMapfvCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetMapfvRequest(ContextTag, Target, Query), cookie) - return GlxGetMapfvCookie{cookie} -} - -// Request reply for GlxGetMapfv -// size: (32 + pad((int(N) * 4))) -type GlxGetMapfvReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum GlxFloat32 - // padding: 12 bytes - Data []GlxFloat32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetMapfv -func (cook GlxGetMapfvCookie) Reply() (*GlxGetMapfvReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetMapfvReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetMapfv -func glxGetMapfvReply(buf []byte) *GlxGetMapfvReply { - v := new(GlxGetMapfvReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = GlxFloat32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]GlxFloat32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = GlxFloat32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetMapfvCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetMapfv -func (c *Conn) glxGetMapfvRequest(ContextTag GlxContextTag, Target uint32, Query uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 121 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Query) - b += 4 - - return buf -} - -// Request GlxGetMapiv -// size: 16 -type GlxGetMapivCookie struct { - *cookie -} - -func (c *Conn) GlxGetMapiv(ContextTag GlxContextTag, Target uint32, Query uint32) GlxGetMapivCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetMapivRequest(ContextTag, Target, Query), cookie) - return GlxGetMapivCookie{cookie} -} - -func (c *Conn) GlxGetMapivUnchecked(ContextTag GlxContextTag, Target uint32, Query uint32) GlxGetMapivCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetMapivRequest(ContextTag, Target, Query), cookie) - return GlxGetMapivCookie{cookie} -} - -// Request reply for GlxGetMapiv -// size: (32 + pad((int(N) * 4))) -type GlxGetMapivReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum int32 - // padding: 12 bytes - Data []int32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetMapiv -func (cook GlxGetMapivCookie) Reply() (*GlxGetMapivReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetMapivReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetMapiv -func glxGetMapivReply(buf []byte) *GlxGetMapivReply { - v := new(GlxGetMapivReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = int32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]int32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = int32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetMapivCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetMapiv -func (c *Conn) glxGetMapivRequest(ContextTag GlxContextTag, Target uint32, Query uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 122 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Query) - b += 4 - - return buf -} - -// Request GlxGetMaterialfv -// size: 16 -type GlxGetMaterialfvCookie struct { - *cookie -} - -func (c *Conn) GlxGetMaterialfv(ContextTag GlxContextTag, Face uint32, Pname uint32) GlxGetMaterialfvCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetMaterialfvRequest(ContextTag, Face, Pname), cookie) - return GlxGetMaterialfvCookie{cookie} -} - -func (c *Conn) GlxGetMaterialfvUnchecked(ContextTag GlxContextTag, Face uint32, Pname uint32) GlxGetMaterialfvCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetMaterialfvRequest(ContextTag, Face, Pname), cookie) - return GlxGetMaterialfvCookie{cookie} -} - -// Request reply for GlxGetMaterialfv -// size: (32 + pad((int(N) * 4))) -type GlxGetMaterialfvReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum GlxFloat32 - // padding: 12 bytes - Data []GlxFloat32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetMaterialfv -func (cook GlxGetMaterialfvCookie) Reply() (*GlxGetMaterialfvReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetMaterialfvReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetMaterialfv -func glxGetMaterialfvReply(buf []byte) *GlxGetMaterialfvReply { - v := new(GlxGetMaterialfvReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = GlxFloat32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]GlxFloat32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = GlxFloat32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetMaterialfvCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetMaterialfv -func (c *Conn) glxGetMaterialfvRequest(ContextTag GlxContextTag, Face uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 123 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Face) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetMaterialiv -// size: 16 -type GlxGetMaterialivCookie struct { - *cookie -} - -func (c *Conn) GlxGetMaterialiv(ContextTag GlxContextTag, Face uint32, Pname uint32) GlxGetMaterialivCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetMaterialivRequest(ContextTag, Face, Pname), cookie) - return GlxGetMaterialivCookie{cookie} -} - -func (c *Conn) GlxGetMaterialivUnchecked(ContextTag GlxContextTag, Face uint32, Pname uint32) GlxGetMaterialivCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetMaterialivRequest(ContextTag, Face, Pname), cookie) - return GlxGetMaterialivCookie{cookie} -} - -// Request reply for GlxGetMaterialiv -// size: (32 + pad((int(N) * 4))) -type GlxGetMaterialivReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum int32 - // padding: 12 bytes - Data []int32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetMaterialiv -func (cook GlxGetMaterialivCookie) Reply() (*GlxGetMaterialivReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetMaterialivReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetMaterialiv -func glxGetMaterialivReply(buf []byte) *GlxGetMaterialivReply { - v := new(GlxGetMaterialivReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = int32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]int32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = int32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetMaterialivCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetMaterialiv -func (c *Conn) glxGetMaterialivRequest(ContextTag GlxContextTag, Face uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 124 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Face) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetPixelMapfv -// size: 12 -type GlxGetPixelMapfvCookie struct { - *cookie -} - -func (c *Conn) GlxGetPixelMapfv(ContextTag GlxContextTag, Map uint32) GlxGetPixelMapfvCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetPixelMapfvRequest(ContextTag, Map), cookie) - return GlxGetPixelMapfvCookie{cookie} -} - -func (c *Conn) GlxGetPixelMapfvUnchecked(ContextTag GlxContextTag, Map uint32) GlxGetPixelMapfvCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetPixelMapfvRequest(ContextTag, Map), cookie) - return GlxGetPixelMapfvCookie{cookie} -} - -// Request reply for GlxGetPixelMapfv -// size: (32 + pad((int(N) * 4))) -type GlxGetPixelMapfvReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum GlxFloat32 - // padding: 12 bytes - Data []GlxFloat32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetPixelMapfv -func (cook GlxGetPixelMapfvCookie) Reply() (*GlxGetPixelMapfvReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetPixelMapfvReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetPixelMapfv -func glxGetPixelMapfvReply(buf []byte) *GlxGetPixelMapfvReply { - v := new(GlxGetPixelMapfvReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = GlxFloat32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]GlxFloat32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = GlxFloat32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetPixelMapfvCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetPixelMapfv -func (c *Conn) glxGetPixelMapfvRequest(ContextTag GlxContextTag, Map uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 125 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Map) - b += 4 - - return buf -} - -// Request GlxGetPixelMapuiv -// size: 12 -type GlxGetPixelMapuivCookie struct { - *cookie -} - -func (c *Conn) GlxGetPixelMapuiv(ContextTag GlxContextTag, Map uint32) GlxGetPixelMapuivCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetPixelMapuivRequest(ContextTag, Map), cookie) - return GlxGetPixelMapuivCookie{cookie} -} - -func (c *Conn) GlxGetPixelMapuivUnchecked(ContextTag GlxContextTag, Map uint32) GlxGetPixelMapuivCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetPixelMapuivRequest(ContextTag, Map), cookie) - return GlxGetPixelMapuivCookie{cookie} -} - -// Request reply for GlxGetPixelMapuiv -// size: (32 + pad((int(N) * 4))) -type GlxGetPixelMapuivReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum uint32 - // padding: 12 bytes - Data []uint32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetPixelMapuiv -func (cook GlxGetPixelMapuivCookie) Reply() (*GlxGetPixelMapuivReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetPixelMapuivReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetPixelMapuiv -func glxGetPixelMapuivReply(buf []byte) *GlxGetPixelMapuivReply { - v := new(GlxGetPixelMapuivReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = Get32(buf[b:]) - b += 4 - - b += 12 // padding - - v.Data = make([]uint32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetPixelMapuivCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetPixelMapuiv -func (c *Conn) glxGetPixelMapuivRequest(ContextTag GlxContextTag, Map uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 126 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Map) - b += 4 - - return buf -} - -// Request GlxGetPixelMapusv -// size: 12 -type GlxGetPixelMapusvCookie struct { - *cookie -} - -func (c *Conn) GlxGetPixelMapusv(ContextTag GlxContextTag, Map uint32) GlxGetPixelMapusvCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetPixelMapusvRequest(ContextTag, Map), cookie) - return GlxGetPixelMapusvCookie{cookie} -} - -func (c *Conn) GlxGetPixelMapusvUnchecked(ContextTag GlxContextTag, Map uint32) GlxGetPixelMapusvCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetPixelMapusvRequest(ContextTag, Map), cookie) - return GlxGetPixelMapusvCookie{cookie} -} - -// Request reply for GlxGetPixelMapusv -// size: (34 + pad((int(N) * 2))) -type GlxGetPixelMapusvReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum uint16 - // padding: 16 bytes - Data []uint16 // size: pad((int(N) * 2)) -} - -// Waits and reads reply data from request GlxGetPixelMapusv -func (cook GlxGetPixelMapusvCookie) Reply() (*GlxGetPixelMapusvReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetPixelMapusvReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetPixelMapusv -func glxGetPixelMapusvReply(buf []byte) *GlxGetPixelMapusvReply { - v := new(GlxGetPixelMapusvReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = Get16(buf[b:]) - b += 2 - - b += 16 // padding - - v.Data = make([]uint16, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = Get16(buf[b:]) - b += 2 - } - b = pad(b) - - return v -} - -func (cook GlxGetPixelMapusvCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetPixelMapusv -func (c *Conn) glxGetPixelMapusvRequest(ContextTag GlxContextTag, Map uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 127 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Map) - b += 4 - - return buf -} - -// Request GlxGetPolygonStipple -// size: 12 -type GlxGetPolygonStippleCookie struct { - *cookie -} - -func (c *Conn) GlxGetPolygonStipple(ContextTag GlxContextTag, LsbFirst bool) GlxGetPolygonStippleCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetPolygonStippleRequest(ContextTag, LsbFirst), cookie) - return GlxGetPolygonStippleCookie{cookie} -} - -func (c *Conn) GlxGetPolygonStippleUnchecked(ContextTag GlxContextTag, LsbFirst bool) GlxGetPolygonStippleCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetPolygonStippleRequest(ContextTag, LsbFirst), cookie) - return GlxGetPolygonStippleCookie{cookie} -} - -// Request reply for GlxGetPolygonStipple -// size: (32 + pad(((int(Length) * 4) * 1))) -type GlxGetPolygonStippleReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 24 bytes - Data []byte // size: pad(((int(Length) * 4) * 1)) -} - -// Waits and reads reply data from request GlxGetPolygonStipple -func (cook GlxGetPolygonStippleCookie) Reply() (*GlxGetPolygonStippleReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetPolygonStippleReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetPolygonStipple -func glxGetPolygonStippleReply(buf []byte) *GlxGetPolygonStippleReply { - v := new(GlxGetPolygonStippleReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 24 // padding - - v.Data = make([]byte, (int(v.Length) * 4)) - copy(v.Data[:(int(v.Length)*4)], buf[b:]) - b += pad(int((int(v.Length) * 4))) - - return v -} - -func (cook GlxGetPolygonStippleCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetPolygonStipple -func (c *Conn) glxGetPolygonStippleRequest(ContextTag GlxContextTag, LsbFirst bool) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 128 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - if LsbFirst { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - return buf -} - -// Request GlxGetString -// size: 12 -type GlxGetStringCookie struct { - *cookie -} - -func (c *Conn) GlxGetString(ContextTag GlxContextTag, Name uint32) GlxGetStringCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetStringRequest(ContextTag, Name), cookie) - return GlxGetStringCookie{cookie} -} - -func (c *Conn) GlxGetStringUnchecked(ContextTag GlxContextTag, Name uint32) GlxGetStringCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetStringRequest(ContextTag, Name), cookie) - return GlxGetStringCookie{cookie} -} - -// Request reply for GlxGetString -// size: (32 + pad((int(N) * 1))) -type GlxGetStringReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - // padding: 16 bytes - String string // size: pad((int(N) * 1)) -} - -// Waits and reads reply data from request GlxGetString -func (cook GlxGetStringCookie) Reply() (*GlxGetStringReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetStringReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetString -func glxGetStringReply(buf []byte) *GlxGetStringReply { - v := new(GlxGetStringReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - b += 16 // padding - - { - byteString := make([]byte, v.N) - copy(byteString[:v.N], buf[b:]) - v.String = string(byteString) - b += pad(int(v.N)) - } - - return v -} - -func (cook GlxGetStringCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetString -func (c *Conn) glxGetStringRequest(ContextTag GlxContextTag, Name uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 129 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Name) - b += 4 - - return buf -} - -// Request GlxGetTexEnvfv -// size: 16 -type GlxGetTexEnvfvCookie struct { - *cookie -} - -func (c *Conn) GlxGetTexEnvfv(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetTexEnvfvCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetTexEnvfvRequest(ContextTag, Target, Pname), cookie) - return GlxGetTexEnvfvCookie{cookie} -} - -func (c *Conn) GlxGetTexEnvfvUnchecked(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetTexEnvfvCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetTexEnvfvRequest(ContextTag, Target, Pname), cookie) - return GlxGetTexEnvfvCookie{cookie} -} - -// Request reply for GlxGetTexEnvfv -// size: (32 + pad((int(N) * 4))) -type GlxGetTexEnvfvReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum GlxFloat32 - // padding: 12 bytes - Data []GlxFloat32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetTexEnvfv -func (cook GlxGetTexEnvfvCookie) Reply() (*GlxGetTexEnvfvReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetTexEnvfvReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetTexEnvfv -func glxGetTexEnvfvReply(buf []byte) *GlxGetTexEnvfvReply { - v := new(GlxGetTexEnvfvReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = GlxFloat32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]GlxFloat32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = GlxFloat32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetTexEnvfvCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetTexEnvfv -func (c *Conn) glxGetTexEnvfvRequest(ContextTag GlxContextTag, Target uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 130 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetTexEnviv -// size: 16 -type GlxGetTexEnvivCookie struct { - *cookie -} - -func (c *Conn) GlxGetTexEnviv(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetTexEnvivCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetTexEnvivRequest(ContextTag, Target, Pname), cookie) - return GlxGetTexEnvivCookie{cookie} -} - -func (c *Conn) GlxGetTexEnvivUnchecked(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetTexEnvivCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetTexEnvivRequest(ContextTag, Target, Pname), cookie) - return GlxGetTexEnvivCookie{cookie} -} - -// Request reply for GlxGetTexEnviv -// size: (32 + pad((int(N) * 4))) -type GlxGetTexEnvivReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum int32 - // padding: 12 bytes - Data []int32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetTexEnviv -func (cook GlxGetTexEnvivCookie) Reply() (*GlxGetTexEnvivReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetTexEnvivReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetTexEnviv -func glxGetTexEnvivReply(buf []byte) *GlxGetTexEnvivReply { - v := new(GlxGetTexEnvivReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = int32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]int32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = int32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetTexEnvivCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetTexEnviv -func (c *Conn) glxGetTexEnvivRequest(ContextTag GlxContextTag, Target uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 131 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetTexGendv -// size: 16 -type GlxGetTexGendvCookie struct { - *cookie -} - -func (c *Conn) GlxGetTexGendv(ContextTag GlxContextTag, Coord uint32, Pname uint32) GlxGetTexGendvCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetTexGendvRequest(ContextTag, Coord, Pname), cookie) - return GlxGetTexGendvCookie{cookie} -} - -func (c *Conn) GlxGetTexGendvUnchecked(ContextTag GlxContextTag, Coord uint32, Pname uint32) GlxGetTexGendvCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetTexGendvRequest(ContextTag, Coord, Pname), cookie) - return GlxGetTexGendvCookie{cookie} -} - -// Request reply for GlxGetTexGendv -// size: (32 + pad((int(N) * 8))) -type GlxGetTexGendvReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum GlxFloat64 - // padding: 8 bytes - Data []GlxFloat64 // size: pad((int(N) * 8)) -} - -// Waits and reads reply data from request GlxGetTexGendv -func (cook GlxGetTexGendvCookie) Reply() (*GlxGetTexGendvReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetTexGendvReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetTexGendv -func glxGetTexGendvReply(buf []byte) *GlxGetTexGendvReply { - v := new(GlxGetTexGendvReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = GlxFloat64(Get64(buf[b:])) - b += 8 - - b += 8 // padding - - v.Data = make([]GlxFloat64, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = GlxFloat64(Get64(buf[b:])) - b += 8 - } - b = pad(b) - - return v -} - -func (cook GlxGetTexGendvCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetTexGendv -func (c *Conn) glxGetTexGendvRequest(ContextTag GlxContextTag, Coord uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 132 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Coord) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetTexGenfv -// size: 16 -type GlxGetTexGenfvCookie struct { - *cookie -} - -func (c *Conn) GlxGetTexGenfv(ContextTag GlxContextTag, Coord uint32, Pname uint32) GlxGetTexGenfvCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetTexGenfvRequest(ContextTag, Coord, Pname), cookie) - return GlxGetTexGenfvCookie{cookie} -} - -func (c *Conn) GlxGetTexGenfvUnchecked(ContextTag GlxContextTag, Coord uint32, Pname uint32) GlxGetTexGenfvCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetTexGenfvRequest(ContextTag, Coord, Pname), cookie) - return GlxGetTexGenfvCookie{cookie} -} - -// Request reply for GlxGetTexGenfv -// size: (32 + pad((int(N) * 4))) -type GlxGetTexGenfvReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum GlxFloat32 - // padding: 12 bytes - Data []GlxFloat32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetTexGenfv -func (cook GlxGetTexGenfvCookie) Reply() (*GlxGetTexGenfvReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetTexGenfvReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetTexGenfv -func glxGetTexGenfvReply(buf []byte) *GlxGetTexGenfvReply { - v := new(GlxGetTexGenfvReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = GlxFloat32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]GlxFloat32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = GlxFloat32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetTexGenfvCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetTexGenfv -func (c *Conn) glxGetTexGenfvRequest(ContextTag GlxContextTag, Coord uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 133 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Coord) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetTexGeniv -// size: 16 -type GlxGetTexGenivCookie struct { - *cookie -} - -func (c *Conn) GlxGetTexGeniv(ContextTag GlxContextTag, Coord uint32, Pname uint32) GlxGetTexGenivCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetTexGenivRequest(ContextTag, Coord, Pname), cookie) - return GlxGetTexGenivCookie{cookie} -} - -func (c *Conn) GlxGetTexGenivUnchecked(ContextTag GlxContextTag, Coord uint32, Pname uint32) GlxGetTexGenivCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetTexGenivRequest(ContextTag, Coord, Pname), cookie) - return GlxGetTexGenivCookie{cookie} -} - -// Request reply for GlxGetTexGeniv -// size: (32 + pad((int(N) * 4))) -type GlxGetTexGenivReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum int32 - // padding: 12 bytes - Data []int32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetTexGeniv -func (cook GlxGetTexGenivCookie) Reply() (*GlxGetTexGenivReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetTexGenivReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetTexGeniv -func glxGetTexGenivReply(buf []byte) *GlxGetTexGenivReply { - v := new(GlxGetTexGenivReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = int32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]int32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = int32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetTexGenivCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetTexGeniv -func (c *Conn) glxGetTexGenivRequest(ContextTag GlxContextTag, Coord uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 134 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Coord) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetTexImage -// size: 28 -type GlxGetTexImageCookie struct { - *cookie -} - -func (c *Conn) GlxGetTexImage(ContextTag GlxContextTag, Target uint32, Level int32, Format uint32, Type uint32, SwapBytes bool) GlxGetTexImageCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetTexImageRequest(ContextTag, Target, Level, Format, Type, SwapBytes), cookie) - return GlxGetTexImageCookie{cookie} -} - -func (c *Conn) GlxGetTexImageUnchecked(ContextTag GlxContextTag, Target uint32, Level int32, Format uint32, Type uint32, SwapBytes bool) GlxGetTexImageCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetTexImageRequest(ContextTag, Target, Level, Format, Type, SwapBytes), cookie) - return GlxGetTexImageCookie{cookie} -} - -// Request reply for GlxGetTexImage -// size: (32 + pad(((int(Length) * 4) * 1))) -type GlxGetTexImageReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 8 bytes - Width int32 - Height int32 - Depth int32 - // padding: 4 bytes - Data []byte // size: pad(((int(Length) * 4) * 1)) -} - -// Waits and reads reply data from request GlxGetTexImage -func (cook GlxGetTexImageCookie) Reply() (*GlxGetTexImageReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetTexImageReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetTexImage -func glxGetTexImageReply(buf []byte) *GlxGetTexImageReply { - v := new(GlxGetTexImageReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 8 // padding - - v.Width = int32(Get32(buf[b:])) - b += 4 - - v.Height = int32(Get32(buf[b:])) - b += 4 - - v.Depth = int32(Get32(buf[b:])) - b += 4 - - b += 4 // padding - - v.Data = make([]byte, (int(v.Length) * 4)) - copy(v.Data[:(int(v.Length)*4)], buf[b:]) - b += pad(int((int(v.Length) * 4))) - - return v -} - -func (cook GlxGetTexImageCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetTexImage -func (c *Conn) glxGetTexImageRequest(ContextTag GlxContextTag, Target uint32, Level int32, Format uint32, Type uint32, SwapBytes bool) []byte { - size := 28 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 135 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], uint32(Level)) - b += 4 - - Put32(buf[b:], Format) - b += 4 - - Put32(buf[b:], Type) - b += 4 - - if SwapBytes { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - return buf -} - -// Request GlxGetTexParameterfv -// size: 16 -type GlxGetTexParameterfvCookie struct { - *cookie -} - -func (c *Conn) GlxGetTexParameterfv(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetTexParameterfvCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetTexParameterfvRequest(ContextTag, Target, Pname), cookie) - return GlxGetTexParameterfvCookie{cookie} -} - -func (c *Conn) GlxGetTexParameterfvUnchecked(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetTexParameterfvCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetTexParameterfvRequest(ContextTag, Target, Pname), cookie) - return GlxGetTexParameterfvCookie{cookie} -} - -// Request reply for GlxGetTexParameterfv -// size: (32 + pad((int(N) * 4))) -type GlxGetTexParameterfvReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum GlxFloat32 - // padding: 12 bytes - Data []GlxFloat32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetTexParameterfv -func (cook GlxGetTexParameterfvCookie) Reply() (*GlxGetTexParameterfvReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetTexParameterfvReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetTexParameterfv -func glxGetTexParameterfvReply(buf []byte) *GlxGetTexParameterfvReply { - v := new(GlxGetTexParameterfvReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = GlxFloat32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]GlxFloat32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = GlxFloat32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetTexParameterfvCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetTexParameterfv -func (c *Conn) glxGetTexParameterfvRequest(ContextTag GlxContextTag, Target uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 136 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetTexParameteriv -// size: 16 -type GlxGetTexParameterivCookie struct { - *cookie -} - -func (c *Conn) GlxGetTexParameteriv(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetTexParameterivCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetTexParameterivRequest(ContextTag, Target, Pname), cookie) - return GlxGetTexParameterivCookie{cookie} -} - -func (c *Conn) GlxGetTexParameterivUnchecked(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetTexParameterivCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetTexParameterivRequest(ContextTag, Target, Pname), cookie) - return GlxGetTexParameterivCookie{cookie} -} - -// Request reply for GlxGetTexParameteriv -// size: (32 + pad((int(N) * 4))) -type GlxGetTexParameterivReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum int32 - // padding: 12 bytes - Data []int32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetTexParameteriv -func (cook GlxGetTexParameterivCookie) Reply() (*GlxGetTexParameterivReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetTexParameterivReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetTexParameteriv -func glxGetTexParameterivReply(buf []byte) *GlxGetTexParameterivReply { - v := new(GlxGetTexParameterivReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = int32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]int32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = int32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetTexParameterivCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetTexParameteriv -func (c *Conn) glxGetTexParameterivRequest(ContextTag GlxContextTag, Target uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 137 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetTexLevelParameterfv -// size: 20 -type GlxGetTexLevelParameterfvCookie struct { - *cookie -} - -func (c *Conn) GlxGetTexLevelParameterfv(ContextTag GlxContextTag, Target uint32, Level int32, Pname uint32) GlxGetTexLevelParameterfvCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetTexLevelParameterfvRequest(ContextTag, Target, Level, Pname), cookie) - return GlxGetTexLevelParameterfvCookie{cookie} -} - -func (c *Conn) GlxGetTexLevelParameterfvUnchecked(ContextTag GlxContextTag, Target uint32, Level int32, Pname uint32) GlxGetTexLevelParameterfvCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetTexLevelParameterfvRequest(ContextTag, Target, Level, Pname), cookie) - return GlxGetTexLevelParameterfvCookie{cookie} -} - -// Request reply for GlxGetTexLevelParameterfv -// size: (32 + pad((int(N) * 4))) -type GlxGetTexLevelParameterfvReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum GlxFloat32 - // padding: 12 bytes - Data []GlxFloat32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetTexLevelParameterfv -func (cook GlxGetTexLevelParameterfvCookie) Reply() (*GlxGetTexLevelParameterfvReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetTexLevelParameterfvReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetTexLevelParameterfv -func glxGetTexLevelParameterfvReply(buf []byte) *GlxGetTexLevelParameterfvReply { - v := new(GlxGetTexLevelParameterfvReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = GlxFloat32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]GlxFloat32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = GlxFloat32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetTexLevelParameterfvCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetTexLevelParameterfv -func (c *Conn) glxGetTexLevelParameterfvRequest(ContextTag GlxContextTag, Target uint32, Level int32, Pname uint32) []byte { - size := 20 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 138 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], uint32(Level)) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetTexLevelParameteriv -// size: 20 -type GlxGetTexLevelParameterivCookie struct { - *cookie -} - -func (c *Conn) GlxGetTexLevelParameteriv(ContextTag GlxContextTag, Target uint32, Level int32, Pname uint32) GlxGetTexLevelParameterivCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetTexLevelParameterivRequest(ContextTag, Target, Level, Pname), cookie) - return GlxGetTexLevelParameterivCookie{cookie} -} - -func (c *Conn) GlxGetTexLevelParameterivUnchecked(ContextTag GlxContextTag, Target uint32, Level int32, Pname uint32) GlxGetTexLevelParameterivCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetTexLevelParameterivRequest(ContextTag, Target, Level, Pname), cookie) - return GlxGetTexLevelParameterivCookie{cookie} -} - -// Request reply for GlxGetTexLevelParameteriv -// size: (32 + pad((int(N) * 4))) -type GlxGetTexLevelParameterivReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum int32 - // padding: 12 bytes - Data []int32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetTexLevelParameteriv -func (cook GlxGetTexLevelParameterivCookie) Reply() (*GlxGetTexLevelParameterivReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetTexLevelParameterivReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetTexLevelParameteriv -func glxGetTexLevelParameterivReply(buf []byte) *GlxGetTexLevelParameterivReply { - v := new(GlxGetTexLevelParameterivReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = int32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]int32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = int32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetTexLevelParameterivCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetTexLevelParameteriv -func (c *Conn) glxGetTexLevelParameterivRequest(ContextTag GlxContextTag, Target uint32, Level int32, Pname uint32) []byte { - size := 20 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 139 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], uint32(Level)) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxIsList -// size: 12 -type GlxIsListCookie struct { - *cookie -} - -func (c *Conn) GlxIsList(ContextTag GlxContextTag, List uint32) GlxIsListCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxIsListRequest(ContextTag, List), cookie) - return GlxIsListCookie{cookie} -} - -func (c *Conn) GlxIsListUnchecked(ContextTag GlxContextTag, List uint32) GlxIsListCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxIsListRequest(ContextTag, List), cookie) - return GlxIsListCookie{cookie} -} - -// Request reply for GlxIsList -// size: 12 -type GlxIsListReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - RetVal GlxBool32 -} - -// Waits and reads reply data from request GlxIsList -func (cook GlxIsListCookie) Reply() (*GlxIsListReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxIsListReply(buf), nil -} - -// Read reply into structure from buffer for GlxIsList -func glxIsListReply(buf []byte) *GlxIsListReply { - v := new(GlxIsListReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.RetVal = GlxBool32(Get32(buf[b:])) - b += 4 - - return v -} - -func (cook GlxIsListCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxIsList -func (c *Conn) glxIsListRequest(ContextTag GlxContextTag, List uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 141 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], List) - b += 4 - - return buf -} - -// Request GlxFlush -// size: 8 -type GlxFlushCookie struct { - *cookie -} - -// Write request to wire for GlxFlush -func (c *Conn) GlxFlush(ContextTag GlxContextTag) GlxFlushCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxFlushRequest(ContextTag), cookie) - return GlxFlushCookie{cookie} -} - -func (c *Conn) GlxFlushChecked(ContextTag GlxContextTag) GlxFlushCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxFlushRequest(ContextTag), cookie) - return GlxFlushCookie{cookie} -} - -func (cook GlxFlushCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxFlush -func (c *Conn) glxFlushRequest(ContextTag GlxContextTag) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 142 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - return buf -} - -// Request GlxAreTexturesResident -// size: pad((12 + pad((int(N) * 4)))) -type GlxAreTexturesResidentCookie struct { - *cookie -} - -func (c *Conn) GlxAreTexturesResident(ContextTag GlxContextTag, N int32, Textures []uint32) GlxAreTexturesResidentCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxAreTexturesResidentRequest(ContextTag, N, Textures), cookie) - return GlxAreTexturesResidentCookie{cookie} -} - -func (c *Conn) GlxAreTexturesResidentUnchecked(ContextTag GlxContextTag, N int32, Textures []uint32) GlxAreTexturesResidentCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxAreTexturesResidentRequest(ContextTag, N, Textures), cookie) - return GlxAreTexturesResidentCookie{cookie} -} - -// Request reply for GlxAreTexturesResident -// size: (32 + pad(((int(Length) * 4) * 1))) -type GlxAreTexturesResidentReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - RetVal GlxBool32 - // padding: 20 bytes - Data []bool // size: pad(((int(Length) * 4) * 1)) -} - -// Waits and reads reply data from request GlxAreTexturesResident -func (cook GlxAreTexturesResidentCookie) Reply() (*GlxAreTexturesResidentReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxAreTexturesResidentReply(buf), nil -} - -// Read reply into structure from buffer for GlxAreTexturesResident -func glxAreTexturesResidentReply(buf []byte) *GlxAreTexturesResidentReply { - v := new(GlxAreTexturesResidentReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.RetVal = GlxBool32(Get32(buf[b:])) - b += 4 - - b += 20 // padding - - v.Data = make([]bool, (int(v.Length) * 4)) - for i := 0; i < int((int(v.Length) * 4)); i++ { - if buf[b] == 1 { - v.Data[i] = true - } else { - v.Data[i] = false - } - b += 1 - } - b = pad(b) - - return v -} - -func (cook GlxAreTexturesResidentCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxAreTexturesResident -func (c *Conn) glxAreTexturesResidentRequest(ContextTag GlxContextTag, N int32, Textures []uint32) []byte { - size := pad((12 + pad((int(N) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 143 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], uint32(N)) - b += 4 - - for i := 0; i < int(N); i++ { - Put32(buf[b:], Textures[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Request GlxDeleteTextures -// size: pad((12 + pad((int(N) * 4)))) -type GlxDeleteTexturesCookie struct { - *cookie -} - -// Write request to wire for GlxDeleteTextures -func (c *Conn) GlxDeleteTextures(ContextTag GlxContextTag, N int32, Textures []uint32) GlxDeleteTexturesCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxDeleteTexturesRequest(ContextTag, N, Textures), cookie) - return GlxDeleteTexturesCookie{cookie} -} - -func (c *Conn) GlxDeleteTexturesChecked(ContextTag GlxContextTag, N int32, Textures []uint32) GlxDeleteTexturesCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxDeleteTexturesRequest(ContextTag, N, Textures), cookie) - return GlxDeleteTexturesCookie{cookie} -} - -func (cook GlxDeleteTexturesCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxDeleteTextures -func (c *Conn) glxDeleteTexturesRequest(ContextTag GlxContextTag, N int32, Textures []uint32) []byte { - size := pad((12 + pad((int(N) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 144 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], uint32(N)) - b += 4 - - for i := 0; i < int(N); i++ { - Put32(buf[b:], Textures[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Request GlxGenTextures -// size: 12 -type GlxGenTexturesCookie struct { - *cookie -} - -func (c *Conn) GlxGenTextures(ContextTag GlxContextTag, N int32) GlxGenTexturesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGenTexturesRequest(ContextTag, N), cookie) - return GlxGenTexturesCookie{cookie} -} - -func (c *Conn) GlxGenTexturesUnchecked(ContextTag GlxContextTag, N int32) GlxGenTexturesCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGenTexturesRequest(ContextTag, N), cookie) - return GlxGenTexturesCookie{cookie} -} - -// Request reply for GlxGenTextures -// size: (32 + pad((int(Length) * 4))) -type GlxGenTexturesReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 24 bytes - Data []uint32 // size: pad((int(Length) * 4)) -} - -// Waits and reads reply data from request GlxGenTextures -func (cook GlxGenTexturesCookie) Reply() (*GlxGenTexturesReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGenTexturesReply(buf), nil -} - -// Read reply into structure from buffer for GlxGenTextures -func glxGenTexturesReply(buf []byte) *GlxGenTexturesReply { - v := new(GlxGenTexturesReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 24 // padding - - v.Data = make([]uint32, v.Length) - for i := 0; i < int(v.Length); i++ { - v.Data[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGenTexturesCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGenTextures -func (c *Conn) glxGenTexturesRequest(ContextTag GlxContextTag, N int32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 145 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], uint32(N)) - b += 4 - - return buf -} - -// Request GlxIsTexture -// size: 12 -type GlxIsTextureCookie struct { - *cookie -} - -func (c *Conn) GlxIsTexture(ContextTag GlxContextTag, Texture uint32) GlxIsTextureCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxIsTextureRequest(ContextTag, Texture), cookie) - return GlxIsTextureCookie{cookie} -} - -func (c *Conn) GlxIsTextureUnchecked(ContextTag GlxContextTag, Texture uint32) GlxIsTextureCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxIsTextureRequest(ContextTag, Texture), cookie) - return GlxIsTextureCookie{cookie} -} - -// Request reply for GlxIsTexture -// size: 12 -type GlxIsTextureReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - RetVal GlxBool32 -} - -// Waits and reads reply data from request GlxIsTexture -func (cook GlxIsTextureCookie) Reply() (*GlxIsTextureReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxIsTextureReply(buf), nil -} - -// Read reply into structure from buffer for GlxIsTexture -func glxIsTextureReply(buf []byte) *GlxIsTextureReply { - v := new(GlxIsTextureReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.RetVal = GlxBool32(Get32(buf[b:])) - b += 4 - - return v -} - -func (cook GlxIsTextureCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxIsTexture -func (c *Conn) glxIsTextureRequest(ContextTag GlxContextTag, Texture uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 146 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Texture) - b += 4 - - return buf -} - -// Request GlxGetColorTable -// size: 24 -type GlxGetColorTableCookie struct { - *cookie -} - -func (c *Conn) GlxGetColorTable(ContextTag GlxContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GlxGetColorTableCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetColorTableRequest(ContextTag, Target, Format, Type, SwapBytes), cookie) - return GlxGetColorTableCookie{cookie} -} - -func (c *Conn) GlxGetColorTableUnchecked(ContextTag GlxContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GlxGetColorTableCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetColorTableRequest(ContextTag, Target, Format, Type, SwapBytes), cookie) - return GlxGetColorTableCookie{cookie} -} - -// Request reply for GlxGetColorTable -// size: (32 + pad(((int(Length) * 4) * 1))) -type GlxGetColorTableReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 8 bytes - Width int32 - // padding: 12 bytes - Data []byte // size: pad(((int(Length) * 4) * 1)) -} - -// Waits and reads reply data from request GlxGetColorTable -func (cook GlxGetColorTableCookie) Reply() (*GlxGetColorTableReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetColorTableReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetColorTable -func glxGetColorTableReply(buf []byte) *GlxGetColorTableReply { - v := new(GlxGetColorTableReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 8 // padding - - v.Width = int32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]byte, (int(v.Length) * 4)) - copy(v.Data[:(int(v.Length)*4)], buf[b:]) - b += pad(int((int(v.Length) * 4))) - - return v -} - -func (cook GlxGetColorTableCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetColorTable -func (c *Conn) glxGetColorTableRequest(ContextTag GlxContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) []byte { - size := 24 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 147 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Format) - b += 4 - - Put32(buf[b:], Type) - b += 4 - - if SwapBytes { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - return buf -} - -// Request GlxGetColorTableParameterfv -// size: 16 -type GlxGetColorTableParameterfvCookie struct { - *cookie -} - -func (c *Conn) GlxGetColorTableParameterfv(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetColorTableParameterfvCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetColorTableParameterfvRequest(ContextTag, Target, Pname), cookie) - return GlxGetColorTableParameterfvCookie{cookie} -} - -func (c *Conn) GlxGetColorTableParameterfvUnchecked(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetColorTableParameterfvCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetColorTableParameterfvRequest(ContextTag, Target, Pname), cookie) - return GlxGetColorTableParameterfvCookie{cookie} -} - -// Request reply for GlxGetColorTableParameterfv -// size: (32 + pad((int(N) * 4))) -type GlxGetColorTableParameterfvReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum GlxFloat32 - // padding: 12 bytes - Data []GlxFloat32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetColorTableParameterfv -func (cook GlxGetColorTableParameterfvCookie) Reply() (*GlxGetColorTableParameterfvReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetColorTableParameterfvReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetColorTableParameterfv -func glxGetColorTableParameterfvReply(buf []byte) *GlxGetColorTableParameterfvReply { - v := new(GlxGetColorTableParameterfvReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = GlxFloat32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]GlxFloat32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = GlxFloat32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetColorTableParameterfvCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetColorTableParameterfv -func (c *Conn) glxGetColorTableParameterfvRequest(ContextTag GlxContextTag, Target uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 148 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetColorTableParameteriv -// size: 16 -type GlxGetColorTableParameterivCookie struct { - *cookie -} - -func (c *Conn) GlxGetColorTableParameteriv(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetColorTableParameterivCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetColorTableParameterivRequest(ContextTag, Target, Pname), cookie) - return GlxGetColorTableParameterivCookie{cookie} -} - -func (c *Conn) GlxGetColorTableParameterivUnchecked(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetColorTableParameterivCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetColorTableParameterivRequest(ContextTag, Target, Pname), cookie) - return GlxGetColorTableParameterivCookie{cookie} -} - -// Request reply for GlxGetColorTableParameteriv -// size: (32 + pad((int(N) * 4))) -type GlxGetColorTableParameterivReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum int32 - // padding: 12 bytes - Data []int32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetColorTableParameteriv -func (cook GlxGetColorTableParameterivCookie) Reply() (*GlxGetColorTableParameterivReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetColorTableParameterivReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetColorTableParameteriv -func glxGetColorTableParameterivReply(buf []byte) *GlxGetColorTableParameterivReply { - v := new(GlxGetColorTableParameterivReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = int32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]int32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = int32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetColorTableParameterivCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetColorTableParameteriv -func (c *Conn) glxGetColorTableParameterivRequest(ContextTag GlxContextTag, Target uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 149 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetConvolutionFilter -// size: 24 -type GlxGetConvolutionFilterCookie struct { - *cookie -} - -func (c *Conn) GlxGetConvolutionFilter(ContextTag GlxContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GlxGetConvolutionFilterCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetConvolutionFilterRequest(ContextTag, Target, Format, Type, SwapBytes), cookie) - return GlxGetConvolutionFilterCookie{cookie} -} - -func (c *Conn) GlxGetConvolutionFilterUnchecked(ContextTag GlxContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GlxGetConvolutionFilterCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetConvolutionFilterRequest(ContextTag, Target, Format, Type, SwapBytes), cookie) - return GlxGetConvolutionFilterCookie{cookie} -} - -// Request reply for GlxGetConvolutionFilter -// size: (32 + pad(((int(Length) * 4) * 1))) -type GlxGetConvolutionFilterReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 8 bytes - Width int32 - Height int32 - // padding: 8 bytes - Data []byte // size: pad(((int(Length) * 4) * 1)) -} - -// Waits and reads reply data from request GlxGetConvolutionFilter -func (cook GlxGetConvolutionFilterCookie) Reply() (*GlxGetConvolutionFilterReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetConvolutionFilterReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetConvolutionFilter -func glxGetConvolutionFilterReply(buf []byte) *GlxGetConvolutionFilterReply { - v := new(GlxGetConvolutionFilterReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 8 // padding - - v.Width = int32(Get32(buf[b:])) - b += 4 - - v.Height = int32(Get32(buf[b:])) - b += 4 - - b += 8 // padding - - v.Data = make([]byte, (int(v.Length) * 4)) - copy(v.Data[:(int(v.Length)*4)], buf[b:]) - b += pad(int((int(v.Length) * 4))) - - return v -} - -func (cook GlxGetConvolutionFilterCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetConvolutionFilter -func (c *Conn) glxGetConvolutionFilterRequest(ContextTag GlxContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) []byte { - size := 24 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 150 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Format) - b += 4 - - Put32(buf[b:], Type) - b += 4 - - if SwapBytes { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - return buf -} - -// Request GlxGetConvolutionParameterfv -// size: 16 -type GlxGetConvolutionParameterfvCookie struct { - *cookie -} - -func (c *Conn) GlxGetConvolutionParameterfv(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetConvolutionParameterfvCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetConvolutionParameterfvRequest(ContextTag, Target, Pname), cookie) - return GlxGetConvolutionParameterfvCookie{cookie} -} - -func (c *Conn) GlxGetConvolutionParameterfvUnchecked(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetConvolutionParameterfvCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetConvolutionParameterfvRequest(ContextTag, Target, Pname), cookie) - return GlxGetConvolutionParameterfvCookie{cookie} -} - -// Request reply for GlxGetConvolutionParameterfv -// size: (32 + pad((int(N) * 4))) -type GlxGetConvolutionParameterfvReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum GlxFloat32 - // padding: 12 bytes - Data []GlxFloat32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetConvolutionParameterfv -func (cook GlxGetConvolutionParameterfvCookie) Reply() (*GlxGetConvolutionParameterfvReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetConvolutionParameterfvReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetConvolutionParameterfv -func glxGetConvolutionParameterfvReply(buf []byte) *GlxGetConvolutionParameterfvReply { - v := new(GlxGetConvolutionParameterfvReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = GlxFloat32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]GlxFloat32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = GlxFloat32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetConvolutionParameterfvCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetConvolutionParameterfv -func (c *Conn) glxGetConvolutionParameterfvRequest(ContextTag GlxContextTag, Target uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 151 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetConvolutionParameteriv -// size: 16 -type GlxGetConvolutionParameterivCookie struct { - *cookie -} - -func (c *Conn) GlxGetConvolutionParameteriv(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetConvolutionParameterivCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetConvolutionParameterivRequest(ContextTag, Target, Pname), cookie) - return GlxGetConvolutionParameterivCookie{cookie} -} - -func (c *Conn) GlxGetConvolutionParameterivUnchecked(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetConvolutionParameterivCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetConvolutionParameterivRequest(ContextTag, Target, Pname), cookie) - return GlxGetConvolutionParameterivCookie{cookie} -} - -// Request reply for GlxGetConvolutionParameteriv -// size: (32 + pad((int(N) * 4))) -type GlxGetConvolutionParameterivReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum int32 - // padding: 12 bytes - Data []int32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetConvolutionParameteriv -func (cook GlxGetConvolutionParameterivCookie) Reply() (*GlxGetConvolutionParameterivReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetConvolutionParameterivReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetConvolutionParameteriv -func glxGetConvolutionParameterivReply(buf []byte) *GlxGetConvolutionParameterivReply { - v := new(GlxGetConvolutionParameterivReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = int32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]int32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = int32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetConvolutionParameterivCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetConvolutionParameteriv -func (c *Conn) glxGetConvolutionParameterivRequest(ContextTag GlxContextTag, Target uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 152 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetSeparableFilter -// size: 24 -type GlxGetSeparableFilterCookie struct { - *cookie -} - -func (c *Conn) GlxGetSeparableFilter(ContextTag GlxContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GlxGetSeparableFilterCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetSeparableFilterRequest(ContextTag, Target, Format, Type, SwapBytes), cookie) - return GlxGetSeparableFilterCookie{cookie} -} - -func (c *Conn) GlxGetSeparableFilterUnchecked(ContextTag GlxContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GlxGetSeparableFilterCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetSeparableFilterRequest(ContextTag, Target, Format, Type, SwapBytes), cookie) - return GlxGetSeparableFilterCookie{cookie} -} - -// Request reply for GlxGetSeparableFilter -// size: (32 + pad(((int(Length) * 4) * 1))) -type GlxGetSeparableFilterReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 8 bytes - RowW int32 - ColH int32 - // padding: 8 bytes - RowsAndCols []byte // size: pad(((int(Length) * 4) * 1)) -} - -// Waits and reads reply data from request GlxGetSeparableFilter -func (cook GlxGetSeparableFilterCookie) Reply() (*GlxGetSeparableFilterReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetSeparableFilterReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetSeparableFilter -func glxGetSeparableFilterReply(buf []byte) *GlxGetSeparableFilterReply { - v := new(GlxGetSeparableFilterReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 8 // padding - - v.RowW = int32(Get32(buf[b:])) - b += 4 - - v.ColH = int32(Get32(buf[b:])) - b += 4 - - b += 8 // padding - - v.RowsAndCols = make([]byte, (int(v.Length) * 4)) - copy(v.RowsAndCols[:(int(v.Length)*4)], buf[b:]) - b += pad(int((int(v.Length) * 4))) - - return v -} - -func (cook GlxGetSeparableFilterCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetSeparableFilter -func (c *Conn) glxGetSeparableFilterRequest(ContextTag GlxContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) []byte { - size := 24 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 153 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Format) - b += 4 - - Put32(buf[b:], Type) - b += 4 - - if SwapBytes { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - return buf -} - -// Request GlxGetHistogram -// size: 24 -type GlxGetHistogramCookie struct { - *cookie -} - -func (c *Conn) GlxGetHistogram(ContextTag GlxContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) GlxGetHistogramCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetHistogramRequest(ContextTag, Target, Format, Type, SwapBytes, Reset), cookie) - return GlxGetHistogramCookie{cookie} -} - -func (c *Conn) GlxGetHistogramUnchecked(ContextTag GlxContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) GlxGetHistogramCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetHistogramRequest(ContextTag, Target, Format, Type, SwapBytes, Reset), cookie) - return GlxGetHistogramCookie{cookie} -} - -// Request reply for GlxGetHistogram -// size: (32 + pad(((int(Length) * 4) * 1))) -type GlxGetHistogramReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 8 bytes - Width int32 - // padding: 12 bytes - Data []byte // size: pad(((int(Length) * 4) * 1)) -} - -// Waits and reads reply data from request GlxGetHistogram -func (cook GlxGetHistogramCookie) Reply() (*GlxGetHistogramReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetHistogramReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetHistogram -func glxGetHistogramReply(buf []byte) *GlxGetHistogramReply { - v := new(GlxGetHistogramReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 8 // padding - - v.Width = int32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]byte, (int(v.Length) * 4)) - copy(v.Data[:(int(v.Length)*4)], buf[b:]) - b += pad(int((int(v.Length) * 4))) - - return v -} - -func (cook GlxGetHistogramCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetHistogram -func (c *Conn) glxGetHistogramRequest(ContextTag GlxContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) []byte { - size := 24 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 154 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Format) - b += 4 - - Put32(buf[b:], Type) - b += 4 - - if SwapBytes { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - if Reset { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - return buf -} - -// Request GlxGetHistogramParameterfv -// size: 16 -type GlxGetHistogramParameterfvCookie struct { - *cookie -} - -func (c *Conn) GlxGetHistogramParameterfv(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetHistogramParameterfvCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetHistogramParameterfvRequest(ContextTag, Target, Pname), cookie) - return GlxGetHistogramParameterfvCookie{cookie} -} - -func (c *Conn) GlxGetHistogramParameterfvUnchecked(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetHistogramParameterfvCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetHistogramParameterfvRequest(ContextTag, Target, Pname), cookie) - return GlxGetHistogramParameterfvCookie{cookie} -} - -// Request reply for GlxGetHistogramParameterfv -// size: (32 + pad((int(N) * 4))) -type GlxGetHistogramParameterfvReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum GlxFloat32 - // padding: 12 bytes - Data []GlxFloat32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetHistogramParameterfv -func (cook GlxGetHistogramParameterfvCookie) Reply() (*GlxGetHistogramParameterfvReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetHistogramParameterfvReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetHistogramParameterfv -func glxGetHistogramParameterfvReply(buf []byte) *GlxGetHistogramParameterfvReply { - v := new(GlxGetHistogramParameterfvReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = GlxFloat32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]GlxFloat32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = GlxFloat32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetHistogramParameterfvCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetHistogramParameterfv -func (c *Conn) glxGetHistogramParameterfvRequest(ContextTag GlxContextTag, Target uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 155 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetHistogramParameteriv -// size: 16 -type GlxGetHistogramParameterivCookie struct { - *cookie -} - -func (c *Conn) GlxGetHistogramParameteriv(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetHistogramParameterivCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetHistogramParameterivRequest(ContextTag, Target, Pname), cookie) - return GlxGetHistogramParameterivCookie{cookie} -} - -func (c *Conn) GlxGetHistogramParameterivUnchecked(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetHistogramParameterivCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetHistogramParameterivRequest(ContextTag, Target, Pname), cookie) - return GlxGetHistogramParameterivCookie{cookie} -} - -// Request reply for GlxGetHistogramParameteriv -// size: (32 + pad((int(N) * 4))) -type GlxGetHistogramParameterivReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum int32 - // padding: 12 bytes - Data []int32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetHistogramParameteriv -func (cook GlxGetHistogramParameterivCookie) Reply() (*GlxGetHistogramParameterivReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetHistogramParameterivReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetHistogramParameteriv -func glxGetHistogramParameterivReply(buf []byte) *GlxGetHistogramParameterivReply { - v := new(GlxGetHistogramParameterivReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = int32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]int32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = int32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetHistogramParameterivCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetHistogramParameteriv -func (c *Conn) glxGetHistogramParameterivRequest(ContextTag GlxContextTag, Target uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 156 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetMinmax -// size: 24 -type GlxGetMinmaxCookie struct { - *cookie -} - -func (c *Conn) GlxGetMinmax(ContextTag GlxContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) GlxGetMinmaxCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetMinmaxRequest(ContextTag, Target, Format, Type, SwapBytes, Reset), cookie) - return GlxGetMinmaxCookie{cookie} -} - -func (c *Conn) GlxGetMinmaxUnchecked(ContextTag GlxContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) GlxGetMinmaxCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetMinmaxRequest(ContextTag, Target, Format, Type, SwapBytes, Reset), cookie) - return GlxGetMinmaxCookie{cookie} -} - -// Request reply for GlxGetMinmax -// size: (32 + pad(((int(Length) * 4) * 1))) -type GlxGetMinmaxReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 24 bytes - Data []byte // size: pad(((int(Length) * 4) * 1)) -} - -// Waits and reads reply data from request GlxGetMinmax -func (cook GlxGetMinmaxCookie) Reply() (*GlxGetMinmaxReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetMinmaxReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetMinmax -func glxGetMinmaxReply(buf []byte) *GlxGetMinmaxReply { - v := new(GlxGetMinmaxReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 24 // padding - - v.Data = make([]byte, (int(v.Length) * 4)) - copy(v.Data[:(int(v.Length)*4)], buf[b:]) - b += pad(int((int(v.Length) * 4))) - - return v -} - -func (cook GlxGetMinmaxCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetMinmax -func (c *Conn) glxGetMinmaxRequest(ContextTag GlxContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) []byte { - size := 24 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 157 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Format) - b += 4 - - Put32(buf[b:], Type) - b += 4 - - if SwapBytes { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - if Reset { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - return buf -} - -// Request GlxGetMinmaxParameterfv -// size: 16 -type GlxGetMinmaxParameterfvCookie struct { - *cookie -} - -func (c *Conn) GlxGetMinmaxParameterfv(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetMinmaxParameterfvCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetMinmaxParameterfvRequest(ContextTag, Target, Pname), cookie) - return GlxGetMinmaxParameterfvCookie{cookie} -} - -func (c *Conn) GlxGetMinmaxParameterfvUnchecked(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetMinmaxParameterfvCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetMinmaxParameterfvRequest(ContextTag, Target, Pname), cookie) - return GlxGetMinmaxParameterfvCookie{cookie} -} - -// Request reply for GlxGetMinmaxParameterfv -// size: (32 + pad((int(N) * 4))) -type GlxGetMinmaxParameterfvReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum GlxFloat32 - // padding: 12 bytes - Data []GlxFloat32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetMinmaxParameterfv -func (cook GlxGetMinmaxParameterfvCookie) Reply() (*GlxGetMinmaxParameterfvReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetMinmaxParameterfvReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetMinmaxParameterfv -func glxGetMinmaxParameterfvReply(buf []byte) *GlxGetMinmaxParameterfvReply { - v := new(GlxGetMinmaxParameterfvReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = GlxFloat32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]GlxFloat32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = GlxFloat32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetMinmaxParameterfvCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetMinmaxParameterfv -func (c *Conn) glxGetMinmaxParameterfvRequest(ContextTag GlxContextTag, Target uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 158 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetMinmaxParameteriv -// size: 16 -type GlxGetMinmaxParameterivCookie struct { - *cookie -} - -func (c *Conn) GlxGetMinmaxParameteriv(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetMinmaxParameterivCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetMinmaxParameterivRequest(ContextTag, Target, Pname), cookie) - return GlxGetMinmaxParameterivCookie{cookie} -} - -func (c *Conn) GlxGetMinmaxParameterivUnchecked(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetMinmaxParameterivCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetMinmaxParameterivRequest(ContextTag, Target, Pname), cookie) - return GlxGetMinmaxParameterivCookie{cookie} -} - -// Request reply for GlxGetMinmaxParameteriv -// size: (32 + pad((int(N) * 4))) -type GlxGetMinmaxParameterivReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum int32 - // padding: 12 bytes - Data []int32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetMinmaxParameteriv -func (cook GlxGetMinmaxParameterivCookie) Reply() (*GlxGetMinmaxParameterivReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetMinmaxParameterivReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetMinmaxParameteriv -func glxGetMinmaxParameterivReply(buf []byte) *GlxGetMinmaxParameterivReply { - v := new(GlxGetMinmaxParameterivReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = int32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]int32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = int32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetMinmaxParameterivCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetMinmaxParameteriv -func (c *Conn) glxGetMinmaxParameterivRequest(ContextTag GlxContextTag, Target uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 159 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetCompressedTexImageARB -// size: 16 -type GlxGetCompressedTexImageARBCookie struct { - *cookie -} - -func (c *Conn) GlxGetCompressedTexImageARB(ContextTag GlxContextTag, Target uint32, Level int32) GlxGetCompressedTexImageARBCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetCompressedTexImageARBRequest(ContextTag, Target, Level), cookie) - return GlxGetCompressedTexImageARBCookie{cookie} -} - -func (c *Conn) GlxGetCompressedTexImageARBUnchecked(ContextTag GlxContextTag, Target uint32, Level int32) GlxGetCompressedTexImageARBCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetCompressedTexImageARBRequest(ContextTag, Target, Level), cookie) - return GlxGetCompressedTexImageARBCookie{cookie} -} - -// Request reply for GlxGetCompressedTexImageARB -// size: (32 + pad(((int(Length) * 4) * 1))) -type GlxGetCompressedTexImageARBReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 8 bytes - Size int32 - // padding: 12 bytes - Data []byte // size: pad(((int(Length) * 4) * 1)) -} - -// Waits and reads reply data from request GlxGetCompressedTexImageARB -func (cook GlxGetCompressedTexImageARBCookie) Reply() (*GlxGetCompressedTexImageARBReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetCompressedTexImageARBReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetCompressedTexImageARB -func glxGetCompressedTexImageARBReply(buf []byte) *GlxGetCompressedTexImageARBReply { - v := new(GlxGetCompressedTexImageARBReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 8 // padding - - v.Size = int32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]byte, (int(v.Length) * 4)) - copy(v.Data[:(int(v.Length)*4)], buf[b:]) - b += pad(int((int(v.Length) * 4))) - - return v -} - -func (cook GlxGetCompressedTexImageARBCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetCompressedTexImageARB -func (c *Conn) glxGetCompressedTexImageARBRequest(ContextTag GlxContextTag, Target uint32, Level int32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 160 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], uint32(Level)) - b += 4 - - return buf -} - -// Request GlxDeleteQueriesARB -// size: pad((12 + pad((int(N) * 4)))) -type GlxDeleteQueriesARBCookie struct { - *cookie -} - -// Write request to wire for GlxDeleteQueriesARB -func (c *Conn) GlxDeleteQueriesARB(ContextTag GlxContextTag, N int32, Ids []uint32) GlxDeleteQueriesARBCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.glxDeleteQueriesARBRequest(ContextTag, N, Ids), cookie) - return GlxDeleteQueriesARBCookie{cookie} -} - -func (c *Conn) GlxDeleteQueriesARBChecked(ContextTag GlxContextTag, N int32, Ids []uint32) GlxDeleteQueriesARBCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.glxDeleteQueriesARBRequest(ContextTag, N, Ids), cookie) - return GlxDeleteQueriesARBCookie{cookie} -} - -func (cook GlxDeleteQueriesARBCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxDeleteQueriesARB -func (c *Conn) glxDeleteQueriesARBRequest(ContextTag GlxContextTag, N int32, Ids []uint32) []byte { - size := pad((12 + pad((int(N) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 161 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], uint32(N)) - b += 4 - - for i := 0; i < int(N); i++ { - Put32(buf[b:], Ids[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Request GlxGenQueriesARB -// size: 12 -type GlxGenQueriesARBCookie struct { - *cookie -} - -func (c *Conn) GlxGenQueriesARB(ContextTag GlxContextTag, N int32) GlxGenQueriesARBCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGenQueriesARBRequest(ContextTag, N), cookie) - return GlxGenQueriesARBCookie{cookie} -} - -func (c *Conn) GlxGenQueriesARBUnchecked(ContextTag GlxContextTag, N int32) GlxGenQueriesARBCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGenQueriesARBRequest(ContextTag, N), cookie) - return GlxGenQueriesARBCookie{cookie} -} - -// Request reply for GlxGenQueriesARB -// size: (32 + pad((int(Length) * 4))) -type GlxGenQueriesARBReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 24 bytes - Data []uint32 // size: pad((int(Length) * 4)) -} - -// Waits and reads reply data from request GlxGenQueriesARB -func (cook GlxGenQueriesARBCookie) Reply() (*GlxGenQueriesARBReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGenQueriesARBReply(buf), nil -} - -// Read reply into structure from buffer for GlxGenQueriesARB -func glxGenQueriesARBReply(buf []byte) *GlxGenQueriesARBReply { - v := new(GlxGenQueriesARBReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 24 // padding - - v.Data = make([]uint32, v.Length) - for i := 0; i < int(v.Length); i++ { - v.Data[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGenQueriesARBCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGenQueriesARB -func (c *Conn) glxGenQueriesARBRequest(ContextTag GlxContextTag, N int32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 162 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], uint32(N)) - b += 4 - - return buf -} - -// Request GlxIsQueryARB -// size: 12 -type GlxIsQueryARBCookie struct { - *cookie -} - -func (c *Conn) GlxIsQueryARB(ContextTag GlxContextTag, Id uint32) GlxIsQueryARBCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxIsQueryARBRequest(ContextTag, Id), cookie) - return GlxIsQueryARBCookie{cookie} -} - -func (c *Conn) GlxIsQueryARBUnchecked(ContextTag GlxContextTag, Id uint32) GlxIsQueryARBCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxIsQueryARBRequest(ContextTag, Id), cookie) - return GlxIsQueryARBCookie{cookie} -} - -// Request reply for GlxIsQueryARB -// size: 12 -type GlxIsQueryARBReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - RetVal GlxBool32 -} - -// Waits and reads reply data from request GlxIsQueryARB -func (cook GlxIsQueryARBCookie) Reply() (*GlxIsQueryARBReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxIsQueryARBReply(buf), nil -} - -// Read reply into structure from buffer for GlxIsQueryARB -func glxIsQueryARBReply(buf []byte) *GlxIsQueryARBReply { - v := new(GlxIsQueryARBReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.RetVal = GlxBool32(Get32(buf[b:])) - b += 4 - - return v -} - -func (cook GlxIsQueryARBCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxIsQueryARB -func (c *Conn) glxIsQueryARBRequest(ContextTag GlxContextTag, Id uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 163 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Id) - b += 4 - - return buf -} - -// Request GlxGetQueryivARB -// size: 16 -type GlxGetQueryivARBCookie struct { - *cookie -} - -func (c *Conn) GlxGetQueryivARB(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetQueryivARBCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetQueryivARBRequest(ContextTag, Target, Pname), cookie) - return GlxGetQueryivARBCookie{cookie} -} - -func (c *Conn) GlxGetQueryivARBUnchecked(ContextTag GlxContextTag, Target uint32, Pname uint32) GlxGetQueryivARBCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetQueryivARBRequest(ContextTag, Target, Pname), cookie) - return GlxGetQueryivARBCookie{cookie} -} - -// Request reply for GlxGetQueryivARB -// size: (32 + pad((int(N) * 4))) -type GlxGetQueryivARBReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum int32 - // padding: 12 bytes - Data []int32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetQueryivARB -func (cook GlxGetQueryivARBCookie) Reply() (*GlxGetQueryivARBReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetQueryivARBReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetQueryivARB -func glxGetQueryivARBReply(buf []byte) *GlxGetQueryivARBReply { - v := new(GlxGetQueryivARBReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = int32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]int32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = int32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetQueryivARBCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetQueryivARB -func (c *Conn) glxGetQueryivARBRequest(ContextTag GlxContextTag, Target uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 164 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Target) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetQueryObjectivARB -// size: 16 -type GlxGetQueryObjectivARBCookie struct { - *cookie -} - -func (c *Conn) GlxGetQueryObjectivARB(ContextTag GlxContextTag, Id uint32, Pname uint32) GlxGetQueryObjectivARBCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetQueryObjectivARBRequest(ContextTag, Id, Pname), cookie) - return GlxGetQueryObjectivARBCookie{cookie} -} - -func (c *Conn) GlxGetQueryObjectivARBUnchecked(ContextTag GlxContextTag, Id uint32, Pname uint32) GlxGetQueryObjectivARBCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetQueryObjectivARBRequest(ContextTag, Id, Pname), cookie) - return GlxGetQueryObjectivARBCookie{cookie} -} - -// Request reply for GlxGetQueryObjectivARB -// size: (32 + pad((int(N) * 4))) -type GlxGetQueryObjectivARBReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum int32 - // padding: 12 bytes - Data []int32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetQueryObjectivARB -func (cook GlxGetQueryObjectivARBCookie) Reply() (*GlxGetQueryObjectivARBReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetQueryObjectivARBReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetQueryObjectivARB -func glxGetQueryObjectivARBReply(buf []byte) *GlxGetQueryObjectivARBReply { - v := new(GlxGetQueryObjectivARBReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = int32(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - v.Data = make([]int32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = int32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetQueryObjectivARBCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetQueryObjectivARB -func (c *Conn) glxGetQueryObjectivARBRequest(ContextTag GlxContextTag, Id uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 165 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Id) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} - -// Request GlxGetQueryObjectuivARB -// size: 16 -type GlxGetQueryObjectuivARBCookie struct { - *cookie -} - -func (c *Conn) GlxGetQueryObjectuivARB(ContextTag GlxContextTag, Id uint32, Pname uint32) GlxGetQueryObjectuivARBCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.glxGetQueryObjectuivARBRequest(ContextTag, Id, Pname), cookie) - return GlxGetQueryObjectuivARBCookie{cookie} -} - -func (c *Conn) GlxGetQueryObjectuivARBUnchecked(ContextTag GlxContextTag, Id uint32, Pname uint32) GlxGetQueryObjectuivARBCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.glxGetQueryObjectuivARBRequest(ContextTag, Id, Pname), cookie) - return GlxGetQueryObjectuivARBCookie{cookie} -} - -// Request reply for GlxGetQueryObjectuivARB -// size: (32 + pad((int(N) * 4))) -type GlxGetQueryObjectuivARBReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 4 bytes - N uint32 - Datum uint32 - // padding: 12 bytes - Data []uint32 // size: pad((int(N) * 4)) -} - -// Waits and reads reply data from request GlxGetQueryObjectuivARB -func (cook GlxGetQueryObjectuivARBCookie) Reply() (*GlxGetQueryObjectuivARBReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return glxGetQueryObjectuivARBReply(buf), nil -} - -// Read reply into structure from buffer for GlxGetQueryObjectuivARB -func glxGetQueryObjectuivARBReply(buf []byte) *GlxGetQueryObjectuivARBReply { - v := new(GlxGetQueryObjectuivARBReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 4 // padding - - v.N = Get32(buf[b:]) - b += 4 - - v.Datum = Get32(buf[b:]) - b += 4 - - b += 12 // padding - - v.Data = make([]uint32, v.N) - for i := 0; i < int(v.N); i++ { - v.Data[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GlxGetQueryObjectuivARBCookie) Check() error { - return cook.check() -} - -// Write request to wire for GlxGetQueryObjectuivARB -func (c *Conn) glxGetQueryObjectuivARBRequest(ContextTag GlxContextTag, Id uint32, Pname uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["GLX"] - b += 1 - - buf[b] = 166 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextTag)) - b += 4 - - Put32(buf[b:], Id) - b += 4 - - Put32(buf[b:], Pname) - b += 4 - - return buf -} diff --git a/nexgb/auto_randr.go b/nexgb/auto_randr.go deleted file mode 100644 index d7e68bd..0000000 --- a/nexgb/auto_randr.go +++ /dev/null @@ -1,4038 +0,0 @@ -package xgb - -/* - This file was generated by randr.xml on May 10 2012 12:39:33pm EDT. - This file is automatically generated. Edit at your peril! -*/ - -// Imports are not necessary for XGB because everything is -// in one package. They are still listed here for reference. -// import "xproto" -// import "render" - -// RandrInit must be called before using the RANDR extension. -func (c *Conn) RandrInit() error { - reply, err := c.QueryExtension(5, "RANDR").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named RANDR could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["RANDR"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["RANDR"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["RANDR"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["RANDR"] = make(map[int]newEventFun) - newExtErrorFuncs["RANDR"] = make(map[int]newErrorFun) -} - -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - -// Skipping definition for base type 'Int8' - -// Skipping definition for base type 'Card16' - -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - -// Skipping definition for base type 'Float' - -const ( - RandrRotationRotate0 = 1 - RandrRotationRotate90 = 2 - RandrRotationRotate180 = 4 - RandrRotationRotate270 = 8 - RandrRotationReflectX = 16 - RandrRotationReflectY = 32 -) - -const ( - RandrSetConfigSuccess = 0 - RandrSetConfigInvalidConfigTime = 1 - RandrSetConfigInvalidTime = 2 - RandrSetConfigFailed = 3 -) - -const ( - RandrNotifyMaskScreenChange = 1 - RandrNotifyMaskCrtcChange = 2 - RandrNotifyMaskOutputChange = 4 - RandrNotifyMaskOutputProperty = 8 -) - -const ( - RandrModeFlagHsyncPositive = 1 - RandrModeFlagHsyncNegative = 2 - RandrModeFlagVsyncPositive = 4 - RandrModeFlagVsyncNegative = 8 - RandrModeFlagInterlace = 16 - RandrModeFlagDoubleScan = 32 - RandrModeFlagCsync = 64 - RandrModeFlagCsyncPositive = 128 - RandrModeFlagCsyncNegative = 256 - RandrModeFlagHskewPresent = 512 - RandrModeFlagBcast = 1024 - RandrModeFlagPixelMultiplex = 2048 - RandrModeFlagDoubleClock = 4096 - RandrModeFlagHalveClock = 8192 -) - -const ( - RandrConnectionConnected = 0 - RandrConnectionDisconnected = 1 - RandrConnectionUnknown = 2 -) - -const ( - RandrNotifyCrtcChange = 0 - RandrNotifyOutputChange = 1 - RandrNotifyOutputProperty = 2 -) - -type RandrMode uint32 - -func (c *Conn) NewRandrModeId() (RandrMode, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return RandrMode(id), nil -} - -type RandrCrtc uint32 - -func (c *Conn) NewRandrCrtcId() (RandrCrtc, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return RandrCrtc(id), nil -} - -type RandrOutput uint32 - -func (c *Conn) NewRandrOutputId() (RandrOutput, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return RandrOutput(id), nil -} - -// 'RandrScreenSize' struct definition -// Size: 8 -type RandrScreenSize struct { - Width uint16 - Height uint16 - Mwidth uint16 - Mheight uint16 -} - -// Struct read RandrScreenSize -func ReadRandrScreenSize(buf []byte, v *RandrScreenSize) int { - b := 0 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - v.Mwidth = Get16(buf[b:]) - b += 2 - - v.Mheight = Get16(buf[b:]) - b += 2 - - return b -} - -// Struct list read RandrScreenSize -func ReadRandrScreenSizeList(buf []byte, dest []RandrScreenSize) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RandrScreenSize{} - b += ReadRandrScreenSize(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RandrScreenSize -func (v RandrScreenSize) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put16(buf[b:], v.Width) - b += 2 - - Put16(buf[b:], v.Height) - b += 2 - - Put16(buf[b:], v.Mwidth) - b += 2 - - Put16(buf[b:], v.Mheight) - b += 2 - - return buf -} - -// Write struct list RandrScreenSize -func RandrScreenSizeListBytes(buf []byte, list []RandrScreenSize) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RandrRefreshRates' struct definition -// Size: (2 + pad((int(NRates) * 2))) -type RandrRefreshRates struct { - NRates uint16 - Rates []uint16 // size: pad((int(NRates) * 2)) -} - -// Struct read RandrRefreshRates -func ReadRandrRefreshRates(buf []byte, v *RandrRefreshRates) int { - b := 0 - - v.NRates = Get16(buf[b:]) - b += 2 - - v.Rates = make([]uint16, v.NRates) - for i := 0; i < int(v.NRates); i++ { - v.Rates[i] = Get16(buf[b:]) - b += 2 - } - b = pad(b) - - return b -} - -// Struct list read RandrRefreshRates -func ReadRandrRefreshRatesList(buf []byte, dest []RandrRefreshRates) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RandrRefreshRates{} - b += ReadRandrRefreshRates(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RandrRefreshRates -func (v RandrRefreshRates) Bytes() []byte { - buf := make([]byte, (2 + pad((int(v.NRates) * 2)))) - b := 0 - - Put16(buf[b:], v.NRates) - b += 2 - - for i := 0; i < int(v.NRates); i++ { - Put16(buf[b:], v.Rates[i]) - b += 2 - } - b = pad(b) - - return buf -} - -// Write struct list RandrRefreshRates -func RandrRefreshRatesListBytes(buf []byte, list []RandrRefreshRates) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size RandrRefreshRates -func RandrRefreshRatesListSize(list []RandrRefreshRates) int { - size := 0 - for _, item := range list { - size += (2 + pad((int(item.NRates) * 2))) - } - return size -} - -// 'RandrModeInfo' struct definition -// Size: 32 -type RandrModeInfo struct { - Id uint32 - Width uint16 - Height uint16 - DotClock uint32 - HsyncStart uint16 - HsyncEnd uint16 - Htotal uint16 - Hskew uint16 - VsyncStart uint16 - VsyncEnd uint16 - Vtotal uint16 - NameLen uint16 - ModeFlags uint32 -} - -// Struct read RandrModeInfo -func ReadRandrModeInfo(buf []byte, v *RandrModeInfo) int { - b := 0 - - v.Id = Get32(buf[b:]) - b += 4 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - v.DotClock = Get32(buf[b:]) - b += 4 - - v.HsyncStart = Get16(buf[b:]) - b += 2 - - v.HsyncEnd = Get16(buf[b:]) - b += 2 - - v.Htotal = Get16(buf[b:]) - b += 2 - - v.Hskew = Get16(buf[b:]) - b += 2 - - v.VsyncStart = Get16(buf[b:]) - b += 2 - - v.VsyncEnd = Get16(buf[b:]) - b += 2 - - v.Vtotal = Get16(buf[b:]) - b += 2 - - v.NameLen = Get16(buf[b:]) - b += 2 - - v.ModeFlags = Get32(buf[b:]) - b += 4 - - return b -} - -// Struct list read RandrModeInfo -func ReadRandrModeInfoList(buf []byte, dest []RandrModeInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RandrModeInfo{} - b += ReadRandrModeInfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RandrModeInfo -func (v RandrModeInfo) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - Put32(buf[b:], v.Id) - b += 4 - - Put16(buf[b:], v.Width) - b += 2 - - Put16(buf[b:], v.Height) - b += 2 - - Put32(buf[b:], v.DotClock) - b += 4 - - Put16(buf[b:], v.HsyncStart) - b += 2 - - Put16(buf[b:], v.HsyncEnd) - b += 2 - - Put16(buf[b:], v.Htotal) - b += 2 - - Put16(buf[b:], v.Hskew) - b += 2 - - Put16(buf[b:], v.VsyncStart) - b += 2 - - Put16(buf[b:], v.VsyncEnd) - b += 2 - - Put16(buf[b:], v.Vtotal) - b += 2 - - Put16(buf[b:], v.NameLen) - b += 2 - - Put32(buf[b:], v.ModeFlags) - b += 4 - - return buf -} - -// Write struct list RandrModeInfo -func RandrModeInfoListBytes(buf []byte, list []RandrModeInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RandrCrtcChange' struct definition -// Size: 28 -type RandrCrtcChange struct { - Timestamp Timestamp - Window Window - Crtc RandrCrtc - Mode RandrMode - Rotation uint16 - // padding: 2 bytes - X int16 - Y int16 - Width uint16 - Height uint16 -} - -// Struct read RandrCrtcChange -func ReadRandrCrtcChange(buf []byte, v *RandrCrtcChange) int { - b := 0 - - v.Timestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - v.Crtc = RandrCrtc(Get32(buf[b:])) - b += 4 - - v.Mode = RandrMode(Get32(buf[b:])) - b += 4 - - v.Rotation = Get16(buf[b:]) - b += 2 - - b += 2 // padding - - v.X = int16(Get16(buf[b:])) - b += 2 - - v.Y = int16(Get16(buf[b:])) - b += 2 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - return b -} - -// Struct list read RandrCrtcChange -func ReadRandrCrtcChangeList(buf []byte, dest []RandrCrtcChange) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RandrCrtcChange{} - b += ReadRandrCrtcChange(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RandrCrtcChange -func (v RandrCrtcChange) Bytes() []byte { - buf := make([]byte, 28) - b := 0 - - Put32(buf[b:], uint32(v.Timestamp)) - b += 4 - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - Put32(buf[b:], uint32(v.Crtc)) - b += 4 - - Put32(buf[b:], uint32(v.Mode)) - b += 4 - - Put16(buf[b:], v.Rotation) - b += 2 - - b += 2 // padding - - Put16(buf[b:], uint16(v.X)) - b += 2 - - Put16(buf[b:], uint16(v.Y)) - b += 2 - - Put16(buf[b:], v.Width) - b += 2 - - Put16(buf[b:], v.Height) - b += 2 - - return buf -} - -// Write struct list RandrCrtcChange -func RandrCrtcChangeListBytes(buf []byte, list []RandrCrtcChange) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RandrOutputChange' struct definition -// Size: 28 -type RandrOutputChange struct { - Timestamp Timestamp - ConfigTimestamp Timestamp - Window Window - Output RandrOutput - Crtc RandrCrtc - Mode RandrMode - Rotation uint16 - Connection byte - SubpixelOrder byte -} - -// Struct read RandrOutputChange -func ReadRandrOutputChange(buf []byte, v *RandrOutputChange) int { - b := 0 - - v.Timestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.ConfigTimestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - v.Output = RandrOutput(Get32(buf[b:])) - b += 4 - - v.Crtc = RandrCrtc(Get32(buf[b:])) - b += 4 - - v.Mode = RandrMode(Get32(buf[b:])) - b += 4 - - v.Rotation = Get16(buf[b:]) - b += 2 - - v.Connection = buf[b] - b += 1 - - v.SubpixelOrder = buf[b] - b += 1 - - return b -} - -// Struct list read RandrOutputChange -func ReadRandrOutputChangeList(buf []byte, dest []RandrOutputChange) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RandrOutputChange{} - b += ReadRandrOutputChange(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RandrOutputChange -func (v RandrOutputChange) Bytes() []byte { - buf := make([]byte, 28) - b := 0 - - Put32(buf[b:], uint32(v.Timestamp)) - b += 4 - - Put32(buf[b:], uint32(v.ConfigTimestamp)) - b += 4 - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - Put32(buf[b:], uint32(v.Output)) - b += 4 - - Put32(buf[b:], uint32(v.Crtc)) - b += 4 - - Put32(buf[b:], uint32(v.Mode)) - b += 4 - - Put16(buf[b:], v.Rotation) - b += 2 - - buf[b] = v.Connection - b += 1 - - buf[b] = v.SubpixelOrder - b += 1 - - return buf -} - -// Write struct list RandrOutputChange -func RandrOutputChangeListBytes(buf []byte, list []RandrOutputChange) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RandrOutputProperty' struct definition -// Size: 28 -type RandrOutputProperty struct { - Window Window - Output RandrOutput - Atom Atom - Timestamp Timestamp - Status byte - // padding: 11 bytes -} - -// Struct read RandrOutputProperty -func ReadRandrOutputProperty(buf []byte, v *RandrOutputProperty) int { - b := 0 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - v.Output = RandrOutput(Get32(buf[b:])) - b += 4 - - v.Atom = Atom(Get32(buf[b:])) - b += 4 - - v.Timestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.Status = buf[b] - b += 1 - - b += 11 // padding - - return b -} - -// Struct list read RandrOutputProperty -func ReadRandrOutputPropertyList(buf []byte, dest []RandrOutputProperty) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RandrOutputProperty{} - b += ReadRandrOutputProperty(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RandrOutputProperty -func (v RandrOutputProperty) Bytes() []byte { - buf := make([]byte, 28) - b := 0 - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - Put32(buf[b:], uint32(v.Output)) - b += 4 - - Put32(buf[b:], uint32(v.Atom)) - b += 4 - - Put32(buf[b:], uint32(v.Timestamp)) - b += 4 - - buf[b] = v.Status - b += 1 - - b += 11 // padding - - return buf -} - -// Write struct list RandrOutputProperty -func RandrOutputPropertyListBytes(buf []byte, list []RandrOutputProperty) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Union definition RandrNotifyDataUnion -// Note that to *create* a Union, you should *never* create -// this struct directly (unless you know what you're doing). -// Instead use one of the following constructors for 'RandrNotifyDataUnion': -// NewRandrNotifyDataUnionCc(Cc RandrCrtcChange) RandrNotifyDataUnion -// NewRandrNotifyDataUnionOc(Oc RandrOutputChange) RandrNotifyDataUnion -// NewRandrNotifyDataUnionOp(Op RandrOutputProperty) RandrNotifyDataUnion -type RandrNotifyDataUnion struct { - Cc RandrCrtcChange - Oc RandrOutputChange - Op RandrOutputProperty -} - -// Union constructor for RandrNotifyDataUnion for field Cc. -func NewRandrNotifyDataUnionCc(Cc RandrCrtcChange) RandrNotifyDataUnion { - var b int - buf := make([]byte, 28) - - { - structBytes := Cc.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - // Create the Union type - v := RandrNotifyDataUnion{} - - // Now copy buf into all fields - - b = 0 // always read the same bytes - v.Cc = RandrCrtcChange{} - b += ReadRandrCrtcChange(buf[b:], &v.Cc) - - b = 0 // always read the same bytes - v.Oc = RandrOutputChange{} - b += ReadRandrOutputChange(buf[b:], &v.Oc) - - b = 0 // always read the same bytes - v.Op = RandrOutputProperty{} - b += ReadRandrOutputProperty(buf[b:], &v.Op) - - return v -} - -// Union constructor for RandrNotifyDataUnion for field Oc. -func NewRandrNotifyDataUnionOc(Oc RandrOutputChange) RandrNotifyDataUnion { - var b int - buf := make([]byte, 28) - - { - structBytes := Oc.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - // Create the Union type - v := RandrNotifyDataUnion{} - - // Now copy buf into all fields - - b = 0 // always read the same bytes - v.Cc = RandrCrtcChange{} - b += ReadRandrCrtcChange(buf[b:], &v.Cc) - - b = 0 // always read the same bytes - v.Oc = RandrOutputChange{} - b += ReadRandrOutputChange(buf[b:], &v.Oc) - - b = 0 // always read the same bytes - v.Op = RandrOutputProperty{} - b += ReadRandrOutputProperty(buf[b:], &v.Op) - - return v -} - -// Union constructor for RandrNotifyDataUnion for field Op. -func NewRandrNotifyDataUnionOp(Op RandrOutputProperty) RandrNotifyDataUnion { - var b int - buf := make([]byte, 28) - - { - structBytes := Op.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - // Create the Union type - v := RandrNotifyDataUnion{} - - // Now copy buf into all fields - - b = 0 // always read the same bytes - v.Cc = RandrCrtcChange{} - b += ReadRandrCrtcChange(buf[b:], &v.Cc) - - b = 0 // always read the same bytes - v.Oc = RandrOutputChange{} - b += ReadRandrOutputChange(buf[b:], &v.Oc) - - b = 0 // always read the same bytes - v.Op = RandrOutputProperty{} - b += ReadRandrOutputProperty(buf[b:], &v.Op) - - return v -} - -// Union read RandrNotifyDataUnion -func ReadRandrNotifyDataUnion(buf []byte, v *RandrNotifyDataUnion) int { - var b int - - b = 0 // re-read the same bytes - v.Cc = RandrCrtcChange{} - b += ReadRandrCrtcChange(buf[b:], &v.Cc) - - b = 0 // re-read the same bytes - v.Oc = RandrOutputChange{} - b += ReadRandrOutputChange(buf[b:], &v.Oc) - - b = 0 // re-read the same bytes - v.Op = RandrOutputProperty{} - b += ReadRandrOutputProperty(buf[b:], &v.Op) - - return 28 -} - -// Union list read RandrNotifyDataUnion -func ReadRandrNotifyDataUnionList(buf []byte, dest []RandrNotifyDataUnion) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RandrNotifyDataUnion{} - b += ReadRandrNotifyDataUnion(buf[b:], &dest[i]) - } - return pad(b) -} - -// Union write RandrNotifyDataUnion -// Each field in a union must contain the same data. -// So simply pick the first field and write that to the wire. -func (v RandrNotifyDataUnion) Bytes() []byte { - buf := make([]byte, 28) - b := 0 - - { - structBytes := v.Cc.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return buf -} - -// Union list write RandrNotifyDataUnion -func RandrNotifyDataUnionListBytes(buf []byte, list []RandrNotifyDataUnion) int { - b := 0 - var unionBytes []byte - for _, item := range list { - unionBytes = item.Bytes() - copy(buf[b:], unionBytes) - b += pad(len(unionBytes)) - } - return b -} - -// Event definition RandrScreenChangeNotify (0) -// Size: 32 - -const RandrScreenChangeNotify = 0 - -type RandrScreenChangeNotifyEvent struct { - Sequence uint16 - Rotation byte - Timestamp Timestamp - ConfigTimestamp Timestamp - Root Window - RequestWindow Window - SizeID uint16 - SubpixelOrder uint16 - Width uint16 - Height uint16 - Mwidth uint16 - Mheight uint16 -} - -// Event read RandrScreenChangeNotify -func NewRandrScreenChangeNotifyEvent(buf []byte) Event { - v := RandrScreenChangeNotifyEvent{} - b := 1 // don't read event number - - v.Rotation = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Timestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.ConfigTimestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.Root = Window(Get32(buf[b:])) - b += 4 - - v.RequestWindow = Window(Get32(buf[b:])) - b += 4 - - v.SizeID = Get16(buf[b:]) - b += 2 - - v.SubpixelOrder = Get16(buf[b:]) - b += 2 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - v.Mwidth = Get16(buf[b:]) - b += 2 - - v.Mheight = Get16(buf[b:]) - b += 2 - - return v -} - -// Event write RandrScreenChangeNotify -func (v RandrScreenChangeNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 0 - b += 1 - - buf[b] = v.Rotation - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Timestamp)) - b += 4 - - Put32(buf[b:], uint32(v.ConfigTimestamp)) - b += 4 - - Put32(buf[b:], uint32(v.Root)) - b += 4 - - Put32(buf[b:], uint32(v.RequestWindow)) - b += 4 - - Put16(buf[b:], v.SizeID) - b += 2 - - Put16(buf[b:], v.SubpixelOrder) - b += 2 - - Put16(buf[b:], v.Width) - b += 2 - - Put16(buf[b:], v.Height) - b += 2 - - Put16(buf[b:], v.Mwidth) - b += 2 - - Put16(buf[b:], v.Mheight) - b += 2 - - return buf -} - -func (v RandrScreenChangeNotifyEvent) ImplementsEvent() {} - -func (v RandrScreenChangeNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v RandrScreenChangeNotifyEvent) String() string { - fieldVals := make([]string, 0, 11) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Rotation: %d", v.Rotation)) - fieldVals = append(fieldVals, sprintf("Timestamp: %d", v.Timestamp)) - fieldVals = append(fieldVals, sprintf("ConfigTimestamp: %d", v.ConfigTimestamp)) - fieldVals = append(fieldVals, sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, sprintf("RequestWindow: %d", v.RequestWindow)) - fieldVals = append(fieldVals, sprintf("SizeID: %d", v.SizeID)) - fieldVals = append(fieldVals, sprintf("SubpixelOrder: %d", v.SubpixelOrder)) - fieldVals = append(fieldVals, sprintf("Width: %d", v.Width)) - fieldVals = append(fieldVals, sprintf("Height: %d", v.Height)) - fieldVals = append(fieldVals, sprintf("Mwidth: %d", v.Mwidth)) - fieldVals = append(fieldVals, sprintf("Mheight: %d", v.Mheight)) - return "RandrScreenChangeNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["RANDR"][0] = NewRandrScreenChangeNotifyEvent -} - -// Event definition RandrNotify (1) -// Size: 32 - -const RandrNotify = 1 - -type RandrNotifyEvent struct { - Sequence uint16 - SubCode byte - U RandrNotifyDataUnion -} - -// Event read RandrNotify -func NewRandrNotifyEvent(buf []byte) Event { - v := RandrNotifyEvent{} - b := 1 // don't read event number - - v.SubCode = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.U = RandrNotifyDataUnion{} - b += ReadRandrNotifyDataUnion(buf[b:], &v.U) - - return v -} - -// Event write RandrNotify -func (v RandrNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 1 - b += 1 - - buf[b] = v.SubCode - b += 1 - - b += 2 // skip sequence number - - { - unionBytes := v.U.Bytes() - copy(buf[b:], unionBytes) - b += pad(len(unionBytes)) - } - - return buf -} - -func (v RandrNotifyEvent) ImplementsEvent() {} - -func (v RandrNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v RandrNotifyEvent) String() string { - fieldVals := make([]string, 0, 2) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("SubCode: %d", v.SubCode)) - return "RandrNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["RANDR"][1] = NewRandrNotifyEvent -} - -// Error definition RandrBadOutput (0) -// Size: 32 - -const BadRandrBadOutput = 0 - -type RandrBadOutputError struct { - Sequence uint16 - NiceName string -} - -// Error read RandrBadOutput -func NewRandrBadOutputError(buf []byte) Error { - v := RandrBadOutputError{} - v.NiceName = "RandrBadOutput" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err RandrBadOutputError) ImplementsError() {} - -func (err RandrBadOutputError) SequenceId() uint16 { - return err.Sequence -} - -func (err RandrBadOutputError) BadId() uint32 { - return 0 -} - -func (err RandrBadOutputError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadRandrBadOutput {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["RANDR"][0] = NewRandrBadOutputError -} - -// Error definition RandrBadCrtc (1) -// Size: 32 - -const BadRandrBadCrtc = 1 - -type RandrBadCrtcError struct { - Sequence uint16 - NiceName string -} - -// Error read RandrBadCrtc -func NewRandrBadCrtcError(buf []byte) Error { - v := RandrBadCrtcError{} - v.NiceName = "RandrBadCrtc" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err RandrBadCrtcError) ImplementsError() {} - -func (err RandrBadCrtcError) SequenceId() uint16 { - return err.Sequence -} - -func (err RandrBadCrtcError) BadId() uint32 { - return 0 -} - -func (err RandrBadCrtcError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadRandrBadCrtc {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["RANDR"][1] = NewRandrBadCrtcError -} - -// Error definition RandrBadMode (2) -// Size: 32 - -const BadRandrBadMode = 2 - -type RandrBadModeError struct { - Sequence uint16 - NiceName string -} - -// Error read RandrBadMode -func NewRandrBadModeError(buf []byte) Error { - v := RandrBadModeError{} - v.NiceName = "RandrBadMode" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err RandrBadModeError) ImplementsError() {} - -func (err RandrBadModeError) SequenceId() uint16 { - return err.Sequence -} - -func (err RandrBadModeError) BadId() uint32 { - return 0 -} - -func (err RandrBadModeError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadRandrBadMode {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["RANDR"][2] = NewRandrBadModeError -} - -// Request RandrQueryVersion -// size: 12 -type RandrQueryVersionCookie struct { - *cookie -} - -func (c *Conn) RandrQueryVersion(MajorVersion uint32, MinorVersion uint32) RandrQueryVersionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrQueryVersionRequest(MajorVersion, MinorVersion), cookie) - return RandrQueryVersionCookie{cookie} -} - -func (c *Conn) RandrQueryVersionUnchecked(MajorVersion uint32, MinorVersion uint32) RandrQueryVersionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.randrQueryVersionRequest(MajorVersion, MinorVersion), cookie) - return RandrQueryVersionCookie{cookie} -} - -// Request reply for RandrQueryVersion -// size: 32 -type RandrQueryVersionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - MajorVersion uint32 - MinorVersion uint32 - // padding: 16 bytes -} - -// Waits and reads reply data from request RandrQueryVersion -func (cook RandrQueryVersionCookie) Reply() (*RandrQueryVersionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return randrQueryVersionReply(buf), nil -} - -// Read reply into structure from buffer for RandrQueryVersion -func randrQueryVersionReply(buf []byte) *RandrQueryVersionReply { - v := new(RandrQueryVersionReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.MajorVersion = Get32(buf[b:]) - b += 4 - - v.MinorVersion = Get32(buf[b:]) - b += 4 - - b += 16 // padding - - return v -} - -func (cook RandrQueryVersionCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrQueryVersion -func (c *Conn) randrQueryVersionRequest(MajorVersion uint32, MinorVersion uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 0 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], MajorVersion) - b += 4 - - Put32(buf[b:], MinorVersion) - b += 4 - - return buf -} - -// Request RandrSetScreenConfig -// size: 24 -type RandrSetScreenConfigCookie struct { - *cookie -} - -func (c *Conn) RandrSetScreenConfig(Window Window, Timestamp Timestamp, ConfigTimestamp Timestamp, SizeID uint16, Rotation uint16, Rate uint16) RandrSetScreenConfigCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrSetScreenConfigRequest(Window, Timestamp, ConfigTimestamp, SizeID, Rotation, Rate), cookie) - return RandrSetScreenConfigCookie{cookie} -} - -func (c *Conn) RandrSetScreenConfigUnchecked(Window Window, Timestamp Timestamp, ConfigTimestamp Timestamp, SizeID uint16, Rotation uint16, Rate uint16) RandrSetScreenConfigCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.randrSetScreenConfigRequest(Window, Timestamp, ConfigTimestamp, SizeID, Rotation, Rate), cookie) - return RandrSetScreenConfigCookie{cookie} -} - -// Request reply for RandrSetScreenConfig -// size: 32 -type RandrSetScreenConfigReply struct { - Sequence uint16 - Length uint32 - Status byte - NewTimestamp Timestamp - ConfigTimestamp Timestamp - Root Window - SubpixelOrder uint16 - // padding: 10 bytes -} - -// Waits and reads reply data from request RandrSetScreenConfig -func (cook RandrSetScreenConfigCookie) Reply() (*RandrSetScreenConfigReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return randrSetScreenConfigReply(buf), nil -} - -// Read reply into structure from buffer for RandrSetScreenConfig -func randrSetScreenConfigReply(buf []byte) *RandrSetScreenConfigReply { - v := new(RandrSetScreenConfigReply) - b := 1 // skip reply determinant - - v.Status = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.NewTimestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.ConfigTimestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.Root = Window(Get32(buf[b:])) - b += 4 - - v.SubpixelOrder = Get16(buf[b:]) - b += 2 - - b += 10 // padding - - return v -} - -func (cook RandrSetScreenConfigCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrSetScreenConfig -func (c *Conn) randrSetScreenConfigRequest(Window Window, Timestamp Timestamp, ConfigTimestamp Timestamp, SizeID uint16, Rotation uint16, Rate uint16) []byte { - size := 24 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 2 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - Put32(buf[b:], uint32(Timestamp)) - b += 4 - - Put32(buf[b:], uint32(ConfigTimestamp)) - b += 4 - - Put16(buf[b:], SizeID) - b += 2 - - Put16(buf[b:], Rotation) - b += 2 - - Put16(buf[b:], Rate) - b += 2 - - b += 2 // padding - - return buf -} - -// Request RandrSelectInput -// size: 12 -type RandrSelectInputCookie struct { - *cookie -} - -// Write request to wire for RandrSelectInput -func (c *Conn) RandrSelectInput(Window Window, Enable uint16) RandrSelectInputCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.randrSelectInputRequest(Window, Enable), cookie) - return RandrSelectInputCookie{cookie} -} - -func (c *Conn) RandrSelectInputChecked(Window Window, Enable uint16) RandrSelectInputCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.randrSelectInputRequest(Window, Enable), cookie) - return RandrSelectInputCookie{cookie} -} - -func (cook RandrSelectInputCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrSelectInput -func (c *Conn) randrSelectInputRequest(Window Window, Enable uint16) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 4 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - Put16(buf[b:], Enable) - b += 2 - - b += 2 // padding - - return buf -} - -// Request RandrGetScreenInfo -// size: 8 -type RandrGetScreenInfoCookie struct { - *cookie -} - -func (c *Conn) RandrGetScreenInfo(Window Window) RandrGetScreenInfoCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrGetScreenInfoRequest(Window), cookie) - return RandrGetScreenInfoCookie{cookie} -} - -func (c *Conn) RandrGetScreenInfoUnchecked(Window Window) RandrGetScreenInfoCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.randrGetScreenInfoRequest(Window), cookie) - return RandrGetScreenInfoCookie{cookie} -} - -// Request reply for RandrGetScreenInfo -// size: ((32 + pad((int(NSizes) * 8))) + RandrRefreshRatesListSize(Rates)) -type RandrGetScreenInfoReply struct { - Sequence uint16 - Length uint32 - Rotations byte - Root Window - Timestamp Timestamp - ConfigTimestamp Timestamp - NSizes uint16 - SizeID uint16 - Rotation uint16 - Rate uint16 - NInfo uint16 - // padding: 2 bytes - Sizes []RandrScreenSize // size: pad((int(NSizes) * 8)) - Rates []RandrRefreshRates // size: RandrRefreshRatesListSize(Rates) -} - -// Waits and reads reply data from request RandrGetScreenInfo -func (cook RandrGetScreenInfoCookie) Reply() (*RandrGetScreenInfoReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return randrGetScreenInfoReply(buf), nil -} - -// Read reply into structure from buffer for RandrGetScreenInfo -func randrGetScreenInfoReply(buf []byte) *RandrGetScreenInfoReply { - v := new(RandrGetScreenInfoReply) - b := 1 // skip reply determinant - - v.Rotations = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Root = Window(Get32(buf[b:])) - b += 4 - - v.Timestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.ConfigTimestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.NSizes = Get16(buf[b:]) - b += 2 - - v.SizeID = Get16(buf[b:]) - b += 2 - - v.Rotation = Get16(buf[b:]) - b += 2 - - v.Rate = Get16(buf[b:]) - b += 2 - - v.NInfo = Get16(buf[b:]) - b += 2 - - b += 2 // padding - - v.Sizes = make([]RandrScreenSize, v.NSizes) - b += ReadRandrScreenSizeList(buf[b:], v.Sizes) - - v.Rates = make([]RandrRefreshRates, (int(v.NInfo) - int(v.NSizes))) - b += ReadRandrRefreshRatesList(buf[b:], v.Rates) - - return v -} - -func (cook RandrGetScreenInfoCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrGetScreenInfo -func (c *Conn) randrGetScreenInfoRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 5 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - return buf -} - -// Request RandrGetScreenSizeRange -// size: 8 -type RandrGetScreenSizeRangeCookie struct { - *cookie -} - -func (c *Conn) RandrGetScreenSizeRange(Window Window) RandrGetScreenSizeRangeCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrGetScreenSizeRangeRequest(Window), cookie) - return RandrGetScreenSizeRangeCookie{cookie} -} - -func (c *Conn) RandrGetScreenSizeRangeUnchecked(Window Window) RandrGetScreenSizeRangeCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.randrGetScreenSizeRangeRequest(Window), cookie) - return RandrGetScreenSizeRangeCookie{cookie} -} - -// Request reply for RandrGetScreenSizeRange -// size: 32 -type RandrGetScreenSizeRangeReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - MinWidth uint16 - MinHeight uint16 - MaxWidth uint16 - MaxHeight uint16 - // padding: 16 bytes -} - -// Waits and reads reply data from request RandrGetScreenSizeRange -func (cook RandrGetScreenSizeRangeCookie) Reply() (*RandrGetScreenSizeRangeReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return randrGetScreenSizeRangeReply(buf), nil -} - -// Read reply into structure from buffer for RandrGetScreenSizeRange -func randrGetScreenSizeRangeReply(buf []byte) *RandrGetScreenSizeRangeReply { - v := new(RandrGetScreenSizeRangeReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.MinWidth = Get16(buf[b:]) - b += 2 - - v.MinHeight = Get16(buf[b:]) - b += 2 - - v.MaxWidth = Get16(buf[b:]) - b += 2 - - v.MaxHeight = Get16(buf[b:]) - b += 2 - - b += 16 // padding - - return v -} - -func (cook RandrGetScreenSizeRangeCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrGetScreenSizeRange -func (c *Conn) randrGetScreenSizeRangeRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 6 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - return buf -} - -// Request RandrSetScreenSize -// size: 20 -type RandrSetScreenSizeCookie struct { - *cookie -} - -// Write request to wire for RandrSetScreenSize -func (c *Conn) RandrSetScreenSize(Window Window, Width uint16, Height uint16, MmWidth uint32, MmHeight uint32) RandrSetScreenSizeCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.randrSetScreenSizeRequest(Window, Width, Height, MmWidth, MmHeight), cookie) - return RandrSetScreenSizeCookie{cookie} -} - -func (c *Conn) RandrSetScreenSizeChecked(Window Window, Width uint16, Height uint16, MmWidth uint32, MmHeight uint32) RandrSetScreenSizeCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.randrSetScreenSizeRequest(Window, Width, Height, MmWidth, MmHeight), cookie) - return RandrSetScreenSizeCookie{cookie} -} - -func (cook RandrSetScreenSizeCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrSetScreenSize -func (c *Conn) randrSetScreenSizeRequest(Window Window, Width uint16, Height uint16, MmWidth uint32, MmHeight uint32) []byte { - size := 20 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 7 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - Put16(buf[b:], Width) - b += 2 - - Put16(buf[b:], Height) - b += 2 - - Put32(buf[b:], MmWidth) - b += 4 - - Put32(buf[b:], MmHeight) - b += 4 - - return buf -} - -// Request RandrGetScreenResources -// size: 8 -type RandrGetScreenResourcesCookie struct { - *cookie -} - -func (c *Conn) RandrGetScreenResources(Window Window) RandrGetScreenResourcesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrGetScreenResourcesRequest(Window), cookie) - return RandrGetScreenResourcesCookie{cookie} -} - -func (c *Conn) RandrGetScreenResourcesUnchecked(Window Window) RandrGetScreenResourcesCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.randrGetScreenResourcesRequest(Window), cookie) - return RandrGetScreenResourcesCookie{cookie} -} - -// Request reply for RandrGetScreenResources -// size: ((((32 + pad((int(NumCrtcs) * 4))) + pad((int(NumOutputs) * 4))) + pad((int(NumModes) * 32))) + pad((int(NamesLen) * 1))) -type RandrGetScreenResourcesReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Timestamp Timestamp - ConfigTimestamp Timestamp - NumCrtcs uint16 - NumOutputs uint16 - NumModes uint16 - NamesLen uint16 - // padding: 8 bytes - Crtcs []RandrCrtc // size: pad((int(NumCrtcs) * 4)) - Outputs []RandrOutput // size: pad((int(NumOutputs) * 4)) - Modes []RandrModeInfo // size: pad((int(NumModes) * 32)) - Names []byte // size: pad((int(NamesLen) * 1)) -} - -// Waits and reads reply data from request RandrGetScreenResources -func (cook RandrGetScreenResourcesCookie) Reply() (*RandrGetScreenResourcesReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return randrGetScreenResourcesReply(buf), nil -} - -// Read reply into structure from buffer for RandrGetScreenResources -func randrGetScreenResourcesReply(buf []byte) *RandrGetScreenResourcesReply { - v := new(RandrGetScreenResourcesReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Timestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.ConfigTimestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.NumCrtcs = Get16(buf[b:]) - b += 2 - - v.NumOutputs = Get16(buf[b:]) - b += 2 - - v.NumModes = Get16(buf[b:]) - b += 2 - - v.NamesLen = Get16(buf[b:]) - b += 2 - - b += 8 // padding - - v.Crtcs = make([]RandrCrtc, v.NumCrtcs) - for i := 0; i < int(v.NumCrtcs); i++ { - v.Crtcs[i] = RandrCrtc(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - v.Outputs = make([]RandrOutput, v.NumOutputs) - for i := 0; i < int(v.NumOutputs); i++ { - v.Outputs[i] = RandrOutput(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - v.Modes = make([]RandrModeInfo, v.NumModes) - b += ReadRandrModeInfoList(buf[b:], v.Modes) - - v.Names = make([]byte, v.NamesLen) - copy(v.Names[:v.NamesLen], buf[b:]) - b += pad(int(v.NamesLen)) - - return v -} - -func (cook RandrGetScreenResourcesCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrGetScreenResources -func (c *Conn) randrGetScreenResourcesRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 8 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - return buf -} - -// Request RandrGetOutputInfo -// size: 12 -type RandrGetOutputInfoCookie struct { - *cookie -} - -func (c *Conn) RandrGetOutputInfo(Output RandrOutput, ConfigTimestamp Timestamp) RandrGetOutputInfoCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrGetOutputInfoRequest(Output, ConfigTimestamp), cookie) - return RandrGetOutputInfoCookie{cookie} -} - -func (c *Conn) RandrGetOutputInfoUnchecked(Output RandrOutput, ConfigTimestamp Timestamp) RandrGetOutputInfoCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.randrGetOutputInfoRequest(Output, ConfigTimestamp), cookie) - return RandrGetOutputInfoCookie{cookie} -} - -// Request reply for RandrGetOutputInfo -// size: ((((36 + pad((int(NumCrtcs) * 4))) + pad((int(NumModes) * 4))) + pad((int(NumClones) * 4))) + pad((int(NameLen) * 1))) -type RandrGetOutputInfoReply struct { - Sequence uint16 - Length uint32 - Status byte - Timestamp Timestamp - Crtc RandrCrtc - MmWidth uint32 - MmHeight uint32 - Connection byte - SubpixelOrder byte - NumCrtcs uint16 - NumModes uint16 - NumPreferred uint16 - NumClones uint16 - NameLen uint16 - Crtcs []RandrCrtc // size: pad((int(NumCrtcs) * 4)) - Modes []RandrMode // size: pad((int(NumModes) * 4)) - Clones []RandrOutput // size: pad((int(NumClones) * 4)) - Name []byte // size: pad((int(NameLen) * 1)) -} - -// Waits and reads reply data from request RandrGetOutputInfo -func (cook RandrGetOutputInfoCookie) Reply() (*RandrGetOutputInfoReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return randrGetOutputInfoReply(buf), nil -} - -// Read reply into structure from buffer for RandrGetOutputInfo -func randrGetOutputInfoReply(buf []byte) *RandrGetOutputInfoReply { - v := new(RandrGetOutputInfoReply) - b := 1 // skip reply determinant - - v.Status = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Timestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.Crtc = RandrCrtc(Get32(buf[b:])) - b += 4 - - v.MmWidth = Get32(buf[b:]) - b += 4 - - v.MmHeight = Get32(buf[b:]) - b += 4 - - v.Connection = buf[b] - b += 1 - - v.SubpixelOrder = buf[b] - b += 1 - - v.NumCrtcs = Get16(buf[b:]) - b += 2 - - v.NumModes = Get16(buf[b:]) - b += 2 - - v.NumPreferred = Get16(buf[b:]) - b += 2 - - v.NumClones = Get16(buf[b:]) - b += 2 - - v.NameLen = Get16(buf[b:]) - b += 2 - - v.Crtcs = make([]RandrCrtc, v.NumCrtcs) - for i := 0; i < int(v.NumCrtcs); i++ { - v.Crtcs[i] = RandrCrtc(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - v.Modes = make([]RandrMode, v.NumModes) - for i := 0; i < int(v.NumModes); i++ { - v.Modes[i] = RandrMode(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - v.Clones = make([]RandrOutput, v.NumClones) - for i := 0; i < int(v.NumClones); i++ { - v.Clones[i] = RandrOutput(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - v.Name = make([]byte, v.NameLen) - copy(v.Name[:v.NameLen], buf[b:]) - b += pad(int(v.NameLen)) - - return v -} - -func (cook RandrGetOutputInfoCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrGetOutputInfo -func (c *Conn) randrGetOutputInfoRequest(Output RandrOutput, ConfigTimestamp Timestamp) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 9 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Output)) - b += 4 - - Put32(buf[b:], uint32(ConfigTimestamp)) - b += 4 - - return buf -} - -// Request RandrListOutputProperties -// size: 8 -type RandrListOutputPropertiesCookie struct { - *cookie -} - -func (c *Conn) RandrListOutputProperties(Output RandrOutput) RandrListOutputPropertiesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrListOutputPropertiesRequest(Output), cookie) - return RandrListOutputPropertiesCookie{cookie} -} - -func (c *Conn) RandrListOutputPropertiesUnchecked(Output RandrOutput) RandrListOutputPropertiesCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.randrListOutputPropertiesRequest(Output), cookie) - return RandrListOutputPropertiesCookie{cookie} -} - -// Request reply for RandrListOutputProperties -// size: (32 + pad((int(NumAtoms) * 4))) -type RandrListOutputPropertiesReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumAtoms uint16 - // padding: 22 bytes - Atoms []Atom // size: pad((int(NumAtoms) * 4)) -} - -// Waits and reads reply data from request RandrListOutputProperties -func (cook RandrListOutputPropertiesCookie) Reply() (*RandrListOutputPropertiesReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return randrListOutputPropertiesReply(buf), nil -} - -// Read reply into structure from buffer for RandrListOutputProperties -func randrListOutputPropertiesReply(buf []byte) *RandrListOutputPropertiesReply { - v := new(RandrListOutputPropertiesReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.NumAtoms = Get16(buf[b:]) - b += 2 - - b += 22 // padding - - v.Atoms = make([]Atom, v.NumAtoms) - for i := 0; i < int(v.NumAtoms); i++ { - v.Atoms[i] = Atom(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook RandrListOutputPropertiesCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrListOutputProperties -func (c *Conn) randrListOutputPropertiesRequest(Output RandrOutput) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 10 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Output)) - b += 4 - - return buf -} - -// Request RandrQueryOutputProperty -// size: 12 -type RandrQueryOutputPropertyCookie struct { - *cookie -} - -func (c *Conn) RandrQueryOutputProperty(Output RandrOutput, Property Atom) RandrQueryOutputPropertyCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrQueryOutputPropertyRequest(Output, Property), cookie) - return RandrQueryOutputPropertyCookie{cookie} -} - -func (c *Conn) RandrQueryOutputPropertyUnchecked(Output RandrOutput, Property Atom) RandrQueryOutputPropertyCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.randrQueryOutputPropertyRequest(Output, Property), cookie) - return RandrQueryOutputPropertyCookie{cookie} -} - -// Request reply for RandrQueryOutputProperty -// size: (32 + pad((int(Length) * 4))) -type RandrQueryOutputPropertyReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Pending bool - Range bool - Immutable bool - // padding: 21 bytes - ValidValues []int32 // size: pad((int(Length) * 4)) -} - -// Waits and reads reply data from request RandrQueryOutputProperty -func (cook RandrQueryOutputPropertyCookie) Reply() (*RandrQueryOutputPropertyReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return randrQueryOutputPropertyReply(buf), nil -} - -// Read reply into structure from buffer for RandrQueryOutputProperty -func randrQueryOutputPropertyReply(buf []byte) *RandrQueryOutputPropertyReply { - v := new(RandrQueryOutputPropertyReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - if buf[b] == 1 { - v.Pending = true - } else { - v.Pending = false - } - b += 1 - - if buf[b] == 1 { - v.Range = true - } else { - v.Range = false - } - b += 1 - - if buf[b] == 1 { - v.Immutable = true - } else { - v.Immutable = false - } - b += 1 - - b += 21 // padding - - v.ValidValues = make([]int32, v.Length) - for i := 0; i < int(v.Length); i++ { - v.ValidValues[i] = int32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook RandrQueryOutputPropertyCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrQueryOutputProperty -func (c *Conn) randrQueryOutputPropertyRequest(Output RandrOutput, Property Atom) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 11 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Output)) - b += 4 - - Put32(buf[b:], uint32(Property)) - b += 4 - - return buf -} - -// Request RandrConfigureOutputProperty -// size: pad((16 + pad((len(Values) * 4)))) -type RandrConfigureOutputPropertyCookie struct { - *cookie -} - -// Write request to wire for RandrConfigureOutputProperty -func (c *Conn) RandrConfigureOutputProperty(Output RandrOutput, Property Atom, Pending bool, Range bool, Values []int32) RandrConfigureOutputPropertyCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.randrConfigureOutputPropertyRequest(Output, Property, Pending, Range, Values), cookie) - return RandrConfigureOutputPropertyCookie{cookie} -} - -func (c *Conn) RandrConfigureOutputPropertyChecked(Output RandrOutput, Property Atom, Pending bool, Range bool, Values []int32) RandrConfigureOutputPropertyCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.randrConfigureOutputPropertyRequest(Output, Property, Pending, Range, Values), cookie) - return RandrConfigureOutputPropertyCookie{cookie} -} - -func (cook RandrConfigureOutputPropertyCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrConfigureOutputProperty -func (c *Conn) randrConfigureOutputPropertyRequest(Output RandrOutput, Property Atom, Pending bool, Range bool, Values []int32) []byte { - size := pad((16 + pad((len(Values) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 12 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Output)) - b += 4 - - Put32(buf[b:], uint32(Property)) - b += 4 - - if Pending { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - if Range { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 2 // padding - - for i := 0; i < int(len(Values)); i++ { - Put32(buf[b:], uint32(Values[i])) - b += 4 - } - b = pad(b) - - return buf -} - -// Request RandrChangeOutputProperty -// size: pad((24 + pad((((int(NumUnits) * int(Format)) / 8) * 1)))) -type RandrChangeOutputPropertyCookie struct { - *cookie -} - -// Write request to wire for RandrChangeOutputProperty -func (c *Conn) RandrChangeOutputProperty(Output RandrOutput, Property Atom, Type Atom, Format byte, Mode byte, NumUnits uint32, Data []byte) RandrChangeOutputPropertyCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.randrChangeOutputPropertyRequest(Output, Property, Type, Format, Mode, NumUnits, Data), cookie) - return RandrChangeOutputPropertyCookie{cookie} -} - -func (c *Conn) RandrChangeOutputPropertyChecked(Output RandrOutput, Property Atom, Type Atom, Format byte, Mode byte, NumUnits uint32, Data []byte) RandrChangeOutputPropertyCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.randrChangeOutputPropertyRequest(Output, Property, Type, Format, Mode, NumUnits, Data), cookie) - return RandrChangeOutputPropertyCookie{cookie} -} - -func (cook RandrChangeOutputPropertyCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrChangeOutputProperty -func (c *Conn) randrChangeOutputPropertyRequest(Output RandrOutput, Property Atom, Type Atom, Format byte, Mode byte, NumUnits uint32, Data []byte) []byte { - size := pad((24 + pad((((int(NumUnits) * int(Format)) / 8) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 13 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Output)) - b += 4 - - Put32(buf[b:], uint32(Property)) - b += 4 - - Put32(buf[b:], uint32(Type)) - b += 4 - - buf[b] = Format - b += 1 - - buf[b] = Mode - b += 1 - - b += 2 // padding - - Put32(buf[b:], NumUnits) - b += 4 - - copy(buf[b:], Data[:((int(NumUnits)*int(Format))/8)]) - b += pad(int(((int(NumUnits) * int(Format)) / 8))) - - return buf -} - -// Request RandrDeleteOutputProperty -// size: 12 -type RandrDeleteOutputPropertyCookie struct { - *cookie -} - -// Write request to wire for RandrDeleteOutputProperty -func (c *Conn) RandrDeleteOutputProperty(Output RandrOutput, Property Atom) RandrDeleteOutputPropertyCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.randrDeleteOutputPropertyRequest(Output, Property), cookie) - return RandrDeleteOutputPropertyCookie{cookie} -} - -func (c *Conn) RandrDeleteOutputPropertyChecked(Output RandrOutput, Property Atom) RandrDeleteOutputPropertyCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.randrDeleteOutputPropertyRequest(Output, Property), cookie) - return RandrDeleteOutputPropertyCookie{cookie} -} - -func (cook RandrDeleteOutputPropertyCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrDeleteOutputProperty -func (c *Conn) randrDeleteOutputPropertyRequest(Output RandrOutput, Property Atom) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 14 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Output)) - b += 4 - - Put32(buf[b:], uint32(Property)) - b += 4 - - return buf -} - -// Request RandrGetOutputProperty -// size: 28 -type RandrGetOutputPropertyCookie struct { - *cookie -} - -func (c *Conn) RandrGetOutputProperty(Output RandrOutput, Property Atom, Type Atom, LongOffset uint32, LongLength uint32, Delete bool, Pending bool) RandrGetOutputPropertyCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrGetOutputPropertyRequest(Output, Property, Type, LongOffset, LongLength, Delete, Pending), cookie) - return RandrGetOutputPropertyCookie{cookie} -} - -func (c *Conn) RandrGetOutputPropertyUnchecked(Output RandrOutput, Property Atom, Type Atom, LongOffset uint32, LongLength uint32, Delete bool, Pending bool) RandrGetOutputPropertyCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.randrGetOutputPropertyRequest(Output, Property, Type, LongOffset, LongLength, Delete, Pending), cookie) - return RandrGetOutputPropertyCookie{cookie} -} - -// Request reply for RandrGetOutputProperty -// size: (32 + pad(((int(NumItems) * (int(Format) / 8)) * 1))) -type RandrGetOutputPropertyReply struct { - Sequence uint16 - Length uint32 - Format byte - Type Atom - BytesAfter uint32 - NumItems uint32 - // padding: 12 bytes - Data []byte // size: pad(((int(NumItems) * (int(Format) / 8)) * 1)) -} - -// Waits and reads reply data from request RandrGetOutputProperty -func (cook RandrGetOutputPropertyCookie) Reply() (*RandrGetOutputPropertyReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return randrGetOutputPropertyReply(buf), nil -} - -// Read reply into structure from buffer for RandrGetOutputProperty -func randrGetOutputPropertyReply(buf []byte) *RandrGetOutputPropertyReply { - v := new(RandrGetOutputPropertyReply) - b := 1 // skip reply determinant - - v.Format = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Type = Atom(Get32(buf[b:])) - b += 4 - - v.BytesAfter = Get32(buf[b:]) - b += 4 - - v.NumItems = Get32(buf[b:]) - b += 4 - - b += 12 // padding - - v.Data = make([]byte, (int(v.NumItems) * (int(v.Format) / 8))) - copy(v.Data[:(int(v.NumItems)*(int(v.Format)/8))], buf[b:]) - b += pad(int((int(v.NumItems) * (int(v.Format) / 8)))) - - return v -} - -func (cook RandrGetOutputPropertyCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrGetOutputProperty -func (c *Conn) randrGetOutputPropertyRequest(Output RandrOutput, Property Atom, Type Atom, LongOffset uint32, LongLength uint32, Delete bool, Pending bool) []byte { - size := 28 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 15 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Output)) - b += 4 - - Put32(buf[b:], uint32(Property)) - b += 4 - - Put32(buf[b:], uint32(Type)) - b += 4 - - Put32(buf[b:], LongOffset) - b += 4 - - Put32(buf[b:], LongLength) - b += 4 - - if Delete { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - if Pending { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 2 // padding - - return buf -} - -// Request RandrCreateMode -// size: pad((40 + pad((len(Name) * 1)))) -type RandrCreateModeCookie struct { - *cookie -} - -func (c *Conn) RandrCreateMode(Window Window, ModeInfo RandrModeInfo, Name string) RandrCreateModeCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrCreateModeRequest(Window, ModeInfo, Name), cookie) - return RandrCreateModeCookie{cookie} -} - -func (c *Conn) RandrCreateModeUnchecked(Window Window, ModeInfo RandrModeInfo, Name string) RandrCreateModeCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.randrCreateModeRequest(Window, ModeInfo, Name), cookie) - return RandrCreateModeCookie{cookie} -} - -// Request reply for RandrCreateMode -// size: 32 -type RandrCreateModeReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Mode RandrMode - // padding: 20 bytes -} - -// Waits and reads reply data from request RandrCreateMode -func (cook RandrCreateModeCookie) Reply() (*RandrCreateModeReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return randrCreateModeReply(buf), nil -} - -// Read reply into structure from buffer for RandrCreateMode -func randrCreateModeReply(buf []byte) *RandrCreateModeReply { - v := new(RandrCreateModeReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Mode = RandrMode(Get32(buf[b:])) - b += 4 - - b += 20 // padding - - return v -} - -func (cook RandrCreateModeCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrCreateMode -func (c *Conn) randrCreateModeRequest(Window Window, ModeInfo RandrModeInfo, Name string) []byte { - size := pad((40 + pad((len(Name) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 16 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - { - structBytes := ModeInfo.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - copy(buf[b:], Name[:len(Name)]) - b += pad(int(len(Name))) - - return buf -} - -// Request RandrDestroyMode -// size: 8 -type RandrDestroyModeCookie struct { - *cookie -} - -// Write request to wire for RandrDestroyMode -func (c *Conn) RandrDestroyMode(Mode RandrMode) RandrDestroyModeCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.randrDestroyModeRequest(Mode), cookie) - return RandrDestroyModeCookie{cookie} -} - -func (c *Conn) RandrDestroyModeChecked(Mode RandrMode) RandrDestroyModeCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.randrDestroyModeRequest(Mode), cookie) - return RandrDestroyModeCookie{cookie} -} - -func (cook RandrDestroyModeCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrDestroyMode -func (c *Conn) randrDestroyModeRequest(Mode RandrMode) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 17 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Mode)) - b += 4 - - return buf -} - -// Request RandrAddOutputMode -// size: 12 -type RandrAddOutputModeCookie struct { - *cookie -} - -// Write request to wire for RandrAddOutputMode -func (c *Conn) RandrAddOutputMode(Output RandrOutput, Mode RandrMode) RandrAddOutputModeCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.randrAddOutputModeRequest(Output, Mode), cookie) - return RandrAddOutputModeCookie{cookie} -} - -func (c *Conn) RandrAddOutputModeChecked(Output RandrOutput, Mode RandrMode) RandrAddOutputModeCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.randrAddOutputModeRequest(Output, Mode), cookie) - return RandrAddOutputModeCookie{cookie} -} - -func (cook RandrAddOutputModeCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrAddOutputMode -func (c *Conn) randrAddOutputModeRequest(Output RandrOutput, Mode RandrMode) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 18 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Output)) - b += 4 - - Put32(buf[b:], uint32(Mode)) - b += 4 - - return buf -} - -// Request RandrDeleteOutputMode -// size: 12 -type RandrDeleteOutputModeCookie struct { - *cookie -} - -// Write request to wire for RandrDeleteOutputMode -func (c *Conn) RandrDeleteOutputMode(Output RandrOutput, Mode RandrMode) RandrDeleteOutputModeCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.randrDeleteOutputModeRequest(Output, Mode), cookie) - return RandrDeleteOutputModeCookie{cookie} -} - -func (c *Conn) RandrDeleteOutputModeChecked(Output RandrOutput, Mode RandrMode) RandrDeleteOutputModeCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.randrDeleteOutputModeRequest(Output, Mode), cookie) - return RandrDeleteOutputModeCookie{cookie} -} - -func (cook RandrDeleteOutputModeCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrDeleteOutputMode -func (c *Conn) randrDeleteOutputModeRequest(Output RandrOutput, Mode RandrMode) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 19 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Output)) - b += 4 - - Put32(buf[b:], uint32(Mode)) - b += 4 - - return buf -} - -// Request RandrGetCrtcInfo -// size: 12 -type RandrGetCrtcInfoCookie struct { - *cookie -} - -func (c *Conn) RandrGetCrtcInfo(Crtc RandrCrtc, ConfigTimestamp Timestamp) RandrGetCrtcInfoCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrGetCrtcInfoRequest(Crtc, ConfigTimestamp), cookie) - return RandrGetCrtcInfoCookie{cookie} -} - -func (c *Conn) RandrGetCrtcInfoUnchecked(Crtc RandrCrtc, ConfigTimestamp Timestamp) RandrGetCrtcInfoCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.randrGetCrtcInfoRequest(Crtc, ConfigTimestamp), cookie) - return RandrGetCrtcInfoCookie{cookie} -} - -// Request reply for RandrGetCrtcInfo -// size: ((32 + pad((int(NumOutputs) * 4))) + pad((int(NumPossibleOutputs) * 4))) -type RandrGetCrtcInfoReply struct { - Sequence uint16 - Length uint32 - Status byte - Timestamp Timestamp - X int16 - Y int16 - Width uint16 - Height uint16 - Mode RandrMode - Rotation uint16 - Rotations uint16 - NumOutputs uint16 - NumPossibleOutputs uint16 - Outputs []RandrOutput // size: pad((int(NumOutputs) * 4)) - Possible []RandrOutput // size: pad((int(NumPossibleOutputs) * 4)) -} - -// Waits and reads reply data from request RandrGetCrtcInfo -func (cook RandrGetCrtcInfoCookie) Reply() (*RandrGetCrtcInfoReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return randrGetCrtcInfoReply(buf), nil -} - -// Read reply into structure from buffer for RandrGetCrtcInfo -func randrGetCrtcInfoReply(buf []byte) *RandrGetCrtcInfoReply { - v := new(RandrGetCrtcInfoReply) - b := 1 // skip reply determinant - - v.Status = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Timestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.X = int16(Get16(buf[b:])) - b += 2 - - v.Y = int16(Get16(buf[b:])) - b += 2 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - v.Mode = RandrMode(Get32(buf[b:])) - b += 4 - - v.Rotation = Get16(buf[b:]) - b += 2 - - v.Rotations = Get16(buf[b:]) - b += 2 - - v.NumOutputs = Get16(buf[b:]) - b += 2 - - v.NumPossibleOutputs = Get16(buf[b:]) - b += 2 - - v.Outputs = make([]RandrOutput, v.NumOutputs) - for i := 0; i < int(v.NumOutputs); i++ { - v.Outputs[i] = RandrOutput(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - v.Possible = make([]RandrOutput, v.NumPossibleOutputs) - for i := 0; i < int(v.NumPossibleOutputs); i++ { - v.Possible[i] = RandrOutput(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook RandrGetCrtcInfoCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrGetCrtcInfo -func (c *Conn) randrGetCrtcInfoRequest(Crtc RandrCrtc, ConfigTimestamp Timestamp) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 20 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Crtc)) - b += 4 - - Put32(buf[b:], uint32(ConfigTimestamp)) - b += 4 - - return buf -} - -// Request RandrSetCrtcConfig -// size: pad((28 + pad((len(Outputs) * 4)))) -type RandrSetCrtcConfigCookie struct { - *cookie -} - -func (c *Conn) RandrSetCrtcConfig(Crtc RandrCrtc, Timestamp Timestamp, ConfigTimestamp Timestamp, X int16, Y int16, Mode RandrMode, Rotation uint16, Outputs []RandrOutput) RandrSetCrtcConfigCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrSetCrtcConfigRequest(Crtc, Timestamp, ConfigTimestamp, X, Y, Mode, Rotation, Outputs), cookie) - return RandrSetCrtcConfigCookie{cookie} -} - -func (c *Conn) RandrSetCrtcConfigUnchecked(Crtc RandrCrtc, Timestamp Timestamp, ConfigTimestamp Timestamp, X int16, Y int16, Mode RandrMode, Rotation uint16, Outputs []RandrOutput) RandrSetCrtcConfigCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.randrSetCrtcConfigRequest(Crtc, Timestamp, ConfigTimestamp, X, Y, Mode, Rotation, Outputs), cookie) - return RandrSetCrtcConfigCookie{cookie} -} - -// Request reply for RandrSetCrtcConfig -// size: 32 -type RandrSetCrtcConfigReply struct { - Sequence uint16 - Length uint32 - Status byte - Timestamp Timestamp - // padding: 20 bytes -} - -// Waits and reads reply data from request RandrSetCrtcConfig -func (cook RandrSetCrtcConfigCookie) Reply() (*RandrSetCrtcConfigReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return randrSetCrtcConfigReply(buf), nil -} - -// Read reply into structure from buffer for RandrSetCrtcConfig -func randrSetCrtcConfigReply(buf []byte) *RandrSetCrtcConfigReply { - v := new(RandrSetCrtcConfigReply) - b := 1 // skip reply determinant - - v.Status = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Timestamp = Timestamp(Get32(buf[b:])) - b += 4 - - b += 20 // padding - - return v -} - -func (cook RandrSetCrtcConfigCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrSetCrtcConfig -func (c *Conn) randrSetCrtcConfigRequest(Crtc RandrCrtc, Timestamp Timestamp, ConfigTimestamp Timestamp, X int16, Y int16, Mode RandrMode, Rotation uint16, Outputs []RandrOutput) []byte { - size := pad((28 + pad((len(Outputs) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 21 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Crtc)) - b += 4 - - Put32(buf[b:], uint32(Timestamp)) - b += 4 - - Put32(buf[b:], uint32(ConfigTimestamp)) - b += 4 - - Put16(buf[b:], uint16(X)) - b += 2 - - Put16(buf[b:], uint16(Y)) - b += 2 - - Put32(buf[b:], uint32(Mode)) - b += 4 - - Put16(buf[b:], Rotation) - b += 2 - - b += 2 // padding - - for i := 0; i < int(len(Outputs)); i++ { - Put32(buf[b:], uint32(Outputs[i])) - b += 4 - } - b = pad(b) - - return buf -} - -// Request RandrGetCrtcGammaSize -// size: 8 -type RandrGetCrtcGammaSizeCookie struct { - *cookie -} - -func (c *Conn) RandrGetCrtcGammaSize(Crtc RandrCrtc) RandrGetCrtcGammaSizeCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrGetCrtcGammaSizeRequest(Crtc), cookie) - return RandrGetCrtcGammaSizeCookie{cookie} -} - -func (c *Conn) RandrGetCrtcGammaSizeUnchecked(Crtc RandrCrtc) RandrGetCrtcGammaSizeCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.randrGetCrtcGammaSizeRequest(Crtc), cookie) - return RandrGetCrtcGammaSizeCookie{cookie} -} - -// Request reply for RandrGetCrtcGammaSize -// size: 32 -type RandrGetCrtcGammaSizeReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Size uint16 - // padding: 22 bytes -} - -// Waits and reads reply data from request RandrGetCrtcGammaSize -func (cook RandrGetCrtcGammaSizeCookie) Reply() (*RandrGetCrtcGammaSizeReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return randrGetCrtcGammaSizeReply(buf), nil -} - -// Read reply into structure from buffer for RandrGetCrtcGammaSize -func randrGetCrtcGammaSizeReply(buf []byte) *RandrGetCrtcGammaSizeReply { - v := new(RandrGetCrtcGammaSizeReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Size = Get16(buf[b:]) - b += 2 - - b += 22 // padding - - return v -} - -func (cook RandrGetCrtcGammaSizeCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrGetCrtcGammaSize -func (c *Conn) randrGetCrtcGammaSizeRequest(Crtc RandrCrtc) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 22 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Crtc)) - b += 4 - - return buf -} - -// Request RandrGetCrtcGamma -// size: 8 -type RandrGetCrtcGammaCookie struct { - *cookie -} - -func (c *Conn) RandrGetCrtcGamma(Crtc RandrCrtc) RandrGetCrtcGammaCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrGetCrtcGammaRequest(Crtc), cookie) - return RandrGetCrtcGammaCookie{cookie} -} - -func (c *Conn) RandrGetCrtcGammaUnchecked(Crtc RandrCrtc) RandrGetCrtcGammaCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.randrGetCrtcGammaRequest(Crtc), cookie) - return RandrGetCrtcGammaCookie{cookie} -} - -// Request reply for RandrGetCrtcGamma -// size: (((32 + pad((int(Size) * 2))) + pad((int(Size) * 2))) + pad((int(Size) * 2))) -type RandrGetCrtcGammaReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Size uint16 - // padding: 22 bytes - Red []uint16 // size: pad((int(Size) * 2)) - Green []uint16 // size: pad((int(Size) * 2)) - Blue []uint16 // size: pad((int(Size) * 2)) -} - -// Waits and reads reply data from request RandrGetCrtcGamma -func (cook RandrGetCrtcGammaCookie) Reply() (*RandrGetCrtcGammaReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return randrGetCrtcGammaReply(buf), nil -} - -// Read reply into structure from buffer for RandrGetCrtcGamma -func randrGetCrtcGammaReply(buf []byte) *RandrGetCrtcGammaReply { - v := new(RandrGetCrtcGammaReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Size = Get16(buf[b:]) - b += 2 - - b += 22 // padding - - v.Red = make([]uint16, v.Size) - for i := 0; i < int(v.Size); i++ { - v.Red[i] = Get16(buf[b:]) - b += 2 - } - b = pad(b) - - v.Green = make([]uint16, v.Size) - for i := 0; i < int(v.Size); i++ { - v.Green[i] = Get16(buf[b:]) - b += 2 - } - b = pad(b) - - v.Blue = make([]uint16, v.Size) - for i := 0; i < int(v.Size); i++ { - v.Blue[i] = Get16(buf[b:]) - b += 2 - } - b = pad(b) - - return v -} - -func (cook RandrGetCrtcGammaCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrGetCrtcGamma -func (c *Conn) randrGetCrtcGammaRequest(Crtc RandrCrtc) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 23 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Crtc)) - b += 4 - - return buf -} - -// Request RandrSetCrtcGamma -// size: pad((((12 + pad((int(Size) * 2))) + pad((int(Size) * 2))) + pad((int(Size) * 2)))) -type RandrSetCrtcGammaCookie struct { - *cookie -} - -// Write request to wire for RandrSetCrtcGamma -func (c *Conn) RandrSetCrtcGamma(Crtc RandrCrtc, Size uint16, Red []uint16, Green []uint16, Blue []uint16) RandrSetCrtcGammaCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.randrSetCrtcGammaRequest(Crtc, Size, Red, Green, Blue), cookie) - return RandrSetCrtcGammaCookie{cookie} -} - -func (c *Conn) RandrSetCrtcGammaChecked(Crtc RandrCrtc, Size uint16, Red []uint16, Green []uint16, Blue []uint16) RandrSetCrtcGammaCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.randrSetCrtcGammaRequest(Crtc, Size, Red, Green, Blue), cookie) - return RandrSetCrtcGammaCookie{cookie} -} - -func (cook RandrSetCrtcGammaCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrSetCrtcGamma -func (c *Conn) randrSetCrtcGammaRequest(Crtc RandrCrtc, Size uint16, Red []uint16, Green []uint16, Blue []uint16) []byte { - size := pad((((12 + pad((int(Size) * 2))) + pad((int(Size) * 2))) + pad((int(Size) * 2)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 24 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Crtc)) - b += 4 - - Put16(buf[b:], Size) - b += 2 - - b += 2 // padding - - for i := 0; i < int(Size); i++ { - Put16(buf[b:], Red[i]) - b += 2 - } - b = pad(b) - - for i := 0; i < int(Size); i++ { - Put16(buf[b:], Green[i]) - b += 2 - } - b = pad(b) - - for i := 0; i < int(Size); i++ { - Put16(buf[b:], Blue[i]) - b += 2 - } - b = pad(b) - - return buf -} - -// Request RandrGetScreenResourcesCurrent -// size: 8 -type RandrGetScreenResourcesCurrentCookie struct { - *cookie -} - -func (c *Conn) RandrGetScreenResourcesCurrent(Window Window) RandrGetScreenResourcesCurrentCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrGetScreenResourcesCurrentRequest(Window), cookie) - return RandrGetScreenResourcesCurrentCookie{cookie} -} - -func (c *Conn) RandrGetScreenResourcesCurrentUnchecked(Window Window) RandrGetScreenResourcesCurrentCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.randrGetScreenResourcesCurrentRequest(Window), cookie) - return RandrGetScreenResourcesCurrentCookie{cookie} -} - -// Request reply for RandrGetScreenResourcesCurrent -// size: ((((32 + pad((int(NumCrtcs) * 4))) + pad((int(NumOutputs) * 4))) + pad((int(NumModes) * 32))) + pad((int(NamesLen) * 1))) -type RandrGetScreenResourcesCurrentReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Timestamp Timestamp - ConfigTimestamp Timestamp - NumCrtcs uint16 - NumOutputs uint16 - NumModes uint16 - NamesLen uint16 - // padding: 8 bytes - Crtcs []RandrCrtc // size: pad((int(NumCrtcs) * 4)) - Outputs []RandrOutput // size: pad((int(NumOutputs) * 4)) - Modes []RandrModeInfo // size: pad((int(NumModes) * 32)) - Names []byte // size: pad((int(NamesLen) * 1)) -} - -// Waits and reads reply data from request RandrGetScreenResourcesCurrent -func (cook RandrGetScreenResourcesCurrentCookie) Reply() (*RandrGetScreenResourcesCurrentReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return randrGetScreenResourcesCurrentReply(buf), nil -} - -// Read reply into structure from buffer for RandrGetScreenResourcesCurrent -func randrGetScreenResourcesCurrentReply(buf []byte) *RandrGetScreenResourcesCurrentReply { - v := new(RandrGetScreenResourcesCurrentReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Timestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.ConfigTimestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.NumCrtcs = Get16(buf[b:]) - b += 2 - - v.NumOutputs = Get16(buf[b:]) - b += 2 - - v.NumModes = Get16(buf[b:]) - b += 2 - - v.NamesLen = Get16(buf[b:]) - b += 2 - - b += 8 // padding - - v.Crtcs = make([]RandrCrtc, v.NumCrtcs) - for i := 0; i < int(v.NumCrtcs); i++ { - v.Crtcs[i] = RandrCrtc(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - v.Outputs = make([]RandrOutput, v.NumOutputs) - for i := 0; i < int(v.NumOutputs); i++ { - v.Outputs[i] = RandrOutput(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - v.Modes = make([]RandrModeInfo, v.NumModes) - b += ReadRandrModeInfoList(buf[b:], v.Modes) - - v.Names = make([]byte, v.NamesLen) - copy(v.Names[:v.NamesLen], buf[b:]) - b += pad(int(v.NamesLen)) - - return v -} - -func (cook RandrGetScreenResourcesCurrentCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrGetScreenResourcesCurrent -func (c *Conn) randrGetScreenResourcesCurrentRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 25 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - return buf -} - -// Request RandrSetCrtcTransform -// size: pad(((48 + pad((int(FilterLen) * 1))) + pad((len(FilterParams) * 4)))) -type RandrSetCrtcTransformCookie struct { - *cookie -} - -// Write request to wire for RandrSetCrtcTransform -func (c *Conn) RandrSetCrtcTransform(Crtc RandrCrtc, Transform RenderTransform, FilterLen uint16, FilterName string, FilterParams []RenderFixed) RandrSetCrtcTransformCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.randrSetCrtcTransformRequest(Crtc, Transform, FilterLen, FilterName, FilterParams), cookie) - return RandrSetCrtcTransformCookie{cookie} -} - -func (c *Conn) RandrSetCrtcTransformChecked(Crtc RandrCrtc, Transform RenderTransform, FilterLen uint16, FilterName string, FilterParams []RenderFixed) RandrSetCrtcTransformCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.randrSetCrtcTransformRequest(Crtc, Transform, FilterLen, FilterName, FilterParams), cookie) - return RandrSetCrtcTransformCookie{cookie} -} - -func (cook RandrSetCrtcTransformCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrSetCrtcTransform -func (c *Conn) randrSetCrtcTransformRequest(Crtc RandrCrtc, Transform RenderTransform, FilterLen uint16, FilterName string, FilterParams []RenderFixed) []byte { - size := pad(((48 + pad((int(FilterLen) * 1))) + pad((len(FilterParams) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 26 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Crtc)) - b += 4 - - { - structBytes := Transform.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - Put16(buf[b:], FilterLen) - b += 2 - - b += 2 // padding - - copy(buf[b:], FilterName[:FilterLen]) - b += pad(int(FilterLen)) - - for i := 0; i < int(len(FilterParams)); i++ { - Put32(buf[b:], uint32(FilterParams[i])) - b += 4 - } - b = pad(b) - - return buf -} - -// Request RandrGetCrtcTransform -// size: 8 -type RandrGetCrtcTransformCookie struct { - *cookie -} - -func (c *Conn) RandrGetCrtcTransform(Crtc RandrCrtc) RandrGetCrtcTransformCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrGetCrtcTransformRequest(Crtc), cookie) - return RandrGetCrtcTransformCookie{cookie} -} - -func (c *Conn) RandrGetCrtcTransformUnchecked(Crtc RandrCrtc) RandrGetCrtcTransformCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.randrGetCrtcTransformRequest(Crtc), cookie) - return RandrGetCrtcTransformCookie{cookie} -} - -// Request reply for RandrGetCrtcTransform -// size: ((((96 + pad((int(PendingLen) * 1))) + pad((int(PendingNparams) * 4))) + pad((int(CurrentLen) * 1))) + pad((int(CurrentNparams) * 4))) -type RandrGetCrtcTransformReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - PendingTransform RenderTransform - HasTransforms bool - // padding: 3 bytes - CurrentTransform RenderTransform - // padding: 4 bytes - PendingLen uint16 - PendingNparams uint16 - CurrentLen uint16 - CurrentNparams uint16 - PendingFilterName string // size: pad((int(PendingLen) * 1)) - PendingParams []RenderFixed // size: pad((int(PendingNparams) * 4)) - CurrentFilterName string // size: pad((int(CurrentLen) * 1)) - CurrentParams []RenderFixed // size: pad((int(CurrentNparams) * 4)) -} - -// Waits and reads reply data from request RandrGetCrtcTransform -func (cook RandrGetCrtcTransformCookie) Reply() (*RandrGetCrtcTransformReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return randrGetCrtcTransformReply(buf), nil -} - -// Read reply into structure from buffer for RandrGetCrtcTransform -func randrGetCrtcTransformReply(buf []byte) *RandrGetCrtcTransformReply { - v := new(RandrGetCrtcTransformReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.PendingTransform = RenderTransform{} - b += ReadRenderTransform(buf[b:], &v.PendingTransform) - - if buf[b] == 1 { - v.HasTransforms = true - } else { - v.HasTransforms = false - } - b += 1 - - b += 3 // padding - - v.CurrentTransform = RenderTransform{} - b += ReadRenderTransform(buf[b:], &v.CurrentTransform) - - b += 4 // padding - - v.PendingLen = Get16(buf[b:]) - b += 2 - - v.PendingNparams = Get16(buf[b:]) - b += 2 - - v.CurrentLen = Get16(buf[b:]) - b += 2 - - v.CurrentNparams = Get16(buf[b:]) - b += 2 - - { - byteString := make([]byte, v.PendingLen) - copy(byteString[:v.PendingLen], buf[b:]) - v.PendingFilterName = string(byteString) - b += pad(int(v.PendingLen)) - } - - v.PendingParams = make([]RenderFixed, v.PendingNparams) - for i := 0; i < int(v.PendingNparams); i++ { - v.PendingParams[i] = RenderFixed(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - { - byteString := make([]byte, v.CurrentLen) - copy(byteString[:v.CurrentLen], buf[b:]) - v.CurrentFilterName = string(byteString) - b += pad(int(v.CurrentLen)) - } - - v.CurrentParams = make([]RenderFixed, v.CurrentNparams) - for i := 0; i < int(v.CurrentNparams); i++ { - v.CurrentParams[i] = RenderFixed(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook RandrGetCrtcTransformCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrGetCrtcTransform -func (c *Conn) randrGetCrtcTransformRequest(Crtc RandrCrtc) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 27 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Crtc)) - b += 4 - - return buf -} - -// Request RandrGetPanning -// size: 8 -type RandrGetPanningCookie struct { - *cookie -} - -func (c *Conn) RandrGetPanning(Crtc RandrCrtc) RandrGetPanningCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrGetPanningRequest(Crtc), cookie) - return RandrGetPanningCookie{cookie} -} - -func (c *Conn) RandrGetPanningUnchecked(Crtc RandrCrtc) RandrGetPanningCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.randrGetPanningRequest(Crtc), cookie) - return RandrGetPanningCookie{cookie} -} - -// Request reply for RandrGetPanning -// size: 36 -type RandrGetPanningReply struct { - Sequence uint16 - Length uint32 - Status byte - Timestamp Timestamp - Left uint16 - Top uint16 - Width uint16 - Height uint16 - TrackLeft uint16 - TrackTop uint16 - TrackWidth uint16 - TrackHeight uint16 - BorderLeft int16 - BorderTop int16 - BorderRight int16 - BorderBottom int16 -} - -// Waits and reads reply data from request RandrGetPanning -func (cook RandrGetPanningCookie) Reply() (*RandrGetPanningReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return randrGetPanningReply(buf), nil -} - -// Read reply into structure from buffer for RandrGetPanning -func randrGetPanningReply(buf []byte) *RandrGetPanningReply { - v := new(RandrGetPanningReply) - b := 1 // skip reply determinant - - v.Status = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Timestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.Left = Get16(buf[b:]) - b += 2 - - v.Top = Get16(buf[b:]) - b += 2 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - v.TrackLeft = Get16(buf[b:]) - b += 2 - - v.TrackTop = Get16(buf[b:]) - b += 2 - - v.TrackWidth = Get16(buf[b:]) - b += 2 - - v.TrackHeight = Get16(buf[b:]) - b += 2 - - v.BorderLeft = int16(Get16(buf[b:])) - b += 2 - - v.BorderTop = int16(Get16(buf[b:])) - b += 2 - - v.BorderRight = int16(Get16(buf[b:])) - b += 2 - - v.BorderBottom = int16(Get16(buf[b:])) - b += 2 - - return v -} - -func (cook RandrGetPanningCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrGetPanning -func (c *Conn) randrGetPanningRequest(Crtc RandrCrtc) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 28 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Crtc)) - b += 4 - - return buf -} - -// Request RandrSetPanning -// size: 36 -type RandrSetPanningCookie struct { - *cookie -} - -func (c *Conn) RandrSetPanning(Crtc RandrCrtc, Timestamp Timestamp, Left uint16, Top uint16, Width uint16, Height uint16, TrackLeft uint16, TrackTop uint16, TrackWidth uint16, TrackHeight uint16, BorderLeft int16, BorderTop int16, BorderRight int16, BorderBottom int16) RandrSetPanningCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrSetPanningRequest(Crtc, Timestamp, Left, Top, Width, Height, TrackLeft, TrackTop, TrackWidth, TrackHeight, BorderLeft, BorderTop, BorderRight, BorderBottom), cookie) - return RandrSetPanningCookie{cookie} -} - -func (c *Conn) RandrSetPanningUnchecked(Crtc RandrCrtc, Timestamp Timestamp, Left uint16, Top uint16, Width uint16, Height uint16, TrackLeft uint16, TrackTop uint16, TrackWidth uint16, TrackHeight uint16, BorderLeft int16, BorderTop int16, BorderRight int16, BorderBottom int16) RandrSetPanningCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.randrSetPanningRequest(Crtc, Timestamp, Left, Top, Width, Height, TrackLeft, TrackTop, TrackWidth, TrackHeight, BorderLeft, BorderTop, BorderRight, BorderBottom), cookie) - return RandrSetPanningCookie{cookie} -} - -// Request reply for RandrSetPanning -// size: 12 -type RandrSetPanningReply struct { - Sequence uint16 - Length uint32 - Status byte - Timestamp Timestamp -} - -// Waits and reads reply data from request RandrSetPanning -func (cook RandrSetPanningCookie) Reply() (*RandrSetPanningReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return randrSetPanningReply(buf), nil -} - -// Read reply into structure from buffer for RandrSetPanning -func randrSetPanningReply(buf []byte) *RandrSetPanningReply { - v := new(RandrSetPanningReply) - b := 1 // skip reply determinant - - v.Status = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Timestamp = Timestamp(Get32(buf[b:])) - b += 4 - - return v -} - -func (cook RandrSetPanningCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrSetPanning -func (c *Conn) randrSetPanningRequest(Crtc RandrCrtc, Timestamp Timestamp, Left uint16, Top uint16, Width uint16, Height uint16, TrackLeft uint16, TrackTop uint16, TrackWidth uint16, TrackHeight uint16, BorderLeft int16, BorderTop int16, BorderRight int16, BorderBottom int16) []byte { - size := 36 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 29 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Crtc)) - b += 4 - - Put32(buf[b:], uint32(Timestamp)) - b += 4 - - Put16(buf[b:], Left) - b += 2 - - Put16(buf[b:], Top) - b += 2 - - Put16(buf[b:], Width) - b += 2 - - Put16(buf[b:], Height) - b += 2 - - Put16(buf[b:], TrackLeft) - b += 2 - - Put16(buf[b:], TrackTop) - b += 2 - - Put16(buf[b:], TrackWidth) - b += 2 - - Put16(buf[b:], TrackHeight) - b += 2 - - Put16(buf[b:], uint16(BorderLeft)) - b += 2 - - Put16(buf[b:], uint16(BorderTop)) - b += 2 - - Put16(buf[b:], uint16(BorderRight)) - b += 2 - - Put16(buf[b:], uint16(BorderBottom)) - b += 2 - - return buf -} - -// Request RandrSetOutputPrimary -// size: 12 -type RandrSetOutputPrimaryCookie struct { - *cookie -} - -// Write request to wire for RandrSetOutputPrimary -func (c *Conn) RandrSetOutputPrimary(Window Window, Output RandrOutput) RandrSetOutputPrimaryCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.randrSetOutputPrimaryRequest(Window, Output), cookie) - return RandrSetOutputPrimaryCookie{cookie} -} - -func (c *Conn) RandrSetOutputPrimaryChecked(Window Window, Output RandrOutput) RandrSetOutputPrimaryCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.randrSetOutputPrimaryRequest(Window, Output), cookie) - return RandrSetOutputPrimaryCookie{cookie} -} - -func (cook RandrSetOutputPrimaryCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrSetOutputPrimary -func (c *Conn) randrSetOutputPrimaryRequest(Window Window, Output RandrOutput) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 30 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - Put32(buf[b:], uint32(Output)) - b += 4 - - return buf -} - -// Request RandrGetOutputPrimary -// size: 8 -type RandrGetOutputPrimaryCookie struct { - *cookie -} - -func (c *Conn) RandrGetOutputPrimary(Window Window) RandrGetOutputPrimaryCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrGetOutputPrimaryRequest(Window), cookie) - return RandrGetOutputPrimaryCookie{cookie} -} - -func (c *Conn) RandrGetOutputPrimaryUnchecked(Window Window) RandrGetOutputPrimaryCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.randrGetOutputPrimaryRequest(Window), cookie) - return RandrGetOutputPrimaryCookie{cookie} -} - -// Request reply for RandrGetOutputPrimary -// size: 12 -type RandrGetOutputPrimaryReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Output RandrOutput -} - -// Waits and reads reply data from request RandrGetOutputPrimary -func (cook RandrGetOutputPrimaryCookie) Reply() (*RandrGetOutputPrimaryReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return randrGetOutputPrimaryReply(buf), nil -} - -// Read reply into structure from buffer for RandrGetOutputPrimary -func randrGetOutputPrimaryReply(buf []byte) *RandrGetOutputPrimaryReply { - v := new(RandrGetOutputPrimaryReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Output = RandrOutput(Get32(buf[b:])) - b += 4 - - return v -} - -func (cook RandrGetOutputPrimaryCookie) Check() error { - return cook.check() -} - -// Write request to wire for RandrGetOutputPrimary -func (c *Conn) randrGetOutputPrimaryRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RANDR"] - b += 1 - - buf[b] = 31 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - return buf -} diff --git a/nexgb/auto_record.go b/nexgb/auto_record.go deleted file mode 100644 index ec936d7..0000000 --- a/nexgb/auto_record.go +++ /dev/null @@ -1,1095 +0,0 @@ -package xgb - -/* - This file was generated by record.xml on May 10 2012 12:39:33pm EDT. - This file is automatically generated. Edit at your peril! -*/ - -// RecordInit must be called before using the RECORD extension. -func (c *Conn) RecordInit() error { - reply, err := c.QueryExtension(6, "RECORD").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named RECORD could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["RECORD"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["RECORD"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["RECORD"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["RECORD"] = make(map[int]newEventFun) - newExtErrorFuncs["RECORD"] = make(map[int]newErrorFun) -} - -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - -// Skipping definition for base type 'Int8' - -// Skipping definition for base type 'Card16' - -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - -// Skipping definition for base type 'Float' - -const ( - RecordHTypeFromServerTime = 1 - RecordHTypeFromClientTime = 2 - RecordHTypeFromClientSequence = 4 -) - -const ( - RecordCsCurrentClients = 1 - RecordCsFutureClients = 2 - RecordCsAllClients = 3 -) - -type RecordContext uint32 - -func (c *Conn) NewRecordContextId() (RecordContext, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return RecordContext(id), nil -} - -type RecordElementHeader byte - -type RecordClientSpec uint32 - -// 'RecordRange8' struct definition -// Size: 2 -type RecordRange8 struct { - First byte - Last byte -} - -// Struct read RecordRange8 -func ReadRecordRange8(buf []byte, v *RecordRange8) int { - b := 0 - - v.First = buf[b] - b += 1 - - v.Last = buf[b] - b += 1 - - return b -} - -// Struct list read RecordRange8 -func ReadRecordRange8List(buf []byte, dest []RecordRange8) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RecordRange8{} - b += ReadRecordRange8(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RecordRange8 -func (v RecordRange8) Bytes() []byte { - buf := make([]byte, 2) - b := 0 - - buf[b] = v.First - b += 1 - - buf[b] = v.Last - b += 1 - - return buf -} - -// Write struct list RecordRange8 -func RecordRange8ListBytes(buf []byte, list []RecordRange8) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RecordRange16' struct definition -// Size: 4 -type RecordRange16 struct { - First uint16 - Last uint16 -} - -// Struct read RecordRange16 -func ReadRecordRange16(buf []byte, v *RecordRange16) int { - b := 0 - - v.First = Get16(buf[b:]) - b += 2 - - v.Last = Get16(buf[b:]) - b += 2 - - return b -} - -// Struct list read RecordRange16 -func ReadRecordRange16List(buf []byte, dest []RecordRange16) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RecordRange16{} - b += ReadRecordRange16(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RecordRange16 -func (v RecordRange16) Bytes() []byte { - buf := make([]byte, 4) - b := 0 - - Put16(buf[b:], v.First) - b += 2 - - Put16(buf[b:], v.Last) - b += 2 - - return buf -} - -// Write struct list RecordRange16 -func RecordRange16ListBytes(buf []byte, list []RecordRange16) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RecordExtRange' struct definition -// Size: 6 -type RecordExtRange struct { - Major RecordRange8 - Minor RecordRange16 -} - -// Struct read RecordExtRange -func ReadRecordExtRange(buf []byte, v *RecordExtRange) int { - b := 0 - - v.Major = RecordRange8{} - b += ReadRecordRange8(buf[b:], &v.Major) - - v.Minor = RecordRange16{} - b += ReadRecordRange16(buf[b:], &v.Minor) - - return b -} - -// Struct list read RecordExtRange -func ReadRecordExtRangeList(buf []byte, dest []RecordExtRange) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RecordExtRange{} - b += ReadRecordExtRange(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RecordExtRange -func (v RecordExtRange) Bytes() []byte { - buf := make([]byte, 6) - b := 0 - - { - structBytes := v.Major.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - { - structBytes := v.Minor.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - return buf -} - -// Write struct list RecordExtRange -func RecordExtRangeListBytes(buf []byte, list []RecordExtRange) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RecordRange' struct definition -// Size: 24 -type RecordRange struct { - CoreRequests RecordRange8 - CoreReplies RecordRange8 - ExtRequests RecordExtRange - ExtReplies RecordExtRange - DeliveredEvents RecordRange8 - DeviceEvents RecordRange8 - Errors RecordRange8 - ClientStarted bool - ClientDied bool -} - -// Struct read RecordRange -func ReadRecordRange(buf []byte, v *RecordRange) int { - b := 0 - - v.CoreRequests = RecordRange8{} - b += ReadRecordRange8(buf[b:], &v.CoreRequests) - - v.CoreReplies = RecordRange8{} - b += ReadRecordRange8(buf[b:], &v.CoreReplies) - - v.ExtRequests = RecordExtRange{} - b += ReadRecordExtRange(buf[b:], &v.ExtRequests) - - v.ExtReplies = RecordExtRange{} - b += ReadRecordExtRange(buf[b:], &v.ExtReplies) - - v.DeliveredEvents = RecordRange8{} - b += ReadRecordRange8(buf[b:], &v.DeliveredEvents) - - v.DeviceEvents = RecordRange8{} - b += ReadRecordRange8(buf[b:], &v.DeviceEvents) - - v.Errors = RecordRange8{} - b += ReadRecordRange8(buf[b:], &v.Errors) - - if buf[b] == 1 { - v.ClientStarted = true - } else { - v.ClientStarted = false - } - b += 1 - - if buf[b] == 1 { - v.ClientDied = true - } else { - v.ClientDied = false - } - b += 1 - - return b -} - -// Struct list read RecordRange -func ReadRecordRangeList(buf []byte, dest []RecordRange) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RecordRange{} - b += ReadRecordRange(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RecordRange -func (v RecordRange) Bytes() []byte { - buf := make([]byte, 24) - b := 0 - - { - structBytes := v.CoreRequests.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - { - structBytes := v.CoreReplies.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - { - structBytes := v.ExtRequests.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - { - structBytes := v.ExtReplies.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - { - structBytes := v.DeliveredEvents.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - { - structBytes := v.DeviceEvents.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - { - structBytes := v.Errors.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - if v.ClientStarted { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - if v.ClientDied { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - return buf -} - -// Write struct list RecordRange -func RecordRangeListBytes(buf []byte, list []RecordRange) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RecordClientInfo' struct definition -// Size: (8 + pad((int(NumRanges) * 24))) -type RecordClientInfo struct { - ClientResource RecordClientSpec - NumRanges uint32 - Ranges []RecordRange // size: pad((int(NumRanges) * 24)) -} - -// Struct read RecordClientInfo -func ReadRecordClientInfo(buf []byte, v *RecordClientInfo) int { - b := 0 - - v.ClientResource = RecordClientSpec(Get32(buf[b:])) - b += 4 - - v.NumRanges = Get32(buf[b:]) - b += 4 - - v.Ranges = make([]RecordRange, v.NumRanges) - b += ReadRecordRangeList(buf[b:], v.Ranges) - - return b -} - -// Struct list read RecordClientInfo -func ReadRecordClientInfoList(buf []byte, dest []RecordClientInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RecordClientInfo{} - b += ReadRecordClientInfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RecordClientInfo -func (v RecordClientInfo) Bytes() []byte { - buf := make([]byte, (8 + pad((int(v.NumRanges) * 24)))) - b := 0 - - Put32(buf[b:], uint32(v.ClientResource)) - b += 4 - - Put32(buf[b:], v.NumRanges) - b += 4 - - b += RecordRangeListBytes(buf[b:], v.Ranges) - - return buf -} - -// Write struct list RecordClientInfo -func RecordClientInfoListBytes(buf []byte, list []RecordClientInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size RecordClientInfo -func RecordClientInfoListSize(list []RecordClientInfo) int { - size := 0 - for _, item := range list { - size += (8 + pad((int(item.NumRanges) * 24))) - } - return size -} - -// Error definition RecordBadContext (0) -// Size: 32 - -const BadRecordBadContext = 0 - -type RecordBadContextError struct { - Sequence uint16 - NiceName string - InvalidRecord uint32 -} - -// Error read RecordBadContext -func NewRecordBadContextError(buf []byte) Error { - v := RecordBadContextError{} - v.NiceName = "RecordBadContext" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.InvalidRecord = Get32(buf[b:]) - b += 4 - - return v -} - -func (err RecordBadContextError) ImplementsError() {} - -func (err RecordBadContextError) SequenceId() uint16 { - return err.Sequence -} - -func (err RecordBadContextError) BadId() uint32 { - return 0 -} - -func (err RecordBadContextError) Error() string { - fieldVals := make([]string, 0, 1) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, sprintf("InvalidRecord: %d", err.InvalidRecord)) - return "BadRecordBadContext {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["RECORD"][0] = NewRecordBadContextError -} - -// Request RecordQueryVersion -// size: 8 -type RecordQueryVersionCookie struct { - *cookie -} - -func (c *Conn) RecordQueryVersion(MajorVersion uint16, MinorVersion uint16) RecordQueryVersionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.recordQueryVersionRequest(MajorVersion, MinorVersion), cookie) - return RecordQueryVersionCookie{cookie} -} - -func (c *Conn) RecordQueryVersionUnchecked(MajorVersion uint16, MinorVersion uint16) RecordQueryVersionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.recordQueryVersionRequest(MajorVersion, MinorVersion), cookie) - return RecordQueryVersionCookie{cookie} -} - -// Request reply for RecordQueryVersion -// size: 12 -type RecordQueryVersionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - MajorVersion uint16 - MinorVersion uint16 -} - -// Waits and reads reply data from request RecordQueryVersion -func (cook RecordQueryVersionCookie) Reply() (*RecordQueryVersionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return recordQueryVersionReply(buf), nil -} - -// Read reply into structure from buffer for RecordQueryVersion -func recordQueryVersionReply(buf []byte) *RecordQueryVersionReply { - v := new(RecordQueryVersionReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.MajorVersion = Get16(buf[b:]) - b += 2 - - v.MinorVersion = Get16(buf[b:]) - b += 2 - - return v -} - -func (cook RecordQueryVersionCookie) Check() error { - return cook.check() -} - -// Write request to wire for RecordQueryVersion -func (c *Conn) recordQueryVersionRequest(MajorVersion uint16, MinorVersion uint16) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RECORD"] - b += 1 - - buf[b] = 0 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], MajorVersion) - b += 2 - - Put16(buf[b:], MinorVersion) - b += 2 - - return buf -} - -// Request RecordCreateContext -// size: pad(((20 + pad((int(NumClientSpecs) * 4))) + pad((int(NumRanges) * 24)))) -type RecordCreateContextCookie struct { - *cookie -} - -// Write request to wire for RecordCreateContext -func (c *Conn) RecordCreateContext(Context RecordContext, ElementHeader RecordElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []RecordClientSpec, Ranges []RecordRange) RecordCreateContextCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.recordCreateContextRequest(Context, ElementHeader, NumClientSpecs, NumRanges, ClientSpecs, Ranges), cookie) - return RecordCreateContextCookie{cookie} -} - -func (c *Conn) RecordCreateContextChecked(Context RecordContext, ElementHeader RecordElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []RecordClientSpec, Ranges []RecordRange) RecordCreateContextCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.recordCreateContextRequest(Context, ElementHeader, NumClientSpecs, NumRanges, ClientSpecs, Ranges), cookie) - return RecordCreateContextCookie{cookie} -} - -func (cook RecordCreateContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for RecordCreateContext -func (c *Conn) recordCreateContextRequest(Context RecordContext, ElementHeader RecordElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []RecordClientSpec, Ranges []RecordRange) []byte { - size := pad(((20 + pad((int(NumClientSpecs) * 4))) + pad((int(NumRanges) * 24)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RECORD"] - b += 1 - - buf[b] = 1 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Context)) - b += 4 - - buf[b] = byte(ElementHeader) - b += 1 - - b += 3 // padding - - Put32(buf[b:], NumClientSpecs) - b += 4 - - Put32(buf[b:], NumRanges) - b += 4 - - for i := 0; i < int(NumClientSpecs); i++ { - Put32(buf[b:], uint32(ClientSpecs[i])) - b += 4 - } - b = pad(b) - - b += RecordRangeListBytes(buf[b:], Ranges) - - return buf -} - -// Request RecordRegisterClients -// size: pad(((20 + pad((int(NumClientSpecs) * 4))) + pad((int(NumRanges) * 24)))) -type RecordRegisterClientsCookie struct { - *cookie -} - -// Write request to wire for RecordRegisterClients -func (c *Conn) RecordRegisterClients(Context RecordContext, ElementHeader RecordElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []RecordClientSpec, Ranges []RecordRange) RecordRegisterClientsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.recordRegisterClientsRequest(Context, ElementHeader, NumClientSpecs, NumRanges, ClientSpecs, Ranges), cookie) - return RecordRegisterClientsCookie{cookie} -} - -func (c *Conn) RecordRegisterClientsChecked(Context RecordContext, ElementHeader RecordElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []RecordClientSpec, Ranges []RecordRange) RecordRegisterClientsCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.recordRegisterClientsRequest(Context, ElementHeader, NumClientSpecs, NumRanges, ClientSpecs, Ranges), cookie) - return RecordRegisterClientsCookie{cookie} -} - -func (cook RecordRegisterClientsCookie) Check() error { - return cook.check() -} - -// Write request to wire for RecordRegisterClients -func (c *Conn) recordRegisterClientsRequest(Context RecordContext, ElementHeader RecordElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []RecordClientSpec, Ranges []RecordRange) []byte { - size := pad(((20 + pad((int(NumClientSpecs) * 4))) + pad((int(NumRanges) * 24)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RECORD"] - b += 1 - - buf[b] = 2 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Context)) - b += 4 - - buf[b] = byte(ElementHeader) - b += 1 - - b += 3 // padding - - Put32(buf[b:], NumClientSpecs) - b += 4 - - Put32(buf[b:], NumRanges) - b += 4 - - for i := 0; i < int(NumClientSpecs); i++ { - Put32(buf[b:], uint32(ClientSpecs[i])) - b += 4 - } - b = pad(b) - - b += RecordRangeListBytes(buf[b:], Ranges) - - return buf -} - -// Request RecordUnregisterClients -// size: pad((12 + pad((int(NumClientSpecs) * 4)))) -type RecordUnregisterClientsCookie struct { - *cookie -} - -// Write request to wire for RecordUnregisterClients -func (c *Conn) RecordUnregisterClients(Context RecordContext, NumClientSpecs uint32, ClientSpecs []RecordClientSpec) RecordUnregisterClientsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.recordUnregisterClientsRequest(Context, NumClientSpecs, ClientSpecs), cookie) - return RecordUnregisterClientsCookie{cookie} -} - -func (c *Conn) RecordUnregisterClientsChecked(Context RecordContext, NumClientSpecs uint32, ClientSpecs []RecordClientSpec) RecordUnregisterClientsCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.recordUnregisterClientsRequest(Context, NumClientSpecs, ClientSpecs), cookie) - return RecordUnregisterClientsCookie{cookie} -} - -func (cook RecordUnregisterClientsCookie) Check() error { - return cook.check() -} - -// Write request to wire for RecordUnregisterClients -func (c *Conn) recordUnregisterClientsRequest(Context RecordContext, NumClientSpecs uint32, ClientSpecs []RecordClientSpec) []byte { - size := pad((12 + pad((int(NumClientSpecs) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RECORD"] - b += 1 - - buf[b] = 3 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Context)) - b += 4 - - Put32(buf[b:], NumClientSpecs) - b += 4 - - for i := 0; i < int(NumClientSpecs); i++ { - Put32(buf[b:], uint32(ClientSpecs[i])) - b += 4 - } - b = pad(b) - - return buf -} - -// Request RecordGetContext -// size: 8 -type RecordGetContextCookie struct { - *cookie -} - -func (c *Conn) RecordGetContext(Context RecordContext) RecordGetContextCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.recordGetContextRequest(Context), cookie) - return RecordGetContextCookie{cookie} -} - -func (c *Conn) RecordGetContextUnchecked(Context RecordContext) RecordGetContextCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.recordGetContextRequest(Context), cookie) - return RecordGetContextCookie{cookie} -} - -// Request reply for RecordGetContext -// size: (32 + RecordClientInfoListSize(InterceptedClients)) -type RecordGetContextReply struct { - Sequence uint16 - Length uint32 - Enabled bool - ElementHeader RecordElementHeader - // padding: 3 bytes - NumInterceptedClients uint32 - // padding: 16 bytes - InterceptedClients []RecordClientInfo // size: RecordClientInfoListSize(InterceptedClients) -} - -// Waits and reads reply data from request RecordGetContext -func (cook RecordGetContextCookie) Reply() (*RecordGetContextReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return recordGetContextReply(buf), nil -} - -// Read reply into structure from buffer for RecordGetContext -func recordGetContextReply(buf []byte) *RecordGetContextReply { - v := new(RecordGetContextReply) - b := 1 // skip reply determinant - - if buf[b] == 1 { - v.Enabled = true - } else { - v.Enabled = false - } - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.ElementHeader = RecordElementHeader(buf[b]) - b += 1 - - b += 3 // padding - - v.NumInterceptedClients = Get32(buf[b:]) - b += 4 - - b += 16 // padding - - v.InterceptedClients = make([]RecordClientInfo, v.NumInterceptedClients) - b += ReadRecordClientInfoList(buf[b:], v.InterceptedClients) - - return v -} - -func (cook RecordGetContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for RecordGetContext -func (c *Conn) recordGetContextRequest(Context RecordContext) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RECORD"] - b += 1 - - buf[b] = 4 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Context)) - b += 4 - - return buf -} - -// Request RecordEnableContext -// size: 8 -type RecordEnableContextCookie struct { - *cookie -} - -func (c *Conn) RecordEnableContext(Context RecordContext) RecordEnableContextCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.recordEnableContextRequest(Context), cookie) - return RecordEnableContextCookie{cookie} -} - -func (c *Conn) RecordEnableContextUnchecked(Context RecordContext) RecordEnableContextCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.recordEnableContextRequest(Context), cookie) - return RecordEnableContextCookie{cookie} -} - -// Request reply for RecordEnableContext -// size: (32 + pad(((int(Length) * 4) * 1))) -type RecordEnableContextReply struct { - Sequence uint16 - Length uint32 - Category byte - ElementHeader RecordElementHeader - ClientSwapped bool - // padding: 2 bytes - XidBase uint32 - ServerTime uint32 - RecSequenceNum uint32 - // padding: 8 bytes - Data []byte // size: pad(((int(Length) * 4) * 1)) -} - -// Waits and reads reply data from request RecordEnableContext -func (cook RecordEnableContextCookie) Reply() (*RecordEnableContextReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return recordEnableContextReply(buf), nil -} - -// Read reply into structure from buffer for RecordEnableContext -func recordEnableContextReply(buf []byte) *RecordEnableContextReply { - v := new(RecordEnableContextReply) - b := 1 // skip reply determinant - - v.Category = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.ElementHeader = RecordElementHeader(buf[b]) - b += 1 - - if buf[b] == 1 { - v.ClientSwapped = true - } else { - v.ClientSwapped = false - } - b += 1 - - b += 2 // padding - - v.XidBase = Get32(buf[b:]) - b += 4 - - v.ServerTime = Get32(buf[b:]) - b += 4 - - v.RecSequenceNum = Get32(buf[b:]) - b += 4 - - b += 8 // padding - - v.Data = make([]byte, (int(v.Length) * 4)) - copy(v.Data[:(int(v.Length)*4)], buf[b:]) - b += pad(int((int(v.Length) * 4))) - - return v -} - -func (cook RecordEnableContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for RecordEnableContext -func (c *Conn) recordEnableContextRequest(Context RecordContext) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RECORD"] - b += 1 - - buf[b] = 5 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Context)) - b += 4 - - return buf -} - -// Request RecordDisableContext -// size: 8 -type RecordDisableContextCookie struct { - *cookie -} - -// Write request to wire for RecordDisableContext -func (c *Conn) RecordDisableContext(Context RecordContext) RecordDisableContextCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.recordDisableContextRequest(Context), cookie) - return RecordDisableContextCookie{cookie} -} - -func (c *Conn) RecordDisableContextChecked(Context RecordContext) RecordDisableContextCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.recordDisableContextRequest(Context), cookie) - return RecordDisableContextCookie{cookie} -} - -func (cook RecordDisableContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for RecordDisableContext -func (c *Conn) recordDisableContextRequest(Context RecordContext) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RECORD"] - b += 1 - - buf[b] = 6 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Context)) - b += 4 - - return buf -} - -// Request RecordFreeContext -// size: 8 -type RecordFreeContextCookie struct { - *cookie -} - -// Write request to wire for RecordFreeContext -func (c *Conn) RecordFreeContext(Context RecordContext) RecordFreeContextCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.recordFreeContextRequest(Context), cookie) - return RecordFreeContextCookie{cookie} -} - -func (c *Conn) RecordFreeContextChecked(Context RecordContext) RecordFreeContextCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.recordFreeContextRequest(Context), cookie) - return RecordFreeContextCookie{cookie} -} - -func (cook RecordFreeContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for RecordFreeContext -func (c *Conn) recordFreeContextRequest(Context RecordContext) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RECORD"] - b += 1 - - buf[b] = 7 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Context)) - b += 4 - - return buf -} diff --git a/nexgb/auto_render.go b/nexgb/auto_render.go deleted file mode 100644 index 5e1ff12..0000000 --- a/nexgb/auto_render.go +++ /dev/null @@ -1,3556 +0,0 @@ -package xgb - -/* - This file was generated by render.xml on May 10 2012 12:39:33pm EDT. - This file is automatically generated. Edit at your peril! -*/ - -// Imports are not necessary for XGB because everything is -// in one package. They are still listed here for reference. -// import "xproto" - -// RenderInit must be called before using the RENDER extension. -func (c *Conn) RenderInit() error { - reply, err := c.QueryExtension(6, "RENDER").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named RENDER could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["RENDER"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["RENDER"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["RENDER"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["RENDER"] = make(map[int]newEventFun) - newExtErrorFuncs["RENDER"] = make(map[int]newErrorFun) -} - -// Skipping definition for base type 'Int8' - -// Skipping definition for base type 'Card16' - -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - -// Skipping definition for base type 'Float' - -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - -const ( - RenderPictTypeIndexed = 0 - RenderPictTypeDirect = 1 -) - -const ( - RenderPictureNone = 0 -) - -const ( - RenderPictOpClear = 0 - RenderPictOpSrc = 1 - RenderPictOpDst = 2 - RenderPictOpOver = 3 - RenderPictOpOverReverse = 4 - RenderPictOpIn = 5 - RenderPictOpInReverse = 6 - RenderPictOpOut = 7 - RenderPictOpOutReverse = 8 - RenderPictOpAtop = 9 - RenderPictOpAtopReverse = 10 - RenderPictOpXor = 11 - RenderPictOpAdd = 12 - RenderPictOpSaturate = 13 - RenderPictOpDisjointClear = 16 - RenderPictOpDisjointSrc = 17 - RenderPictOpDisjointDst = 18 - RenderPictOpDisjointOver = 19 - RenderPictOpDisjointOverReverse = 20 - RenderPictOpDisjointIn = 21 - RenderPictOpDisjointInReverse = 22 - RenderPictOpDisjointOut = 23 - RenderPictOpDisjointOutReverse = 24 - RenderPictOpDisjointAtop = 25 - RenderPictOpDisjointAtopReverse = 26 - RenderPictOpDisjointXor = 27 - RenderPictOpConjointClear = 32 - RenderPictOpConjointSrc = 33 - RenderPictOpConjointDst = 34 - RenderPictOpConjointOver = 35 - RenderPictOpConjointOverReverse = 36 - RenderPictOpConjointIn = 37 - RenderPictOpConjointInReverse = 38 - RenderPictOpConjointOut = 39 - RenderPictOpConjointOutReverse = 40 - RenderPictOpConjointAtop = 41 - RenderPictOpConjointAtopReverse = 42 - RenderPictOpConjointXor = 43 - RenderPictOpMultiply = 48 - RenderPictOpScreen = 49 - RenderPictOpOverlay = 50 - RenderPictOpDarken = 51 - RenderPictOpLighten = 52 - RenderPictOpColorDodge = 53 - RenderPictOpColorBurn = 54 - RenderPictOpHardLight = 55 - RenderPictOpSoftLight = 56 - RenderPictOpDifference = 57 - RenderPictOpExclusion = 58 - RenderPictOpHSLHue = 59 - RenderPictOpHSLSaturation = 60 - RenderPictOpHSLColor = 61 - RenderPictOpHSLLuminosity = 62 -) - -const ( - RenderPolyEdgeSharp = 0 - RenderPolyEdgeSmooth = 1 -) - -const ( - RenderPolyModePrecise = 0 - RenderPolyModeImprecise = 1 -) - -const ( - RenderCpRepeat = 1 - RenderCpAlphaMap = 2 - RenderCpAlphaXOrigin = 4 - RenderCpAlphaYOrigin = 8 - RenderCpClipXOrigin = 16 - RenderCpClipYOrigin = 32 - RenderCpClipMask = 64 - RenderCpGraphicsExposure = 128 - RenderCpSubwindowMode = 256 - RenderCpPolyEdge = 512 - RenderCpPolyMode = 1024 - RenderCpDither = 2048 - RenderCpComponentAlpha = 4096 -) - -const ( - RenderSubPixelUnknown = 0 - RenderSubPixelHorizontalRGB = 1 - RenderSubPixelHorizontalBGR = 2 - RenderSubPixelVerticalRGB = 3 - RenderSubPixelVerticalBGR = 4 - RenderSubPixelNone = 5 -) - -const ( - RenderRepeatNone = 0 - RenderRepeatNormal = 1 - RenderRepeatPad = 2 - RenderRepeatReflect = 3 -) - -type RenderGlyphset uint32 - -func (c *Conn) NewRenderGlyphsetId() (RenderGlyphset, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return RenderGlyphset(id), nil -} - -type RenderPicture uint32 - -func (c *Conn) NewRenderPictureId() (RenderPicture, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return RenderPicture(id), nil -} - -type RenderPictformat uint32 - -func (c *Conn) NewRenderPictformatId() (RenderPictformat, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return RenderPictformat(id), nil -} - -type RenderGlyph uint32 - -type RenderFixed int32 - -// 'RenderDirectformat' struct definition -// Size: 16 -type RenderDirectformat struct { - RedShift uint16 - RedMask uint16 - GreenShift uint16 - GreenMask uint16 - BlueShift uint16 - BlueMask uint16 - AlphaShift uint16 - AlphaMask uint16 -} - -// Struct read RenderDirectformat -func ReadRenderDirectformat(buf []byte, v *RenderDirectformat) int { - b := 0 - - v.RedShift = Get16(buf[b:]) - b += 2 - - v.RedMask = Get16(buf[b:]) - b += 2 - - v.GreenShift = Get16(buf[b:]) - b += 2 - - v.GreenMask = Get16(buf[b:]) - b += 2 - - v.BlueShift = Get16(buf[b:]) - b += 2 - - v.BlueMask = Get16(buf[b:]) - b += 2 - - v.AlphaShift = Get16(buf[b:]) - b += 2 - - v.AlphaMask = Get16(buf[b:]) - b += 2 - - return b -} - -// Struct list read RenderDirectformat -func ReadRenderDirectformatList(buf []byte, dest []RenderDirectformat) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RenderDirectformat{} - b += ReadRenderDirectformat(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RenderDirectformat -func (v RenderDirectformat) Bytes() []byte { - buf := make([]byte, 16) - b := 0 - - Put16(buf[b:], v.RedShift) - b += 2 - - Put16(buf[b:], v.RedMask) - b += 2 - - Put16(buf[b:], v.GreenShift) - b += 2 - - Put16(buf[b:], v.GreenMask) - b += 2 - - Put16(buf[b:], v.BlueShift) - b += 2 - - Put16(buf[b:], v.BlueMask) - b += 2 - - Put16(buf[b:], v.AlphaShift) - b += 2 - - Put16(buf[b:], v.AlphaMask) - b += 2 - - return buf -} - -// Write struct list RenderDirectformat -func RenderDirectformatListBytes(buf []byte, list []RenderDirectformat) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RenderPictforminfo' struct definition -// Size: 28 -type RenderPictforminfo struct { - Id RenderPictformat - Type byte - Depth byte - // padding: 2 bytes - Direct RenderDirectformat - Colormap Colormap -} - -// Struct read RenderPictforminfo -func ReadRenderPictforminfo(buf []byte, v *RenderPictforminfo) int { - b := 0 - - v.Id = RenderPictformat(Get32(buf[b:])) - b += 4 - - v.Type = buf[b] - b += 1 - - v.Depth = buf[b] - b += 1 - - b += 2 // padding - - v.Direct = RenderDirectformat{} - b += ReadRenderDirectformat(buf[b:], &v.Direct) - - v.Colormap = Colormap(Get32(buf[b:])) - b += 4 - - return b -} - -// Struct list read RenderPictforminfo -func ReadRenderPictforminfoList(buf []byte, dest []RenderPictforminfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RenderPictforminfo{} - b += ReadRenderPictforminfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RenderPictforminfo -func (v RenderPictforminfo) Bytes() []byte { - buf := make([]byte, 28) - b := 0 - - Put32(buf[b:], uint32(v.Id)) - b += 4 - - buf[b] = v.Type - b += 1 - - buf[b] = v.Depth - b += 1 - - b += 2 // padding - - { - structBytes := v.Direct.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - Put32(buf[b:], uint32(v.Colormap)) - b += 4 - - return buf -} - -// Write struct list RenderPictforminfo -func RenderPictforminfoListBytes(buf []byte, list []RenderPictforminfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RenderPictvisual' struct definition -// Size: 8 -type RenderPictvisual struct { - Visual Visualid - Format RenderPictformat -} - -// Struct read RenderPictvisual -func ReadRenderPictvisual(buf []byte, v *RenderPictvisual) int { - b := 0 - - v.Visual = Visualid(Get32(buf[b:])) - b += 4 - - v.Format = RenderPictformat(Get32(buf[b:])) - b += 4 - - return b -} - -// Struct list read RenderPictvisual -func ReadRenderPictvisualList(buf []byte, dest []RenderPictvisual) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RenderPictvisual{} - b += ReadRenderPictvisual(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RenderPictvisual -func (v RenderPictvisual) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put32(buf[b:], uint32(v.Visual)) - b += 4 - - Put32(buf[b:], uint32(v.Format)) - b += 4 - - return buf -} - -// Write struct list RenderPictvisual -func RenderPictvisualListBytes(buf []byte, list []RenderPictvisual) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RenderPictdepth' struct definition -// Size: (8 + pad((int(NumVisuals) * 8))) -type RenderPictdepth struct { - Depth byte - // padding: 1 bytes - NumVisuals uint16 - // padding: 4 bytes - Visuals []RenderPictvisual // size: pad((int(NumVisuals) * 8)) -} - -// Struct read RenderPictdepth -func ReadRenderPictdepth(buf []byte, v *RenderPictdepth) int { - b := 0 - - v.Depth = buf[b] - b += 1 - - b += 1 // padding - - v.NumVisuals = Get16(buf[b:]) - b += 2 - - b += 4 // padding - - v.Visuals = make([]RenderPictvisual, v.NumVisuals) - b += ReadRenderPictvisualList(buf[b:], v.Visuals) - - return b -} - -// Struct list read RenderPictdepth -func ReadRenderPictdepthList(buf []byte, dest []RenderPictdepth) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RenderPictdepth{} - b += ReadRenderPictdepth(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RenderPictdepth -func (v RenderPictdepth) Bytes() []byte { - buf := make([]byte, (8 + pad((int(v.NumVisuals) * 8)))) - b := 0 - - buf[b] = v.Depth - b += 1 - - b += 1 // padding - - Put16(buf[b:], v.NumVisuals) - b += 2 - - b += 4 // padding - - b += RenderPictvisualListBytes(buf[b:], v.Visuals) - - return buf -} - -// Write struct list RenderPictdepth -func RenderPictdepthListBytes(buf []byte, list []RenderPictdepth) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size RenderPictdepth -func RenderPictdepthListSize(list []RenderPictdepth) int { - size := 0 - for _, item := range list { - size += (8 + pad((int(item.NumVisuals) * 8))) - } - return size -} - -// 'RenderPictscreen' struct definition -// Size: (8 + RenderPictdepthListSize(Depths)) -type RenderPictscreen struct { - NumDepths uint32 - Fallback RenderPictformat - Depths []RenderPictdepth // size: RenderPictdepthListSize(Depths) -} - -// Struct read RenderPictscreen -func ReadRenderPictscreen(buf []byte, v *RenderPictscreen) int { - b := 0 - - v.NumDepths = Get32(buf[b:]) - b += 4 - - v.Fallback = RenderPictformat(Get32(buf[b:])) - b += 4 - - v.Depths = make([]RenderPictdepth, v.NumDepths) - b += ReadRenderPictdepthList(buf[b:], v.Depths) - - return b -} - -// Struct list read RenderPictscreen -func ReadRenderPictscreenList(buf []byte, dest []RenderPictscreen) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RenderPictscreen{} - b += ReadRenderPictscreen(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RenderPictscreen -func (v RenderPictscreen) Bytes() []byte { - buf := make([]byte, (8 + RenderPictdepthListSize(v.Depths))) - b := 0 - - Put32(buf[b:], v.NumDepths) - b += 4 - - Put32(buf[b:], uint32(v.Fallback)) - b += 4 - - b += RenderPictdepthListBytes(buf[b:], v.Depths) - - return buf -} - -// Write struct list RenderPictscreen -func RenderPictscreenListBytes(buf []byte, list []RenderPictscreen) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size RenderPictscreen -func RenderPictscreenListSize(list []RenderPictscreen) int { - size := 0 - for _, item := range list { - size += (8 + RenderPictdepthListSize(item.Depths)) - } - return size -} - -// 'RenderIndexvalue' struct definition -// Size: 12 -type RenderIndexvalue struct { - Pixel uint32 - Red uint16 - Green uint16 - Blue uint16 - Alpha uint16 -} - -// Struct read RenderIndexvalue -func ReadRenderIndexvalue(buf []byte, v *RenderIndexvalue) int { - b := 0 - - v.Pixel = Get32(buf[b:]) - b += 4 - - v.Red = Get16(buf[b:]) - b += 2 - - v.Green = Get16(buf[b:]) - b += 2 - - v.Blue = Get16(buf[b:]) - b += 2 - - v.Alpha = Get16(buf[b:]) - b += 2 - - return b -} - -// Struct list read RenderIndexvalue -func ReadRenderIndexvalueList(buf []byte, dest []RenderIndexvalue) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RenderIndexvalue{} - b += ReadRenderIndexvalue(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RenderIndexvalue -func (v RenderIndexvalue) Bytes() []byte { - buf := make([]byte, 12) - b := 0 - - Put32(buf[b:], v.Pixel) - b += 4 - - Put16(buf[b:], v.Red) - b += 2 - - Put16(buf[b:], v.Green) - b += 2 - - Put16(buf[b:], v.Blue) - b += 2 - - Put16(buf[b:], v.Alpha) - b += 2 - - return buf -} - -// Write struct list RenderIndexvalue -func RenderIndexvalueListBytes(buf []byte, list []RenderIndexvalue) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RenderColor' struct definition -// Size: 8 -type RenderColor struct { - Red uint16 - Green uint16 - Blue uint16 - Alpha uint16 -} - -// Struct read RenderColor -func ReadRenderColor(buf []byte, v *RenderColor) int { - b := 0 - - v.Red = Get16(buf[b:]) - b += 2 - - v.Green = Get16(buf[b:]) - b += 2 - - v.Blue = Get16(buf[b:]) - b += 2 - - v.Alpha = Get16(buf[b:]) - b += 2 - - return b -} - -// Struct list read RenderColor -func ReadRenderColorList(buf []byte, dest []RenderColor) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RenderColor{} - b += ReadRenderColor(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RenderColor -func (v RenderColor) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put16(buf[b:], v.Red) - b += 2 - - Put16(buf[b:], v.Green) - b += 2 - - Put16(buf[b:], v.Blue) - b += 2 - - Put16(buf[b:], v.Alpha) - b += 2 - - return buf -} - -// Write struct list RenderColor -func RenderColorListBytes(buf []byte, list []RenderColor) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RenderPointfix' struct definition -// Size: 8 -type RenderPointfix struct { - X RenderFixed - Y RenderFixed -} - -// Struct read RenderPointfix -func ReadRenderPointfix(buf []byte, v *RenderPointfix) int { - b := 0 - - v.X = RenderFixed(Get32(buf[b:])) - b += 4 - - v.Y = RenderFixed(Get32(buf[b:])) - b += 4 - - return b -} - -// Struct list read RenderPointfix -func ReadRenderPointfixList(buf []byte, dest []RenderPointfix) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RenderPointfix{} - b += ReadRenderPointfix(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RenderPointfix -func (v RenderPointfix) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put32(buf[b:], uint32(v.X)) - b += 4 - - Put32(buf[b:], uint32(v.Y)) - b += 4 - - return buf -} - -// Write struct list RenderPointfix -func RenderPointfixListBytes(buf []byte, list []RenderPointfix) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RenderLinefix' struct definition -// Size: 16 -type RenderLinefix struct { - P1 RenderPointfix - P2 RenderPointfix -} - -// Struct read RenderLinefix -func ReadRenderLinefix(buf []byte, v *RenderLinefix) int { - b := 0 - - v.P1 = RenderPointfix{} - b += ReadRenderPointfix(buf[b:], &v.P1) - - v.P2 = RenderPointfix{} - b += ReadRenderPointfix(buf[b:], &v.P2) - - return b -} - -// Struct list read RenderLinefix -func ReadRenderLinefixList(buf []byte, dest []RenderLinefix) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RenderLinefix{} - b += ReadRenderLinefix(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RenderLinefix -func (v RenderLinefix) Bytes() []byte { - buf := make([]byte, 16) - b := 0 - - { - structBytes := v.P1.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - { - structBytes := v.P2.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - return buf -} - -// Write struct list RenderLinefix -func RenderLinefixListBytes(buf []byte, list []RenderLinefix) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RenderTriangle' struct definition -// Size: 24 -type RenderTriangle struct { - P1 RenderPointfix - P2 RenderPointfix - P3 RenderPointfix -} - -// Struct read RenderTriangle -func ReadRenderTriangle(buf []byte, v *RenderTriangle) int { - b := 0 - - v.P1 = RenderPointfix{} - b += ReadRenderPointfix(buf[b:], &v.P1) - - v.P2 = RenderPointfix{} - b += ReadRenderPointfix(buf[b:], &v.P2) - - v.P3 = RenderPointfix{} - b += ReadRenderPointfix(buf[b:], &v.P3) - - return b -} - -// Struct list read RenderTriangle -func ReadRenderTriangleList(buf []byte, dest []RenderTriangle) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RenderTriangle{} - b += ReadRenderTriangle(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RenderTriangle -func (v RenderTriangle) Bytes() []byte { - buf := make([]byte, 24) - b := 0 - - { - structBytes := v.P1.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - { - structBytes := v.P2.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - { - structBytes := v.P3.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - return buf -} - -// Write struct list RenderTriangle -func RenderTriangleListBytes(buf []byte, list []RenderTriangle) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RenderTrapezoid' struct definition -// Size: 40 -type RenderTrapezoid struct { - Top RenderFixed - Bottom RenderFixed - Left RenderLinefix - Right RenderLinefix -} - -// Struct read RenderTrapezoid -func ReadRenderTrapezoid(buf []byte, v *RenderTrapezoid) int { - b := 0 - - v.Top = RenderFixed(Get32(buf[b:])) - b += 4 - - v.Bottom = RenderFixed(Get32(buf[b:])) - b += 4 - - v.Left = RenderLinefix{} - b += ReadRenderLinefix(buf[b:], &v.Left) - - v.Right = RenderLinefix{} - b += ReadRenderLinefix(buf[b:], &v.Right) - - return b -} - -// Struct list read RenderTrapezoid -func ReadRenderTrapezoidList(buf []byte, dest []RenderTrapezoid) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RenderTrapezoid{} - b += ReadRenderTrapezoid(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RenderTrapezoid -func (v RenderTrapezoid) Bytes() []byte { - buf := make([]byte, 40) - b := 0 - - Put32(buf[b:], uint32(v.Top)) - b += 4 - - Put32(buf[b:], uint32(v.Bottom)) - b += 4 - - { - structBytes := v.Left.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - { - structBytes := v.Right.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - return buf -} - -// Write struct list RenderTrapezoid -func RenderTrapezoidListBytes(buf []byte, list []RenderTrapezoid) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RenderGlyphinfo' struct definition -// Size: 12 -type RenderGlyphinfo struct { - Width uint16 - Height uint16 - X int16 - Y int16 - XOff int16 - YOff int16 -} - -// Struct read RenderGlyphinfo -func ReadRenderGlyphinfo(buf []byte, v *RenderGlyphinfo) int { - b := 0 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - v.X = int16(Get16(buf[b:])) - b += 2 - - v.Y = int16(Get16(buf[b:])) - b += 2 - - v.XOff = int16(Get16(buf[b:])) - b += 2 - - v.YOff = int16(Get16(buf[b:])) - b += 2 - - return b -} - -// Struct list read RenderGlyphinfo -func ReadRenderGlyphinfoList(buf []byte, dest []RenderGlyphinfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RenderGlyphinfo{} - b += ReadRenderGlyphinfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RenderGlyphinfo -func (v RenderGlyphinfo) Bytes() []byte { - buf := make([]byte, 12) - b := 0 - - Put16(buf[b:], v.Width) - b += 2 - - Put16(buf[b:], v.Height) - b += 2 - - Put16(buf[b:], uint16(v.X)) - b += 2 - - Put16(buf[b:], uint16(v.Y)) - b += 2 - - Put16(buf[b:], uint16(v.XOff)) - b += 2 - - Put16(buf[b:], uint16(v.YOff)) - b += 2 - - return buf -} - -// Write struct list RenderGlyphinfo -func RenderGlyphinfoListBytes(buf []byte, list []RenderGlyphinfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RenderTransform' struct definition -// Size: 36 -type RenderTransform struct { - Matrix11 RenderFixed - Matrix12 RenderFixed - Matrix13 RenderFixed - Matrix21 RenderFixed - Matrix22 RenderFixed - Matrix23 RenderFixed - Matrix31 RenderFixed - Matrix32 RenderFixed - Matrix33 RenderFixed -} - -// Struct read RenderTransform -func ReadRenderTransform(buf []byte, v *RenderTransform) int { - b := 0 - - v.Matrix11 = RenderFixed(Get32(buf[b:])) - b += 4 - - v.Matrix12 = RenderFixed(Get32(buf[b:])) - b += 4 - - v.Matrix13 = RenderFixed(Get32(buf[b:])) - b += 4 - - v.Matrix21 = RenderFixed(Get32(buf[b:])) - b += 4 - - v.Matrix22 = RenderFixed(Get32(buf[b:])) - b += 4 - - v.Matrix23 = RenderFixed(Get32(buf[b:])) - b += 4 - - v.Matrix31 = RenderFixed(Get32(buf[b:])) - b += 4 - - v.Matrix32 = RenderFixed(Get32(buf[b:])) - b += 4 - - v.Matrix33 = RenderFixed(Get32(buf[b:])) - b += 4 - - return b -} - -// Struct list read RenderTransform -func ReadRenderTransformList(buf []byte, dest []RenderTransform) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RenderTransform{} - b += ReadRenderTransform(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RenderTransform -func (v RenderTransform) Bytes() []byte { - buf := make([]byte, 36) - b := 0 - - Put32(buf[b:], uint32(v.Matrix11)) - b += 4 - - Put32(buf[b:], uint32(v.Matrix12)) - b += 4 - - Put32(buf[b:], uint32(v.Matrix13)) - b += 4 - - Put32(buf[b:], uint32(v.Matrix21)) - b += 4 - - Put32(buf[b:], uint32(v.Matrix22)) - b += 4 - - Put32(buf[b:], uint32(v.Matrix23)) - b += 4 - - Put32(buf[b:], uint32(v.Matrix31)) - b += 4 - - Put32(buf[b:], uint32(v.Matrix32)) - b += 4 - - Put32(buf[b:], uint32(v.Matrix33)) - b += 4 - - return buf -} - -// Write struct list RenderTransform -func RenderTransformListBytes(buf []byte, list []RenderTransform) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RenderAnimcursorelt' struct definition -// Size: 8 -type RenderAnimcursorelt struct { - Cursor Cursor - Delay uint32 -} - -// Struct read RenderAnimcursorelt -func ReadRenderAnimcursorelt(buf []byte, v *RenderAnimcursorelt) int { - b := 0 - - v.Cursor = Cursor(Get32(buf[b:])) - b += 4 - - v.Delay = Get32(buf[b:]) - b += 4 - - return b -} - -// Struct list read RenderAnimcursorelt -func ReadRenderAnimcursoreltList(buf []byte, dest []RenderAnimcursorelt) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RenderAnimcursorelt{} - b += ReadRenderAnimcursorelt(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RenderAnimcursorelt -func (v RenderAnimcursorelt) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put32(buf[b:], uint32(v.Cursor)) - b += 4 - - Put32(buf[b:], v.Delay) - b += 4 - - return buf -} - -// Write struct list RenderAnimcursorelt -func RenderAnimcursoreltListBytes(buf []byte, list []RenderAnimcursorelt) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RenderSpanfix' struct definition -// Size: 12 -type RenderSpanfix struct { - L RenderFixed - R RenderFixed - Y RenderFixed -} - -// Struct read RenderSpanfix -func ReadRenderSpanfix(buf []byte, v *RenderSpanfix) int { - b := 0 - - v.L = RenderFixed(Get32(buf[b:])) - b += 4 - - v.R = RenderFixed(Get32(buf[b:])) - b += 4 - - v.Y = RenderFixed(Get32(buf[b:])) - b += 4 - - return b -} - -// Struct list read RenderSpanfix -func ReadRenderSpanfixList(buf []byte, dest []RenderSpanfix) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RenderSpanfix{} - b += ReadRenderSpanfix(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RenderSpanfix -func (v RenderSpanfix) Bytes() []byte { - buf := make([]byte, 12) - b := 0 - - Put32(buf[b:], uint32(v.L)) - b += 4 - - Put32(buf[b:], uint32(v.R)) - b += 4 - - Put32(buf[b:], uint32(v.Y)) - b += 4 - - return buf -} - -// Write struct list RenderSpanfix -func RenderSpanfixListBytes(buf []byte, list []RenderSpanfix) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'RenderTrap' struct definition -// Size: 24 -type RenderTrap struct { - Top RenderSpanfix - Bot RenderSpanfix -} - -// Struct read RenderTrap -func ReadRenderTrap(buf []byte, v *RenderTrap) int { - b := 0 - - v.Top = RenderSpanfix{} - b += ReadRenderSpanfix(buf[b:], &v.Top) - - v.Bot = RenderSpanfix{} - b += ReadRenderSpanfix(buf[b:], &v.Bot) - - return b -} - -// Struct list read RenderTrap -func ReadRenderTrapList(buf []byte, dest []RenderTrap) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = RenderTrap{} - b += ReadRenderTrap(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write RenderTrap -func (v RenderTrap) Bytes() []byte { - buf := make([]byte, 24) - b := 0 - - { - structBytes := v.Top.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - { - structBytes := v.Bot.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - return buf -} - -// Write struct list RenderTrap -func RenderTrapListBytes(buf []byte, list []RenderTrap) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Error definition RenderPictFormat (0) -// Size: 32 - -const BadRenderPictFormat = 0 - -type RenderPictFormatError struct { - Sequence uint16 - NiceName string -} - -// Error read RenderPictFormat -func NewRenderPictFormatError(buf []byte) Error { - v := RenderPictFormatError{} - v.NiceName = "RenderPictFormat" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err RenderPictFormatError) ImplementsError() {} - -func (err RenderPictFormatError) SequenceId() uint16 { - return err.Sequence -} - -func (err RenderPictFormatError) BadId() uint32 { - return 0 -} - -func (err RenderPictFormatError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadRenderPictFormat {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["RENDER"][0] = NewRenderPictFormatError -} - -// Error definition RenderPicture (1) -// Size: 32 - -const BadRenderPicture = 1 - -type RenderPictureError struct { - Sequence uint16 - NiceName string -} - -// Error read RenderPicture -func NewRenderPictureError(buf []byte) Error { - v := RenderPictureError{} - v.NiceName = "RenderPicture" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err RenderPictureError) ImplementsError() {} - -func (err RenderPictureError) SequenceId() uint16 { - return err.Sequence -} - -func (err RenderPictureError) BadId() uint32 { - return 0 -} - -func (err RenderPictureError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadRenderPicture {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["RENDER"][1] = NewRenderPictureError -} - -// Error definition RenderPictOp (2) -// Size: 32 - -const BadRenderPictOp = 2 - -type RenderPictOpError struct { - Sequence uint16 - NiceName string -} - -// Error read RenderPictOp -func NewRenderPictOpError(buf []byte) Error { - v := RenderPictOpError{} - v.NiceName = "RenderPictOp" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err RenderPictOpError) ImplementsError() {} - -func (err RenderPictOpError) SequenceId() uint16 { - return err.Sequence -} - -func (err RenderPictOpError) BadId() uint32 { - return 0 -} - -func (err RenderPictOpError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadRenderPictOp {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["RENDER"][2] = NewRenderPictOpError -} - -// Error definition RenderGlyphSet (3) -// Size: 32 - -const BadRenderGlyphSet = 3 - -type RenderGlyphSetError struct { - Sequence uint16 - NiceName string -} - -// Error read RenderGlyphSet -func NewRenderGlyphSetError(buf []byte) Error { - v := RenderGlyphSetError{} - v.NiceName = "RenderGlyphSet" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err RenderGlyphSetError) ImplementsError() {} - -func (err RenderGlyphSetError) SequenceId() uint16 { - return err.Sequence -} - -func (err RenderGlyphSetError) BadId() uint32 { - return 0 -} - -func (err RenderGlyphSetError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadRenderGlyphSet {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["RENDER"][3] = NewRenderGlyphSetError -} - -// Error definition RenderGlyph (4) -// Size: 32 - -const BadRenderGlyph = 4 - -type RenderGlyphError struct { - Sequence uint16 - NiceName string -} - -// Error read RenderGlyph -func NewRenderGlyphError(buf []byte) Error { - v := RenderGlyphError{} - v.NiceName = "RenderGlyph" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err RenderGlyphError) ImplementsError() {} - -func (err RenderGlyphError) SequenceId() uint16 { - return err.Sequence -} - -func (err RenderGlyphError) BadId() uint32 { - return 0 -} - -func (err RenderGlyphError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadRenderGlyph {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["RENDER"][4] = NewRenderGlyphError -} - -// Request RenderQueryVersion -// size: 12 -type RenderQueryVersionCookie struct { - *cookie -} - -func (c *Conn) RenderQueryVersion(ClientMajorVersion uint32, ClientMinorVersion uint32) RenderQueryVersionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.renderQueryVersionRequest(ClientMajorVersion, ClientMinorVersion), cookie) - return RenderQueryVersionCookie{cookie} -} - -func (c *Conn) RenderQueryVersionUnchecked(ClientMajorVersion uint32, ClientMinorVersion uint32) RenderQueryVersionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.renderQueryVersionRequest(ClientMajorVersion, ClientMinorVersion), cookie) - return RenderQueryVersionCookie{cookie} -} - -// Request reply for RenderQueryVersion -// size: 32 -type RenderQueryVersionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - MajorVersion uint32 - MinorVersion uint32 - // padding: 16 bytes -} - -// Waits and reads reply data from request RenderQueryVersion -func (cook RenderQueryVersionCookie) Reply() (*RenderQueryVersionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return renderQueryVersionReply(buf), nil -} - -// Read reply into structure from buffer for RenderQueryVersion -func renderQueryVersionReply(buf []byte) *RenderQueryVersionReply { - v := new(RenderQueryVersionReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.MajorVersion = Get32(buf[b:]) - b += 4 - - v.MinorVersion = Get32(buf[b:]) - b += 4 - - b += 16 // padding - - return v -} - -func (cook RenderQueryVersionCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderQueryVersion -func (c *Conn) renderQueryVersionRequest(ClientMajorVersion uint32, ClientMinorVersion uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 0 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], ClientMajorVersion) - b += 4 - - Put32(buf[b:], ClientMinorVersion) - b += 4 - - return buf -} - -// Request RenderQueryPictFormats -// size: 4 -type RenderQueryPictFormatsCookie struct { - *cookie -} - -func (c *Conn) RenderQueryPictFormats() RenderQueryPictFormatsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.renderQueryPictFormatsRequest(), cookie) - return RenderQueryPictFormatsCookie{cookie} -} - -func (c *Conn) RenderQueryPictFormatsUnchecked() RenderQueryPictFormatsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.renderQueryPictFormatsRequest(), cookie) - return RenderQueryPictFormatsCookie{cookie} -} - -// Request reply for RenderQueryPictFormats -// size: (((32 + pad((int(NumFormats) * 28))) + RenderPictscreenListSize(Screens)) + pad((int(NumSubpixel) * 4))) -type RenderQueryPictFormatsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumFormats uint32 - NumScreens uint32 - NumDepths uint32 - NumVisuals uint32 - NumSubpixel uint32 - // padding: 4 bytes - Formats []RenderPictforminfo // size: pad((int(NumFormats) * 28)) - Screens []RenderPictscreen // size: RenderPictscreenListSize(Screens) - Subpixels []uint32 // size: pad((int(NumSubpixel) * 4)) -} - -// Waits and reads reply data from request RenderQueryPictFormats -func (cook RenderQueryPictFormatsCookie) Reply() (*RenderQueryPictFormatsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return renderQueryPictFormatsReply(buf), nil -} - -// Read reply into structure from buffer for RenderQueryPictFormats -func renderQueryPictFormatsReply(buf []byte) *RenderQueryPictFormatsReply { - v := new(RenderQueryPictFormatsReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.NumFormats = Get32(buf[b:]) - b += 4 - - v.NumScreens = Get32(buf[b:]) - b += 4 - - v.NumDepths = Get32(buf[b:]) - b += 4 - - v.NumVisuals = Get32(buf[b:]) - b += 4 - - v.NumSubpixel = Get32(buf[b:]) - b += 4 - - b += 4 // padding - - v.Formats = make([]RenderPictforminfo, v.NumFormats) - b += ReadRenderPictforminfoList(buf[b:], v.Formats) - - v.Screens = make([]RenderPictscreen, v.NumScreens) - b += ReadRenderPictscreenList(buf[b:], v.Screens) - - v.Subpixels = make([]uint32, v.NumSubpixel) - for i := 0; i < int(v.NumSubpixel); i++ { - v.Subpixels[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook RenderQueryPictFormatsCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderQueryPictFormats -func (c *Conn) renderQueryPictFormatsRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 1 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request RenderQueryPictIndexValues -// size: 8 -type RenderQueryPictIndexValuesCookie struct { - *cookie -} - -func (c *Conn) RenderQueryPictIndexValues(Format RenderPictformat) RenderQueryPictIndexValuesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.renderQueryPictIndexValuesRequest(Format), cookie) - return RenderQueryPictIndexValuesCookie{cookie} -} - -func (c *Conn) RenderQueryPictIndexValuesUnchecked(Format RenderPictformat) RenderQueryPictIndexValuesCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.renderQueryPictIndexValuesRequest(Format), cookie) - return RenderQueryPictIndexValuesCookie{cookie} -} - -// Request reply for RenderQueryPictIndexValues -// size: (32 + pad((int(NumValues) * 12))) -type RenderQueryPictIndexValuesReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumValues uint32 - // padding: 20 bytes - Values []RenderIndexvalue // size: pad((int(NumValues) * 12)) -} - -// Waits and reads reply data from request RenderQueryPictIndexValues -func (cook RenderQueryPictIndexValuesCookie) Reply() (*RenderQueryPictIndexValuesReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return renderQueryPictIndexValuesReply(buf), nil -} - -// Read reply into structure from buffer for RenderQueryPictIndexValues -func renderQueryPictIndexValuesReply(buf []byte) *RenderQueryPictIndexValuesReply { - v := new(RenderQueryPictIndexValuesReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.NumValues = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Values = make([]RenderIndexvalue, v.NumValues) - b += ReadRenderIndexvalueList(buf[b:], v.Values) - - return v -} - -func (cook RenderQueryPictIndexValuesCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderQueryPictIndexValues -func (c *Conn) renderQueryPictIndexValuesRequest(Format RenderPictformat) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 2 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Format)) - b += 4 - - return buf -} - -// Request RenderCreatePicture -// size: pad((16 + (4 + pad((4 * popCount(int(ValueMask))))))) -type RenderCreatePictureCookie struct { - *cookie -} - -// Write request to wire for RenderCreatePicture -func (c *Conn) RenderCreatePicture(Pid RenderPicture, Drawable Drawable, Format RenderPictformat, ValueMask uint32, ValueList []uint32) RenderCreatePictureCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderCreatePictureRequest(Pid, Drawable, Format, ValueMask, ValueList), cookie) - return RenderCreatePictureCookie{cookie} -} - -func (c *Conn) RenderCreatePictureChecked(Pid RenderPicture, Drawable Drawable, Format RenderPictformat, ValueMask uint32, ValueList []uint32) RenderCreatePictureCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderCreatePictureRequest(Pid, Drawable, Format, ValueMask, ValueList), cookie) - return RenderCreatePictureCookie{cookie} -} - -func (cook RenderCreatePictureCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderCreatePicture -func (c *Conn) renderCreatePictureRequest(Pid RenderPicture, Drawable Drawable, Format RenderPictformat, ValueMask uint32, ValueList []uint32) []byte { - size := pad((16 + (4 + pad((4 * popCount(int(ValueMask))))))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 4 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Pid)) - b += 4 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], uint32(Format)) - b += 4 - - Put32(buf[b:], ValueMask) - b += 4 - for i := 0; i < popCount(int(ValueMask)); i++ { - Put32(buf[b:], ValueList[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Request RenderChangePicture -// size: pad((8 + (4 + pad((4 * popCount(int(ValueMask))))))) -type RenderChangePictureCookie struct { - *cookie -} - -// Write request to wire for RenderChangePicture -func (c *Conn) RenderChangePicture(Picture RenderPicture, ValueMask uint32, ValueList []uint32) RenderChangePictureCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderChangePictureRequest(Picture, ValueMask, ValueList), cookie) - return RenderChangePictureCookie{cookie} -} - -func (c *Conn) RenderChangePictureChecked(Picture RenderPicture, ValueMask uint32, ValueList []uint32) RenderChangePictureCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderChangePictureRequest(Picture, ValueMask, ValueList), cookie) - return RenderChangePictureCookie{cookie} -} - -func (cook RenderChangePictureCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderChangePicture -func (c *Conn) renderChangePictureRequest(Picture RenderPicture, ValueMask uint32, ValueList []uint32) []byte { - size := pad((8 + (4 + pad((4 * popCount(int(ValueMask))))))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 5 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Picture)) - b += 4 - - Put32(buf[b:], ValueMask) - b += 4 - for i := 0; i < popCount(int(ValueMask)); i++ { - Put32(buf[b:], ValueList[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Request RenderSetPictureClipRectangles -// size: pad((12 + pad((len(Rectangles) * 8)))) -type RenderSetPictureClipRectanglesCookie struct { - *cookie -} - -// Write request to wire for RenderSetPictureClipRectangles -func (c *Conn) RenderSetPictureClipRectangles(Picture RenderPicture, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) RenderSetPictureClipRectanglesCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderSetPictureClipRectanglesRequest(Picture, ClipXOrigin, ClipYOrigin, Rectangles), cookie) - return RenderSetPictureClipRectanglesCookie{cookie} -} - -func (c *Conn) RenderSetPictureClipRectanglesChecked(Picture RenderPicture, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) RenderSetPictureClipRectanglesCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderSetPictureClipRectanglesRequest(Picture, ClipXOrigin, ClipYOrigin, Rectangles), cookie) - return RenderSetPictureClipRectanglesCookie{cookie} -} - -func (cook RenderSetPictureClipRectanglesCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderSetPictureClipRectangles -func (c *Conn) renderSetPictureClipRectanglesRequest(Picture RenderPicture, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) []byte { - size := pad((12 + pad((len(Rectangles) * 8)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 6 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Picture)) - b += 4 - - Put16(buf[b:], uint16(ClipXOrigin)) - b += 2 - - Put16(buf[b:], uint16(ClipYOrigin)) - b += 2 - - b += RectangleListBytes(buf[b:], Rectangles) - - return buf -} - -// Request RenderFreePicture -// size: 8 -type RenderFreePictureCookie struct { - *cookie -} - -// Write request to wire for RenderFreePicture -func (c *Conn) RenderFreePicture(Picture RenderPicture) RenderFreePictureCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderFreePictureRequest(Picture), cookie) - return RenderFreePictureCookie{cookie} -} - -func (c *Conn) RenderFreePictureChecked(Picture RenderPicture) RenderFreePictureCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderFreePictureRequest(Picture), cookie) - return RenderFreePictureCookie{cookie} -} - -func (cook RenderFreePictureCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderFreePicture -func (c *Conn) renderFreePictureRequest(Picture RenderPicture) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 7 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Picture)) - b += 4 - - return buf -} - -// Request RenderComposite -// size: 36 -type RenderCompositeCookie struct { - *cookie -} - -// Write request to wire for RenderComposite -func (c *Conn) RenderComposite(Op byte, Src RenderPicture, Mask RenderPicture, Dst RenderPicture, SrcX int16, SrcY int16, MaskX int16, MaskY int16, DstX int16, DstY int16, Width uint16, Height uint16) RenderCompositeCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderCompositeRequest(Op, Src, Mask, Dst, SrcX, SrcY, MaskX, MaskY, DstX, DstY, Width, Height), cookie) - return RenderCompositeCookie{cookie} -} - -func (c *Conn) RenderCompositeChecked(Op byte, Src RenderPicture, Mask RenderPicture, Dst RenderPicture, SrcX int16, SrcY int16, MaskX int16, MaskY int16, DstX int16, DstY int16, Width uint16, Height uint16) RenderCompositeCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderCompositeRequest(Op, Src, Mask, Dst, SrcX, SrcY, MaskX, MaskY, DstX, DstY, Width, Height), cookie) - return RenderCompositeCookie{cookie} -} - -func (cook RenderCompositeCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderComposite -func (c *Conn) renderCompositeRequest(Op byte, Src RenderPicture, Mask RenderPicture, Dst RenderPicture, SrcX int16, SrcY int16, MaskX int16, MaskY int16, DstX int16, DstY int16, Width uint16, Height uint16) []byte { - size := 36 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 8 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = Op - b += 1 - - b += 3 // padding - - Put32(buf[b:], uint32(Src)) - b += 4 - - Put32(buf[b:], uint32(Mask)) - b += 4 - - Put32(buf[b:], uint32(Dst)) - b += 4 - - Put16(buf[b:], uint16(SrcX)) - b += 2 - - Put16(buf[b:], uint16(SrcY)) - b += 2 - - Put16(buf[b:], uint16(MaskX)) - b += 2 - - Put16(buf[b:], uint16(MaskY)) - b += 2 - - Put16(buf[b:], uint16(DstX)) - b += 2 - - Put16(buf[b:], uint16(DstY)) - b += 2 - - Put16(buf[b:], Width) - b += 2 - - Put16(buf[b:], Height) - b += 2 - - return buf -} - -// Request RenderTrapezoids -// size: pad((24 + pad((len(Traps) * 40)))) -type RenderTrapezoidsCookie struct { - *cookie -} - -// Write request to wire for RenderTrapezoids -func (c *Conn) RenderTrapezoids(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, SrcX int16, SrcY int16, Traps []RenderTrapezoid) RenderTrapezoidsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderTrapezoidsRequest(Op, Src, Dst, MaskFormat, SrcX, SrcY, Traps), cookie) - return RenderTrapezoidsCookie{cookie} -} - -func (c *Conn) RenderTrapezoidsChecked(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, SrcX int16, SrcY int16, Traps []RenderTrapezoid) RenderTrapezoidsCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderTrapezoidsRequest(Op, Src, Dst, MaskFormat, SrcX, SrcY, Traps), cookie) - return RenderTrapezoidsCookie{cookie} -} - -func (cook RenderTrapezoidsCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderTrapezoids -func (c *Conn) renderTrapezoidsRequest(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, SrcX int16, SrcY int16, Traps []RenderTrapezoid) []byte { - size := pad((24 + pad((len(Traps) * 40)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 10 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = Op - b += 1 - - b += 3 // padding - - Put32(buf[b:], uint32(Src)) - b += 4 - - Put32(buf[b:], uint32(Dst)) - b += 4 - - Put32(buf[b:], uint32(MaskFormat)) - b += 4 - - Put16(buf[b:], uint16(SrcX)) - b += 2 - - Put16(buf[b:], uint16(SrcY)) - b += 2 - - b += RenderTrapezoidListBytes(buf[b:], Traps) - - return buf -} - -// Request RenderTriangles -// size: pad((24 + pad((len(Triangles) * 24)))) -type RenderTrianglesCookie struct { - *cookie -} - -// Write request to wire for RenderTriangles -func (c *Conn) RenderTriangles(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, SrcX int16, SrcY int16, Triangles []RenderTriangle) RenderTrianglesCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderTrianglesRequest(Op, Src, Dst, MaskFormat, SrcX, SrcY, Triangles), cookie) - return RenderTrianglesCookie{cookie} -} - -func (c *Conn) RenderTrianglesChecked(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, SrcX int16, SrcY int16, Triangles []RenderTriangle) RenderTrianglesCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderTrianglesRequest(Op, Src, Dst, MaskFormat, SrcX, SrcY, Triangles), cookie) - return RenderTrianglesCookie{cookie} -} - -func (cook RenderTrianglesCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderTriangles -func (c *Conn) renderTrianglesRequest(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, SrcX int16, SrcY int16, Triangles []RenderTriangle) []byte { - size := pad((24 + pad((len(Triangles) * 24)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 11 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = Op - b += 1 - - b += 3 // padding - - Put32(buf[b:], uint32(Src)) - b += 4 - - Put32(buf[b:], uint32(Dst)) - b += 4 - - Put32(buf[b:], uint32(MaskFormat)) - b += 4 - - Put16(buf[b:], uint16(SrcX)) - b += 2 - - Put16(buf[b:], uint16(SrcY)) - b += 2 - - b += RenderTriangleListBytes(buf[b:], Triangles) - - return buf -} - -// Request RenderTriStrip -// size: pad((24 + pad((len(Points) * 8)))) -type RenderTriStripCookie struct { - *cookie -} - -// Write request to wire for RenderTriStrip -func (c *Conn) RenderTriStrip(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, SrcX int16, SrcY int16, Points []RenderPointfix) RenderTriStripCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderTriStripRequest(Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie) - return RenderTriStripCookie{cookie} -} - -func (c *Conn) RenderTriStripChecked(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, SrcX int16, SrcY int16, Points []RenderPointfix) RenderTriStripCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderTriStripRequest(Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie) - return RenderTriStripCookie{cookie} -} - -func (cook RenderTriStripCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderTriStrip -func (c *Conn) renderTriStripRequest(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, SrcX int16, SrcY int16, Points []RenderPointfix) []byte { - size := pad((24 + pad((len(Points) * 8)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 12 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = Op - b += 1 - - b += 3 // padding - - Put32(buf[b:], uint32(Src)) - b += 4 - - Put32(buf[b:], uint32(Dst)) - b += 4 - - Put32(buf[b:], uint32(MaskFormat)) - b += 4 - - Put16(buf[b:], uint16(SrcX)) - b += 2 - - Put16(buf[b:], uint16(SrcY)) - b += 2 - - b += RenderPointfixListBytes(buf[b:], Points) - - return buf -} - -// Request RenderTriFan -// size: pad((24 + pad((len(Points) * 8)))) -type RenderTriFanCookie struct { - *cookie -} - -// Write request to wire for RenderTriFan -func (c *Conn) RenderTriFan(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, SrcX int16, SrcY int16, Points []RenderPointfix) RenderTriFanCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderTriFanRequest(Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie) - return RenderTriFanCookie{cookie} -} - -func (c *Conn) RenderTriFanChecked(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, SrcX int16, SrcY int16, Points []RenderPointfix) RenderTriFanCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderTriFanRequest(Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie) - return RenderTriFanCookie{cookie} -} - -func (cook RenderTriFanCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderTriFan -func (c *Conn) renderTriFanRequest(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, SrcX int16, SrcY int16, Points []RenderPointfix) []byte { - size := pad((24 + pad((len(Points) * 8)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 13 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = Op - b += 1 - - b += 3 // padding - - Put32(buf[b:], uint32(Src)) - b += 4 - - Put32(buf[b:], uint32(Dst)) - b += 4 - - Put32(buf[b:], uint32(MaskFormat)) - b += 4 - - Put16(buf[b:], uint16(SrcX)) - b += 2 - - Put16(buf[b:], uint16(SrcY)) - b += 2 - - b += RenderPointfixListBytes(buf[b:], Points) - - return buf -} - -// Request RenderCreateGlyphSet -// size: 12 -type RenderCreateGlyphSetCookie struct { - *cookie -} - -// Write request to wire for RenderCreateGlyphSet -func (c *Conn) RenderCreateGlyphSet(Gsid RenderGlyphset, Format RenderPictformat) RenderCreateGlyphSetCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderCreateGlyphSetRequest(Gsid, Format), cookie) - return RenderCreateGlyphSetCookie{cookie} -} - -func (c *Conn) RenderCreateGlyphSetChecked(Gsid RenderGlyphset, Format RenderPictformat) RenderCreateGlyphSetCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderCreateGlyphSetRequest(Gsid, Format), cookie) - return RenderCreateGlyphSetCookie{cookie} -} - -func (cook RenderCreateGlyphSetCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderCreateGlyphSet -func (c *Conn) renderCreateGlyphSetRequest(Gsid RenderGlyphset, Format RenderPictformat) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 17 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Gsid)) - b += 4 - - Put32(buf[b:], uint32(Format)) - b += 4 - - return buf -} - -// Request RenderReferenceGlyphSet -// size: 12 -type RenderReferenceGlyphSetCookie struct { - *cookie -} - -// Write request to wire for RenderReferenceGlyphSet -func (c *Conn) RenderReferenceGlyphSet(Gsid RenderGlyphset, Existing RenderGlyphset) RenderReferenceGlyphSetCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderReferenceGlyphSetRequest(Gsid, Existing), cookie) - return RenderReferenceGlyphSetCookie{cookie} -} - -func (c *Conn) RenderReferenceGlyphSetChecked(Gsid RenderGlyphset, Existing RenderGlyphset) RenderReferenceGlyphSetCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderReferenceGlyphSetRequest(Gsid, Existing), cookie) - return RenderReferenceGlyphSetCookie{cookie} -} - -func (cook RenderReferenceGlyphSetCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderReferenceGlyphSet -func (c *Conn) renderReferenceGlyphSetRequest(Gsid RenderGlyphset, Existing RenderGlyphset) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 18 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Gsid)) - b += 4 - - Put32(buf[b:], uint32(Existing)) - b += 4 - - return buf -} - -// Request RenderFreeGlyphSet -// size: 8 -type RenderFreeGlyphSetCookie struct { - *cookie -} - -// Write request to wire for RenderFreeGlyphSet -func (c *Conn) RenderFreeGlyphSet(Glyphset RenderGlyphset) RenderFreeGlyphSetCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderFreeGlyphSetRequest(Glyphset), cookie) - return RenderFreeGlyphSetCookie{cookie} -} - -func (c *Conn) RenderFreeGlyphSetChecked(Glyphset RenderGlyphset) RenderFreeGlyphSetCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderFreeGlyphSetRequest(Glyphset), cookie) - return RenderFreeGlyphSetCookie{cookie} -} - -func (cook RenderFreeGlyphSetCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderFreeGlyphSet -func (c *Conn) renderFreeGlyphSetRequest(Glyphset RenderGlyphset) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 19 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Glyphset)) - b += 4 - - return buf -} - -// Request RenderAddGlyphs -// size: pad((((12 + pad((int(GlyphsLen) * 4))) + pad((int(GlyphsLen) * 12))) + pad((len(Data) * 1)))) -type RenderAddGlyphsCookie struct { - *cookie -} - -// Write request to wire for RenderAddGlyphs -func (c *Conn) RenderAddGlyphs(Glyphset RenderGlyphset, GlyphsLen uint32, Glyphids []uint32, Glyphs []RenderGlyphinfo, Data []byte) RenderAddGlyphsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderAddGlyphsRequest(Glyphset, GlyphsLen, Glyphids, Glyphs, Data), cookie) - return RenderAddGlyphsCookie{cookie} -} - -func (c *Conn) RenderAddGlyphsChecked(Glyphset RenderGlyphset, GlyphsLen uint32, Glyphids []uint32, Glyphs []RenderGlyphinfo, Data []byte) RenderAddGlyphsCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderAddGlyphsRequest(Glyphset, GlyphsLen, Glyphids, Glyphs, Data), cookie) - return RenderAddGlyphsCookie{cookie} -} - -func (cook RenderAddGlyphsCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderAddGlyphs -func (c *Conn) renderAddGlyphsRequest(Glyphset RenderGlyphset, GlyphsLen uint32, Glyphids []uint32, Glyphs []RenderGlyphinfo, Data []byte) []byte { - size := pad((((12 + pad((int(GlyphsLen) * 4))) + pad((int(GlyphsLen) * 12))) + pad((len(Data) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 20 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Glyphset)) - b += 4 - - Put32(buf[b:], GlyphsLen) - b += 4 - - for i := 0; i < int(GlyphsLen); i++ { - Put32(buf[b:], Glyphids[i]) - b += 4 - } - b = pad(b) - - b += RenderGlyphinfoListBytes(buf[b:], Glyphs) - - copy(buf[b:], Data[:len(Data)]) - b += pad(int(len(Data))) - - return buf -} - -// Request RenderFreeGlyphs -// size: pad((8 + pad((len(Glyphs) * 4)))) -type RenderFreeGlyphsCookie struct { - *cookie -} - -// Write request to wire for RenderFreeGlyphs -func (c *Conn) RenderFreeGlyphs(Glyphset RenderGlyphset, Glyphs []RenderGlyph) RenderFreeGlyphsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderFreeGlyphsRequest(Glyphset, Glyphs), cookie) - return RenderFreeGlyphsCookie{cookie} -} - -func (c *Conn) RenderFreeGlyphsChecked(Glyphset RenderGlyphset, Glyphs []RenderGlyph) RenderFreeGlyphsCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderFreeGlyphsRequest(Glyphset, Glyphs), cookie) - return RenderFreeGlyphsCookie{cookie} -} - -func (cook RenderFreeGlyphsCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderFreeGlyphs -func (c *Conn) renderFreeGlyphsRequest(Glyphset RenderGlyphset, Glyphs []RenderGlyph) []byte { - size := pad((8 + pad((len(Glyphs) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 22 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Glyphset)) - b += 4 - - for i := 0; i < int(len(Glyphs)); i++ { - Put32(buf[b:], uint32(Glyphs[i])) - b += 4 - } - b = pad(b) - - return buf -} - -// Request RenderCompositeGlyphs8 -// size: pad((28 + pad((len(Glyphcmds) * 1)))) -type RenderCompositeGlyphs8Cookie struct { - *cookie -} - -// Write request to wire for RenderCompositeGlyphs8 -func (c *Conn) RenderCompositeGlyphs8(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, Glyphset RenderGlyphset, SrcX int16, SrcY int16, Glyphcmds []byte) RenderCompositeGlyphs8Cookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderCompositeGlyphs8Request(Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) - return RenderCompositeGlyphs8Cookie{cookie} -} - -func (c *Conn) RenderCompositeGlyphs8Checked(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, Glyphset RenderGlyphset, SrcX int16, SrcY int16, Glyphcmds []byte) RenderCompositeGlyphs8Cookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderCompositeGlyphs8Request(Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) - return RenderCompositeGlyphs8Cookie{cookie} -} - -func (cook RenderCompositeGlyphs8Cookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderCompositeGlyphs8 -func (c *Conn) renderCompositeGlyphs8Request(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, Glyphset RenderGlyphset, SrcX int16, SrcY int16, Glyphcmds []byte) []byte { - size := pad((28 + pad((len(Glyphcmds) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 23 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = Op - b += 1 - - b += 3 // padding - - Put32(buf[b:], uint32(Src)) - b += 4 - - Put32(buf[b:], uint32(Dst)) - b += 4 - - Put32(buf[b:], uint32(MaskFormat)) - b += 4 - - Put32(buf[b:], uint32(Glyphset)) - b += 4 - - Put16(buf[b:], uint16(SrcX)) - b += 2 - - Put16(buf[b:], uint16(SrcY)) - b += 2 - - copy(buf[b:], Glyphcmds[:len(Glyphcmds)]) - b += pad(int(len(Glyphcmds))) - - return buf -} - -// Request RenderCompositeGlyphs16 -// size: pad((28 + pad((len(Glyphcmds) * 1)))) -type RenderCompositeGlyphs16Cookie struct { - *cookie -} - -// Write request to wire for RenderCompositeGlyphs16 -func (c *Conn) RenderCompositeGlyphs16(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, Glyphset RenderGlyphset, SrcX int16, SrcY int16, Glyphcmds []byte) RenderCompositeGlyphs16Cookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderCompositeGlyphs16Request(Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) - return RenderCompositeGlyphs16Cookie{cookie} -} - -func (c *Conn) RenderCompositeGlyphs16Checked(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, Glyphset RenderGlyphset, SrcX int16, SrcY int16, Glyphcmds []byte) RenderCompositeGlyphs16Cookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderCompositeGlyphs16Request(Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) - return RenderCompositeGlyphs16Cookie{cookie} -} - -func (cook RenderCompositeGlyphs16Cookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderCompositeGlyphs16 -func (c *Conn) renderCompositeGlyphs16Request(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, Glyphset RenderGlyphset, SrcX int16, SrcY int16, Glyphcmds []byte) []byte { - size := pad((28 + pad((len(Glyphcmds) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 24 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = Op - b += 1 - - b += 3 // padding - - Put32(buf[b:], uint32(Src)) - b += 4 - - Put32(buf[b:], uint32(Dst)) - b += 4 - - Put32(buf[b:], uint32(MaskFormat)) - b += 4 - - Put32(buf[b:], uint32(Glyphset)) - b += 4 - - Put16(buf[b:], uint16(SrcX)) - b += 2 - - Put16(buf[b:], uint16(SrcY)) - b += 2 - - copy(buf[b:], Glyphcmds[:len(Glyphcmds)]) - b += pad(int(len(Glyphcmds))) - - return buf -} - -// Request RenderCompositeGlyphs32 -// size: pad((28 + pad((len(Glyphcmds) * 1)))) -type RenderCompositeGlyphs32Cookie struct { - *cookie -} - -// Write request to wire for RenderCompositeGlyphs32 -func (c *Conn) RenderCompositeGlyphs32(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, Glyphset RenderGlyphset, SrcX int16, SrcY int16, Glyphcmds []byte) RenderCompositeGlyphs32Cookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderCompositeGlyphs32Request(Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) - return RenderCompositeGlyphs32Cookie{cookie} -} - -func (c *Conn) RenderCompositeGlyphs32Checked(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, Glyphset RenderGlyphset, SrcX int16, SrcY int16, Glyphcmds []byte) RenderCompositeGlyphs32Cookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderCompositeGlyphs32Request(Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) - return RenderCompositeGlyphs32Cookie{cookie} -} - -func (cook RenderCompositeGlyphs32Cookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderCompositeGlyphs32 -func (c *Conn) renderCompositeGlyphs32Request(Op byte, Src RenderPicture, Dst RenderPicture, MaskFormat RenderPictformat, Glyphset RenderGlyphset, SrcX int16, SrcY int16, Glyphcmds []byte) []byte { - size := pad((28 + pad((len(Glyphcmds) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 25 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = Op - b += 1 - - b += 3 // padding - - Put32(buf[b:], uint32(Src)) - b += 4 - - Put32(buf[b:], uint32(Dst)) - b += 4 - - Put32(buf[b:], uint32(MaskFormat)) - b += 4 - - Put32(buf[b:], uint32(Glyphset)) - b += 4 - - Put16(buf[b:], uint16(SrcX)) - b += 2 - - Put16(buf[b:], uint16(SrcY)) - b += 2 - - copy(buf[b:], Glyphcmds[:len(Glyphcmds)]) - b += pad(int(len(Glyphcmds))) - - return buf -} - -// Request RenderFillRectangles -// size: pad((20 + pad((len(Rects) * 8)))) -type RenderFillRectanglesCookie struct { - *cookie -} - -// Write request to wire for RenderFillRectangles -func (c *Conn) RenderFillRectangles(Op byte, Dst RenderPicture, Color RenderColor, Rects []Rectangle) RenderFillRectanglesCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderFillRectanglesRequest(Op, Dst, Color, Rects), cookie) - return RenderFillRectanglesCookie{cookie} -} - -func (c *Conn) RenderFillRectanglesChecked(Op byte, Dst RenderPicture, Color RenderColor, Rects []Rectangle) RenderFillRectanglesCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderFillRectanglesRequest(Op, Dst, Color, Rects), cookie) - return RenderFillRectanglesCookie{cookie} -} - -func (cook RenderFillRectanglesCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderFillRectangles -func (c *Conn) renderFillRectanglesRequest(Op byte, Dst RenderPicture, Color RenderColor, Rects []Rectangle) []byte { - size := pad((20 + pad((len(Rects) * 8)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 26 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = Op - b += 1 - - b += 3 // padding - - Put32(buf[b:], uint32(Dst)) - b += 4 - - { - structBytes := Color.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - b += RectangleListBytes(buf[b:], Rects) - - return buf -} - -// Request RenderCreateCursor -// size: 16 -type RenderCreateCursorCookie struct { - *cookie -} - -// Write request to wire for RenderCreateCursor -func (c *Conn) RenderCreateCursor(Cid Cursor, Source RenderPicture, X uint16, Y uint16) RenderCreateCursorCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderCreateCursorRequest(Cid, Source, X, Y), cookie) - return RenderCreateCursorCookie{cookie} -} - -func (c *Conn) RenderCreateCursorChecked(Cid Cursor, Source RenderPicture, X uint16, Y uint16) RenderCreateCursorCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderCreateCursorRequest(Cid, Source, X, Y), cookie) - return RenderCreateCursorCookie{cookie} -} - -func (cook RenderCreateCursorCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderCreateCursor -func (c *Conn) renderCreateCursorRequest(Cid Cursor, Source RenderPicture, X uint16, Y uint16) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 27 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cid)) - b += 4 - - Put32(buf[b:], uint32(Source)) - b += 4 - - Put16(buf[b:], X) - b += 2 - - Put16(buf[b:], Y) - b += 2 - - return buf -} - -// Request RenderSetPictureTransform -// size: 44 -type RenderSetPictureTransformCookie struct { - *cookie -} - -// Write request to wire for RenderSetPictureTransform -func (c *Conn) RenderSetPictureTransform(Picture RenderPicture, Transform RenderTransform) RenderSetPictureTransformCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderSetPictureTransformRequest(Picture, Transform), cookie) - return RenderSetPictureTransformCookie{cookie} -} - -func (c *Conn) RenderSetPictureTransformChecked(Picture RenderPicture, Transform RenderTransform) RenderSetPictureTransformCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderSetPictureTransformRequest(Picture, Transform), cookie) - return RenderSetPictureTransformCookie{cookie} -} - -func (cook RenderSetPictureTransformCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderSetPictureTransform -func (c *Conn) renderSetPictureTransformRequest(Picture RenderPicture, Transform RenderTransform) []byte { - size := 44 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 28 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Picture)) - b += 4 - - { - structBytes := Transform.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - return buf -} - -// Request RenderQueryFilters -// size: 8 -type RenderQueryFiltersCookie struct { - *cookie -} - -func (c *Conn) RenderQueryFilters(Drawable Drawable) RenderQueryFiltersCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.renderQueryFiltersRequest(Drawable), cookie) - return RenderQueryFiltersCookie{cookie} -} - -func (c *Conn) RenderQueryFiltersUnchecked(Drawable Drawable) RenderQueryFiltersCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.renderQueryFiltersRequest(Drawable), cookie) - return RenderQueryFiltersCookie{cookie} -} - -// Request reply for RenderQueryFilters -// size: ((32 + pad((int(NumAliases) * 2))) + StrListSize(Filters)) -type RenderQueryFiltersReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumAliases uint32 - NumFilters uint32 - // padding: 16 bytes - Aliases []uint16 // size: pad((int(NumAliases) * 2)) - Filters []Str // size: StrListSize(Filters) -} - -// Waits and reads reply data from request RenderQueryFilters -func (cook RenderQueryFiltersCookie) Reply() (*RenderQueryFiltersReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return renderQueryFiltersReply(buf), nil -} - -// Read reply into structure from buffer for RenderQueryFilters -func renderQueryFiltersReply(buf []byte) *RenderQueryFiltersReply { - v := new(RenderQueryFiltersReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.NumAliases = Get32(buf[b:]) - b += 4 - - v.NumFilters = Get32(buf[b:]) - b += 4 - - b += 16 // padding - - v.Aliases = make([]uint16, v.NumAliases) - for i := 0; i < int(v.NumAliases); i++ { - v.Aliases[i] = Get16(buf[b:]) - b += 2 - } - b = pad(b) - - v.Filters = make([]Str, v.NumFilters) - b += ReadStrList(buf[b:], v.Filters) - - return v -} - -func (cook RenderQueryFiltersCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderQueryFilters -func (c *Conn) renderQueryFiltersRequest(Drawable Drawable) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 29 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - return buf -} - -// Request RenderSetPictureFilter -// size: pad(((12 + pad((int(FilterLen) * 1))) + pad((len(Values) * 4)))) -type RenderSetPictureFilterCookie struct { - *cookie -} - -// Write request to wire for RenderSetPictureFilter -func (c *Conn) RenderSetPictureFilter(Picture RenderPicture, FilterLen uint16, Filter string, Values []RenderFixed) RenderSetPictureFilterCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderSetPictureFilterRequest(Picture, FilterLen, Filter, Values), cookie) - return RenderSetPictureFilterCookie{cookie} -} - -func (c *Conn) RenderSetPictureFilterChecked(Picture RenderPicture, FilterLen uint16, Filter string, Values []RenderFixed) RenderSetPictureFilterCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderSetPictureFilterRequest(Picture, FilterLen, Filter, Values), cookie) - return RenderSetPictureFilterCookie{cookie} -} - -func (cook RenderSetPictureFilterCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderSetPictureFilter -func (c *Conn) renderSetPictureFilterRequest(Picture RenderPicture, FilterLen uint16, Filter string, Values []RenderFixed) []byte { - size := pad(((12 + pad((int(FilterLen) * 1))) + pad((len(Values) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 30 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Picture)) - b += 4 - - Put16(buf[b:], FilterLen) - b += 2 - - b += 2 // padding - - copy(buf[b:], Filter[:FilterLen]) - b += pad(int(FilterLen)) - - for i := 0; i < int(len(Values)); i++ { - Put32(buf[b:], uint32(Values[i])) - b += 4 - } - b = pad(b) - - return buf -} - -// Request RenderCreateAnimCursor -// size: pad((8 + pad((len(Cursors) * 8)))) -type RenderCreateAnimCursorCookie struct { - *cookie -} - -// Write request to wire for RenderCreateAnimCursor -func (c *Conn) RenderCreateAnimCursor(Cid Cursor, Cursors []RenderAnimcursorelt) RenderCreateAnimCursorCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderCreateAnimCursorRequest(Cid, Cursors), cookie) - return RenderCreateAnimCursorCookie{cookie} -} - -func (c *Conn) RenderCreateAnimCursorChecked(Cid Cursor, Cursors []RenderAnimcursorelt) RenderCreateAnimCursorCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderCreateAnimCursorRequest(Cid, Cursors), cookie) - return RenderCreateAnimCursorCookie{cookie} -} - -func (cook RenderCreateAnimCursorCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderCreateAnimCursor -func (c *Conn) renderCreateAnimCursorRequest(Cid Cursor, Cursors []RenderAnimcursorelt) []byte { - size := pad((8 + pad((len(Cursors) * 8)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 31 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cid)) - b += 4 - - b += RenderAnimcursoreltListBytes(buf[b:], Cursors) - - return buf -} - -// Request RenderAddTraps -// size: pad((12 + pad((len(Traps) * 24)))) -type RenderAddTrapsCookie struct { - *cookie -} - -// Write request to wire for RenderAddTraps -func (c *Conn) RenderAddTraps(Picture RenderPicture, XOff int16, YOff int16, Traps []RenderTrap) RenderAddTrapsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderAddTrapsRequest(Picture, XOff, YOff, Traps), cookie) - return RenderAddTrapsCookie{cookie} -} - -func (c *Conn) RenderAddTrapsChecked(Picture RenderPicture, XOff int16, YOff int16, Traps []RenderTrap) RenderAddTrapsCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderAddTrapsRequest(Picture, XOff, YOff, Traps), cookie) - return RenderAddTrapsCookie{cookie} -} - -func (cook RenderAddTrapsCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderAddTraps -func (c *Conn) renderAddTrapsRequest(Picture RenderPicture, XOff int16, YOff int16, Traps []RenderTrap) []byte { - size := pad((12 + pad((len(Traps) * 24)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 32 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Picture)) - b += 4 - - Put16(buf[b:], uint16(XOff)) - b += 2 - - Put16(buf[b:], uint16(YOff)) - b += 2 - - b += RenderTrapListBytes(buf[b:], Traps) - - return buf -} - -// Request RenderCreateSolidFill -// size: 16 -type RenderCreateSolidFillCookie struct { - *cookie -} - -// Write request to wire for RenderCreateSolidFill -func (c *Conn) RenderCreateSolidFill(Picture RenderPicture, Color RenderColor) RenderCreateSolidFillCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderCreateSolidFillRequest(Picture, Color), cookie) - return RenderCreateSolidFillCookie{cookie} -} - -func (c *Conn) RenderCreateSolidFillChecked(Picture RenderPicture, Color RenderColor) RenderCreateSolidFillCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderCreateSolidFillRequest(Picture, Color), cookie) - return RenderCreateSolidFillCookie{cookie} -} - -func (cook RenderCreateSolidFillCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderCreateSolidFill -func (c *Conn) renderCreateSolidFillRequest(Picture RenderPicture, Color RenderColor) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 33 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Picture)) - b += 4 - - { - structBytes := Color.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - return buf -} - -// Request RenderCreateLinearGradient -// size: pad(((28 + pad((int(NumStops) * 4))) + pad((int(NumStops) * 8)))) -type RenderCreateLinearGradientCookie struct { - *cookie -} - -// Write request to wire for RenderCreateLinearGradient -func (c *Conn) RenderCreateLinearGradient(Picture RenderPicture, P1 RenderPointfix, P2 RenderPointfix, NumStops uint32, Stops []RenderFixed, Colors []RenderColor) RenderCreateLinearGradientCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderCreateLinearGradientRequest(Picture, P1, P2, NumStops, Stops, Colors), cookie) - return RenderCreateLinearGradientCookie{cookie} -} - -func (c *Conn) RenderCreateLinearGradientChecked(Picture RenderPicture, P1 RenderPointfix, P2 RenderPointfix, NumStops uint32, Stops []RenderFixed, Colors []RenderColor) RenderCreateLinearGradientCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderCreateLinearGradientRequest(Picture, P1, P2, NumStops, Stops, Colors), cookie) - return RenderCreateLinearGradientCookie{cookie} -} - -func (cook RenderCreateLinearGradientCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderCreateLinearGradient -func (c *Conn) renderCreateLinearGradientRequest(Picture RenderPicture, P1 RenderPointfix, P2 RenderPointfix, NumStops uint32, Stops []RenderFixed, Colors []RenderColor) []byte { - size := pad(((28 + pad((int(NumStops) * 4))) + pad((int(NumStops) * 8)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 34 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Picture)) - b += 4 - - { - structBytes := P1.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - { - structBytes := P2.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - Put32(buf[b:], NumStops) - b += 4 - - for i := 0; i < int(NumStops); i++ { - Put32(buf[b:], uint32(Stops[i])) - b += 4 - } - b = pad(b) - - b += RenderColorListBytes(buf[b:], Colors) - - return buf -} - -// Request RenderCreateRadialGradient -// size: pad(((36 + pad((int(NumStops) * 4))) + pad((int(NumStops) * 8)))) -type RenderCreateRadialGradientCookie struct { - *cookie -} - -// Write request to wire for RenderCreateRadialGradient -func (c *Conn) RenderCreateRadialGradient(Picture RenderPicture, Inner RenderPointfix, Outer RenderPointfix, InnerRadius RenderFixed, OuterRadius RenderFixed, NumStops uint32, Stops []RenderFixed, Colors []RenderColor) RenderCreateRadialGradientCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderCreateRadialGradientRequest(Picture, Inner, Outer, InnerRadius, OuterRadius, NumStops, Stops, Colors), cookie) - return RenderCreateRadialGradientCookie{cookie} -} - -func (c *Conn) RenderCreateRadialGradientChecked(Picture RenderPicture, Inner RenderPointfix, Outer RenderPointfix, InnerRadius RenderFixed, OuterRadius RenderFixed, NumStops uint32, Stops []RenderFixed, Colors []RenderColor) RenderCreateRadialGradientCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderCreateRadialGradientRequest(Picture, Inner, Outer, InnerRadius, OuterRadius, NumStops, Stops, Colors), cookie) - return RenderCreateRadialGradientCookie{cookie} -} - -func (cook RenderCreateRadialGradientCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderCreateRadialGradient -func (c *Conn) renderCreateRadialGradientRequest(Picture RenderPicture, Inner RenderPointfix, Outer RenderPointfix, InnerRadius RenderFixed, OuterRadius RenderFixed, NumStops uint32, Stops []RenderFixed, Colors []RenderColor) []byte { - size := pad(((36 + pad((int(NumStops) * 4))) + pad((int(NumStops) * 8)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 35 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Picture)) - b += 4 - - { - structBytes := Inner.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - { - structBytes := Outer.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - Put32(buf[b:], uint32(InnerRadius)) - b += 4 - - Put32(buf[b:], uint32(OuterRadius)) - b += 4 - - Put32(buf[b:], NumStops) - b += 4 - - for i := 0; i < int(NumStops); i++ { - Put32(buf[b:], uint32(Stops[i])) - b += 4 - } - b = pad(b) - - b += RenderColorListBytes(buf[b:], Colors) - - return buf -} - -// Request RenderCreateConicalGradient -// size: pad(((24 + pad((int(NumStops) * 4))) + pad((int(NumStops) * 8)))) -type RenderCreateConicalGradientCookie struct { - *cookie -} - -// Write request to wire for RenderCreateConicalGradient -func (c *Conn) RenderCreateConicalGradient(Picture RenderPicture, Center RenderPointfix, Angle RenderFixed, NumStops uint32, Stops []RenderFixed, Colors []RenderColor) RenderCreateConicalGradientCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderCreateConicalGradientRequest(Picture, Center, Angle, NumStops, Stops, Colors), cookie) - return RenderCreateConicalGradientCookie{cookie} -} - -func (c *Conn) RenderCreateConicalGradientChecked(Picture RenderPicture, Center RenderPointfix, Angle RenderFixed, NumStops uint32, Stops []RenderFixed, Colors []RenderColor) RenderCreateConicalGradientCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.renderCreateConicalGradientRequest(Picture, Center, Angle, NumStops, Stops, Colors), cookie) - return RenderCreateConicalGradientCookie{cookie} -} - -func (cook RenderCreateConicalGradientCookie) Check() error { - return cook.check() -} - -// Write request to wire for RenderCreateConicalGradient -func (c *Conn) renderCreateConicalGradientRequest(Picture RenderPicture, Center RenderPointfix, Angle RenderFixed, NumStops uint32, Stops []RenderFixed, Colors []RenderColor) []byte { - size := pad(((24 + pad((int(NumStops) * 4))) + pad((int(NumStops) * 8)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["RENDER"] - b += 1 - - buf[b] = 36 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Picture)) - b += 4 - - { - structBytes := Center.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - Put32(buf[b:], uint32(Angle)) - b += 4 - - Put32(buf[b:], NumStops) - b += 4 - - for i := 0; i < int(NumStops); i++ { - Put32(buf[b:], uint32(Stops[i])) - b += 4 - } - b = pad(b) - - b += RenderColorListBytes(buf[b:], Colors) - - return buf -} diff --git a/nexgb/auto_res.go b/nexgb/auto_res.go deleted file mode 100644 index a2f9914..0000000 --- a/nexgb/auto_res.go +++ /dev/null @@ -1,528 +0,0 @@ -package xgb - -/* - This file was generated by res.xml on May 10 2012 12:39:33pm EDT. - This file is automatically generated. Edit at your peril! -*/ - -// Imports are not necessary for XGB because everything is -// in one package. They are still listed here for reference. -// import "xproto" - -// ResInit must be called before using the X-Resource extension. -func (c *Conn) ResInit() error { - reply, err := c.QueryExtension(10, "X-Resource").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named X-Resource could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["X-Resource"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["X-Resource"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["X-Resource"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["X-Resource"] = make(map[int]newEventFun) - newExtErrorFuncs["X-Resource"] = make(map[int]newErrorFun) -} - -// Skipping definition for base type 'Int8' - -// Skipping definition for base type 'Card16' - -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - -// Skipping definition for base type 'Float' - -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - -// 'ResClient' struct definition -// Size: 8 -type ResClient struct { - ResourceBase uint32 - ResourceMask uint32 -} - -// Struct read ResClient -func ReadResClient(buf []byte, v *ResClient) int { - b := 0 - - v.ResourceBase = Get32(buf[b:]) - b += 4 - - v.ResourceMask = Get32(buf[b:]) - b += 4 - - return b -} - -// Struct list read ResClient -func ReadResClientList(buf []byte, dest []ResClient) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = ResClient{} - b += ReadResClient(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write ResClient -func (v ResClient) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put32(buf[b:], v.ResourceBase) - b += 4 - - Put32(buf[b:], v.ResourceMask) - b += 4 - - return buf -} - -// Write struct list ResClient -func ResClientListBytes(buf []byte, list []ResClient) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'ResType' struct definition -// Size: 8 -type ResType struct { - ResourceType Atom - Count uint32 -} - -// Struct read ResType -func ReadResType(buf []byte, v *ResType) int { - b := 0 - - v.ResourceType = Atom(Get32(buf[b:])) - b += 4 - - v.Count = Get32(buf[b:]) - b += 4 - - return b -} - -// Struct list read ResType -func ReadResTypeList(buf []byte, dest []ResType) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = ResType{} - b += ReadResType(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write ResType -func (v ResType) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put32(buf[b:], uint32(v.ResourceType)) - b += 4 - - Put32(buf[b:], v.Count) - b += 4 - - return buf -} - -// Write struct list ResType -func ResTypeListBytes(buf []byte, list []ResType) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Request ResQueryVersion -// size: 8 -type ResQueryVersionCookie struct { - *cookie -} - -func (c *Conn) ResQueryVersion(ClientMajor byte, ClientMinor byte) ResQueryVersionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.resQueryVersionRequest(ClientMajor, ClientMinor), cookie) - return ResQueryVersionCookie{cookie} -} - -func (c *Conn) ResQueryVersionUnchecked(ClientMajor byte, ClientMinor byte) ResQueryVersionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.resQueryVersionRequest(ClientMajor, ClientMinor), cookie) - return ResQueryVersionCookie{cookie} -} - -// Request reply for ResQueryVersion -// size: 12 -type ResQueryVersionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ServerMajor uint16 - ServerMinor uint16 -} - -// Waits and reads reply data from request ResQueryVersion -func (cook ResQueryVersionCookie) Reply() (*ResQueryVersionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return resQueryVersionReply(buf), nil -} - -// Read reply into structure from buffer for ResQueryVersion -func resQueryVersionReply(buf []byte) *ResQueryVersionReply { - v := new(ResQueryVersionReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.ServerMajor = Get16(buf[b:]) - b += 2 - - v.ServerMinor = Get16(buf[b:]) - b += 2 - - return v -} - -func (cook ResQueryVersionCookie) Check() error { - return cook.check() -} - -// Write request to wire for ResQueryVersion -func (c *Conn) resQueryVersionRequest(ClientMajor byte, ClientMinor byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["X-RESOURCE"] - b += 1 - - buf[b] = 0 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = ClientMajor - b += 1 - - buf[b] = ClientMinor - b += 1 - - return buf -} - -// Request ResQueryClients -// size: 4 -type ResQueryClientsCookie struct { - *cookie -} - -func (c *Conn) ResQueryClients() ResQueryClientsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.resQueryClientsRequest(), cookie) - return ResQueryClientsCookie{cookie} -} - -func (c *Conn) ResQueryClientsUnchecked() ResQueryClientsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.resQueryClientsRequest(), cookie) - return ResQueryClientsCookie{cookie} -} - -// Request reply for ResQueryClients -// size: (32 + pad((int(NumClients) * 8))) -type ResQueryClientsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumClients uint32 - // padding: 20 bytes - Clients []ResClient // size: pad((int(NumClients) * 8)) -} - -// Waits and reads reply data from request ResQueryClients -func (cook ResQueryClientsCookie) Reply() (*ResQueryClientsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return resQueryClientsReply(buf), nil -} - -// Read reply into structure from buffer for ResQueryClients -func resQueryClientsReply(buf []byte) *ResQueryClientsReply { - v := new(ResQueryClientsReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.NumClients = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Clients = make([]ResClient, v.NumClients) - b += ReadResClientList(buf[b:], v.Clients) - - return v -} - -func (cook ResQueryClientsCookie) Check() error { - return cook.check() -} - -// Write request to wire for ResQueryClients -func (c *Conn) resQueryClientsRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["X-RESOURCE"] - b += 1 - - buf[b] = 1 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request ResQueryClientResources -// size: 8 -type ResQueryClientResourcesCookie struct { - *cookie -} - -func (c *Conn) ResQueryClientResources(Xid uint32) ResQueryClientResourcesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.resQueryClientResourcesRequest(Xid), cookie) - return ResQueryClientResourcesCookie{cookie} -} - -func (c *Conn) ResQueryClientResourcesUnchecked(Xid uint32) ResQueryClientResourcesCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.resQueryClientResourcesRequest(Xid), cookie) - return ResQueryClientResourcesCookie{cookie} -} - -// Request reply for ResQueryClientResources -// size: (32 + pad((int(NumTypes) * 8))) -type ResQueryClientResourcesReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumTypes uint32 - // padding: 20 bytes - Types []ResType // size: pad((int(NumTypes) * 8)) -} - -// Waits and reads reply data from request ResQueryClientResources -func (cook ResQueryClientResourcesCookie) Reply() (*ResQueryClientResourcesReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return resQueryClientResourcesReply(buf), nil -} - -// Read reply into structure from buffer for ResQueryClientResources -func resQueryClientResourcesReply(buf []byte) *ResQueryClientResourcesReply { - v := new(ResQueryClientResourcesReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.NumTypes = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Types = make([]ResType, v.NumTypes) - b += ReadResTypeList(buf[b:], v.Types) - - return v -} - -func (cook ResQueryClientResourcesCookie) Check() error { - return cook.check() -} - -// Write request to wire for ResQueryClientResources -func (c *Conn) resQueryClientResourcesRequest(Xid uint32) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["X-RESOURCE"] - b += 1 - - buf[b] = 2 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Xid) - b += 4 - - return buf -} - -// Request ResQueryClientPixmapBytes -// size: 8 -type ResQueryClientPixmapBytesCookie struct { - *cookie -} - -func (c *Conn) ResQueryClientPixmapBytes(Xid uint32) ResQueryClientPixmapBytesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.resQueryClientPixmapBytesRequest(Xid), cookie) - return ResQueryClientPixmapBytesCookie{cookie} -} - -func (c *Conn) ResQueryClientPixmapBytesUnchecked(Xid uint32) ResQueryClientPixmapBytesCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.resQueryClientPixmapBytesRequest(Xid), cookie) - return ResQueryClientPixmapBytesCookie{cookie} -} - -// Request reply for ResQueryClientPixmapBytes -// size: 16 -type ResQueryClientPixmapBytesReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Bytes uint32 - BytesOverflow uint32 -} - -// Waits and reads reply data from request ResQueryClientPixmapBytes -func (cook ResQueryClientPixmapBytesCookie) Reply() (*ResQueryClientPixmapBytesReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return resQueryClientPixmapBytesReply(buf), nil -} - -// Read reply into structure from buffer for ResQueryClientPixmapBytes -func resQueryClientPixmapBytesReply(buf []byte) *ResQueryClientPixmapBytesReply { - v := new(ResQueryClientPixmapBytesReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Bytes = Get32(buf[b:]) - b += 4 - - v.BytesOverflow = Get32(buf[b:]) - b += 4 - - return v -} - -func (cook ResQueryClientPixmapBytesCookie) Check() error { - return cook.check() -} - -// Write request to wire for ResQueryClientPixmapBytes -func (c *Conn) resQueryClientPixmapBytesRequest(Xid uint32) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["X-RESOURCE"] - b += 1 - - buf[b] = 3 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Xid) - b += 4 - - return buf -} diff --git a/nexgb/auto_screensaver.go b/nexgb/auto_screensaver.go deleted file mode 100644 index 4f6fea0..0000000 --- a/nexgb/auto_screensaver.go +++ /dev/null @@ -1,627 +0,0 @@ -package xgb - -/* - This file was generated by screensaver.xml on May 10 2012 12:39:34pm EDT. - This file is automatically generated. Edit at your peril! -*/ - -// Imports are not necessary for XGB because everything is -// in one package. They are still listed here for reference. -// import "xproto" - -// ScreensaverInit must be called before using the MIT-SCREEN-SAVER extension. -func (c *Conn) ScreensaverInit() error { - reply, err := c.QueryExtension(16, "MIT-SCREEN-SAVER").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named MIT-SCREEN-SAVER could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["MIT-SCREEN-SAVER"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["MIT-SCREEN-SAVER"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["MIT-SCREEN-SAVER"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["MIT-SCREEN-SAVER"] = make(map[int]newEventFun) - newExtErrorFuncs["MIT-SCREEN-SAVER"] = make(map[int]newErrorFun) -} - -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - -// Skipping definition for base type 'Int8' - -// Skipping definition for base type 'Card16' - -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - -// Skipping definition for base type 'Float' - -const ( - ScreensaverKindBlanked = 0 - ScreensaverKindInternal = 1 - ScreensaverKindExternal = 2 -) - -const ( - ScreensaverEventNotifyMask = 1 - ScreensaverEventCycleMask = 2 -) - -const ( - ScreensaverStateOff = 0 - ScreensaverStateOn = 1 - ScreensaverStateCycle = 2 - ScreensaverStateDisabled = 3 -) - -// Event definition ScreensaverNotify (0) -// Size: 32 - -const ScreensaverNotify = 0 - -type ScreensaverNotifyEvent struct { - Sequence uint16 - Code byte - State byte - // padding: 1 bytes - SequenceNumber uint16 - Time Timestamp - Root Window - Window Window - Kind byte - Forced bool - // padding: 14 bytes -} - -// Event read ScreensaverNotify -func NewScreensaverNotifyEvent(buf []byte) Event { - v := ScreensaverNotifyEvent{} - b := 1 // don't read event number - - v.Code = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.State = buf[b] - b += 1 - - b += 1 // padding - - v.SequenceNumber = Get16(buf[b:]) - b += 2 - - v.Time = Timestamp(Get32(buf[b:])) - b += 4 - - v.Root = Window(Get32(buf[b:])) - b += 4 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - v.Kind = buf[b] - b += 1 - - if buf[b] == 1 { - v.Forced = true - } else { - v.Forced = false - } - b += 1 - - b += 14 // padding - - return v -} - -// Event write ScreensaverNotify -func (v ScreensaverNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 0 - b += 1 - - buf[b] = v.Code - b += 1 - - b += 2 // skip sequence number - - buf[b] = v.State - b += 1 - - b += 1 // padding - - Put16(buf[b:], v.SequenceNumber) - b += 2 - - Put32(buf[b:], uint32(v.Time)) - b += 4 - - Put32(buf[b:], uint32(v.Root)) - b += 4 - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - buf[b] = v.Kind - b += 1 - - if v.Forced { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 14 // padding - - return buf -} - -func (v ScreensaverNotifyEvent) ImplementsEvent() {} - -func (v ScreensaverNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v ScreensaverNotifyEvent) String() string { - fieldVals := make([]string, 0, 10) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Code: %d", v.Code)) - fieldVals = append(fieldVals, sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, sprintf("SequenceNumber: %d", v.SequenceNumber)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, sprintf("Kind: %d", v.Kind)) - fieldVals = append(fieldVals, sprintf("Forced: %t", v.Forced)) - return "ScreensaverNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["MIT-SCREEN-SAVER"][0] = NewScreensaverNotifyEvent -} - -// Request ScreensaverQueryVersion -// size: 8 -type ScreensaverQueryVersionCookie struct { - *cookie -} - -func (c *Conn) ScreensaverQueryVersion(ClientMajorVersion byte, ClientMinorVersion byte) ScreensaverQueryVersionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.screensaverQueryVersionRequest(ClientMajorVersion, ClientMinorVersion), cookie) - return ScreensaverQueryVersionCookie{cookie} -} - -func (c *Conn) ScreensaverQueryVersionUnchecked(ClientMajorVersion byte, ClientMinorVersion byte) ScreensaverQueryVersionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.screensaverQueryVersionRequest(ClientMajorVersion, ClientMinorVersion), cookie) - return ScreensaverQueryVersionCookie{cookie} -} - -// Request reply for ScreensaverQueryVersion -// size: 32 -type ScreensaverQueryVersionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ServerMajorVersion uint16 - ServerMinorVersion uint16 - // padding: 20 bytes -} - -// Waits and reads reply data from request ScreensaverQueryVersion -func (cook ScreensaverQueryVersionCookie) Reply() (*ScreensaverQueryVersionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return screensaverQueryVersionReply(buf), nil -} - -// Read reply into structure from buffer for ScreensaverQueryVersion -func screensaverQueryVersionReply(buf []byte) *ScreensaverQueryVersionReply { - v := new(ScreensaverQueryVersionReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.ServerMajorVersion = Get16(buf[b:]) - b += 2 - - v.ServerMinorVersion = Get16(buf[b:]) - b += 2 - - b += 20 // padding - - return v -} - -func (cook ScreensaverQueryVersionCookie) Check() error { - return cook.check() -} - -// Write request to wire for ScreensaverQueryVersion -func (c *Conn) screensaverQueryVersionRequest(ClientMajorVersion byte, ClientMinorVersion byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["MIT-SCREEN-SAVER"] - b += 1 - - buf[b] = 0 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = ClientMajorVersion - b += 1 - - buf[b] = ClientMinorVersion - b += 1 - - b += 2 // padding - - return buf -} - -// Request ScreensaverQueryInfo -// size: 8 -type ScreensaverQueryInfoCookie struct { - *cookie -} - -func (c *Conn) ScreensaverQueryInfo(Drawable Drawable) ScreensaverQueryInfoCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.screensaverQueryInfoRequest(Drawable), cookie) - return ScreensaverQueryInfoCookie{cookie} -} - -func (c *Conn) ScreensaverQueryInfoUnchecked(Drawable Drawable) ScreensaverQueryInfoCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.screensaverQueryInfoRequest(Drawable), cookie) - return ScreensaverQueryInfoCookie{cookie} -} - -// Request reply for ScreensaverQueryInfo -// size: 32 -type ScreensaverQueryInfoReply struct { - Sequence uint16 - Length uint32 - State byte - SaverWindow Window - MsUntilServer uint32 - MsSinceUserInput uint32 - EventMask uint32 - Kind byte - // padding: 7 bytes -} - -// Waits and reads reply data from request ScreensaverQueryInfo -func (cook ScreensaverQueryInfoCookie) Reply() (*ScreensaverQueryInfoReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return screensaverQueryInfoReply(buf), nil -} - -// Read reply into structure from buffer for ScreensaverQueryInfo -func screensaverQueryInfoReply(buf []byte) *ScreensaverQueryInfoReply { - v := new(ScreensaverQueryInfoReply) - b := 1 // skip reply determinant - - v.State = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.SaverWindow = Window(Get32(buf[b:])) - b += 4 - - v.MsUntilServer = Get32(buf[b:]) - b += 4 - - v.MsSinceUserInput = Get32(buf[b:]) - b += 4 - - v.EventMask = Get32(buf[b:]) - b += 4 - - v.Kind = buf[b] - b += 1 - - b += 7 // padding - - return v -} - -func (cook ScreensaverQueryInfoCookie) Check() error { - return cook.check() -} - -// Write request to wire for ScreensaverQueryInfo -func (c *Conn) screensaverQueryInfoRequest(Drawable Drawable) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["MIT-SCREEN-SAVER"] - b += 1 - - buf[b] = 1 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - return buf -} - -// Request ScreensaverSelectInput -// size: 12 -type ScreensaverSelectInputCookie struct { - *cookie -} - -// Write request to wire for ScreensaverSelectInput -func (c *Conn) ScreensaverSelectInput(Drawable Drawable, EventMask uint32) ScreensaverSelectInputCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.screensaverSelectInputRequest(Drawable, EventMask), cookie) - return ScreensaverSelectInputCookie{cookie} -} - -func (c *Conn) ScreensaverSelectInputChecked(Drawable Drawable, EventMask uint32) ScreensaverSelectInputCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.screensaverSelectInputRequest(Drawable, EventMask), cookie) - return ScreensaverSelectInputCookie{cookie} -} - -func (cook ScreensaverSelectInputCookie) Check() error { - return cook.check() -} - -// Write request to wire for ScreensaverSelectInput -func (c *Conn) screensaverSelectInputRequest(Drawable Drawable, EventMask uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["MIT-SCREEN-SAVER"] - b += 1 - - buf[b] = 2 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], EventMask) - b += 4 - - return buf -} - -// Request ScreensaverSetAttributes -// size: pad((24 + (4 + pad((4 * popCount(int(ValueMask))))))) -type ScreensaverSetAttributesCookie struct { - *cookie -} - -// Write request to wire for ScreensaverSetAttributes -func (c *Conn) ScreensaverSetAttributes(Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class byte, Depth byte, Visual Visualid, ValueMask uint32, ValueList []uint32) ScreensaverSetAttributesCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.screensaverSetAttributesRequest(Drawable, X, Y, Width, Height, BorderWidth, Class, Depth, Visual, ValueMask, ValueList), cookie) - return ScreensaverSetAttributesCookie{cookie} -} - -func (c *Conn) ScreensaverSetAttributesChecked(Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class byte, Depth byte, Visual Visualid, ValueMask uint32, ValueList []uint32) ScreensaverSetAttributesCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.screensaverSetAttributesRequest(Drawable, X, Y, Width, Height, BorderWidth, Class, Depth, Visual, ValueMask, ValueList), cookie) - return ScreensaverSetAttributesCookie{cookie} -} - -func (cook ScreensaverSetAttributesCookie) Check() error { - return cook.check() -} - -// Write request to wire for ScreensaverSetAttributes -func (c *Conn) screensaverSetAttributesRequest(Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class byte, Depth byte, Visual Visualid, ValueMask uint32, ValueList []uint32) []byte { - size := pad((24 + (4 + pad((4 * popCount(int(ValueMask))))))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["MIT-SCREEN-SAVER"] - b += 1 - - buf[b] = 3 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put16(buf[b:], uint16(X)) - b += 2 - - Put16(buf[b:], uint16(Y)) - b += 2 - - Put16(buf[b:], Width) - b += 2 - - Put16(buf[b:], Height) - b += 2 - - Put16(buf[b:], BorderWidth) - b += 2 - - buf[b] = Class - b += 1 - - buf[b] = Depth - b += 1 - - Put32(buf[b:], uint32(Visual)) - b += 4 - - Put32(buf[b:], ValueMask) - b += 4 - for i := 0; i < popCount(int(ValueMask)); i++ { - Put32(buf[b:], ValueList[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Request ScreensaverUnsetAttributes -// size: 8 -type ScreensaverUnsetAttributesCookie struct { - *cookie -} - -// Write request to wire for ScreensaverUnsetAttributes -func (c *Conn) ScreensaverUnsetAttributes(Drawable Drawable) ScreensaverUnsetAttributesCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.screensaverUnsetAttributesRequest(Drawable), cookie) - return ScreensaverUnsetAttributesCookie{cookie} -} - -func (c *Conn) ScreensaverUnsetAttributesChecked(Drawable Drawable) ScreensaverUnsetAttributesCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.screensaverUnsetAttributesRequest(Drawable), cookie) - return ScreensaverUnsetAttributesCookie{cookie} -} - -func (cook ScreensaverUnsetAttributesCookie) Check() error { - return cook.check() -} - -// Write request to wire for ScreensaverUnsetAttributes -func (c *Conn) screensaverUnsetAttributesRequest(Drawable Drawable) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["MIT-SCREEN-SAVER"] - b += 1 - - buf[b] = 4 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - return buf -} - -// Request ScreensaverSuspend -// size: 8 -type ScreensaverSuspendCookie struct { - *cookie -} - -// Write request to wire for ScreensaverSuspend -func (c *Conn) ScreensaverSuspend(Suspend bool) ScreensaverSuspendCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.screensaverSuspendRequest(Suspend), cookie) - return ScreensaverSuspendCookie{cookie} -} - -func (c *Conn) ScreensaverSuspendChecked(Suspend bool) ScreensaverSuspendCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.screensaverSuspendRequest(Suspend), cookie) - return ScreensaverSuspendCookie{cookie} -} - -func (cook ScreensaverSuspendCookie) Check() error { - return cook.check() -} - -// Write request to wire for ScreensaverSuspend -func (c *Conn) screensaverSuspendRequest(Suspend bool) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["MIT-SCREEN-SAVER"] - b += 1 - - buf[b] = 5 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - if Suspend { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 3 // padding - - return buf -} diff --git a/nexgb/auto_shape.go b/nexgb/auto_shape.go deleted file mode 100644 index 90d67cf..0000000 --- a/nexgb/auto_shape.go +++ /dev/null @@ -1,897 +0,0 @@ -package xgb - -/* - This file was generated by shape.xml on May 10 2012 12:39:34pm EDT. - This file is automatically generated. Edit at your peril! -*/ - -// Imports are not necessary for XGB because everything is -// in one package. They are still listed here for reference. -// import "xproto" - -// ShapeInit must be called before using the SHAPE extension. -func (c *Conn) ShapeInit() error { - reply, err := c.QueryExtension(5, "SHAPE").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named SHAPE could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["SHAPE"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["SHAPE"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["SHAPE"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["SHAPE"] = make(map[int]newEventFun) - newExtErrorFuncs["SHAPE"] = make(map[int]newErrorFun) -} - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - -// Skipping definition for base type 'Int8' - -// Skipping definition for base type 'Card16' - -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - -// Skipping definition for base type 'Float' - -// Skipping definition for base type 'Card8' - -const ( - ShapeSoSet = 0 - ShapeSoUnion = 1 - ShapeSoIntersect = 2 - ShapeSoSubtract = 3 - ShapeSoInvert = 4 -) - -const ( - ShapeSkBounding = 0 - ShapeSkClip = 1 - ShapeSkInput = 2 -) - -type ShapeOp byte - -type ShapeKind byte - -// Event definition ShapeNotify (0) -// Size: 32 - -const ShapeNotify = 0 - -type ShapeNotifyEvent struct { - Sequence uint16 - ShapeKind ShapeKind - AffectedWindow Window - ExtentsX int16 - ExtentsY int16 - ExtentsWidth uint16 - ExtentsHeight uint16 - ServerTime Timestamp - Shaped bool - // padding: 11 bytes -} - -// Event read ShapeNotify -func NewShapeNotifyEvent(buf []byte) Event { - v := ShapeNotifyEvent{} - b := 1 // don't read event number - - v.ShapeKind = ShapeKind(buf[b]) - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.AffectedWindow = Window(Get32(buf[b:])) - b += 4 - - v.ExtentsX = int16(Get16(buf[b:])) - b += 2 - - v.ExtentsY = int16(Get16(buf[b:])) - b += 2 - - v.ExtentsWidth = Get16(buf[b:]) - b += 2 - - v.ExtentsHeight = Get16(buf[b:]) - b += 2 - - v.ServerTime = Timestamp(Get32(buf[b:])) - b += 4 - - if buf[b] == 1 { - v.Shaped = true - } else { - v.Shaped = false - } - b += 1 - - b += 11 // padding - - return v -} - -// Event write ShapeNotify -func (v ShapeNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 0 - b += 1 - - buf[b] = byte(v.ShapeKind) - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.AffectedWindow)) - b += 4 - - Put16(buf[b:], uint16(v.ExtentsX)) - b += 2 - - Put16(buf[b:], uint16(v.ExtentsY)) - b += 2 - - Put16(buf[b:], v.ExtentsWidth) - b += 2 - - Put16(buf[b:], v.ExtentsHeight) - b += 2 - - Put32(buf[b:], uint32(v.ServerTime)) - b += 4 - - if v.Shaped { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 11 // padding - - return buf -} - -func (v ShapeNotifyEvent) ImplementsEvent() {} - -func (v ShapeNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v ShapeNotifyEvent) String() string { - fieldVals := make([]string, 0, 9) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("ShapeKind: %d", v.ShapeKind)) - fieldVals = append(fieldVals, sprintf("AffectedWindow: %d", v.AffectedWindow)) - fieldVals = append(fieldVals, sprintf("ExtentsX: %d", v.ExtentsX)) - fieldVals = append(fieldVals, sprintf("ExtentsY: %d", v.ExtentsY)) - fieldVals = append(fieldVals, sprintf("ExtentsWidth: %d", v.ExtentsWidth)) - fieldVals = append(fieldVals, sprintf("ExtentsHeight: %d", v.ExtentsHeight)) - fieldVals = append(fieldVals, sprintf("ServerTime: %d", v.ServerTime)) - fieldVals = append(fieldVals, sprintf("Shaped: %t", v.Shaped)) - return "ShapeNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["SHAPE"][0] = NewShapeNotifyEvent -} - -// Request ShapeQueryVersion -// size: 4 -type ShapeQueryVersionCookie struct { - *cookie -} - -func (c *Conn) ShapeQueryVersion() ShapeQueryVersionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.shapeQueryVersionRequest(), cookie) - return ShapeQueryVersionCookie{cookie} -} - -func (c *Conn) ShapeQueryVersionUnchecked() ShapeQueryVersionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.shapeQueryVersionRequest(), cookie) - return ShapeQueryVersionCookie{cookie} -} - -// Request reply for ShapeQueryVersion -// size: 12 -type ShapeQueryVersionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - MajorVersion uint16 - MinorVersion uint16 -} - -// Waits and reads reply data from request ShapeQueryVersion -func (cook ShapeQueryVersionCookie) Reply() (*ShapeQueryVersionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return shapeQueryVersionReply(buf), nil -} - -// Read reply into structure from buffer for ShapeQueryVersion -func shapeQueryVersionReply(buf []byte) *ShapeQueryVersionReply { - v := new(ShapeQueryVersionReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.MajorVersion = Get16(buf[b:]) - b += 2 - - v.MinorVersion = Get16(buf[b:]) - b += 2 - - return v -} - -func (cook ShapeQueryVersionCookie) Check() error { - return cook.check() -} - -// Write request to wire for ShapeQueryVersion -func (c *Conn) shapeQueryVersionRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SHAPE"] - b += 1 - - buf[b] = 0 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request ShapeRectangles -// size: pad((16 + pad((len(Rectangles) * 8)))) -type ShapeRectanglesCookie struct { - *cookie -} - -// Write request to wire for ShapeRectangles -func (c *Conn) ShapeRectangles(Operation ShapeOp, DestinationKind ShapeKind, Ordering byte, DestinationWindow Window, XOffset int16, YOffset int16, Rectangles []Rectangle) ShapeRectanglesCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.shapeRectanglesRequest(Operation, DestinationKind, Ordering, DestinationWindow, XOffset, YOffset, Rectangles), cookie) - return ShapeRectanglesCookie{cookie} -} - -func (c *Conn) ShapeRectanglesChecked(Operation ShapeOp, DestinationKind ShapeKind, Ordering byte, DestinationWindow Window, XOffset int16, YOffset int16, Rectangles []Rectangle) ShapeRectanglesCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.shapeRectanglesRequest(Operation, DestinationKind, Ordering, DestinationWindow, XOffset, YOffset, Rectangles), cookie) - return ShapeRectanglesCookie{cookie} -} - -func (cook ShapeRectanglesCookie) Check() error { - return cook.check() -} - -// Write request to wire for ShapeRectangles -func (c *Conn) shapeRectanglesRequest(Operation ShapeOp, DestinationKind ShapeKind, Ordering byte, DestinationWindow Window, XOffset int16, YOffset int16, Rectangles []Rectangle) []byte { - size := pad((16 + pad((len(Rectangles) * 8)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SHAPE"] - b += 1 - - buf[b] = 1 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = byte(Operation) - b += 1 - - buf[b] = byte(DestinationKind) - b += 1 - - buf[b] = Ordering - b += 1 - - b += 1 // padding - - Put32(buf[b:], uint32(DestinationWindow)) - b += 4 - - Put16(buf[b:], uint16(XOffset)) - b += 2 - - Put16(buf[b:], uint16(YOffset)) - b += 2 - - b += RectangleListBytes(buf[b:], Rectangles) - - return buf -} - -// Request ShapeMask -// size: 20 -type ShapeMaskCookie struct { - *cookie -} - -// Write request to wire for ShapeMask -func (c *Conn) ShapeMask(Operation ShapeOp, DestinationKind ShapeKind, DestinationWindow Window, XOffset int16, YOffset int16, SourceBitmap Pixmap) ShapeMaskCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.shapeMaskRequest(Operation, DestinationKind, DestinationWindow, XOffset, YOffset, SourceBitmap), cookie) - return ShapeMaskCookie{cookie} -} - -func (c *Conn) ShapeMaskChecked(Operation ShapeOp, DestinationKind ShapeKind, DestinationWindow Window, XOffset int16, YOffset int16, SourceBitmap Pixmap) ShapeMaskCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.shapeMaskRequest(Operation, DestinationKind, DestinationWindow, XOffset, YOffset, SourceBitmap), cookie) - return ShapeMaskCookie{cookie} -} - -func (cook ShapeMaskCookie) Check() error { - return cook.check() -} - -// Write request to wire for ShapeMask -func (c *Conn) shapeMaskRequest(Operation ShapeOp, DestinationKind ShapeKind, DestinationWindow Window, XOffset int16, YOffset int16, SourceBitmap Pixmap) []byte { - size := 20 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SHAPE"] - b += 1 - - buf[b] = 2 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = byte(Operation) - b += 1 - - buf[b] = byte(DestinationKind) - b += 1 - - b += 2 // padding - - Put32(buf[b:], uint32(DestinationWindow)) - b += 4 - - Put16(buf[b:], uint16(XOffset)) - b += 2 - - Put16(buf[b:], uint16(YOffset)) - b += 2 - - Put32(buf[b:], uint32(SourceBitmap)) - b += 4 - - return buf -} - -// Request ShapeCombine -// size: 20 -type ShapeCombineCookie struct { - *cookie -} - -// Write request to wire for ShapeCombine -func (c *Conn) ShapeCombine(Operation ShapeOp, DestinationKind ShapeKind, SourceKind ShapeKind, DestinationWindow Window, XOffset int16, YOffset int16, SourceWindow Window) ShapeCombineCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.shapeCombineRequest(Operation, DestinationKind, SourceKind, DestinationWindow, XOffset, YOffset, SourceWindow), cookie) - return ShapeCombineCookie{cookie} -} - -func (c *Conn) ShapeCombineChecked(Operation ShapeOp, DestinationKind ShapeKind, SourceKind ShapeKind, DestinationWindow Window, XOffset int16, YOffset int16, SourceWindow Window) ShapeCombineCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.shapeCombineRequest(Operation, DestinationKind, SourceKind, DestinationWindow, XOffset, YOffset, SourceWindow), cookie) - return ShapeCombineCookie{cookie} -} - -func (cook ShapeCombineCookie) Check() error { - return cook.check() -} - -// Write request to wire for ShapeCombine -func (c *Conn) shapeCombineRequest(Operation ShapeOp, DestinationKind ShapeKind, SourceKind ShapeKind, DestinationWindow Window, XOffset int16, YOffset int16, SourceWindow Window) []byte { - size := 20 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SHAPE"] - b += 1 - - buf[b] = 3 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = byte(Operation) - b += 1 - - buf[b] = byte(DestinationKind) - b += 1 - - buf[b] = byte(SourceKind) - b += 1 - - b += 1 // padding - - Put32(buf[b:], uint32(DestinationWindow)) - b += 4 - - Put16(buf[b:], uint16(XOffset)) - b += 2 - - Put16(buf[b:], uint16(YOffset)) - b += 2 - - Put32(buf[b:], uint32(SourceWindow)) - b += 4 - - return buf -} - -// Request ShapeOffset -// size: 16 -type ShapeOffsetCookie struct { - *cookie -} - -// Write request to wire for ShapeOffset -func (c *Conn) ShapeOffset(DestinationKind ShapeKind, DestinationWindow Window, XOffset int16, YOffset int16) ShapeOffsetCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.shapeOffsetRequest(DestinationKind, DestinationWindow, XOffset, YOffset), cookie) - return ShapeOffsetCookie{cookie} -} - -func (c *Conn) ShapeOffsetChecked(DestinationKind ShapeKind, DestinationWindow Window, XOffset int16, YOffset int16) ShapeOffsetCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.shapeOffsetRequest(DestinationKind, DestinationWindow, XOffset, YOffset), cookie) - return ShapeOffsetCookie{cookie} -} - -func (cook ShapeOffsetCookie) Check() error { - return cook.check() -} - -// Write request to wire for ShapeOffset -func (c *Conn) shapeOffsetRequest(DestinationKind ShapeKind, DestinationWindow Window, XOffset int16, YOffset int16) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SHAPE"] - b += 1 - - buf[b] = 4 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = byte(DestinationKind) - b += 1 - - b += 3 // padding - - Put32(buf[b:], uint32(DestinationWindow)) - b += 4 - - Put16(buf[b:], uint16(XOffset)) - b += 2 - - Put16(buf[b:], uint16(YOffset)) - b += 2 - - return buf -} - -// Request ShapeQueryExtents -// size: 8 -type ShapeQueryExtentsCookie struct { - *cookie -} - -func (c *Conn) ShapeQueryExtents(DestinationWindow Window) ShapeQueryExtentsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.shapeQueryExtentsRequest(DestinationWindow), cookie) - return ShapeQueryExtentsCookie{cookie} -} - -func (c *Conn) ShapeQueryExtentsUnchecked(DestinationWindow Window) ShapeQueryExtentsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.shapeQueryExtentsRequest(DestinationWindow), cookie) - return ShapeQueryExtentsCookie{cookie} -} - -// Request reply for ShapeQueryExtents -// size: 28 -type ShapeQueryExtentsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - BoundingShaped bool - ClipShaped bool - // padding: 2 bytes - BoundingShapeExtentsX int16 - BoundingShapeExtentsY int16 - BoundingShapeExtentsWidth uint16 - BoundingShapeExtentsHeight uint16 - ClipShapeExtentsX int16 - ClipShapeExtentsY int16 - ClipShapeExtentsWidth uint16 - ClipShapeExtentsHeight uint16 -} - -// Waits and reads reply data from request ShapeQueryExtents -func (cook ShapeQueryExtentsCookie) Reply() (*ShapeQueryExtentsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return shapeQueryExtentsReply(buf), nil -} - -// Read reply into structure from buffer for ShapeQueryExtents -func shapeQueryExtentsReply(buf []byte) *ShapeQueryExtentsReply { - v := new(ShapeQueryExtentsReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - if buf[b] == 1 { - v.BoundingShaped = true - } else { - v.BoundingShaped = false - } - b += 1 - - if buf[b] == 1 { - v.ClipShaped = true - } else { - v.ClipShaped = false - } - b += 1 - - b += 2 // padding - - v.BoundingShapeExtentsX = int16(Get16(buf[b:])) - b += 2 - - v.BoundingShapeExtentsY = int16(Get16(buf[b:])) - b += 2 - - v.BoundingShapeExtentsWidth = Get16(buf[b:]) - b += 2 - - v.BoundingShapeExtentsHeight = Get16(buf[b:]) - b += 2 - - v.ClipShapeExtentsX = int16(Get16(buf[b:])) - b += 2 - - v.ClipShapeExtentsY = int16(Get16(buf[b:])) - b += 2 - - v.ClipShapeExtentsWidth = Get16(buf[b:]) - b += 2 - - v.ClipShapeExtentsHeight = Get16(buf[b:]) - b += 2 - - return v -} - -func (cook ShapeQueryExtentsCookie) Check() error { - return cook.check() -} - -// Write request to wire for ShapeQueryExtents -func (c *Conn) shapeQueryExtentsRequest(DestinationWindow Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SHAPE"] - b += 1 - - buf[b] = 5 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(DestinationWindow)) - b += 4 - - return buf -} - -// Request ShapeSelectInput -// size: 12 -type ShapeSelectInputCookie struct { - *cookie -} - -// Write request to wire for ShapeSelectInput -func (c *Conn) ShapeSelectInput(DestinationWindow Window, Enable bool) ShapeSelectInputCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.shapeSelectInputRequest(DestinationWindow, Enable), cookie) - return ShapeSelectInputCookie{cookie} -} - -func (c *Conn) ShapeSelectInputChecked(DestinationWindow Window, Enable bool) ShapeSelectInputCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.shapeSelectInputRequest(DestinationWindow, Enable), cookie) - return ShapeSelectInputCookie{cookie} -} - -func (cook ShapeSelectInputCookie) Check() error { - return cook.check() -} - -// Write request to wire for ShapeSelectInput -func (c *Conn) shapeSelectInputRequest(DestinationWindow Window, Enable bool) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SHAPE"] - b += 1 - - buf[b] = 6 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(DestinationWindow)) - b += 4 - - if Enable { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 3 // padding - - return buf -} - -// Request ShapeInputSelected -// size: 8 -type ShapeInputSelectedCookie struct { - *cookie -} - -func (c *Conn) ShapeInputSelected(DestinationWindow Window) ShapeInputSelectedCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.shapeInputSelectedRequest(DestinationWindow), cookie) - return ShapeInputSelectedCookie{cookie} -} - -func (c *Conn) ShapeInputSelectedUnchecked(DestinationWindow Window) ShapeInputSelectedCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.shapeInputSelectedRequest(DestinationWindow), cookie) - return ShapeInputSelectedCookie{cookie} -} - -// Request reply for ShapeInputSelected -// size: 8 -type ShapeInputSelectedReply struct { - Sequence uint16 - Length uint32 - Enabled bool -} - -// Waits and reads reply data from request ShapeInputSelected -func (cook ShapeInputSelectedCookie) Reply() (*ShapeInputSelectedReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return shapeInputSelectedReply(buf), nil -} - -// Read reply into structure from buffer for ShapeInputSelected -func shapeInputSelectedReply(buf []byte) *ShapeInputSelectedReply { - v := new(ShapeInputSelectedReply) - b := 1 // skip reply determinant - - if buf[b] == 1 { - v.Enabled = true - } else { - v.Enabled = false - } - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - return v -} - -func (cook ShapeInputSelectedCookie) Check() error { - return cook.check() -} - -// Write request to wire for ShapeInputSelected -func (c *Conn) shapeInputSelectedRequest(DestinationWindow Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SHAPE"] - b += 1 - - buf[b] = 7 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(DestinationWindow)) - b += 4 - - return buf -} - -// Request ShapeGetRectangles -// size: 12 -type ShapeGetRectanglesCookie struct { - *cookie -} - -func (c *Conn) ShapeGetRectangles(Window Window, SourceKind ShapeKind) ShapeGetRectanglesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.shapeGetRectanglesRequest(Window, SourceKind), cookie) - return ShapeGetRectanglesCookie{cookie} -} - -func (c *Conn) ShapeGetRectanglesUnchecked(Window Window, SourceKind ShapeKind) ShapeGetRectanglesCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.shapeGetRectanglesRequest(Window, SourceKind), cookie) - return ShapeGetRectanglesCookie{cookie} -} - -// Request reply for ShapeGetRectangles -// size: (32 + pad((int(RectanglesLen) * 8))) -type ShapeGetRectanglesReply struct { - Sequence uint16 - Length uint32 - Ordering byte - RectanglesLen uint32 - // padding: 20 bytes - Rectangles []Rectangle // size: pad((int(RectanglesLen) * 8)) -} - -// Waits and reads reply data from request ShapeGetRectangles -func (cook ShapeGetRectanglesCookie) Reply() (*ShapeGetRectanglesReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return shapeGetRectanglesReply(buf), nil -} - -// Read reply into structure from buffer for ShapeGetRectangles -func shapeGetRectanglesReply(buf []byte) *ShapeGetRectanglesReply { - v := new(ShapeGetRectanglesReply) - b := 1 // skip reply determinant - - v.Ordering = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.RectanglesLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Rectangles = make([]Rectangle, v.RectanglesLen) - b += ReadRectangleList(buf[b:], v.Rectangles) - - return v -} - -func (cook ShapeGetRectanglesCookie) Check() error { - return cook.check() -} - -// Write request to wire for ShapeGetRectangles -func (c *Conn) shapeGetRectanglesRequest(Window Window, SourceKind ShapeKind) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SHAPE"] - b += 1 - - buf[b] = 8 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - buf[b] = byte(SourceKind) - b += 1 - - b += 3 // padding - - return buf -} diff --git a/nexgb/auto_shm.go b/nexgb/auto_shm.go deleted file mode 100644 index 392c5ff..0000000 --- a/nexgb/auto_shm.go +++ /dev/null @@ -1,678 +0,0 @@ -package xgb - -/* - This file was generated by shm.xml on May 10 2012 12:39:34pm EDT. - This file is automatically generated. Edit at your peril! -*/ - -// Imports are not necessary for XGB because everything is -// in one package. They are still listed here for reference. -// import "xproto" - -// ShmInit must be called before using the MIT-SHM extension. -func (c *Conn) ShmInit() error { - reply, err := c.QueryExtension(7, "MIT-SHM").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named MIT-SHM could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["MIT-SHM"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["MIT-SHM"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["MIT-SHM"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["MIT-SHM"] = make(map[int]newEventFun) - newExtErrorFuncs["MIT-SHM"] = make(map[int]newErrorFun) -} - -// Skipping definition for base type 'Card16' - -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - -// Skipping definition for base type 'Float' - -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - -// Skipping definition for base type 'Int8' - -type ShmSeg uint32 - -func (c *Conn) NewShmSegId() (ShmSeg, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return ShmSeg(id), nil -} - -// Event definition ShmCompletion (0) -// Size: 32 - -const ShmCompletion = 0 - -type ShmCompletionEvent struct { - Sequence uint16 - // padding: 1 bytes - Drawable Drawable - MinorEvent uint16 - MajorEvent byte - // padding: 1 bytes - Shmseg ShmSeg - Offset uint32 -} - -// Event read ShmCompletion -func NewShmCompletionEvent(buf []byte) Event { - v := ShmCompletionEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Drawable = Drawable(Get32(buf[b:])) - b += 4 - - v.MinorEvent = Get16(buf[b:]) - b += 2 - - v.MajorEvent = buf[b] - b += 1 - - b += 1 // padding - - v.Shmseg = ShmSeg(Get32(buf[b:])) - b += 4 - - v.Offset = Get32(buf[b:]) - b += 4 - - return v -} - -// Event write ShmCompletion -func (v ShmCompletionEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 0 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Drawable)) - b += 4 - - Put16(buf[b:], v.MinorEvent) - b += 2 - - buf[b] = v.MajorEvent - b += 1 - - b += 1 // padding - - Put32(buf[b:], uint32(v.Shmseg)) - b += 4 - - Put32(buf[b:], v.Offset) - b += 4 - - return buf -} - -func (v ShmCompletionEvent) ImplementsEvent() {} - -func (v ShmCompletionEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v ShmCompletionEvent) String() string { - fieldVals := make([]string, 0, 7) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Drawable: %d", v.Drawable)) - fieldVals = append(fieldVals, sprintf("MinorEvent: %d", v.MinorEvent)) - fieldVals = append(fieldVals, sprintf("MajorEvent: %d", v.MajorEvent)) - fieldVals = append(fieldVals, sprintf("Shmseg: %d", v.Shmseg)) - fieldVals = append(fieldVals, sprintf("Offset: %d", v.Offset)) - return "ShmCompletion {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["MIT-SHM"][0] = NewShmCompletionEvent -} - -// ErrorCopy definition ShmBadSeg (0) - -const BadShmBadSeg = 0 - -type ShmBadSegError ValueError - -func NewShmBadSegError(buf []byte) Error { - v := ShmBadSegError(NewValueError(buf).(ValueError)) - v.NiceName = "ShmBadSeg" - return v -} - -func (err ShmBadSegError) ImplementsError() {} - -func (err ShmBadSegError) SequenceId() uint16 { - return err.Sequence -} - -func (err ShmBadSegError) BadId() uint32 { - return 0 -} - -func (err ShmBadSegError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadShmBadSeg {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["MIT-SHM"][0] = NewShmBadSegError -} - -// Request ShmQueryVersion -// size: 4 -type ShmQueryVersionCookie struct { - *cookie -} - -func (c *Conn) ShmQueryVersion() ShmQueryVersionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.shmQueryVersionRequest(), cookie) - return ShmQueryVersionCookie{cookie} -} - -func (c *Conn) ShmQueryVersionUnchecked() ShmQueryVersionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.shmQueryVersionRequest(), cookie) - return ShmQueryVersionCookie{cookie} -} - -// Request reply for ShmQueryVersion -// size: 32 -type ShmQueryVersionReply struct { - Sequence uint16 - Length uint32 - SharedPixmaps bool - MajorVersion uint16 - MinorVersion uint16 - Uid uint16 - Gid uint16 - PixmapFormat byte - // padding: 15 bytes -} - -// Waits and reads reply data from request ShmQueryVersion -func (cook ShmQueryVersionCookie) Reply() (*ShmQueryVersionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return shmQueryVersionReply(buf), nil -} - -// Read reply into structure from buffer for ShmQueryVersion -func shmQueryVersionReply(buf []byte) *ShmQueryVersionReply { - v := new(ShmQueryVersionReply) - b := 1 // skip reply determinant - - if buf[b] == 1 { - v.SharedPixmaps = true - } else { - v.SharedPixmaps = false - } - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.MajorVersion = Get16(buf[b:]) - b += 2 - - v.MinorVersion = Get16(buf[b:]) - b += 2 - - v.Uid = Get16(buf[b:]) - b += 2 - - v.Gid = Get16(buf[b:]) - b += 2 - - v.PixmapFormat = buf[b] - b += 1 - - b += 15 // padding - - return v -} - -func (cook ShmQueryVersionCookie) Check() error { - return cook.check() -} - -// Write request to wire for ShmQueryVersion -func (c *Conn) shmQueryVersionRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["MIT-SHM"] - b += 1 - - buf[b] = 0 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request ShmAttach -// size: 16 -type ShmAttachCookie struct { - *cookie -} - -// Write request to wire for ShmAttach -func (c *Conn) ShmAttach(Shmseg ShmSeg, Shmid uint32, ReadOnly bool) ShmAttachCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.shmAttachRequest(Shmseg, Shmid, ReadOnly), cookie) - return ShmAttachCookie{cookie} -} - -func (c *Conn) ShmAttachChecked(Shmseg ShmSeg, Shmid uint32, ReadOnly bool) ShmAttachCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.shmAttachRequest(Shmseg, Shmid, ReadOnly), cookie) - return ShmAttachCookie{cookie} -} - -func (cook ShmAttachCookie) Check() error { - return cook.check() -} - -// Write request to wire for ShmAttach -func (c *Conn) shmAttachRequest(Shmseg ShmSeg, Shmid uint32, ReadOnly bool) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["MIT-SHM"] - b += 1 - - buf[b] = 1 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Shmseg)) - b += 4 - - Put32(buf[b:], Shmid) - b += 4 - - if ReadOnly { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 3 // padding - - return buf -} - -// Request ShmDetach -// size: 8 -type ShmDetachCookie struct { - *cookie -} - -// Write request to wire for ShmDetach -func (c *Conn) ShmDetach(Shmseg ShmSeg) ShmDetachCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.shmDetachRequest(Shmseg), cookie) - return ShmDetachCookie{cookie} -} - -func (c *Conn) ShmDetachChecked(Shmseg ShmSeg) ShmDetachCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.shmDetachRequest(Shmseg), cookie) - return ShmDetachCookie{cookie} -} - -func (cook ShmDetachCookie) Check() error { - return cook.check() -} - -// Write request to wire for ShmDetach -func (c *Conn) shmDetachRequest(Shmseg ShmSeg) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["MIT-SHM"] - b += 1 - - buf[b] = 2 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Shmseg)) - b += 4 - - return buf -} - -// Request ShmPutImage -// size: 40 -type ShmPutImageCookie struct { - *cookie -} - -// Write request to wire for ShmPutImage -func (c *Conn) ShmPutImage(Drawable Drawable, Gc Gcontext, TotalWidth uint16, TotalHeight uint16, SrcX uint16, SrcY uint16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16, Depth byte, Format byte, SendEvent byte, Shmseg ShmSeg, Offset uint32) ShmPutImageCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.shmPutImageRequest(Drawable, Gc, TotalWidth, TotalHeight, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY, Depth, Format, SendEvent, Shmseg, Offset), cookie) - return ShmPutImageCookie{cookie} -} - -func (c *Conn) ShmPutImageChecked(Drawable Drawable, Gc Gcontext, TotalWidth uint16, TotalHeight uint16, SrcX uint16, SrcY uint16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16, Depth byte, Format byte, SendEvent byte, Shmseg ShmSeg, Offset uint32) ShmPutImageCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.shmPutImageRequest(Drawable, Gc, TotalWidth, TotalHeight, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY, Depth, Format, SendEvent, Shmseg, Offset), cookie) - return ShmPutImageCookie{cookie} -} - -func (cook ShmPutImageCookie) Check() error { - return cook.check() -} - -// Write request to wire for ShmPutImage -func (c *Conn) shmPutImageRequest(Drawable Drawable, Gc Gcontext, TotalWidth uint16, TotalHeight uint16, SrcX uint16, SrcY uint16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16, Depth byte, Format byte, SendEvent byte, Shmseg ShmSeg, Offset uint32) []byte { - size := 40 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["MIT-SHM"] - b += 1 - - buf[b] = 3 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - Put16(buf[b:], TotalWidth) - b += 2 - - Put16(buf[b:], TotalHeight) - b += 2 - - Put16(buf[b:], SrcX) - b += 2 - - Put16(buf[b:], SrcY) - b += 2 - - Put16(buf[b:], SrcWidth) - b += 2 - - Put16(buf[b:], SrcHeight) - b += 2 - - Put16(buf[b:], uint16(DstX)) - b += 2 - - Put16(buf[b:], uint16(DstY)) - b += 2 - - buf[b] = Depth - b += 1 - - buf[b] = Format - b += 1 - - buf[b] = SendEvent - b += 1 - - b += 1 // padding - - Put32(buf[b:], uint32(Shmseg)) - b += 4 - - Put32(buf[b:], Offset) - b += 4 - - return buf -} - -// Request ShmGetImage -// size: 32 -type ShmGetImageCookie struct { - *cookie -} - -func (c *Conn) ShmGetImage(Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32, Format byte, Shmseg ShmSeg, Offset uint32) ShmGetImageCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.shmGetImageRequest(Drawable, X, Y, Width, Height, PlaneMask, Format, Shmseg, Offset), cookie) - return ShmGetImageCookie{cookie} -} - -func (c *Conn) ShmGetImageUnchecked(Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32, Format byte, Shmseg ShmSeg, Offset uint32) ShmGetImageCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.shmGetImageRequest(Drawable, X, Y, Width, Height, PlaneMask, Format, Shmseg, Offset), cookie) - return ShmGetImageCookie{cookie} -} - -// Request reply for ShmGetImage -// size: 16 -type ShmGetImageReply struct { - Sequence uint16 - Length uint32 - Depth byte - Visual Visualid - Size uint32 -} - -// Waits and reads reply data from request ShmGetImage -func (cook ShmGetImageCookie) Reply() (*ShmGetImageReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return shmGetImageReply(buf), nil -} - -// Read reply into structure from buffer for ShmGetImage -func shmGetImageReply(buf []byte) *ShmGetImageReply { - v := new(ShmGetImageReply) - b := 1 // skip reply determinant - - v.Depth = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Visual = Visualid(Get32(buf[b:])) - b += 4 - - v.Size = Get32(buf[b:]) - b += 4 - - return v -} - -func (cook ShmGetImageCookie) Check() error { - return cook.check() -} - -// Write request to wire for ShmGetImage -func (c *Conn) shmGetImageRequest(Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32, Format byte, Shmseg ShmSeg, Offset uint32) []byte { - size := 32 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["MIT-SHM"] - b += 1 - - buf[b] = 4 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put16(buf[b:], uint16(X)) - b += 2 - - Put16(buf[b:], uint16(Y)) - b += 2 - - Put16(buf[b:], Width) - b += 2 - - Put16(buf[b:], Height) - b += 2 - - Put32(buf[b:], PlaneMask) - b += 4 - - buf[b] = Format - b += 1 - - b += 3 // padding - - Put32(buf[b:], uint32(Shmseg)) - b += 4 - - Put32(buf[b:], Offset) - b += 4 - - return buf -} - -// Request ShmCreatePixmap -// size: 28 -type ShmCreatePixmapCookie struct { - *cookie -} - -// Write request to wire for ShmCreatePixmap -func (c *Conn) ShmCreatePixmap(Pid Pixmap, Drawable Drawable, Width uint16, Height uint16, Depth byte, Shmseg ShmSeg, Offset uint32) ShmCreatePixmapCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.shmCreatePixmapRequest(Pid, Drawable, Width, Height, Depth, Shmseg, Offset), cookie) - return ShmCreatePixmapCookie{cookie} -} - -func (c *Conn) ShmCreatePixmapChecked(Pid Pixmap, Drawable Drawable, Width uint16, Height uint16, Depth byte, Shmseg ShmSeg, Offset uint32) ShmCreatePixmapCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.shmCreatePixmapRequest(Pid, Drawable, Width, Height, Depth, Shmseg, Offset), cookie) - return ShmCreatePixmapCookie{cookie} -} - -func (cook ShmCreatePixmapCookie) Check() error { - return cook.check() -} - -// Write request to wire for ShmCreatePixmap -func (c *Conn) shmCreatePixmapRequest(Pid Pixmap, Drawable Drawable, Width uint16, Height uint16, Depth byte, Shmseg ShmSeg, Offset uint32) []byte { - size := 28 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["MIT-SHM"] - b += 1 - - buf[b] = 5 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Pid)) - b += 4 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put16(buf[b:], Width) - b += 2 - - Put16(buf[b:], Height) - b += 2 - - buf[b] = Depth - b += 1 - - b += 3 // padding - - Put32(buf[b:], uint32(Shmseg)) - b += 4 - - Put32(buf[b:], Offset) - b += 4 - - return buf -} diff --git a/nexgb/auto_sync.go b/nexgb/auto_sync.go deleted file mode 100644 index 2fc2982..0000000 --- a/nexgb/auto_sync.go +++ /dev/null @@ -1,1949 +0,0 @@ -package xgb - -/* - This file was generated by sync.xml on May 10 2012 12:39:34pm EDT. - This file is automatically generated. Edit at your peril! -*/ - -// Imports are not necessary for XGB because everything is -// in one package. They are still listed here for reference. -// import "xproto" - -// SyncInit must be called before using the SYNC extension. -func (c *Conn) SyncInit() error { - reply, err := c.QueryExtension(4, "SYNC").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named SYNC could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["SYNC"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["SYNC"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["SYNC"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["SYNC"] = make(map[int]newEventFun) - newExtErrorFuncs["SYNC"] = make(map[int]newErrorFun) -} - -// Skipping definition for base type 'Card16' - -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - -// Skipping definition for base type 'Float' - -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - -// Skipping definition for base type 'Int8' - -const ( - SyncAlarmstateActive = 0 - SyncAlarmstateInactive = 1 - SyncAlarmstateDestroyed = 2 -) - -const ( - SyncTesttypePositiveTransition = 0 - SyncTesttypeNegativeTransition = 1 - SyncTesttypePositiveComparison = 2 - SyncTesttypeNegativeComparison = 3 -) - -const ( - SyncValuetypeAbsolute = 0 - SyncValuetypeRelative = 1 -) - -const ( - SyncCaCounter = 1 - SyncCaValueType = 2 - SyncCaValue = 4 - SyncCaTestType = 8 - SyncCaDelta = 16 - SyncCaEvents = 32 -) - -type SyncAlarm uint32 - -func (c *Conn) NewSyncAlarmId() (SyncAlarm, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return SyncAlarm(id), nil -} - -type SyncCounter uint32 - -func (c *Conn) NewSyncCounterId() (SyncCounter, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return SyncCounter(id), nil -} - -type SyncFence uint32 - -func (c *Conn) NewSyncFenceId() (SyncFence, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return SyncFence(id), nil -} - -// 'SyncInt64' struct definition -// Size: 8 -type SyncInt64 struct { - Hi int32 - Lo uint32 -} - -// Struct read SyncInt64 -func ReadSyncInt64(buf []byte, v *SyncInt64) int { - b := 0 - - v.Hi = int32(Get32(buf[b:])) - b += 4 - - v.Lo = Get32(buf[b:]) - b += 4 - - return b -} - -// Struct list read SyncInt64 -func ReadSyncInt64List(buf []byte, dest []SyncInt64) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = SyncInt64{} - b += ReadSyncInt64(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write SyncInt64 -func (v SyncInt64) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put32(buf[b:], uint32(v.Hi)) - b += 4 - - Put32(buf[b:], v.Lo) - b += 4 - - return buf -} - -// Write struct list SyncInt64 -func SyncInt64ListBytes(buf []byte, list []SyncInt64) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'SyncSystemcounter' struct definition -// Size: (14 + pad((int(NameLen) * 1))) -type SyncSystemcounter struct { - Counter SyncCounter - Resolution SyncInt64 - NameLen uint16 - Name string // size: pad((int(NameLen) * 1)) -} - -// Struct read SyncSystemcounter -func ReadSyncSystemcounter(buf []byte, v *SyncSystemcounter) int { - b := 0 - - v.Counter = SyncCounter(Get32(buf[b:])) - b += 4 - - v.Resolution = SyncInt64{} - b += ReadSyncInt64(buf[b:], &v.Resolution) - - v.NameLen = Get16(buf[b:]) - b += 2 - - { - byteString := make([]byte, v.NameLen) - copy(byteString[:v.NameLen], buf[b:]) - v.Name = string(byteString) - b += pad(int(v.NameLen)) - } - - return b -} - -// Struct list read SyncSystemcounter -func ReadSyncSystemcounterList(buf []byte, dest []SyncSystemcounter) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = SyncSystemcounter{} - b += ReadSyncSystemcounter(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write SyncSystemcounter -func (v SyncSystemcounter) Bytes() []byte { - buf := make([]byte, (14 + pad((int(v.NameLen) * 1)))) - b := 0 - - Put32(buf[b:], uint32(v.Counter)) - b += 4 - - { - structBytes := v.Resolution.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - Put16(buf[b:], v.NameLen) - b += 2 - - copy(buf[b:], v.Name[:v.NameLen]) - b += pad(int(v.NameLen)) - - return buf -} - -// Write struct list SyncSystemcounter -func SyncSystemcounterListBytes(buf []byte, list []SyncSystemcounter) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size SyncSystemcounter -func SyncSystemcounterListSize(list []SyncSystemcounter) int { - size := 0 - for _, item := range list { - size += (14 + pad((int(item.NameLen) * 1))) - } - return size -} - -// 'SyncTrigger' struct definition -// Size: 20 -type SyncTrigger struct { - Counter SyncCounter - WaitType uint32 - WaitValue SyncInt64 - TestType uint32 -} - -// Struct read SyncTrigger -func ReadSyncTrigger(buf []byte, v *SyncTrigger) int { - b := 0 - - v.Counter = SyncCounter(Get32(buf[b:])) - b += 4 - - v.WaitType = Get32(buf[b:]) - b += 4 - - v.WaitValue = SyncInt64{} - b += ReadSyncInt64(buf[b:], &v.WaitValue) - - v.TestType = Get32(buf[b:]) - b += 4 - - return b -} - -// Struct list read SyncTrigger -func ReadSyncTriggerList(buf []byte, dest []SyncTrigger) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = SyncTrigger{} - b += ReadSyncTrigger(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write SyncTrigger -func (v SyncTrigger) Bytes() []byte { - buf := make([]byte, 20) - b := 0 - - Put32(buf[b:], uint32(v.Counter)) - b += 4 - - Put32(buf[b:], v.WaitType) - b += 4 - - { - structBytes := v.WaitValue.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - Put32(buf[b:], v.TestType) - b += 4 - - return buf -} - -// Write struct list SyncTrigger -func SyncTriggerListBytes(buf []byte, list []SyncTrigger) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'SyncWaitcondition' struct definition -// Size: 28 -type SyncWaitcondition struct { - Trigger SyncTrigger - EventThreshold SyncInt64 -} - -// Struct read SyncWaitcondition -func ReadSyncWaitcondition(buf []byte, v *SyncWaitcondition) int { - b := 0 - - v.Trigger = SyncTrigger{} - b += ReadSyncTrigger(buf[b:], &v.Trigger) - - v.EventThreshold = SyncInt64{} - b += ReadSyncInt64(buf[b:], &v.EventThreshold) - - return b -} - -// Struct list read SyncWaitcondition -func ReadSyncWaitconditionList(buf []byte, dest []SyncWaitcondition) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = SyncWaitcondition{} - b += ReadSyncWaitcondition(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write SyncWaitcondition -func (v SyncWaitcondition) Bytes() []byte { - buf := make([]byte, 28) - b := 0 - - { - structBytes := v.Trigger.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - { - structBytes := v.EventThreshold.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - return buf -} - -// Write struct list SyncWaitcondition -func SyncWaitconditionListBytes(buf []byte, list []SyncWaitcondition) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Event definition SyncCounterNotify (0) -// Size: 32 - -const SyncCounterNotify = 0 - -type SyncCounterNotifyEvent struct { - Sequence uint16 - Kind byte - Counter SyncCounter - WaitValue SyncInt64 - CounterValue SyncInt64 - Timestamp Timestamp - Count uint16 - Destroyed bool - // padding: 1 bytes -} - -// Event read SyncCounterNotify -func NewSyncCounterNotifyEvent(buf []byte) Event { - v := SyncCounterNotifyEvent{} - b := 1 // don't read event number - - v.Kind = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Counter = SyncCounter(Get32(buf[b:])) - b += 4 - - v.WaitValue = SyncInt64{} - b += ReadSyncInt64(buf[b:], &v.WaitValue) - - v.CounterValue = SyncInt64{} - b += ReadSyncInt64(buf[b:], &v.CounterValue) - - v.Timestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.Count = Get16(buf[b:]) - b += 2 - - if buf[b] == 1 { - v.Destroyed = true - } else { - v.Destroyed = false - } - b += 1 - - b += 1 // padding - - return v -} - -// Event write SyncCounterNotify -func (v SyncCounterNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 0 - b += 1 - - buf[b] = v.Kind - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Counter)) - b += 4 - - { - structBytes := v.WaitValue.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - { - structBytes := v.CounterValue.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - Put32(buf[b:], uint32(v.Timestamp)) - b += 4 - - Put16(buf[b:], v.Count) - b += 2 - - if v.Destroyed { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 1 // padding - - return buf -} - -func (v SyncCounterNotifyEvent) ImplementsEvent() {} - -func (v SyncCounterNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v SyncCounterNotifyEvent) String() string { - fieldVals := make([]string, 0, 8) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Kind: %d", v.Kind)) - fieldVals = append(fieldVals, sprintf("Counter: %d", v.Counter)) - fieldVals = append(fieldVals, sprintf("Timestamp: %d", v.Timestamp)) - fieldVals = append(fieldVals, sprintf("Count: %d", v.Count)) - fieldVals = append(fieldVals, sprintf("Destroyed: %t", v.Destroyed)) - return "SyncCounterNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["SYNC"][0] = NewSyncCounterNotifyEvent -} - -// Event definition SyncAlarmNotify (1) -// Size: 32 - -const SyncAlarmNotify = 1 - -type SyncAlarmNotifyEvent struct { - Sequence uint16 - Kind byte - Alarm SyncAlarm - CounterValue SyncInt64 - AlarmValue SyncInt64 - Timestamp Timestamp - State byte - // padding: 3 bytes -} - -// Event read SyncAlarmNotify -func NewSyncAlarmNotifyEvent(buf []byte) Event { - v := SyncAlarmNotifyEvent{} - b := 1 // don't read event number - - v.Kind = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Alarm = SyncAlarm(Get32(buf[b:])) - b += 4 - - v.CounterValue = SyncInt64{} - b += ReadSyncInt64(buf[b:], &v.CounterValue) - - v.AlarmValue = SyncInt64{} - b += ReadSyncInt64(buf[b:], &v.AlarmValue) - - v.Timestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.State = buf[b] - b += 1 - - b += 3 // padding - - return v -} - -// Event write SyncAlarmNotify -func (v SyncAlarmNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 1 - b += 1 - - buf[b] = v.Kind - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Alarm)) - b += 4 - - { - structBytes := v.CounterValue.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - { - structBytes := v.AlarmValue.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - Put32(buf[b:], uint32(v.Timestamp)) - b += 4 - - buf[b] = v.State - b += 1 - - b += 3 // padding - - return buf -} - -func (v SyncAlarmNotifyEvent) ImplementsEvent() {} - -func (v SyncAlarmNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v SyncAlarmNotifyEvent) String() string { - fieldVals := make([]string, 0, 7) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Kind: %d", v.Kind)) - fieldVals = append(fieldVals, sprintf("Alarm: %d", v.Alarm)) - fieldVals = append(fieldVals, sprintf("Timestamp: %d", v.Timestamp)) - fieldVals = append(fieldVals, sprintf("State: %d", v.State)) - return "SyncAlarmNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["SYNC"][1] = NewSyncAlarmNotifyEvent -} - -// Error definition SyncCounter (0) -// Size: 32 - -const BadSyncCounter = 0 - -type SyncCounterError struct { - Sequence uint16 - NiceName string - BadCounter uint32 - MinorOpcode uint16 - MajorOpcode byte -} - -// Error read SyncCounter -func NewSyncCounterError(buf []byte) Error { - v := SyncCounterError{} - v.NiceName = "SyncCounter" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.BadCounter = Get32(buf[b:]) - b += 4 - - v.MinorOpcode = Get16(buf[b:]) - b += 2 - - v.MajorOpcode = buf[b] - b += 1 - - return v -} - -func (err SyncCounterError) ImplementsError() {} - -func (err SyncCounterError) SequenceId() uint16 { - return err.Sequence -} - -func (err SyncCounterError) BadId() uint32 { - return 0 -} - -func (err SyncCounterError) Error() string { - fieldVals := make([]string, 0, 3) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, sprintf("BadCounter: %d", err.BadCounter)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadSyncCounter {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["SYNC"][0] = NewSyncCounterError -} - -// Error definition SyncAlarm (1) -// Size: 32 - -const BadSyncAlarm = 1 - -type SyncAlarmError struct { - Sequence uint16 - NiceName string - BadAlarm uint32 - MinorOpcode uint16 - MajorOpcode byte -} - -// Error read SyncAlarm -func NewSyncAlarmError(buf []byte) Error { - v := SyncAlarmError{} - v.NiceName = "SyncAlarm" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.BadAlarm = Get32(buf[b:]) - b += 4 - - v.MinorOpcode = Get16(buf[b:]) - b += 2 - - v.MajorOpcode = buf[b] - b += 1 - - return v -} - -func (err SyncAlarmError) ImplementsError() {} - -func (err SyncAlarmError) SequenceId() uint16 { - return err.Sequence -} - -func (err SyncAlarmError) BadId() uint32 { - return 0 -} - -func (err SyncAlarmError) Error() string { - fieldVals := make([]string, 0, 3) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, sprintf("BadAlarm: %d", err.BadAlarm)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadSyncAlarm {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["SYNC"][1] = NewSyncAlarmError -} - -// Request SyncInitialize -// size: 8 -type SyncInitializeCookie struct { - *cookie -} - -func (c *Conn) SyncInitialize(DesiredMajorVersion byte, DesiredMinorVersion byte) SyncInitializeCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.syncInitializeRequest(DesiredMajorVersion, DesiredMinorVersion), cookie) - return SyncInitializeCookie{cookie} -} - -func (c *Conn) SyncInitializeUnchecked(DesiredMajorVersion byte, DesiredMinorVersion byte) SyncInitializeCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.syncInitializeRequest(DesiredMajorVersion, DesiredMinorVersion), cookie) - return SyncInitializeCookie{cookie} -} - -// Request reply for SyncInitialize -// size: 32 -type SyncInitializeReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - MajorVersion byte - MinorVersion byte - // padding: 22 bytes -} - -// Waits and reads reply data from request SyncInitialize -func (cook SyncInitializeCookie) Reply() (*SyncInitializeReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return syncInitializeReply(buf), nil -} - -// Read reply into structure from buffer for SyncInitialize -func syncInitializeReply(buf []byte) *SyncInitializeReply { - v := new(SyncInitializeReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.MajorVersion = buf[b] - b += 1 - - v.MinorVersion = buf[b] - b += 1 - - b += 22 // padding - - return v -} - -func (cook SyncInitializeCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncInitialize -func (c *Conn) syncInitializeRequest(DesiredMajorVersion byte, DesiredMinorVersion byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - b += 1 - - buf[b] = 0 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = DesiredMajorVersion - b += 1 - - buf[b] = DesiredMinorVersion - b += 1 - - return buf -} - -// Request SyncListSystemCounters -// size: 4 -type SyncListSystemCountersCookie struct { - *cookie -} - -func (c *Conn) SyncListSystemCounters() SyncListSystemCountersCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.syncListSystemCountersRequest(), cookie) - return SyncListSystemCountersCookie{cookie} -} - -func (c *Conn) SyncListSystemCountersUnchecked() SyncListSystemCountersCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.syncListSystemCountersRequest(), cookie) - return SyncListSystemCountersCookie{cookie} -} - -// Request reply for SyncListSystemCounters -// size: (32 + SyncSystemcounterListSize(Counters)) -type SyncListSystemCountersReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - CountersLen uint32 - // padding: 20 bytes - Counters []SyncSystemcounter // size: SyncSystemcounterListSize(Counters) -} - -// Waits and reads reply data from request SyncListSystemCounters -func (cook SyncListSystemCountersCookie) Reply() (*SyncListSystemCountersReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return syncListSystemCountersReply(buf), nil -} - -// Read reply into structure from buffer for SyncListSystemCounters -func syncListSystemCountersReply(buf []byte) *SyncListSystemCountersReply { - v := new(SyncListSystemCountersReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.CountersLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Counters = make([]SyncSystemcounter, v.CountersLen) - b += ReadSyncSystemcounterList(buf[b:], v.Counters) - - return v -} - -func (cook SyncListSystemCountersCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncListSystemCounters -func (c *Conn) syncListSystemCountersRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - b += 1 - - buf[b] = 1 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request SyncCreateCounter -// size: 16 -type SyncCreateCounterCookie struct { - *cookie -} - -// Write request to wire for SyncCreateCounter -func (c *Conn) SyncCreateCounter(Id SyncCounter, InitialValue SyncInt64) SyncCreateCounterCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.syncCreateCounterRequest(Id, InitialValue), cookie) - return SyncCreateCounterCookie{cookie} -} - -func (c *Conn) SyncCreateCounterChecked(Id SyncCounter, InitialValue SyncInt64) SyncCreateCounterCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.syncCreateCounterRequest(Id, InitialValue), cookie) - return SyncCreateCounterCookie{cookie} -} - -func (cook SyncCreateCounterCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncCreateCounter -func (c *Conn) syncCreateCounterRequest(Id SyncCounter, InitialValue SyncInt64) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - b += 1 - - buf[b] = 2 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Id)) - b += 4 - - { - structBytes := InitialValue.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - return buf -} - -// Request SyncDestroyCounter -// size: 8 -type SyncDestroyCounterCookie struct { - *cookie -} - -// Write request to wire for SyncDestroyCounter -func (c *Conn) SyncDestroyCounter(Counter SyncCounter) SyncDestroyCounterCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.syncDestroyCounterRequest(Counter), cookie) - return SyncDestroyCounterCookie{cookie} -} - -func (c *Conn) SyncDestroyCounterChecked(Counter SyncCounter) SyncDestroyCounterCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.syncDestroyCounterRequest(Counter), cookie) - return SyncDestroyCounterCookie{cookie} -} - -func (cook SyncDestroyCounterCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncDestroyCounter -func (c *Conn) syncDestroyCounterRequest(Counter SyncCounter) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - b += 1 - - buf[b] = 6 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Counter)) - b += 4 - - return buf -} - -// Request SyncQueryCounter -// size: 8 -type SyncQueryCounterCookie struct { - *cookie -} - -func (c *Conn) SyncQueryCounter(Counter SyncCounter) SyncQueryCounterCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.syncQueryCounterRequest(Counter), cookie) - return SyncQueryCounterCookie{cookie} -} - -func (c *Conn) SyncQueryCounterUnchecked(Counter SyncCounter) SyncQueryCounterCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.syncQueryCounterRequest(Counter), cookie) - return SyncQueryCounterCookie{cookie} -} - -// Request reply for SyncQueryCounter -// size: 16 -type SyncQueryCounterReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - CounterValue SyncInt64 -} - -// Waits and reads reply data from request SyncQueryCounter -func (cook SyncQueryCounterCookie) Reply() (*SyncQueryCounterReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return syncQueryCounterReply(buf), nil -} - -// Read reply into structure from buffer for SyncQueryCounter -func syncQueryCounterReply(buf []byte) *SyncQueryCounterReply { - v := new(SyncQueryCounterReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.CounterValue = SyncInt64{} - b += ReadSyncInt64(buf[b:], &v.CounterValue) - - return v -} - -func (cook SyncQueryCounterCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncQueryCounter -func (c *Conn) syncQueryCounterRequest(Counter SyncCounter) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - b += 1 - - buf[b] = 5 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Counter)) - b += 4 - - return buf -} - -// Request SyncAwait -// size: pad((4 + pad((len(WaitList) * 28)))) -type SyncAwaitCookie struct { - *cookie -} - -// Write request to wire for SyncAwait -func (c *Conn) SyncAwait(WaitList []SyncWaitcondition) SyncAwaitCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.syncAwaitRequest(WaitList), cookie) - return SyncAwaitCookie{cookie} -} - -func (c *Conn) SyncAwaitChecked(WaitList []SyncWaitcondition) SyncAwaitCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.syncAwaitRequest(WaitList), cookie) - return SyncAwaitCookie{cookie} -} - -func (cook SyncAwaitCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncAwait -func (c *Conn) syncAwaitRequest(WaitList []SyncWaitcondition) []byte { - size := pad((4 + pad((len(WaitList) * 28)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - b += 1 - - buf[b] = 7 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - b += SyncWaitconditionListBytes(buf[b:], WaitList) - - return buf -} - -// Request SyncChangeCounter -// size: 16 -type SyncChangeCounterCookie struct { - *cookie -} - -// Write request to wire for SyncChangeCounter -func (c *Conn) SyncChangeCounter(Counter SyncCounter, Amount SyncInt64) SyncChangeCounterCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.syncChangeCounterRequest(Counter, Amount), cookie) - return SyncChangeCounterCookie{cookie} -} - -func (c *Conn) SyncChangeCounterChecked(Counter SyncCounter, Amount SyncInt64) SyncChangeCounterCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.syncChangeCounterRequest(Counter, Amount), cookie) - return SyncChangeCounterCookie{cookie} -} - -func (cook SyncChangeCounterCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncChangeCounter -func (c *Conn) syncChangeCounterRequest(Counter SyncCounter, Amount SyncInt64) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - b += 1 - - buf[b] = 4 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Counter)) - b += 4 - - { - structBytes := Amount.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - return buf -} - -// Request SyncSetCounter -// size: 16 -type SyncSetCounterCookie struct { - *cookie -} - -// Write request to wire for SyncSetCounter -func (c *Conn) SyncSetCounter(Counter SyncCounter, Value SyncInt64) SyncSetCounterCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.syncSetCounterRequest(Counter, Value), cookie) - return SyncSetCounterCookie{cookie} -} - -func (c *Conn) SyncSetCounterChecked(Counter SyncCounter, Value SyncInt64) SyncSetCounterCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.syncSetCounterRequest(Counter, Value), cookie) - return SyncSetCounterCookie{cookie} -} - -func (cook SyncSetCounterCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncSetCounter -func (c *Conn) syncSetCounterRequest(Counter SyncCounter, Value SyncInt64) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - b += 1 - - buf[b] = 3 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Counter)) - b += 4 - - { - structBytes := Value.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - return buf -} - -// Request SyncCreateAlarm -// size: pad((8 + (4 + pad((4 * popCount(int(ValueMask))))))) -type SyncCreateAlarmCookie struct { - *cookie -} - -// Write request to wire for SyncCreateAlarm -func (c *Conn) SyncCreateAlarm(Id SyncAlarm, ValueMask uint32, ValueList []uint32) SyncCreateAlarmCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.syncCreateAlarmRequest(Id, ValueMask, ValueList), cookie) - return SyncCreateAlarmCookie{cookie} -} - -func (c *Conn) SyncCreateAlarmChecked(Id SyncAlarm, ValueMask uint32, ValueList []uint32) SyncCreateAlarmCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.syncCreateAlarmRequest(Id, ValueMask, ValueList), cookie) - return SyncCreateAlarmCookie{cookie} -} - -func (cook SyncCreateAlarmCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncCreateAlarm -func (c *Conn) syncCreateAlarmRequest(Id SyncAlarm, ValueMask uint32, ValueList []uint32) []byte { - size := pad((8 + (4 + pad((4 * popCount(int(ValueMask))))))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - b += 1 - - buf[b] = 8 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Id)) - b += 4 - - Put32(buf[b:], ValueMask) - b += 4 - for i := 0; i < popCount(int(ValueMask)); i++ { - Put32(buf[b:], ValueList[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Request SyncChangeAlarm -// size: pad((8 + (4 + pad((4 * popCount(int(ValueMask))))))) -type SyncChangeAlarmCookie struct { - *cookie -} - -// Write request to wire for SyncChangeAlarm -func (c *Conn) SyncChangeAlarm(Id SyncAlarm, ValueMask uint32, ValueList []uint32) SyncChangeAlarmCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.syncChangeAlarmRequest(Id, ValueMask, ValueList), cookie) - return SyncChangeAlarmCookie{cookie} -} - -func (c *Conn) SyncChangeAlarmChecked(Id SyncAlarm, ValueMask uint32, ValueList []uint32) SyncChangeAlarmCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.syncChangeAlarmRequest(Id, ValueMask, ValueList), cookie) - return SyncChangeAlarmCookie{cookie} -} - -func (cook SyncChangeAlarmCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncChangeAlarm -func (c *Conn) syncChangeAlarmRequest(Id SyncAlarm, ValueMask uint32, ValueList []uint32) []byte { - size := pad((8 + (4 + pad((4 * popCount(int(ValueMask))))))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - b += 1 - - buf[b] = 9 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Id)) - b += 4 - - Put32(buf[b:], ValueMask) - b += 4 - for i := 0; i < popCount(int(ValueMask)); i++ { - Put32(buf[b:], ValueList[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Request SyncDestroyAlarm -// size: 8 -type SyncDestroyAlarmCookie struct { - *cookie -} - -// Write request to wire for SyncDestroyAlarm -func (c *Conn) SyncDestroyAlarm(Alarm SyncAlarm) SyncDestroyAlarmCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.syncDestroyAlarmRequest(Alarm), cookie) - return SyncDestroyAlarmCookie{cookie} -} - -func (c *Conn) SyncDestroyAlarmChecked(Alarm SyncAlarm) SyncDestroyAlarmCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.syncDestroyAlarmRequest(Alarm), cookie) - return SyncDestroyAlarmCookie{cookie} -} - -func (cook SyncDestroyAlarmCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncDestroyAlarm -func (c *Conn) syncDestroyAlarmRequest(Alarm SyncAlarm) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - b += 1 - - buf[b] = 11 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Alarm)) - b += 4 - - return buf -} - -// Request SyncQueryAlarm -// size: 8 -type SyncQueryAlarmCookie struct { - *cookie -} - -func (c *Conn) SyncQueryAlarm(Alarm SyncAlarm) SyncQueryAlarmCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.syncQueryAlarmRequest(Alarm), cookie) - return SyncQueryAlarmCookie{cookie} -} - -func (c *Conn) SyncQueryAlarmUnchecked(Alarm SyncAlarm) SyncQueryAlarmCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.syncQueryAlarmRequest(Alarm), cookie) - return SyncQueryAlarmCookie{cookie} -} - -// Request reply for SyncQueryAlarm -// size: 40 -type SyncQueryAlarmReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Trigger SyncTrigger - Delta SyncInt64 - Events bool - State byte - // padding: 2 bytes -} - -// Waits and reads reply data from request SyncQueryAlarm -func (cook SyncQueryAlarmCookie) Reply() (*SyncQueryAlarmReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return syncQueryAlarmReply(buf), nil -} - -// Read reply into structure from buffer for SyncQueryAlarm -func syncQueryAlarmReply(buf []byte) *SyncQueryAlarmReply { - v := new(SyncQueryAlarmReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Trigger = SyncTrigger{} - b += ReadSyncTrigger(buf[b:], &v.Trigger) - - v.Delta = SyncInt64{} - b += ReadSyncInt64(buf[b:], &v.Delta) - - if buf[b] == 1 { - v.Events = true - } else { - v.Events = false - } - b += 1 - - v.State = buf[b] - b += 1 - - b += 2 // padding - - return v -} - -func (cook SyncQueryAlarmCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncQueryAlarm -func (c *Conn) syncQueryAlarmRequest(Alarm SyncAlarm) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - b += 1 - - buf[b] = 10 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Alarm)) - b += 4 - - return buf -} - -// Request SyncSetPriority -// size: 12 -type SyncSetPriorityCookie struct { - *cookie -} - -// Write request to wire for SyncSetPriority -func (c *Conn) SyncSetPriority(Id uint32, Priority int32) SyncSetPriorityCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.syncSetPriorityRequest(Id, Priority), cookie) - return SyncSetPriorityCookie{cookie} -} - -func (c *Conn) SyncSetPriorityChecked(Id uint32, Priority int32) SyncSetPriorityCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.syncSetPriorityRequest(Id, Priority), cookie) - return SyncSetPriorityCookie{cookie} -} - -func (cook SyncSetPriorityCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncSetPriority -func (c *Conn) syncSetPriorityRequest(Id uint32, Priority int32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - b += 1 - - buf[b] = 12 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Id) - b += 4 - - Put32(buf[b:], uint32(Priority)) - b += 4 - - return buf -} - -// Request SyncGetPriority -// size: 8 -type SyncGetPriorityCookie struct { - *cookie -} - -func (c *Conn) SyncGetPriority(Id uint32) SyncGetPriorityCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.syncGetPriorityRequest(Id), cookie) - return SyncGetPriorityCookie{cookie} -} - -func (c *Conn) SyncGetPriorityUnchecked(Id uint32) SyncGetPriorityCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.syncGetPriorityRequest(Id), cookie) - return SyncGetPriorityCookie{cookie} -} - -// Request reply for SyncGetPriority -// size: 12 -type SyncGetPriorityReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Priority int32 -} - -// Waits and reads reply data from request SyncGetPriority -func (cook SyncGetPriorityCookie) Reply() (*SyncGetPriorityReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return syncGetPriorityReply(buf), nil -} - -// Read reply into structure from buffer for SyncGetPriority -func syncGetPriorityReply(buf []byte) *SyncGetPriorityReply { - v := new(SyncGetPriorityReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Priority = int32(Get32(buf[b:])) - b += 4 - - return v -} - -func (cook SyncGetPriorityCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncGetPriority -func (c *Conn) syncGetPriorityRequest(Id uint32) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - b += 1 - - buf[b] = 13 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Id) - b += 4 - - return buf -} - -// Request SyncCreateFence -// size: 16 -type SyncCreateFenceCookie struct { - *cookie -} - -// Write request to wire for SyncCreateFence -func (c *Conn) SyncCreateFence(Drawable Drawable, Fence SyncFence, InitiallyTriggered bool) SyncCreateFenceCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.syncCreateFenceRequest(Drawable, Fence, InitiallyTriggered), cookie) - return SyncCreateFenceCookie{cookie} -} - -func (c *Conn) SyncCreateFenceChecked(Drawable Drawable, Fence SyncFence, InitiallyTriggered bool) SyncCreateFenceCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.syncCreateFenceRequest(Drawable, Fence, InitiallyTriggered), cookie) - return SyncCreateFenceCookie{cookie} -} - -func (cook SyncCreateFenceCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncCreateFence -func (c *Conn) syncCreateFenceRequest(Drawable Drawable, Fence SyncFence, InitiallyTriggered bool) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - b += 1 - - buf[b] = 14 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], uint32(Fence)) - b += 4 - - if InitiallyTriggered { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - return buf -} - -// Request SyncTriggerFence -// size: 8 -type SyncTriggerFenceCookie struct { - *cookie -} - -// Write request to wire for SyncTriggerFence -func (c *Conn) SyncTriggerFence(Fence SyncFence) SyncTriggerFenceCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.syncTriggerFenceRequest(Fence), cookie) - return SyncTriggerFenceCookie{cookie} -} - -func (c *Conn) SyncTriggerFenceChecked(Fence SyncFence) SyncTriggerFenceCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.syncTriggerFenceRequest(Fence), cookie) - return SyncTriggerFenceCookie{cookie} -} - -func (cook SyncTriggerFenceCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncTriggerFence -func (c *Conn) syncTriggerFenceRequest(Fence SyncFence) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - b += 1 - - buf[b] = 15 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Fence)) - b += 4 - - return buf -} - -// Request SyncResetFence -// size: 8 -type SyncResetFenceCookie struct { - *cookie -} - -// Write request to wire for SyncResetFence -func (c *Conn) SyncResetFence(Fence SyncFence) SyncResetFenceCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.syncResetFenceRequest(Fence), cookie) - return SyncResetFenceCookie{cookie} -} - -func (c *Conn) SyncResetFenceChecked(Fence SyncFence) SyncResetFenceCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.syncResetFenceRequest(Fence), cookie) - return SyncResetFenceCookie{cookie} -} - -func (cook SyncResetFenceCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncResetFence -func (c *Conn) syncResetFenceRequest(Fence SyncFence) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - b += 1 - - buf[b] = 16 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Fence)) - b += 4 - - return buf -} - -// Request SyncDestroyFence -// size: 8 -type SyncDestroyFenceCookie struct { - *cookie -} - -// Write request to wire for SyncDestroyFence -func (c *Conn) SyncDestroyFence(Fence SyncFence) SyncDestroyFenceCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.syncDestroyFenceRequest(Fence), cookie) - return SyncDestroyFenceCookie{cookie} -} - -func (c *Conn) SyncDestroyFenceChecked(Fence SyncFence) SyncDestroyFenceCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.syncDestroyFenceRequest(Fence), cookie) - return SyncDestroyFenceCookie{cookie} -} - -func (cook SyncDestroyFenceCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncDestroyFence -func (c *Conn) syncDestroyFenceRequest(Fence SyncFence) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - b += 1 - - buf[b] = 17 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Fence)) - b += 4 - - return buf -} - -// Request SyncQueryFence -// size: 8 -type SyncQueryFenceCookie struct { - *cookie -} - -func (c *Conn) SyncQueryFence(Fence SyncFence) SyncQueryFenceCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.syncQueryFenceRequest(Fence), cookie) - return SyncQueryFenceCookie{cookie} -} - -func (c *Conn) SyncQueryFenceUnchecked(Fence SyncFence) SyncQueryFenceCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.syncQueryFenceRequest(Fence), cookie) - return SyncQueryFenceCookie{cookie} -} - -// Request reply for SyncQueryFence -// size: 32 -type SyncQueryFenceReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Triggered bool - // padding: 23 bytes -} - -// Waits and reads reply data from request SyncQueryFence -func (cook SyncQueryFenceCookie) Reply() (*SyncQueryFenceReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return syncQueryFenceReply(buf), nil -} - -// Read reply into structure from buffer for SyncQueryFence -func syncQueryFenceReply(buf []byte) *SyncQueryFenceReply { - v := new(SyncQueryFenceReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - if buf[b] == 1 { - v.Triggered = true - } else { - v.Triggered = false - } - b += 1 - - b += 23 // padding - - return v -} - -func (cook SyncQueryFenceCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncQueryFence -func (c *Conn) syncQueryFenceRequest(Fence SyncFence) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - b += 1 - - buf[b] = 18 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Fence)) - b += 4 - - return buf -} - -// Request SyncAwaitFence -// size: pad((4 + pad((len(FenceList) * 4)))) -type SyncAwaitFenceCookie struct { - *cookie -} - -// Write request to wire for SyncAwaitFence -func (c *Conn) SyncAwaitFence(FenceList []SyncFence) SyncAwaitFenceCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.syncAwaitFenceRequest(FenceList), cookie) - return SyncAwaitFenceCookie{cookie} -} - -func (c *Conn) SyncAwaitFenceChecked(FenceList []SyncFence) SyncAwaitFenceCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.syncAwaitFenceRequest(FenceList), cookie) - return SyncAwaitFenceCookie{cookie} -} - -func (cook SyncAwaitFenceCookie) Check() error { - return cook.check() -} - -// Write request to wire for SyncAwaitFence -func (c *Conn) syncAwaitFenceRequest(FenceList []SyncFence) []byte { - size := pad((4 + pad((len(FenceList) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SYNC"] - b += 1 - - buf[b] = 19 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - for i := 0; i < int(len(FenceList)); i++ { - Put32(buf[b:], uint32(FenceList[i])) - b += 4 - } - b = pad(b) - - return buf -} diff --git a/nexgb/auto_xc_misc.go b/nexgb/auto_xc_misc.go deleted file mode 100644 index bce7d29..0000000 --- a/nexgb/auto_xc_misc.go +++ /dev/null @@ -1,326 +0,0 @@ -package xgb - -/* - This file was generated by xc_misc.xml on May 10 2012 12:39:34pm EDT. - This file is automatically generated. Edit at your peril! -*/ - -// Xc_miscInit must be called before using the XC-MISC extension. -func (c *Conn) Xc_miscInit() error { - reply, err := c.QueryExtension(7, "XC-MISC").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named XC-MISC could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["XC-MISC"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["XC-MISC"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["XC-MISC"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["XC-MISC"] = make(map[int]newEventFun) - newExtErrorFuncs["XC-MISC"] = make(map[int]newErrorFun) -} - -// Skipping definition for base type 'Float' - -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - -// Skipping definition for base type 'Int8' - -// Skipping definition for base type 'Card16' - -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - -// Request Xc_miscGetVersion -// size: 8 -type Xc_miscGetVersionCookie struct { - *cookie -} - -func (c *Conn) Xc_miscGetVersion(ClientMajorVersion uint16, ClientMinorVersion uint16) Xc_miscGetVersionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xc_miscGetVersionRequest(ClientMajorVersion, ClientMinorVersion), cookie) - return Xc_miscGetVersionCookie{cookie} -} - -func (c *Conn) Xc_miscGetVersionUnchecked(ClientMajorVersion uint16, ClientMinorVersion uint16) Xc_miscGetVersionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xc_miscGetVersionRequest(ClientMajorVersion, ClientMinorVersion), cookie) - return Xc_miscGetVersionCookie{cookie} -} - -// Request reply for Xc_miscGetVersion -// size: 12 -type Xc_miscGetVersionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ServerMajorVersion uint16 - ServerMinorVersion uint16 -} - -// Waits and reads reply data from request Xc_miscGetVersion -func (cook Xc_miscGetVersionCookie) Reply() (*Xc_miscGetVersionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xc_miscGetVersionReply(buf), nil -} - -// Read reply into structure from buffer for Xc_miscGetVersion -func xc_miscGetVersionReply(buf []byte) *Xc_miscGetVersionReply { - v := new(Xc_miscGetVersionReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.ServerMajorVersion = Get16(buf[b:]) - b += 2 - - v.ServerMinorVersion = Get16(buf[b:]) - b += 2 - - return v -} - -func (cook Xc_miscGetVersionCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xc_miscGetVersion -func (c *Conn) xc_miscGetVersionRequest(ClientMajorVersion uint16, ClientMinorVersion uint16) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XC-MISC"] - b += 1 - - buf[b] = 0 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], ClientMajorVersion) - b += 2 - - Put16(buf[b:], ClientMinorVersion) - b += 2 - - return buf -} - -// Request Xc_miscGetXIDRange -// size: 4 -type Xc_miscGetXIDRangeCookie struct { - *cookie -} - -func (c *Conn) Xc_miscGetXIDRange() Xc_miscGetXIDRangeCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xc_miscGetXIDRangeRequest(), cookie) - return Xc_miscGetXIDRangeCookie{cookie} -} - -func (c *Conn) Xc_miscGetXIDRangeUnchecked() Xc_miscGetXIDRangeCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xc_miscGetXIDRangeRequest(), cookie) - return Xc_miscGetXIDRangeCookie{cookie} -} - -// Request reply for Xc_miscGetXIDRange -// size: 16 -type Xc_miscGetXIDRangeReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - StartId uint32 - Count uint32 -} - -// Waits and reads reply data from request Xc_miscGetXIDRange -func (cook Xc_miscGetXIDRangeCookie) Reply() (*Xc_miscGetXIDRangeReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xc_miscGetXIDRangeReply(buf), nil -} - -// Read reply into structure from buffer for Xc_miscGetXIDRange -func xc_miscGetXIDRangeReply(buf []byte) *Xc_miscGetXIDRangeReply { - v := new(Xc_miscGetXIDRangeReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.StartId = Get32(buf[b:]) - b += 4 - - v.Count = Get32(buf[b:]) - b += 4 - - return v -} - -func (cook Xc_miscGetXIDRangeCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xc_miscGetXIDRange -func (c *Conn) xc_miscGetXIDRangeRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XC-MISC"] - b += 1 - - buf[b] = 1 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request Xc_miscGetXIDList -// size: 8 -type Xc_miscGetXIDListCookie struct { - *cookie -} - -func (c *Conn) Xc_miscGetXIDList(Count uint32) Xc_miscGetXIDListCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xc_miscGetXIDListRequest(Count), cookie) - return Xc_miscGetXIDListCookie{cookie} -} - -func (c *Conn) Xc_miscGetXIDListUnchecked(Count uint32) Xc_miscGetXIDListCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xc_miscGetXIDListRequest(Count), cookie) - return Xc_miscGetXIDListCookie{cookie} -} - -// Request reply for Xc_miscGetXIDList -// size: (32 + pad((int(IdsLen) * 4))) -type Xc_miscGetXIDListReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - IdsLen uint32 - // padding: 20 bytes - Ids []uint32 // size: pad((int(IdsLen) * 4)) -} - -// Waits and reads reply data from request Xc_miscGetXIDList -func (cook Xc_miscGetXIDListCookie) Reply() (*Xc_miscGetXIDListReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xc_miscGetXIDListReply(buf), nil -} - -// Read reply into structure from buffer for Xc_miscGetXIDList -func xc_miscGetXIDListReply(buf []byte) *Xc_miscGetXIDListReply { - v := new(Xc_miscGetXIDListReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.IdsLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Ids = make([]uint32, v.IdsLen) - for i := 0; i < int(v.IdsLen); i++ { - v.Ids[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook Xc_miscGetXIDListCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xc_miscGetXIDList -func (c *Conn) xc_miscGetXIDListRequest(Count uint32) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XC-MISC"] - b += 1 - - buf[b] = 2 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Count) - b += 4 - - return buf -} diff --git a/nexgb/auto_xevie.go b/nexgb/auto_xevie.go deleted file mode 100644 index 33a05cf..0000000 --- a/nexgb/auto_xevie.go +++ /dev/null @@ -1,539 +0,0 @@ -package xgb - -/* - This file was generated by xevie.xml on May 10 2012 12:39:34pm EDT. - This file is automatically generated. Edit at your peril! -*/ - -// XevieInit must be called before using the XEVIE extension. -func (c *Conn) XevieInit() error { - reply, err := c.QueryExtension(5, "XEVIE").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named XEVIE could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["XEVIE"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["XEVIE"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["XEVIE"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["XEVIE"] = make(map[int]newEventFun) - newExtErrorFuncs["XEVIE"] = make(map[int]newErrorFun) -} - -// Skipping definition for base type 'Int8' - -// Skipping definition for base type 'Card16' - -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - -// Skipping definition for base type 'Float' - -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - -const ( - XevieDatatypeUnmodified = 0 - XevieDatatypeModified = 1 -) - -// 'XevieEvent' struct definition -// Size: 32 -type XevieEvent struct { - // padding: 32 bytes -} - -// Struct read XevieEvent -func ReadXevieEvent(buf []byte, v *XevieEvent) int { - b := 0 - - b += 32 // padding - - return b -} - -// Struct list read XevieEvent -func ReadXevieEventList(buf []byte, dest []XevieEvent) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XevieEvent{} - b += ReadXevieEvent(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XevieEvent -func (v XevieEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - b += 32 // padding - - return buf -} - -// Write struct list XevieEvent -func XevieEventListBytes(buf []byte, list []XevieEvent) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Request XevieQueryVersion -// size: 8 -type XevieQueryVersionCookie struct { - *cookie -} - -func (c *Conn) XevieQueryVersion(ClientMajorVersion uint16, ClientMinorVersion uint16) XevieQueryVersionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xevieQueryVersionRequest(ClientMajorVersion, ClientMinorVersion), cookie) - return XevieQueryVersionCookie{cookie} -} - -func (c *Conn) XevieQueryVersionUnchecked(ClientMajorVersion uint16, ClientMinorVersion uint16) XevieQueryVersionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xevieQueryVersionRequest(ClientMajorVersion, ClientMinorVersion), cookie) - return XevieQueryVersionCookie{cookie} -} - -// Request reply for XevieQueryVersion -// size: 32 -type XevieQueryVersionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ServerMajorVersion uint16 - ServerMinorVersion uint16 - // padding: 20 bytes -} - -// Waits and reads reply data from request XevieQueryVersion -func (cook XevieQueryVersionCookie) Reply() (*XevieQueryVersionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xevieQueryVersionReply(buf), nil -} - -// Read reply into structure from buffer for XevieQueryVersion -func xevieQueryVersionReply(buf []byte) *XevieQueryVersionReply { - v := new(XevieQueryVersionReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.ServerMajorVersion = Get16(buf[b:]) - b += 2 - - v.ServerMinorVersion = Get16(buf[b:]) - b += 2 - - b += 20 // padding - - return v -} - -func (cook XevieQueryVersionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XevieQueryVersion -func (c *Conn) xevieQueryVersionRequest(ClientMajorVersion uint16, ClientMinorVersion uint16) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XEVIE"] - b += 1 - - buf[b] = 0 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], ClientMajorVersion) - b += 2 - - Put16(buf[b:], ClientMinorVersion) - b += 2 - - return buf -} - -// Request XevieStart -// size: 8 -type XevieStartCookie struct { - *cookie -} - -func (c *Conn) XevieStart(Screen uint32) XevieStartCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xevieStartRequest(Screen), cookie) - return XevieStartCookie{cookie} -} - -func (c *Conn) XevieStartUnchecked(Screen uint32) XevieStartCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xevieStartRequest(Screen), cookie) - return XevieStartCookie{cookie} -} - -// Request reply for XevieStart -// size: 32 -type XevieStartReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 24 bytes -} - -// Waits and reads reply data from request XevieStart -func (cook XevieStartCookie) Reply() (*XevieStartReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xevieStartReply(buf), nil -} - -// Read reply into structure from buffer for XevieStart -func xevieStartReply(buf []byte) *XevieStartReply { - v := new(XevieStartReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 24 // padding - - return v -} - -func (cook XevieStartCookie) Check() error { - return cook.check() -} - -// Write request to wire for XevieStart -func (c *Conn) xevieStartRequest(Screen uint32) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XEVIE"] - b += 1 - - buf[b] = 1 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Screen) - b += 4 - - return buf -} - -// Request XevieEnd -// size: 8 -type XevieEndCookie struct { - *cookie -} - -func (c *Conn) XevieEnd(Cmap uint32) XevieEndCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xevieEndRequest(Cmap), cookie) - return XevieEndCookie{cookie} -} - -func (c *Conn) XevieEndUnchecked(Cmap uint32) XevieEndCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xevieEndRequest(Cmap), cookie) - return XevieEndCookie{cookie} -} - -// Request reply for XevieEnd -// size: 32 -type XevieEndReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 24 bytes -} - -// Waits and reads reply data from request XevieEnd -func (cook XevieEndCookie) Reply() (*XevieEndReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xevieEndReply(buf), nil -} - -// Read reply into structure from buffer for XevieEnd -func xevieEndReply(buf []byte) *XevieEndReply { - v := new(XevieEndReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 24 // padding - - return v -} - -func (cook XevieEndCookie) Check() error { - return cook.check() -} - -// Write request to wire for XevieEnd -func (c *Conn) xevieEndRequest(Cmap uint32) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XEVIE"] - b += 1 - - buf[b] = 2 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Cmap) - b += 4 - - return buf -} - -// Request XevieSend -// size: 104 -type XevieSendCookie struct { - *cookie -} - -func (c *Conn) XevieSend(Event XevieEvent, DataType uint32) XevieSendCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xevieSendRequest(Event, DataType), cookie) - return XevieSendCookie{cookie} -} - -func (c *Conn) XevieSendUnchecked(Event XevieEvent, DataType uint32) XevieSendCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xevieSendRequest(Event, DataType), cookie) - return XevieSendCookie{cookie} -} - -// Request reply for XevieSend -// size: 32 -type XevieSendReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 24 bytes -} - -// Waits and reads reply data from request XevieSend -func (cook XevieSendCookie) Reply() (*XevieSendReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xevieSendReply(buf), nil -} - -// Read reply into structure from buffer for XevieSend -func xevieSendReply(buf []byte) *XevieSendReply { - v := new(XevieSendReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 24 // padding - - return v -} - -func (cook XevieSendCookie) Check() error { - return cook.check() -} - -// Write request to wire for XevieSend -func (c *Conn) xevieSendRequest(Event XevieEvent, DataType uint32) []byte { - size := 104 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XEVIE"] - b += 1 - - buf[b] = 3 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - { - structBytes := Event.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - Put32(buf[b:], DataType) - b += 4 - - b += 64 // padding - - return buf -} - -// Request XevieSelectInput -// size: 8 -type XevieSelectInputCookie struct { - *cookie -} - -func (c *Conn) XevieSelectInput(EventMask uint32) XevieSelectInputCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xevieSelectInputRequest(EventMask), cookie) - return XevieSelectInputCookie{cookie} -} - -func (c *Conn) XevieSelectInputUnchecked(EventMask uint32) XevieSelectInputCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xevieSelectInputRequest(EventMask), cookie) - return XevieSelectInputCookie{cookie} -} - -// Request reply for XevieSelectInput -// size: 32 -type XevieSelectInputReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 24 bytes -} - -// Waits and reads reply data from request XevieSelectInput -func (cook XevieSelectInputCookie) Reply() (*XevieSelectInputReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xevieSelectInputReply(buf), nil -} - -// Read reply into structure from buffer for XevieSelectInput -func xevieSelectInputReply(buf []byte) *XevieSelectInputReply { - v := new(XevieSelectInputReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 24 // padding - - return v -} - -func (cook XevieSelectInputCookie) Check() error { - return cook.check() -} - -// Write request to wire for XevieSelectInput -func (c *Conn) xevieSelectInputRequest(EventMask uint32) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XEVIE"] - b += 1 - - buf[b] = 4 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], EventMask) - b += 4 - - return buf -} diff --git a/nexgb/auto_xf86dri.go b/nexgb/auto_xf86dri.go deleted file mode 100644 index 4caa416..0000000 --- a/nexgb/auto_xf86dri.go +++ /dev/null @@ -1,1151 +0,0 @@ -package xgb - -/* - This file was generated by xf86dri.xml on May 10 2012 12:39:34pm EDT. - This file is automatically generated. Edit at your peril! -*/ - -// Xf86driInit must be called before using the XFree86-DRI extension. -func (c *Conn) Xf86driInit() error { - reply, err := c.QueryExtension(11, "XFree86-DRI").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named XFree86-DRI could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["XFree86-DRI"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["XFree86-DRI"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["XFree86-DRI"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["XFree86-DRI"] = make(map[int]newEventFun) - newExtErrorFuncs["XFree86-DRI"] = make(map[int]newErrorFun) -} - -// Skipping definition for base type 'Float' - -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - -// Skipping definition for base type 'Int8' - -// Skipping definition for base type 'Card16' - -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - -// 'Xf86driDrmClipRect' struct definition -// Size: 8 -type Xf86driDrmClipRect struct { - X1 int16 - Y1 int16 - X2 int16 - X3 int16 -} - -// Struct read Xf86driDrmClipRect -func ReadXf86driDrmClipRect(buf []byte, v *Xf86driDrmClipRect) int { - b := 0 - - v.X1 = int16(Get16(buf[b:])) - b += 2 - - v.Y1 = int16(Get16(buf[b:])) - b += 2 - - v.X2 = int16(Get16(buf[b:])) - b += 2 - - v.X3 = int16(Get16(buf[b:])) - b += 2 - - return b -} - -// Struct list read Xf86driDrmClipRect -func ReadXf86driDrmClipRectList(buf []byte, dest []Xf86driDrmClipRect) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Xf86driDrmClipRect{} - b += ReadXf86driDrmClipRect(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write Xf86driDrmClipRect -func (v Xf86driDrmClipRect) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put16(buf[b:], uint16(v.X1)) - b += 2 - - Put16(buf[b:], uint16(v.Y1)) - b += 2 - - Put16(buf[b:], uint16(v.X2)) - b += 2 - - Put16(buf[b:], uint16(v.X3)) - b += 2 - - return buf -} - -// Write struct list Xf86driDrmClipRect -func Xf86driDrmClipRectListBytes(buf []byte, list []Xf86driDrmClipRect) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Request Xf86driQueryVersion -// size: 4 -type Xf86driQueryVersionCookie struct { - *cookie -} - -func (c *Conn) Xf86driQueryVersion() Xf86driQueryVersionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86driQueryVersionRequest(), cookie) - return Xf86driQueryVersionCookie{cookie} -} - -func (c *Conn) Xf86driQueryVersionUnchecked() Xf86driQueryVersionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86driQueryVersionRequest(), cookie) - return Xf86driQueryVersionCookie{cookie} -} - -// Request reply for Xf86driQueryVersion -// size: 16 -type Xf86driQueryVersionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - DriMajorVersion uint16 - DriMinorVersion uint16 - DriMinorPatch uint32 -} - -// Waits and reads reply data from request Xf86driQueryVersion -func (cook Xf86driQueryVersionCookie) Reply() (*Xf86driQueryVersionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86driQueryVersionReply(buf), nil -} - -// Read reply into structure from buffer for Xf86driQueryVersion -func xf86driQueryVersionReply(buf []byte) *Xf86driQueryVersionReply { - v := new(Xf86driQueryVersionReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.DriMajorVersion = Get16(buf[b:]) - b += 2 - - v.DriMinorVersion = Get16(buf[b:]) - b += 2 - - v.DriMinorPatch = Get32(buf[b:]) - b += 4 - - return v -} - -func (cook Xf86driQueryVersionCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86driQueryVersion -func (c *Conn) xf86driQueryVersionRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-DRI"] - b += 1 - - buf[b] = 0 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request Xf86driQueryDirectRenderingCapable -// size: 8 -type Xf86driQueryDirectRenderingCapableCookie struct { - *cookie -} - -func (c *Conn) Xf86driQueryDirectRenderingCapable(Screen uint32) Xf86driQueryDirectRenderingCapableCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86driQueryDirectRenderingCapableRequest(Screen), cookie) - return Xf86driQueryDirectRenderingCapableCookie{cookie} -} - -func (c *Conn) Xf86driQueryDirectRenderingCapableUnchecked(Screen uint32) Xf86driQueryDirectRenderingCapableCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86driQueryDirectRenderingCapableRequest(Screen), cookie) - return Xf86driQueryDirectRenderingCapableCookie{cookie} -} - -// Request reply for Xf86driQueryDirectRenderingCapable -// size: 9 -type Xf86driQueryDirectRenderingCapableReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - IsCapable bool -} - -// Waits and reads reply data from request Xf86driQueryDirectRenderingCapable -func (cook Xf86driQueryDirectRenderingCapableCookie) Reply() (*Xf86driQueryDirectRenderingCapableReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86driQueryDirectRenderingCapableReply(buf), nil -} - -// Read reply into structure from buffer for Xf86driQueryDirectRenderingCapable -func xf86driQueryDirectRenderingCapableReply(buf []byte) *Xf86driQueryDirectRenderingCapableReply { - v := new(Xf86driQueryDirectRenderingCapableReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - if buf[b] == 1 { - v.IsCapable = true - } else { - v.IsCapable = false - } - b += 1 - - return v -} - -func (cook Xf86driQueryDirectRenderingCapableCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86driQueryDirectRenderingCapable -func (c *Conn) xf86driQueryDirectRenderingCapableRequest(Screen uint32) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-DRI"] - b += 1 - - buf[b] = 1 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Screen) - b += 4 - - return buf -} - -// Request Xf86driOpenConnection -// size: 8 -type Xf86driOpenConnectionCookie struct { - *cookie -} - -func (c *Conn) Xf86driOpenConnection(Screen uint32) Xf86driOpenConnectionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86driOpenConnectionRequest(Screen), cookie) - return Xf86driOpenConnectionCookie{cookie} -} - -func (c *Conn) Xf86driOpenConnectionUnchecked(Screen uint32) Xf86driOpenConnectionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86driOpenConnectionRequest(Screen), cookie) - return Xf86driOpenConnectionCookie{cookie} -} - -// Request reply for Xf86driOpenConnection -// size: (32 + pad((int(BusIdLen) * 1))) -type Xf86driOpenConnectionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - SareaHandleLow uint32 - SareaHandleHigh uint32 - BusIdLen uint32 - // padding: 12 bytes - BusId string // size: pad((int(BusIdLen) * 1)) -} - -// Waits and reads reply data from request Xf86driOpenConnection -func (cook Xf86driOpenConnectionCookie) Reply() (*Xf86driOpenConnectionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86driOpenConnectionReply(buf), nil -} - -// Read reply into structure from buffer for Xf86driOpenConnection -func xf86driOpenConnectionReply(buf []byte) *Xf86driOpenConnectionReply { - v := new(Xf86driOpenConnectionReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.SareaHandleLow = Get32(buf[b:]) - b += 4 - - v.SareaHandleHigh = Get32(buf[b:]) - b += 4 - - v.BusIdLen = Get32(buf[b:]) - b += 4 - - b += 12 // padding - - { - byteString := make([]byte, v.BusIdLen) - copy(byteString[:v.BusIdLen], buf[b:]) - v.BusId = string(byteString) - b += pad(int(v.BusIdLen)) - } - - return v -} - -func (cook Xf86driOpenConnectionCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86driOpenConnection -func (c *Conn) xf86driOpenConnectionRequest(Screen uint32) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-DRI"] - b += 1 - - buf[b] = 2 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Screen) - b += 4 - - return buf -} - -// Request Xf86driCloseConnection -// size: 8 -type Xf86driCloseConnectionCookie struct { - *cookie -} - -// Write request to wire for Xf86driCloseConnection -func (c *Conn) Xf86driCloseConnection(Screen uint32) Xf86driCloseConnectionCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xf86driCloseConnectionRequest(Screen), cookie) - return Xf86driCloseConnectionCookie{cookie} -} - -func (c *Conn) Xf86driCloseConnectionChecked(Screen uint32) Xf86driCloseConnectionCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xf86driCloseConnectionRequest(Screen), cookie) - return Xf86driCloseConnectionCookie{cookie} -} - -func (cook Xf86driCloseConnectionCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86driCloseConnection -func (c *Conn) xf86driCloseConnectionRequest(Screen uint32) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-DRI"] - b += 1 - - buf[b] = 3 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Screen) - b += 4 - - return buf -} - -// Request Xf86driGetClientDriverName -// size: 8 -type Xf86driGetClientDriverNameCookie struct { - *cookie -} - -func (c *Conn) Xf86driGetClientDriverName(Screen uint32) Xf86driGetClientDriverNameCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86driGetClientDriverNameRequest(Screen), cookie) - return Xf86driGetClientDriverNameCookie{cookie} -} - -func (c *Conn) Xf86driGetClientDriverNameUnchecked(Screen uint32) Xf86driGetClientDriverNameCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86driGetClientDriverNameRequest(Screen), cookie) - return Xf86driGetClientDriverNameCookie{cookie} -} - -// Request reply for Xf86driGetClientDriverName -// size: (32 + pad((int(ClientDriverNameLen) * 1))) -type Xf86driGetClientDriverNameReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ClientDriverMajorVersion uint32 - ClientDriverMinorVersion uint32 - ClientDriverPatchVersion uint32 - ClientDriverNameLen uint32 - // padding: 8 bytes - ClientDriverName string // size: pad((int(ClientDriverNameLen) * 1)) -} - -// Waits and reads reply data from request Xf86driGetClientDriverName -func (cook Xf86driGetClientDriverNameCookie) Reply() (*Xf86driGetClientDriverNameReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86driGetClientDriverNameReply(buf), nil -} - -// Read reply into structure from buffer for Xf86driGetClientDriverName -func xf86driGetClientDriverNameReply(buf []byte) *Xf86driGetClientDriverNameReply { - v := new(Xf86driGetClientDriverNameReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.ClientDriverMajorVersion = Get32(buf[b:]) - b += 4 - - v.ClientDriverMinorVersion = Get32(buf[b:]) - b += 4 - - v.ClientDriverPatchVersion = Get32(buf[b:]) - b += 4 - - v.ClientDriverNameLen = Get32(buf[b:]) - b += 4 - - b += 8 // padding - - { - byteString := make([]byte, v.ClientDriverNameLen) - copy(byteString[:v.ClientDriverNameLen], buf[b:]) - v.ClientDriverName = string(byteString) - b += pad(int(v.ClientDriverNameLen)) - } - - return v -} - -func (cook Xf86driGetClientDriverNameCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86driGetClientDriverName -func (c *Conn) xf86driGetClientDriverNameRequest(Screen uint32) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-DRI"] - b += 1 - - buf[b] = 4 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Screen) - b += 4 - - return buf -} - -// Request Xf86driCreateContext -// size: 16 -type Xf86driCreateContextCookie struct { - *cookie -} - -func (c *Conn) Xf86driCreateContext(Screen uint32, Visual uint32, Context uint32) Xf86driCreateContextCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86driCreateContextRequest(Screen, Visual, Context), cookie) - return Xf86driCreateContextCookie{cookie} -} - -func (c *Conn) Xf86driCreateContextUnchecked(Screen uint32, Visual uint32, Context uint32) Xf86driCreateContextCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86driCreateContextRequest(Screen, Visual, Context), cookie) - return Xf86driCreateContextCookie{cookie} -} - -// Request reply for Xf86driCreateContext -// size: 12 -type Xf86driCreateContextReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - HwContext uint32 -} - -// Waits and reads reply data from request Xf86driCreateContext -func (cook Xf86driCreateContextCookie) Reply() (*Xf86driCreateContextReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86driCreateContextReply(buf), nil -} - -// Read reply into structure from buffer for Xf86driCreateContext -func xf86driCreateContextReply(buf []byte) *Xf86driCreateContextReply { - v := new(Xf86driCreateContextReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.HwContext = Get32(buf[b:]) - b += 4 - - return v -} - -func (cook Xf86driCreateContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86driCreateContext -func (c *Conn) xf86driCreateContextRequest(Screen uint32, Visual uint32, Context uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-DRI"] - b += 1 - - buf[b] = 5 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Screen) - b += 4 - - Put32(buf[b:], Visual) - b += 4 - - Put32(buf[b:], Context) - b += 4 - - return buf -} - -// Request Xf86driDestroyContext -// size: 12 -type Xf86driDestroyContextCookie struct { - *cookie -} - -// Write request to wire for Xf86driDestroyContext -func (c *Conn) Xf86driDestroyContext(Screen uint32, Context uint32) Xf86driDestroyContextCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xf86driDestroyContextRequest(Screen, Context), cookie) - return Xf86driDestroyContextCookie{cookie} -} - -func (c *Conn) Xf86driDestroyContextChecked(Screen uint32, Context uint32) Xf86driDestroyContextCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xf86driDestroyContextRequest(Screen, Context), cookie) - return Xf86driDestroyContextCookie{cookie} -} - -func (cook Xf86driDestroyContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86driDestroyContext -func (c *Conn) xf86driDestroyContextRequest(Screen uint32, Context uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-DRI"] - b += 1 - - buf[b] = 6 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Screen) - b += 4 - - Put32(buf[b:], Context) - b += 4 - - return buf -} - -// Request Xf86driCreateDrawable -// size: 12 -type Xf86driCreateDrawableCookie struct { - *cookie -} - -func (c *Conn) Xf86driCreateDrawable(Screen uint32, Drawable uint32) Xf86driCreateDrawableCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86driCreateDrawableRequest(Screen, Drawable), cookie) - return Xf86driCreateDrawableCookie{cookie} -} - -func (c *Conn) Xf86driCreateDrawableUnchecked(Screen uint32, Drawable uint32) Xf86driCreateDrawableCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86driCreateDrawableRequest(Screen, Drawable), cookie) - return Xf86driCreateDrawableCookie{cookie} -} - -// Request reply for Xf86driCreateDrawable -// size: 12 -type Xf86driCreateDrawableReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - HwDrawableHandle uint32 -} - -// Waits and reads reply data from request Xf86driCreateDrawable -func (cook Xf86driCreateDrawableCookie) Reply() (*Xf86driCreateDrawableReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86driCreateDrawableReply(buf), nil -} - -// Read reply into structure from buffer for Xf86driCreateDrawable -func xf86driCreateDrawableReply(buf []byte) *Xf86driCreateDrawableReply { - v := new(Xf86driCreateDrawableReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.HwDrawableHandle = Get32(buf[b:]) - b += 4 - - return v -} - -func (cook Xf86driCreateDrawableCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86driCreateDrawable -func (c *Conn) xf86driCreateDrawableRequest(Screen uint32, Drawable uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-DRI"] - b += 1 - - buf[b] = 7 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Screen) - b += 4 - - Put32(buf[b:], Drawable) - b += 4 - - return buf -} - -// Request Xf86driDestroyDrawable -// size: 12 -type Xf86driDestroyDrawableCookie struct { - *cookie -} - -// Write request to wire for Xf86driDestroyDrawable -func (c *Conn) Xf86driDestroyDrawable(Screen uint32, Drawable uint32) Xf86driDestroyDrawableCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xf86driDestroyDrawableRequest(Screen, Drawable), cookie) - return Xf86driDestroyDrawableCookie{cookie} -} - -func (c *Conn) Xf86driDestroyDrawableChecked(Screen uint32, Drawable uint32) Xf86driDestroyDrawableCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xf86driDestroyDrawableRequest(Screen, Drawable), cookie) - return Xf86driDestroyDrawableCookie{cookie} -} - -func (cook Xf86driDestroyDrawableCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86driDestroyDrawable -func (c *Conn) xf86driDestroyDrawableRequest(Screen uint32, Drawable uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-DRI"] - b += 1 - - buf[b] = 8 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Screen) - b += 4 - - Put32(buf[b:], Drawable) - b += 4 - - return buf -} - -// Request Xf86driGetDrawableInfo -// size: 12 -type Xf86driGetDrawableInfoCookie struct { - *cookie -} - -func (c *Conn) Xf86driGetDrawableInfo(Screen uint32, Drawable uint32) Xf86driGetDrawableInfoCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86driGetDrawableInfoRequest(Screen, Drawable), cookie) - return Xf86driGetDrawableInfoCookie{cookie} -} - -func (c *Conn) Xf86driGetDrawableInfoUnchecked(Screen uint32, Drawable uint32) Xf86driGetDrawableInfoCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86driGetDrawableInfoRequest(Screen, Drawable), cookie) - return Xf86driGetDrawableInfoCookie{cookie} -} - -// Request reply for Xf86driGetDrawableInfo -// size: ((36 + pad((int(NumClipRects) * 8))) + pad((int(NumBackClipRects) * 8))) -type Xf86driGetDrawableInfoReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - DrawableTableIndex uint32 - DrawableTableStamp uint32 - DrawableOriginX int16 - DrawableOriginY int16 - DrawableSizeW int16 - DrawableSizeH int16 - NumClipRects uint32 - BackX int16 - BackY int16 - NumBackClipRects uint32 - ClipRects []Xf86driDrmClipRect // size: pad((int(NumClipRects) * 8)) - BackClipRects []Xf86driDrmClipRect // size: pad((int(NumBackClipRects) * 8)) -} - -// Waits and reads reply data from request Xf86driGetDrawableInfo -func (cook Xf86driGetDrawableInfoCookie) Reply() (*Xf86driGetDrawableInfoReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86driGetDrawableInfoReply(buf), nil -} - -// Read reply into structure from buffer for Xf86driGetDrawableInfo -func xf86driGetDrawableInfoReply(buf []byte) *Xf86driGetDrawableInfoReply { - v := new(Xf86driGetDrawableInfoReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.DrawableTableIndex = Get32(buf[b:]) - b += 4 - - v.DrawableTableStamp = Get32(buf[b:]) - b += 4 - - v.DrawableOriginX = int16(Get16(buf[b:])) - b += 2 - - v.DrawableOriginY = int16(Get16(buf[b:])) - b += 2 - - v.DrawableSizeW = int16(Get16(buf[b:])) - b += 2 - - v.DrawableSizeH = int16(Get16(buf[b:])) - b += 2 - - v.NumClipRects = Get32(buf[b:]) - b += 4 - - v.BackX = int16(Get16(buf[b:])) - b += 2 - - v.BackY = int16(Get16(buf[b:])) - b += 2 - - v.NumBackClipRects = Get32(buf[b:]) - b += 4 - - v.ClipRects = make([]Xf86driDrmClipRect, v.NumClipRects) - b += ReadXf86driDrmClipRectList(buf[b:], v.ClipRects) - - v.BackClipRects = make([]Xf86driDrmClipRect, v.NumBackClipRects) - b += ReadXf86driDrmClipRectList(buf[b:], v.BackClipRects) - - return v -} - -func (cook Xf86driGetDrawableInfoCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86driGetDrawableInfo -func (c *Conn) xf86driGetDrawableInfoRequest(Screen uint32, Drawable uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-DRI"] - b += 1 - - buf[b] = 9 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Screen) - b += 4 - - Put32(buf[b:], Drawable) - b += 4 - - return buf -} - -// Request Xf86driGetDeviceInfo -// size: 8 -type Xf86driGetDeviceInfoCookie struct { - *cookie -} - -func (c *Conn) Xf86driGetDeviceInfo(Screen uint32) Xf86driGetDeviceInfoCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86driGetDeviceInfoRequest(Screen), cookie) - return Xf86driGetDeviceInfoCookie{cookie} -} - -func (c *Conn) Xf86driGetDeviceInfoUnchecked(Screen uint32) Xf86driGetDeviceInfoCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86driGetDeviceInfoRequest(Screen), cookie) - return Xf86driGetDeviceInfoCookie{cookie} -} - -// Request reply for Xf86driGetDeviceInfo -// size: (32 + pad((int(DevicePrivateSize) * 4))) -type Xf86driGetDeviceInfoReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - FramebufferHandleLow uint32 - FramebufferHandleHigh uint32 - FramebufferOriginOffset uint32 - FramebufferSize uint32 - FramebufferStride uint32 - DevicePrivateSize uint32 - DevicePrivate []uint32 // size: pad((int(DevicePrivateSize) * 4)) -} - -// Waits and reads reply data from request Xf86driGetDeviceInfo -func (cook Xf86driGetDeviceInfoCookie) Reply() (*Xf86driGetDeviceInfoReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86driGetDeviceInfoReply(buf), nil -} - -// Read reply into structure from buffer for Xf86driGetDeviceInfo -func xf86driGetDeviceInfoReply(buf []byte) *Xf86driGetDeviceInfoReply { - v := new(Xf86driGetDeviceInfoReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.FramebufferHandleLow = Get32(buf[b:]) - b += 4 - - v.FramebufferHandleHigh = Get32(buf[b:]) - b += 4 - - v.FramebufferOriginOffset = Get32(buf[b:]) - b += 4 - - v.FramebufferSize = Get32(buf[b:]) - b += 4 - - v.FramebufferStride = Get32(buf[b:]) - b += 4 - - v.DevicePrivateSize = Get32(buf[b:]) - b += 4 - - v.DevicePrivate = make([]uint32, v.DevicePrivateSize) - for i := 0; i < int(v.DevicePrivateSize); i++ { - v.DevicePrivate[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook Xf86driGetDeviceInfoCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86driGetDeviceInfo -func (c *Conn) xf86driGetDeviceInfoRequest(Screen uint32) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-DRI"] - b += 1 - - buf[b] = 10 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Screen) - b += 4 - - return buf -} - -// Request Xf86driAuthConnection -// size: 12 -type Xf86driAuthConnectionCookie struct { - *cookie -} - -func (c *Conn) Xf86driAuthConnection(Screen uint32, Magic uint32) Xf86driAuthConnectionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86driAuthConnectionRequest(Screen, Magic), cookie) - return Xf86driAuthConnectionCookie{cookie} -} - -func (c *Conn) Xf86driAuthConnectionUnchecked(Screen uint32, Magic uint32) Xf86driAuthConnectionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86driAuthConnectionRequest(Screen, Magic), cookie) - return Xf86driAuthConnectionCookie{cookie} -} - -// Request reply for Xf86driAuthConnection -// size: 12 -type Xf86driAuthConnectionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Authenticated uint32 -} - -// Waits and reads reply data from request Xf86driAuthConnection -func (cook Xf86driAuthConnectionCookie) Reply() (*Xf86driAuthConnectionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86driAuthConnectionReply(buf), nil -} - -// Read reply into structure from buffer for Xf86driAuthConnection -func xf86driAuthConnectionReply(buf []byte) *Xf86driAuthConnectionReply { - v := new(Xf86driAuthConnectionReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Authenticated = Get32(buf[b:]) - b += 4 - - return v -} - -func (cook Xf86driAuthConnectionCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86driAuthConnection -func (c *Conn) xf86driAuthConnectionRequest(Screen uint32, Magic uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-DRI"] - b += 1 - - buf[b] = 11 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Screen) - b += 4 - - Put32(buf[b:], Magic) - b += 4 - - return buf -} diff --git a/nexgb/auto_xf86vidmode.go b/nexgb/auto_xf86vidmode.go deleted file mode 100644 index 983c021..0000000 --- a/nexgb/auto_xf86vidmode.go +++ /dev/null @@ -1,2398 +0,0 @@ -package xgb - -/* - This file was generated by xf86vidmode.xml on May 10 2012 12:39:34pm EDT. - This file is automatically generated. Edit at your peril! -*/ - -// Xf86vidmodeInit must be called before using the XFree86-VidModeExtension extension. -func (c *Conn) Xf86vidmodeInit() error { - reply, err := c.QueryExtension(24, "XFree86-VidModeExtension").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named XFree86-VidModeExtension could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["XFree86-VidModeExtension"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["XFree86-VidModeExtension"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["XFree86-VidModeExtension"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["XFree86-VidModeExtension"] = make(map[int]newEventFun) - newExtErrorFuncs["XFree86-VidModeExtension"] = make(map[int]newErrorFun) -} - -// Skipping definition for base type 'Card16' - -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - -// Skipping definition for base type 'Float' - -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - -// Skipping definition for base type 'Int8' - -const ( - Xf86vidmodeModeFlagPositiveHsync = 1 - Xf86vidmodeModeFlagNegativeHsync = 2 - Xf86vidmodeModeFlagPositiveVsync = 4 - Xf86vidmodeModeFlagNegativeVsync = 8 - Xf86vidmodeModeFlagInterlace = 16 - Xf86vidmodeModeFlagCompositeSync = 32 - Xf86vidmodeModeFlagPositiveCsync = 64 - Xf86vidmodeModeFlagNegativeCsync = 128 - Xf86vidmodeModeFlagHSkew = 256 - Xf86vidmodeModeFlagBroadcast = 512 - Xf86vidmodeModeFlagPixmux = 1024 - Xf86vidmodeModeFlagDoubleClock = 2048 - Xf86vidmodeModeFlagHalfClock = 4096 -) - -const ( - Xf86vidmodeClockFlagProgramable = 1 -) - -const ( - Xf86vidmodePermissionRead = 1 - Xf86vidmodePermissionWrite = 2 -) - -type Xf86vidmodeSyncrange uint32 - -type Xf86vidmodeDotclock uint32 - -// 'Xf86vidmodeModeInfo' struct definition -// Size: 48 -type Xf86vidmodeModeInfo struct { - Dotclock Xf86vidmodeDotclock - Hdisplay uint16 - Hsyncstart uint16 - Hsyncend uint16 - Htotal uint16 - Hskew uint32 - Vdisplay uint16 - Vsyncstart uint16 - Vsyncend uint16 - Vtotal uint16 - // padding: 4 bytes - Flags uint32 - // padding: 12 bytes - Privsize uint32 -} - -// Struct read Xf86vidmodeModeInfo -func ReadXf86vidmodeModeInfo(buf []byte, v *Xf86vidmodeModeInfo) int { - b := 0 - - v.Dotclock = Xf86vidmodeDotclock(Get32(buf[b:])) - b += 4 - - v.Hdisplay = Get16(buf[b:]) - b += 2 - - v.Hsyncstart = Get16(buf[b:]) - b += 2 - - v.Hsyncend = Get16(buf[b:]) - b += 2 - - v.Htotal = Get16(buf[b:]) - b += 2 - - v.Hskew = Get32(buf[b:]) - b += 4 - - v.Vdisplay = Get16(buf[b:]) - b += 2 - - v.Vsyncstart = Get16(buf[b:]) - b += 2 - - v.Vsyncend = Get16(buf[b:]) - b += 2 - - v.Vtotal = Get16(buf[b:]) - b += 2 - - b += 4 // padding - - v.Flags = Get32(buf[b:]) - b += 4 - - b += 12 // padding - - v.Privsize = Get32(buf[b:]) - b += 4 - - return b -} - -// Struct list read Xf86vidmodeModeInfo -func ReadXf86vidmodeModeInfoList(buf []byte, dest []Xf86vidmodeModeInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Xf86vidmodeModeInfo{} - b += ReadXf86vidmodeModeInfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write Xf86vidmodeModeInfo -func (v Xf86vidmodeModeInfo) Bytes() []byte { - buf := make([]byte, 48) - b := 0 - - Put32(buf[b:], uint32(v.Dotclock)) - b += 4 - - Put16(buf[b:], v.Hdisplay) - b += 2 - - Put16(buf[b:], v.Hsyncstart) - b += 2 - - Put16(buf[b:], v.Hsyncend) - b += 2 - - Put16(buf[b:], v.Htotal) - b += 2 - - Put32(buf[b:], v.Hskew) - b += 4 - - Put16(buf[b:], v.Vdisplay) - b += 2 - - Put16(buf[b:], v.Vsyncstart) - b += 2 - - Put16(buf[b:], v.Vsyncend) - b += 2 - - Put16(buf[b:], v.Vtotal) - b += 2 - - b += 4 // padding - - Put32(buf[b:], v.Flags) - b += 4 - - b += 12 // padding - - Put32(buf[b:], v.Privsize) - b += 4 - - return buf -} - -// Write struct list Xf86vidmodeModeInfo -func Xf86vidmodeModeInfoListBytes(buf []byte, list []Xf86vidmodeModeInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Error definition Xf86vidmodeBadClock (0) -// Size: 32 - -const BadXf86vidmodeBadClock = 0 - -type Xf86vidmodeBadClockError struct { - Sequence uint16 - NiceName string -} - -// Error read Xf86vidmodeBadClock -func NewXf86vidmodeBadClockError(buf []byte) Error { - v := Xf86vidmodeBadClockError{} - v.NiceName = "Xf86vidmodeBadClock" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err Xf86vidmodeBadClockError) ImplementsError() {} - -func (err Xf86vidmodeBadClockError) SequenceId() uint16 { - return err.Sequence -} - -func (err Xf86vidmodeBadClockError) BadId() uint32 { - return 0 -} - -func (err Xf86vidmodeBadClockError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadXf86vidmodeBadClock {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["XFree86-VidModeExtension"][0] = NewXf86vidmodeBadClockError -} - -// Error definition Xf86vidmodeBadHTimings (1) -// Size: 32 - -const BadXf86vidmodeBadHTimings = 1 - -type Xf86vidmodeBadHTimingsError struct { - Sequence uint16 - NiceName string -} - -// Error read Xf86vidmodeBadHTimings -func NewXf86vidmodeBadHTimingsError(buf []byte) Error { - v := Xf86vidmodeBadHTimingsError{} - v.NiceName = "Xf86vidmodeBadHTimings" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err Xf86vidmodeBadHTimingsError) ImplementsError() {} - -func (err Xf86vidmodeBadHTimingsError) SequenceId() uint16 { - return err.Sequence -} - -func (err Xf86vidmodeBadHTimingsError) BadId() uint32 { - return 0 -} - -func (err Xf86vidmodeBadHTimingsError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadXf86vidmodeBadHTimings {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["XFree86-VidModeExtension"][1] = NewXf86vidmodeBadHTimingsError -} - -// Error definition Xf86vidmodeBadVTimings (2) -// Size: 32 - -const BadXf86vidmodeBadVTimings = 2 - -type Xf86vidmodeBadVTimingsError struct { - Sequence uint16 - NiceName string -} - -// Error read Xf86vidmodeBadVTimings -func NewXf86vidmodeBadVTimingsError(buf []byte) Error { - v := Xf86vidmodeBadVTimingsError{} - v.NiceName = "Xf86vidmodeBadVTimings" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err Xf86vidmodeBadVTimingsError) ImplementsError() {} - -func (err Xf86vidmodeBadVTimingsError) SequenceId() uint16 { - return err.Sequence -} - -func (err Xf86vidmodeBadVTimingsError) BadId() uint32 { - return 0 -} - -func (err Xf86vidmodeBadVTimingsError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadXf86vidmodeBadVTimings {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["XFree86-VidModeExtension"][2] = NewXf86vidmodeBadVTimingsError -} - -// Error definition Xf86vidmodeModeUnsuitable (3) -// Size: 32 - -const BadXf86vidmodeModeUnsuitable = 3 - -type Xf86vidmodeModeUnsuitableError struct { - Sequence uint16 - NiceName string -} - -// Error read Xf86vidmodeModeUnsuitable -func NewXf86vidmodeModeUnsuitableError(buf []byte) Error { - v := Xf86vidmodeModeUnsuitableError{} - v.NiceName = "Xf86vidmodeModeUnsuitable" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err Xf86vidmodeModeUnsuitableError) ImplementsError() {} - -func (err Xf86vidmodeModeUnsuitableError) SequenceId() uint16 { - return err.Sequence -} - -func (err Xf86vidmodeModeUnsuitableError) BadId() uint32 { - return 0 -} - -func (err Xf86vidmodeModeUnsuitableError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadXf86vidmodeModeUnsuitable {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["XFree86-VidModeExtension"][3] = NewXf86vidmodeModeUnsuitableError -} - -// Error definition Xf86vidmodeExtensionDisabled (4) -// Size: 32 - -const BadXf86vidmodeExtensionDisabled = 4 - -type Xf86vidmodeExtensionDisabledError struct { - Sequence uint16 - NiceName string -} - -// Error read Xf86vidmodeExtensionDisabled -func NewXf86vidmodeExtensionDisabledError(buf []byte) Error { - v := Xf86vidmodeExtensionDisabledError{} - v.NiceName = "Xf86vidmodeExtensionDisabled" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err Xf86vidmodeExtensionDisabledError) ImplementsError() {} - -func (err Xf86vidmodeExtensionDisabledError) SequenceId() uint16 { - return err.Sequence -} - -func (err Xf86vidmodeExtensionDisabledError) BadId() uint32 { - return 0 -} - -func (err Xf86vidmodeExtensionDisabledError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadXf86vidmodeExtensionDisabled {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["XFree86-VidModeExtension"][4] = NewXf86vidmodeExtensionDisabledError -} - -// Error definition Xf86vidmodeClientNotLocal (5) -// Size: 32 - -const BadXf86vidmodeClientNotLocal = 5 - -type Xf86vidmodeClientNotLocalError struct { - Sequence uint16 - NiceName string -} - -// Error read Xf86vidmodeClientNotLocal -func NewXf86vidmodeClientNotLocalError(buf []byte) Error { - v := Xf86vidmodeClientNotLocalError{} - v.NiceName = "Xf86vidmodeClientNotLocal" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err Xf86vidmodeClientNotLocalError) ImplementsError() {} - -func (err Xf86vidmodeClientNotLocalError) SequenceId() uint16 { - return err.Sequence -} - -func (err Xf86vidmodeClientNotLocalError) BadId() uint32 { - return 0 -} - -func (err Xf86vidmodeClientNotLocalError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadXf86vidmodeClientNotLocal {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["XFree86-VidModeExtension"][5] = NewXf86vidmodeClientNotLocalError -} - -// Error definition Xf86vidmodeZoomLocked (6) -// Size: 32 - -const BadXf86vidmodeZoomLocked = 6 - -type Xf86vidmodeZoomLockedError struct { - Sequence uint16 - NiceName string -} - -// Error read Xf86vidmodeZoomLocked -func NewXf86vidmodeZoomLockedError(buf []byte) Error { - v := Xf86vidmodeZoomLockedError{} - v.NiceName = "Xf86vidmodeZoomLocked" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err Xf86vidmodeZoomLockedError) ImplementsError() {} - -func (err Xf86vidmodeZoomLockedError) SequenceId() uint16 { - return err.Sequence -} - -func (err Xf86vidmodeZoomLockedError) BadId() uint32 { - return 0 -} - -func (err Xf86vidmodeZoomLockedError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadXf86vidmodeZoomLocked {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["XFree86-VidModeExtension"][6] = NewXf86vidmodeZoomLockedError -} - -// Request Xf86vidmodeQueryVersion -// size: 4 -type Xf86vidmodeQueryVersionCookie struct { - *cookie -} - -func (c *Conn) Xf86vidmodeQueryVersion() Xf86vidmodeQueryVersionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86vidmodeQueryVersionRequest(), cookie) - return Xf86vidmodeQueryVersionCookie{cookie} -} - -func (c *Conn) Xf86vidmodeQueryVersionUnchecked() Xf86vidmodeQueryVersionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86vidmodeQueryVersionRequest(), cookie) - return Xf86vidmodeQueryVersionCookie{cookie} -} - -// Request reply for Xf86vidmodeQueryVersion -// size: 12 -type Xf86vidmodeQueryVersionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - MajorVersion uint16 - MinorVersion uint16 -} - -// Waits and reads reply data from request Xf86vidmodeQueryVersion -func (cook Xf86vidmodeQueryVersionCookie) Reply() (*Xf86vidmodeQueryVersionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86vidmodeQueryVersionReply(buf), nil -} - -// Read reply into structure from buffer for Xf86vidmodeQueryVersion -func xf86vidmodeQueryVersionReply(buf []byte) *Xf86vidmodeQueryVersionReply { - v := new(Xf86vidmodeQueryVersionReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.MajorVersion = Get16(buf[b:]) - b += 2 - - v.MinorVersion = Get16(buf[b:]) - b += 2 - - return v -} - -func (cook Xf86vidmodeQueryVersionCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeQueryVersion -func (c *Conn) xf86vidmodeQueryVersionRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 - - buf[b] = 0 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request Xf86vidmodeGetModeLine -// size: 8 -type Xf86vidmodeGetModeLineCookie struct { - *cookie -} - -func (c *Conn) Xf86vidmodeGetModeLine(Screen uint16) Xf86vidmodeGetModeLineCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86vidmodeGetModeLineRequest(Screen), cookie) - return Xf86vidmodeGetModeLineCookie{cookie} -} - -func (c *Conn) Xf86vidmodeGetModeLineUnchecked(Screen uint16) Xf86vidmodeGetModeLineCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86vidmodeGetModeLineRequest(Screen), cookie) - return Xf86vidmodeGetModeLineCookie{cookie} -} - -// Request reply for Xf86vidmodeGetModeLine -// size: (52 + pad((int(Privsize) * 1))) -type Xf86vidmodeGetModeLineReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Dotclock Xf86vidmodeDotclock - Hdisplay uint16 - Hsyncstart uint16 - Hsyncend uint16 - Htotal uint16 - Hskew uint16 - Vdisplay uint16 - Vsyncstart uint16 - Vsyncend uint16 - Vtotal uint16 - // padding: 2 bytes - Flags uint32 - // padding: 12 bytes - Privsize uint32 - Private []byte // size: pad((int(Privsize) * 1)) -} - -// Waits and reads reply data from request Xf86vidmodeGetModeLine -func (cook Xf86vidmodeGetModeLineCookie) Reply() (*Xf86vidmodeGetModeLineReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86vidmodeGetModeLineReply(buf), nil -} - -// Read reply into structure from buffer for Xf86vidmodeGetModeLine -func xf86vidmodeGetModeLineReply(buf []byte) *Xf86vidmodeGetModeLineReply { - v := new(Xf86vidmodeGetModeLineReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Dotclock = Xf86vidmodeDotclock(Get32(buf[b:])) - b += 4 - - v.Hdisplay = Get16(buf[b:]) - b += 2 - - v.Hsyncstart = Get16(buf[b:]) - b += 2 - - v.Hsyncend = Get16(buf[b:]) - b += 2 - - v.Htotal = Get16(buf[b:]) - b += 2 - - v.Hskew = Get16(buf[b:]) - b += 2 - - v.Vdisplay = Get16(buf[b:]) - b += 2 - - v.Vsyncstart = Get16(buf[b:]) - b += 2 - - v.Vsyncend = Get16(buf[b:]) - b += 2 - - v.Vtotal = Get16(buf[b:]) - b += 2 - - b += 2 // padding - - v.Flags = Get32(buf[b:]) - b += 4 - - b += 12 // padding - - v.Privsize = Get32(buf[b:]) - b += 4 - - v.Private = make([]byte, v.Privsize) - copy(v.Private[:v.Privsize], buf[b:]) - b += pad(int(v.Privsize)) - - return v -} - -func (cook Xf86vidmodeGetModeLineCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeGetModeLine -func (c *Conn) xf86vidmodeGetModeLineRequest(Screen uint16) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 - - buf[b] = 1 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], Screen) - b += 2 - - b += 2 // padding - - return buf -} - -// Request Xf86vidmodeModModeLine -// size: pad((48 + pad((int(Privsize) * 1)))) -type Xf86vidmodeModModeLineCookie struct { - *cookie -} - -// Write request to wire for Xf86vidmodeModModeLine -func (c *Conn) Xf86vidmodeModModeLine(Screen uint32, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) Xf86vidmodeModModeLineCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xf86vidmodeModModeLineRequest(Screen, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) - return Xf86vidmodeModModeLineCookie{cookie} -} - -func (c *Conn) Xf86vidmodeModModeLineChecked(Screen uint32, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) Xf86vidmodeModModeLineCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xf86vidmodeModModeLineRequest(Screen, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) - return Xf86vidmodeModModeLineCookie{cookie} -} - -func (cook Xf86vidmodeModModeLineCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeModModeLine -func (c *Conn) xf86vidmodeModModeLineRequest(Screen uint32, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) []byte { - size := pad((48 + pad((int(Privsize) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 - - buf[b] = 2 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Screen) - b += 4 - - Put16(buf[b:], Hdisplay) - b += 2 - - Put16(buf[b:], Hsyncstart) - b += 2 - - Put16(buf[b:], Hsyncend) - b += 2 - - Put16(buf[b:], Htotal) - b += 2 - - Put16(buf[b:], Hskew) - b += 2 - - Put16(buf[b:], Vdisplay) - b += 2 - - Put16(buf[b:], Vsyncstart) - b += 2 - - Put16(buf[b:], Vsyncend) - b += 2 - - Put16(buf[b:], Vtotal) - b += 2 - - b += 2 // padding - - Put32(buf[b:], Flags) - b += 4 - - b += 12 // padding - - Put32(buf[b:], Privsize) - b += 4 - - copy(buf[b:], Private[:Privsize]) - b += pad(int(Privsize)) - - return buf -} - -// Request Xf86vidmodeSwitchMode -// size: 8 -type Xf86vidmodeSwitchModeCookie struct { - *cookie -} - -// Write request to wire for Xf86vidmodeSwitchMode -func (c *Conn) Xf86vidmodeSwitchMode(Screen uint16, Zoom uint16) Xf86vidmodeSwitchModeCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xf86vidmodeSwitchModeRequest(Screen, Zoom), cookie) - return Xf86vidmodeSwitchModeCookie{cookie} -} - -func (c *Conn) Xf86vidmodeSwitchModeChecked(Screen uint16, Zoom uint16) Xf86vidmodeSwitchModeCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xf86vidmodeSwitchModeRequest(Screen, Zoom), cookie) - return Xf86vidmodeSwitchModeCookie{cookie} -} - -func (cook Xf86vidmodeSwitchModeCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeSwitchMode -func (c *Conn) xf86vidmodeSwitchModeRequest(Screen uint16, Zoom uint16) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 - - buf[b] = 3 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], Screen) - b += 2 - - Put16(buf[b:], Zoom) - b += 2 - - return buf -} - -// Request Xf86vidmodeGetMonitor -// size: 8 -type Xf86vidmodeGetMonitorCookie struct { - *cookie -} - -func (c *Conn) Xf86vidmodeGetMonitor(Screen uint16) Xf86vidmodeGetMonitorCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86vidmodeGetMonitorRequest(Screen), cookie) - return Xf86vidmodeGetMonitorCookie{cookie} -} - -func (c *Conn) Xf86vidmodeGetMonitorUnchecked(Screen uint16) Xf86vidmodeGetMonitorCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86vidmodeGetMonitorRequest(Screen), cookie) - return Xf86vidmodeGetMonitorCookie{cookie} -} - -// Request reply for Xf86vidmodeGetMonitor -// size: (((((32 + pad((int(NumHsync) * 4))) + pad((int(NumVsync) * 4))) + pad((int(VendorLength) * 1))) + pad(((((int(VendorLength) + 3) & -4) - int(VendorLength)) * 1))) + pad((int(ModelLength) * 1))) -type Xf86vidmodeGetMonitorReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - VendorLength byte - ModelLength byte - NumHsync byte - NumVsync byte - // padding: 20 bytes - Hsync []Xf86vidmodeSyncrange // size: pad((int(NumHsync) * 4)) - Vsync []Xf86vidmodeSyncrange // size: pad((int(NumVsync) * 4)) - Vendor string // size: pad((int(VendorLength) * 1)) - AlignmentPad []byte // size: pad(((((int(VendorLength) + 3) & -4) - int(VendorLength)) * 1)) - Model string // size: pad((int(ModelLength) * 1)) -} - -// Waits and reads reply data from request Xf86vidmodeGetMonitor -func (cook Xf86vidmodeGetMonitorCookie) Reply() (*Xf86vidmodeGetMonitorReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86vidmodeGetMonitorReply(buf), nil -} - -// Read reply into structure from buffer for Xf86vidmodeGetMonitor -func xf86vidmodeGetMonitorReply(buf []byte) *Xf86vidmodeGetMonitorReply { - v := new(Xf86vidmodeGetMonitorReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.VendorLength = buf[b] - b += 1 - - v.ModelLength = buf[b] - b += 1 - - v.NumHsync = buf[b] - b += 1 - - v.NumVsync = buf[b] - b += 1 - - b += 20 // padding - - v.Hsync = make([]Xf86vidmodeSyncrange, v.NumHsync) - for i := 0; i < int(v.NumHsync); i++ { - v.Hsync[i] = Xf86vidmodeSyncrange(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - v.Vsync = make([]Xf86vidmodeSyncrange, v.NumVsync) - for i := 0; i < int(v.NumVsync); i++ { - v.Vsync[i] = Xf86vidmodeSyncrange(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - { - byteString := make([]byte, v.VendorLength) - copy(byteString[:v.VendorLength], buf[b:]) - v.Vendor = string(byteString) - b += pad(int(v.VendorLength)) - } - - v.AlignmentPad = make([]byte, (((int(v.VendorLength) + 3) & -4) - int(v.VendorLength))) - copy(v.AlignmentPad[:(((int(v.VendorLength)+3)&-4)-int(v.VendorLength))], buf[b:]) - b += pad(int((((int(v.VendorLength) + 3) & -4) - int(v.VendorLength)))) - - { - byteString := make([]byte, v.ModelLength) - copy(byteString[:v.ModelLength], buf[b:]) - v.Model = string(byteString) - b += pad(int(v.ModelLength)) - } - - return v -} - -func (cook Xf86vidmodeGetMonitorCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeGetMonitor -func (c *Conn) xf86vidmodeGetMonitorRequest(Screen uint16) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 - - buf[b] = 4 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], Screen) - b += 2 - - b += 2 // padding - - return buf -} - -// Request Xf86vidmodeLockModeSwitch -// size: 8 -type Xf86vidmodeLockModeSwitchCookie struct { - *cookie -} - -// Write request to wire for Xf86vidmodeLockModeSwitch -func (c *Conn) Xf86vidmodeLockModeSwitch(Screen uint16, Lock uint16) Xf86vidmodeLockModeSwitchCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xf86vidmodeLockModeSwitchRequest(Screen, Lock), cookie) - return Xf86vidmodeLockModeSwitchCookie{cookie} -} - -func (c *Conn) Xf86vidmodeLockModeSwitchChecked(Screen uint16, Lock uint16) Xf86vidmodeLockModeSwitchCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xf86vidmodeLockModeSwitchRequest(Screen, Lock), cookie) - return Xf86vidmodeLockModeSwitchCookie{cookie} -} - -func (cook Xf86vidmodeLockModeSwitchCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeLockModeSwitch -func (c *Conn) xf86vidmodeLockModeSwitchRequest(Screen uint16, Lock uint16) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 - - buf[b] = 5 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], Screen) - b += 2 - - Put16(buf[b:], Lock) - b += 2 - - return buf -} - -// Request Xf86vidmodeGetAllModeLines -// size: 8 -type Xf86vidmodeGetAllModeLinesCookie struct { - *cookie -} - -func (c *Conn) Xf86vidmodeGetAllModeLines(Screen uint16) Xf86vidmodeGetAllModeLinesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86vidmodeGetAllModeLinesRequest(Screen), cookie) - return Xf86vidmodeGetAllModeLinesCookie{cookie} -} - -func (c *Conn) Xf86vidmodeGetAllModeLinesUnchecked(Screen uint16) Xf86vidmodeGetAllModeLinesCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86vidmodeGetAllModeLinesRequest(Screen), cookie) - return Xf86vidmodeGetAllModeLinesCookie{cookie} -} - -// Request reply for Xf86vidmodeGetAllModeLines -// size: (32 + pad((int(Modecount) * 48))) -type Xf86vidmodeGetAllModeLinesReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Modecount uint32 - // padding: 20 bytes - Modeinfo []Xf86vidmodeModeInfo // size: pad((int(Modecount) * 48)) -} - -// Waits and reads reply data from request Xf86vidmodeGetAllModeLines -func (cook Xf86vidmodeGetAllModeLinesCookie) Reply() (*Xf86vidmodeGetAllModeLinesReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86vidmodeGetAllModeLinesReply(buf), nil -} - -// Read reply into structure from buffer for Xf86vidmodeGetAllModeLines -func xf86vidmodeGetAllModeLinesReply(buf []byte) *Xf86vidmodeGetAllModeLinesReply { - v := new(Xf86vidmodeGetAllModeLinesReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Modecount = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Modeinfo = make([]Xf86vidmodeModeInfo, v.Modecount) - b += ReadXf86vidmodeModeInfoList(buf[b:], v.Modeinfo) - - return v -} - -func (cook Xf86vidmodeGetAllModeLinesCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeGetAllModeLines -func (c *Conn) xf86vidmodeGetAllModeLinesRequest(Screen uint16) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 - - buf[b] = 6 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], Screen) - b += 2 - - b += 2 // padding - - return buf -} - -// Request Xf86vidmodeAddModeLine -// size: pad((92 + pad((int(Privsize) * 1)))) -type Xf86vidmodeAddModeLineCookie struct { - *cookie -} - -// Write request to wire for Xf86vidmodeAddModeLine -func (c *Conn) Xf86vidmodeAddModeLine(Screen uint32, Dotclock Xf86vidmodeDotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, AfterDotclock Xf86vidmodeDotclock, AfterHdisplay uint16, AfterHsyncstart uint16, AfterHsyncend uint16, AfterHtotal uint16, AfterHskew uint16, AfterVdisplay uint16, AfterVsyncstart uint16, AfterVsyncend uint16, AfterVtotal uint16, AfterFlags uint32, Private []byte) Xf86vidmodeAddModeLineCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xf86vidmodeAddModeLineRequest(Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, AfterDotclock, AfterHdisplay, AfterHsyncstart, AfterHsyncend, AfterHtotal, AfterHskew, AfterVdisplay, AfterVsyncstart, AfterVsyncend, AfterVtotal, AfterFlags, Private), cookie) - return Xf86vidmodeAddModeLineCookie{cookie} -} - -func (c *Conn) Xf86vidmodeAddModeLineChecked(Screen uint32, Dotclock Xf86vidmodeDotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, AfterDotclock Xf86vidmodeDotclock, AfterHdisplay uint16, AfterHsyncstart uint16, AfterHsyncend uint16, AfterHtotal uint16, AfterHskew uint16, AfterVdisplay uint16, AfterVsyncstart uint16, AfterVsyncend uint16, AfterVtotal uint16, AfterFlags uint32, Private []byte) Xf86vidmodeAddModeLineCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xf86vidmodeAddModeLineRequest(Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, AfterDotclock, AfterHdisplay, AfterHsyncstart, AfterHsyncend, AfterHtotal, AfterHskew, AfterVdisplay, AfterVsyncstart, AfterVsyncend, AfterVtotal, AfterFlags, Private), cookie) - return Xf86vidmodeAddModeLineCookie{cookie} -} - -func (cook Xf86vidmodeAddModeLineCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeAddModeLine -func (c *Conn) xf86vidmodeAddModeLineRequest(Screen uint32, Dotclock Xf86vidmodeDotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, AfterDotclock Xf86vidmodeDotclock, AfterHdisplay uint16, AfterHsyncstart uint16, AfterHsyncend uint16, AfterHtotal uint16, AfterHskew uint16, AfterVdisplay uint16, AfterVsyncstart uint16, AfterVsyncend uint16, AfterVtotal uint16, AfterFlags uint32, Private []byte) []byte { - size := pad((92 + pad((int(Privsize) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 - - buf[b] = 7 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Screen) - b += 4 - - Put32(buf[b:], uint32(Dotclock)) - b += 4 - - Put16(buf[b:], Hdisplay) - b += 2 - - Put16(buf[b:], Hsyncstart) - b += 2 - - Put16(buf[b:], Hsyncend) - b += 2 - - Put16(buf[b:], Htotal) - b += 2 - - Put16(buf[b:], Hskew) - b += 2 - - Put16(buf[b:], Vdisplay) - b += 2 - - Put16(buf[b:], Vsyncstart) - b += 2 - - Put16(buf[b:], Vsyncend) - b += 2 - - Put16(buf[b:], Vtotal) - b += 2 - - b += 2 // padding - - Put32(buf[b:], Flags) - b += 4 - - b += 12 // padding - - Put32(buf[b:], Privsize) - b += 4 - - Put32(buf[b:], uint32(AfterDotclock)) - b += 4 - - Put16(buf[b:], AfterHdisplay) - b += 2 - - Put16(buf[b:], AfterHsyncstart) - b += 2 - - Put16(buf[b:], AfterHsyncend) - b += 2 - - Put16(buf[b:], AfterHtotal) - b += 2 - - Put16(buf[b:], AfterHskew) - b += 2 - - Put16(buf[b:], AfterVdisplay) - b += 2 - - Put16(buf[b:], AfterVsyncstart) - b += 2 - - Put16(buf[b:], AfterVsyncend) - b += 2 - - Put16(buf[b:], AfterVtotal) - b += 2 - - b += 2 // padding - - Put32(buf[b:], AfterFlags) - b += 4 - - b += 12 // padding - - copy(buf[b:], Private[:Privsize]) - b += pad(int(Privsize)) - - return buf -} - -// Request Xf86vidmodeDeleteModeLine -// size: pad((52 + pad((int(Privsize) * 1)))) -type Xf86vidmodeDeleteModeLineCookie struct { - *cookie -} - -// Write request to wire for Xf86vidmodeDeleteModeLine -func (c *Conn) Xf86vidmodeDeleteModeLine(Screen uint32, Dotclock Xf86vidmodeDotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) Xf86vidmodeDeleteModeLineCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xf86vidmodeDeleteModeLineRequest(Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) - return Xf86vidmodeDeleteModeLineCookie{cookie} -} - -func (c *Conn) Xf86vidmodeDeleteModeLineChecked(Screen uint32, Dotclock Xf86vidmodeDotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) Xf86vidmodeDeleteModeLineCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xf86vidmodeDeleteModeLineRequest(Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) - return Xf86vidmodeDeleteModeLineCookie{cookie} -} - -func (cook Xf86vidmodeDeleteModeLineCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeDeleteModeLine -func (c *Conn) xf86vidmodeDeleteModeLineRequest(Screen uint32, Dotclock Xf86vidmodeDotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) []byte { - size := pad((52 + pad((int(Privsize) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 - - buf[b] = 8 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Screen) - b += 4 - - Put32(buf[b:], uint32(Dotclock)) - b += 4 - - Put16(buf[b:], Hdisplay) - b += 2 - - Put16(buf[b:], Hsyncstart) - b += 2 - - Put16(buf[b:], Hsyncend) - b += 2 - - Put16(buf[b:], Htotal) - b += 2 - - Put16(buf[b:], Hskew) - b += 2 - - Put16(buf[b:], Vdisplay) - b += 2 - - Put16(buf[b:], Vsyncstart) - b += 2 - - Put16(buf[b:], Vsyncend) - b += 2 - - Put16(buf[b:], Vtotal) - b += 2 - - b += 2 // padding - - Put32(buf[b:], Flags) - b += 4 - - b += 12 // padding - - Put32(buf[b:], Privsize) - b += 4 - - copy(buf[b:], Private[:Privsize]) - b += pad(int(Privsize)) - - return buf -} - -// Request Xf86vidmodeValidateModeLine -// size: pad((52 + pad((int(Privsize) * 1)))) -type Xf86vidmodeValidateModeLineCookie struct { - *cookie -} - -func (c *Conn) Xf86vidmodeValidateModeLine(Screen uint32, Dotclock Xf86vidmodeDotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) Xf86vidmodeValidateModeLineCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86vidmodeValidateModeLineRequest(Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) - return Xf86vidmodeValidateModeLineCookie{cookie} -} - -func (c *Conn) Xf86vidmodeValidateModeLineUnchecked(Screen uint32, Dotclock Xf86vidmodeDotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) Xf86vidmodeValidateModeLineCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86vidmodeValidateModeLineRequest(Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) - return Xf86vidmodeValidateModeLineCookie{cookie} -} - -// Request reply for Xf86vidmodeValidateModeLine -// size: 32 -type Xf86vidmodeValidateModeLineReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Status uint32 - // padding: 20 bytes -} - -// Waits and reads reply data from request Xf86vidmodeValidateModeLine -func (cook Xf86vidmodeValidateModeLineCookie) Reply() (*Xf86vidmodeValidateModeLineReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86vidmodeValidateModeLineReply(buf), nil -} - -// Read reply into structure from buffer for Xf86vidmodeValidateModeLine -func xf86vidmodeValidateModeLineReply(buf []byte) *Xf86vidmodeValidateModeLineReply { - v := new(Xf86vidmodeValidateModeLineReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Status = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - return v -} - -func (cook Xf86vidmodeValidateModeLineCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeValidateModeLine -func (c *Conn) xf86vidmodeValidateModeLineRequest(Screen uint32, Dotclock Xf86vidmodeDotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) []byte { - size := pad((52 + pad((int(Privsize) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 - - buf[b] = 9 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Screen) - b += 4 - - Put32(buf[b:], uint32(Dotclock)) - b += 4 - - Put16(buf[b:], Hdisplay) - b += 2 - - Put16(buf[b:], Hsyncstart) - b += 2 - - Put16(buf[b:], Hsyncend) - b += 2 - - Put16(buf[b:], Htotal) - b += 2 - - Put16(buf[b:], Hskew) - b += 2 - - Put16(buf[b:], Vdisplay) - b += 2 - - Put16(buf[b:], Vsyncstart) - b += 2 - - Put16(buf[b:], Vsyncend) - b += 2 - - Put16(buf[b:], Vtotal) - b += 2 - - b += 2 // padding - - Put32(buf[b:], Flags) - b += 4 - - b += 12 // padding - - Put32(buf[b:], Privsize) - b += 4 - - copy(buf[b:], Private[:Privsize]) - b += pad(int(Privsize)) - - return buf -} - -// Request Xf86vidmodeSwitchToMode -// size: pad((52 + pad((int(Privsize) * 1)))) -type Xf86vidmodeSwitchToModeCookie struct { - *cookie -} - -// Write request to wire for Xf86vidmodeSwitchToMode -func (c *Conn) Xf86vidmodeSwitchToMode(Screen uint32, Dotclock Xf86vidmodeDotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) Xf86vidmodeSwitchToModeCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xf86vidmodeSwitchToModeRequest(Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) - return Xf86vidmodeSwitchToModeCookie{cookie} -} - -func (c *Conn) Xf86vidmodeSwitchToModeChecked(Screen uint32, Dotclock Xf86vidmodeDotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) Xf86vidmodeSwitchToModeCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xf86vidmodeSwitchToModeRequest(Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) - return Xf86vidmodeSwitchToModeCookie{cookie} -} - -func (cook Xf86vidmodeSwitchToModeCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeSwitchToMode -func (c *Conn) xf86vidmodeSwitchToModeRequest(Screen uint32, Dotclock Xf86vidmodeDotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) []byte { - size := pad((52 + pad((int(Privsize) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 - - buf[b] = 10 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Screen) - b += 4 - - Put32(buf[b:], uint32(Dotclock)) - b += 4 - - Put16(buf[b:], Hdisplay) - b += 2 - - Put16(buf[b:], Hsyncstart) - b += 2 - - Put16(buf[b:], Hsyncend) - b += 2 - - Put16(buf[b:], Htotal) - b += 2 - - Put16(buf[b:], Hskew) - b += 2 - - Put16(buf[b:], Vdisplay) - b += 2 - - Put16(buf[b:], Vsyncstart) - b += 2 - - Put16(buf[b:], Vsyncend) - b += 2 - - Put16(buf[b:], Vtotal) - b += 2 - - b += 2 // padding - - Put32(buf[b:], Flags) - b += 4 - - b += 12 // padding - - Put32(buf[b:], Privsize) - b += 4 - - copy(buf[b:], Private[:Privsize]) - b += pad(int(Privsize)) - - return buf -} - -// Request Xf86vidmodeGetViewPort -// size: 8 -type Xf86vidmodeGetViewPortCookie struct { - *cookie -} - -func (c *Conn) Xf86vidmodeGetViewPort(Screen uint16) Xf86vidmodeGetViewPortCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86vidmodeGetViewPortRequest(Screen), cookie) - return Xf86vidmodeGetViewPortCookie{cookie} -} - -func (c *Conn) Xf86vidmodeGetViewPortUnchecked(Screen uint16) Xf86vidmodeGetViewPortCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86vidmodeGetViewPortRequest(Screen), cookie) - return Xf86vidmodeGetViewPortCookie{cookie} -} - -// Request reply for Xf86vidmodeGetViewPort -// size: 32 -type Xf86vidmodeGetViewPortReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - X uint32 - Y uint32 - // padding: 16 bytes -} - -// Waits and reads reply data from request Xf86vidmodeGetViewPort -func (cook Xf86vidmodeGetViewPortCookie) Reply() (*Xf86vidmodeGetViewPortReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86vidmodeGetViewPortReply(buf), nil -} - -// Read reply into structure from buffer for Xf86vidmodeGetViewPort -func xf86vidmodeGetViewPortReply(buf []byte) *Xf86vidmodeGetViewPortReply { - v := new(Xf86vidmodeGetViewPortReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.X = Get32(buf[b:]) - b += 4 - - v.Y = Get32(buf[b:]) - b += 4 - - b += 16 // padding - - return v -} - -func (cook Xf86vidmodeGetViewPortCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeGetViewPort -func (c *Conn) xf86vidmodeGetViewPortRequest(Screen uint16) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 - - buf[b] = 11 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], Screen) - b += 2 - - b += 2 // padding - - return buf -} - -// Request Xf86vidmodeSetViewPort -// size: 16 -type Xf86vidmodeSetViewPortCookie struct { - *cookie -} - -// Write request to wire for Xf86vidmodeSetViewPort -func (c *Conn) Xf86vidmodeSetViewPort(Screen uint16, X uint32, Y uint32) Xf86vidmodeSetViewPortCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xf86vidmodeSetViewPortRequest(Screen, X, Y), cookie) - return Xf86vidmodeSetViewPortCookie{cookie} -} - -func (c *Conn) Xf86vidmodeSetViewPortChecked(Screen uint16, X uint32, Y uint32) Xf86vidmodeSetViewPortCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xf86vidmodeSetViewPortRequest(Screen, X, Y), cookie) - return Xf86vidmodeSetViewPortCookie{cookie} -} - -func (cook Xf86vidmodeSetViewPortCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeSetViewPort -func (c *Conn) xf86vidmodeSetViewPortRequest(Screen uint16, X uint32, Y uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 - - buf[b] = 12 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], Screen) - b += 2 - - b += 2 // padding - - Put32(buf[b:], X) - b += 4 - - Put32(buf[b:], Y) - b += 4 - - return buf -} - -// Request Xf86vidmodeGetDotClocks -// size: 8 -type Xf86vidmodeGetDotClocksCookie struct { - *cookie -} - -func (c *Conn) Xf86vidmodeGetDotClocks(Screen uint16) Xf86vidmodeGetDotClocksCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86vidmodeGetDotClocksRequest(Screen), cookie) - return Xf86vidmodeGetDotClocksCookie{cookie} -} - -func (c *Conn) Xf86vidmodeGetDotClocksUnchecked(Screen uint16) Xf86vidmodeGetDotClocksCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86vidmodeGetDotClocksRequest(Screen), cookie) - return Xf86vidmodeGetDotClocksCookie{cookie} -} - -// Request reply for Xf86vidmodeGetDotClocks -// size: (32 + pad((((1 - (int(Flags) & 1)) * int(Clocks)) * 4))) -type Xf86vidmodeGetDotClocksReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Flags uint32 - Clocks uint32 - Maxclocks uint32 - // padding: 12 bytes - Clock []uint32 // size: pad((((1 - (int(Flags) & 1)) * int(Clocks)) * 4)) -} - -// Waits and reads reply data from request Xf86vidmodeGetDotClocks -func (cook Xf86vidmodeGetDotClocksCookie) Reply() (*Xf86vidmodeGetDotClocksReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86vidmodeGetDotClocksReply(buf), nil -} - -// Read reply into structure from buffer for Xf86vidmodeGetDotClocks -func xf86vidmodeGetDotClocksReply(buf []byte) *Xf86vidmodeGetDotClocksReply { - v := new(Xf86vidmodeGetDotClocksReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Flags = Get32(buf[b:]) - b += 4 - - v.Clocks = Get32(buf[b:]) - b += 4 - - v.Maxclocks = Get32(buf[b:]) - b += 4 - - b += 12 // padding - - v.Clock = make([]uint32, ((1 - (int(v.Flags) & 1)) * int(v.Clocks))) - for i := 0; i < int(((1 - (int(v.Flags) & 1)) * int(v.Clocks))); i++ { - v.Clock[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook Xf86vidmodeGetDotClocksCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeGetDotClocks -func (c *Conn) xf86vidmodeGetDotClocksRequest(Screen uint16) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 - - buf[b] = 13 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], Screen) - b += 2 - - b += 2 // padding - - return buf -} - -// Request Xf86vidmodeSetClientVersion -// size: 8 -type Xf86vidmodeSetClientVersionCookie struct { - *cookie -} - -// Write request to wire for Xf86vidmodeSetClientVersion -func (c *Conn) Xf86vidmodeSetClientVersion(Major uint16, Minor uint16) Xf86vidmodeSetClientVersionCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xf86vidmodeSetClientVersionRequest(Major, Minor), cookie) - return Xf86vidmodeSetClientVersionCookie{cookie} -} - -func (c *Conn) Xf86vidmodeSetClientVersionChecked(Major uint16, Minor uint16) Xf86vidmodeSetClientVersionCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xf86vidmodeSetClientVersionRequest(Major, Minor), cookie) - return Xf86vidmodeSetClientVersionCookie{cookie} -} - -func (cook Xf86vidmodeSetClientVersionCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeSetClientVersion -func (c *Conn) xf86vidmodeSetClientVersionRequest(Major uint16, Minor uint16) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 - - buf[b] = 14 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], Major) - b += 2 - - Put16(buf[b:], Minor) - b += 2 - - return buf -} - -// Request Xf86vidmodeSetGamma -// size: 32 -type Xf86vidmodeSetGammaCookie struct { - *cookie -} - -// Write request to wire for Xf86vidmodeSetGamma -func (c *Conn) Xf86vidmodeSetGamma(Screen uint16, Red uint32, Green uint32, Blue uint32) Xf86vidmodeSetGammaCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xf86vidmodeSetGammaRequest(Screen, Red, Green, Blue), cookie) - return Xf86vidmodeSetGammaCookie{cookie} -} - -func (c *Conn) Xf86vidmodeSetGammaChecked(Screen uint16, Red uint32, Green uint32, Blue uint32) Xf86vidmodeSetGammaCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xf86vidmodeSetGammaRequest(Screen, Red, Green, Blue), cookie) - return Xf86vidmodeSetGammaCookie{cookie} -} - -func (cook Xf86vidmodeSetGammaCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeSetGamma -func (c *Conn) xf86vidmodeSetGammaRequest(Screen uint16, Red uint32, Green uint32, Blue uint32) []byte { - size := 32 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 - - buf[b] = 15 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], Screen) - b += 2 - - b += 2 // padding - - Put32(buf[b:], Red) - b += 4 - - Put32(buf[b:], Green) - b += 4 - - Put32(buf[b:], Blue) - b += 4 - - b += 12 // padding - - return buf -} - -// Request Xf86vidmodeGetGamma -// size: 32 -type Xf86vidmodeGetGammaCookie struct { - *cookie -} - -func (c *Conn) Xf86vidmodeGetGamma(Screen uint16) Xf86vidmodeGetGammaCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86vidmodeGetGammaRequest(Screen), cookie) - return Xf86vidmodeGetGammaCookie{cookie} -} - -func (c *Conn) Xf86vidmodeGetGammaUnchecked(Screen uint16) Xf86vidmodeGetGammaCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86vidmodeGetGammaRequest(Screen), cookie) - return Xf86vidmodeGetGammaCookie{cookie} -} - -// Request reply for Xf86vidmodeGetGamma -// size: 32 -type Xf86vidmodeGetGammaReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Red uint32 - Green uint32 - Blue uint32 - // padding: 12 bytes -} - -// Waits and reads reply data from request Xf86vidmodeGetGamma -func (cook Xf86vidmodeGetGammaCookie) Reply() (*Xf86vidmodeGetGammaReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86vidmodeGetGammaReply(buf), nil -} - -// Read reply into structure from buffer for Xf86vidmodeGetGamma -func xf86vidmodeGetGammaReply(buf []byte) *Xf86vidmodeGetGammaReply { - v := new(Xf86vidmodeGetGammaReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Red = Get32(buf[b:]) - b += 4 - - v.Green = Get32(buf[b:]) - b += 4 - - v.Blue = Get32(buf[b:]) - b += 4 - - b += 12 // padding - - return v -} - -func (cook Xf86vidmodeGetGammaCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeGetGamma -func (c *Conn) xf86vidmodeGetGammaRequest(Screen uint16) []byte { - size := 32 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 - - buf[b] = 16 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], Screen) - b += 2 - - b += 26 // padding - - return buf -} - -// Request Xf86vidmodeGetGammaRamp -// size: 8 -type Xf86vidmodeGetGammaRampCookie struct { - *cookie -} - -func (c *Conn) Xf86vidmodeGetGammaRamp(Screen uint16, Size uint16) Xf86vidmodeGetGammaRampCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86vidmodeGetGammaRampRequest(Screen, Size), cookie) - return Xf86vidmodeGetGammaRampCookie{cookie} -} - -func (c *Conn) Xf86vidmodeGetGammaRampUnchecked(Screen uint16, Size uint16) Xf86vidmodeGetGammaRampCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86vidmodeGetGammaRampRequest(Screen, Size), cookie) - return Xf86vidmodeGetGammaRampCookie{cookie} -} - -// Request reply for Xf86vidmodeGetGammaRamp -// size: (((32 + pad((((int(Size) + 1) & -2) * 2))) + pad((((int(Size) + 1) & -2) * 2))) + pad((((int(Size) + 1) & -2) * 2))) -type Xf86vidmodeGetGammaRampReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Size uint16 - // padding: 22 bytes - Red []uint16 // size: pad((((int(Size) + 1) & -2) * 2)) - Green []uint16 // size: pad((((int(Size) + 1) & -2) * 2)) - Blue []uint16 // size: pad((((int(Size) + 1) & -2) * 2)) -} - -// Waits and reads reply data from request Xf86vidmodeGetGammaRamp -func (cook Xf86vidmodeGetGammaRampCookie) Reply() (*Xf86vidmodeGetGammaRampReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86vidmodeGetGammaRampReply(buf), nil -} - -// Read reply into structure from buffer for Xf86vidmodeGetGammaRamp -func xf86vidmodeGetGammaRampReply(buf []byte) *Xf86vidmodeGetGammaRampReply { - v := new(Xf86vidmodeGetGammaRampReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Size = Get16(buf[b:]) - b += 2 - - b += 22 // padding - - v.Red = make([]uint16, ((int(v.Size) + 1) & -2)) - for i := 0; i < int(((int(v.Size) + 1) & -2)); i++ { - v.Red[i] = Get16(buf[b:]) - b += 2 - } - b = pad(b) - - v.Green = make([]uint16, ((int(v.Size) + 1) & -2)) - for i := 0; i < int(((int(v.Size) + 1) & -2)); i++ { - v.Green[i] = Get16(buf[b:]) - b += 2 - } - b = pad(b) - - v.Blue = make([]uint16, ((int(v.Size) + 1) & -2)) - for i := 0; i < int(((int(v.Size) + 1) & -2)); i++ { - v.Blue[i] = Get16(buf[b:]) - b += 2 - } - b = pad(b) - - return v -} - -func (cook Xf86vidmodeGetGammaRampCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeGetGammaRamp -func (c *Conn) xf86vidmodeGetGammaRampRequest(Screen uint16, Size uint16) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 - - buf[b] = 17 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], Screen) - b += 2 - - Put16(buf[b:], Size) - b += 2 - - return buf -} - -// Request Xf86vidmodeSetGammaRamp -// size: pad((((8 + pad((((int(Size) + 1) & -2) * 2))) + pad((((int(Size) + 1) & -2) * 2))) + pad((((int(Size) + 1) & -2) * 2)))) -type Xf86vidmodeSetGammaRampCookie struct { - *cookie -} - -// Write request to wire for Xf86vidmodeSetGammaRamp -func (c *Conn) Xf86vidmodeSetGammaRamp(Screen uint16, Size uint16, Red []uint16, Green []uint16, Blue []uint16) Xf86vidmodeSetGammaRampCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xf86vidmodeSetGammaRampRequest(Screen, Size, Red, Green, Blue), cookie) - return Xf86vidmodeSetGammaRampCookie{cookie} -} - -func (c *Conn) Xf86vidmodeSetGammaRampChecked(Screen uint16, Size uint16, Red []uint16, Green []uint16, Blue []uint16) Xf86vidmodeSetGammaRampCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xf86vidmodeSetGammaRampRequest(Screen, Size, Red, Green, Blue), cookie) - return Xf86vidmodeSetGammaRampCookie{cookie} -} - -func (cook Xf86vidmodeSetGammaRampCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeSetGammaRamp -func (c *Conn) xf86vidmodeSetGammaRampRequest(Screen uint16, Size uint16, Red []uint16, Green []uint16, Blue []uint16) []byte { - size := pad((((8 + pad((((int(Size) + 1) & -2) * 2))) + pad((((int(Size) + 1) & -2) * 2))) + pad((((int(Size) + 1) & -2) * 2)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 - - buf[b] = 18 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], Screen) - b += 2 - - Put16(buf[b:], Size) - b += 2 - - for i := 0; i < int(((int(Size) + 1) & -2)); i++ { - Put16(buf[b:], Red[i]) - b += 2 - } - b = pad(b) - - for i := 0; i < int(((int(Size) + 1) & -2)); i++ { - Put16(buf[b:], Green[i]) - b += 2 - } - b = pad(b) - - for i := 0; i < int(((int(Size) + 1) & -2)); i++ { - Put16(buf[b:], Blue[i]) - b += 2 - } - b = pad(b) - - return buf -} - -// Request Xf86vidmodeGetGammaRampSize -// size: 8 -type Xf86vidmodeGetGammaRampSizeCookie struct { - *cookie -} - -func (c *Conn) Xf86vidmodeGetGammaRampSize(Screen uint16) Xf86vidmodeGetGammaRampSizeCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86vidmodeGetGammaRampSizeRequest(Screen), cookie) - return Xf86vidmodeGetGammaRampSizeCookie{cookie} -} - -func (c *Conn) Xf86vidmodeGetGammaRampSizeUnchecked(Screen uint16) Xf86vidmodeGetGammaRampSizeCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86vidmodeGetGammaRampSizeRequest(Screen), cookie) - return Xf86vidmodeGetGammaRampSizeCookie{cookie} -} - -// Request reply for Xf86vidmodeGetGammaRampSize -// size: 32 -type Xf86vidmodeGetGammaRampSizeReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Size uint16 - // padding: 22 bytes -} - -// Waits and reads reply data from request Xf86vidmodeGetGammaRampSize -func (cook Xf86vidmodeGetGammaRampSizeCookie) Reply() (*Xf86vidmodeGetGammaRampSizeReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86vidmodeGetGammaRampSizeReply(buf), nil -} - -// Read reply into structure from buffer for Xf86vidmodeGetGammaRampSize -func xf86vidmodeGetGammaRampSizeReply(buf []byte) *Xf86vidmodeGetGammaRampSizeReply { - v := new(Xf86vidmodeGetGammaRampSizeReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Size = Get16(buf[b:]) - b += 2 - - b += 22 // padding - - return v -} - -func (cook Xf86vidmodeGetGammaRampSizeCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeGetGammaRampSize -func (c *Conn) xf86vidmodeGetGammaRampSizeRequest(Screen uint16) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 - - buf[b] = 19 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], Screen) - b += 2 - - b += 2 // padding - - return buf -} - -// Request Xf86vidmodeGetPermissions -// size: 8 -type Xf86vidmodeGetPermissionsCookie struct { - *cookie -} - -func (c *Conn) Xf86vidmodeGetPermissions(Screen uint16) Xf86vidmodeGetPermissionsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xf86vidmodeGetPermissionsRequest(Screen), cookie) - return Xf86vidmodeGetPermissionsCookie{cookie} -} - -func (c *Conn) Xf86vidmodeGetPermissionsUnchecked(Screen uint16) Xf86vidmodeGetPermissionsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xf86vidmodeGetPermissionsRequest(Screen), cookie) - return Xf86vidmodeGetPermissionsCookie{cookie} -} - -// Request reply for Xf86vidmodeGetPermissions -// size: 32 -type Xf86vidmodeGetPermissionsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Permissions uint32 - // padding: 20 bytes -} - -// Waits and reads reply data from request Xf86vidmodeGetPermissions -func (cook Xf86vidmodeGetPermissionsCookie) Reply() (*Xf86vidmodeGetPermissionsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xf86vidmodeGetPermissionsReply(buf), nil -} - -// Read reply into structure from buffer for Xf86vidmodeGetPermissions -func xf86vidmodeGetPermissionsReply(buf []byte) *Xf86vidmodeGetPermissionsReply { - v := new(Xf86vidmodeGetPermissionsReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Permissions = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - return v -} - -func (cook Xf86vidmodeGetPermissionsCookie) Check() error { - return cook.check() -} - -// Write request to wire for Xf86vidmodeGetPermissions -func (c *Conn) xf86vidmodeGetPermissionsRequest(Screen uint16) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFREE86-VIDMODEEXTENSION"] - b += 1 - - buf[b] = 20 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], Screen) - b += 2 - - b += 2 // padding - - return buf -} diff --git a/nexgb/auto_xfixes.go b/nexgb/auto_xfixes.go deleted file mode 100644 index 9284f6b..0000000 --- a/nexgb/auto_xfixes.go +++ /dev/null @@ -1,2173 +0,0 @@ -package xgb - -/* - This file was generated by xfixes.xml on May 10 2012 12:39:34pm EDT. - This file is automatically generated. Edit at your peril! -*/ - -// Imports are not necessary for XGB because everything is -// in one package. They are still listed here for reference. -// import "xproto" -// import "render" -// import "shape" - -// XfixesInit must be called before using the XFIXES extension. -func (c *Conn) XfixesInit() error { - reply, err := c.QueryExtension(6, "XFIXES").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named XFIXES could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["XFIXES"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["XFIXES"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["XFIXES"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["XFIXES"] = make(map[int]newEventFun) - newExtErrorFuncs["XFIXES"] = make(map[int]newErrorFun) -} - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - -// Skipping definition for base type 'Int8' - -// Skipping definition for base type 'Card16' - -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - -// Skipping definition for base type 'Float' - -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -const ( - XfixesSaveSetModeInsert = 0 - XfixesSaveSetModeDelete = 1 -) - -const ( - XfixesSaveSetTargetNearest = 0 - XfixesSaveSetTargetRoot = 1 -) - -const ( - XfixesSaveSetMappingMap = 0 - XfixesSaveSetMappingUnmap = 1 -) - -const ( - XfixesSelectionEventSetSelectionOwner = 0 - XfixesSelectionEventSelectionWindowDestroy = 1 - XfixesSelectionEventSelectionClientClose = 2 -) - -const ( - XfixesSelectionEventMaskSetSelectionOwner = 1 - XfixesSelectionEventMaskSelectionWindowDestroy = 2 - XfixesSelectionEventMaskSelectionClientClose = 4 -) - -const ( - XfixesCursorNotifyDisplayCursor = 0 -) - -const ( - XfixesCursorNotifyMaskDisplayCursor = 1 -) - -const ( - XfixesRegionNone = 0 -) - -type XfixesRegion uint32 - -func (c *Conn) NewXfixesRegionId() (XfixesRegion, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return XfixesRegion(id), nil -} - -// Event definition XfixesSelectionNotify (0) -// Size: 32 - -const XfixesSelectionNotify = 0 - -type XfixesSelectionNotifyEvent struct { - Sequence uint16 - Subtype byte - Window Window - Owner Window - Selection Atom - Timestamp Timestamp - SelectionTimestamp Timestamp - // padding: 8 bytes -} - -// Event read XfixesSelectionNotify -func NewXfixesSelectionNotifyEvent(buf []byte) Event { - v := XfixesSelectionNotifyEvent{} - b := 1 // don't read event number - - v.Subtype = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - v.Owner = Window(Get32(buf[b:])) - b += 4 - - v.Selection = Atom(Get32(buf[b:])) - b += 4 - - v.Timestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.SelectionTimestamp = Timestamp(Get32(buf[b:])) - b += 4 - - b += 8 // padding - - return v -} - -// Event write XfixesSelectionNotify -func (v XfixesSelectionNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 0 - b += 1 - - buf[b] = v.Subtype - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - Put32(buf[b:], uint32(v.Owner)) - b += 4 - - Put32(buf[b:], uint32(v.Selection)) - b += 4 - - Put32(buf[b:], uint32(v.Timestamp)) - b += 4 - - Put32(buf[b:], uint32(v.SelectionTimestamp)) - b += 4 - - b += 8 // padding - - return buf -} - -func (v XfixesSelectionNotifyEvent) ImplementsEvent() {} - -func (v XfixesSelectionNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XfixesSelectionNotifyEvent) String() string { - fieldVals := make([]string, 0, 7) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Subtype: %d", v.Subtype)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, sprintf("Owner: %d", v.Owner)) - fieldVals = append(fieldVals, sprintf("Selection: %d", v.Selection)) - fieldVals = append(fieldVals, sprintf("Timestamp: %d", v.Timestamp)) - fieldVals = append(fieldVals, sprintf("SelectionTimestamp: %d", v.SelectionTimestamp)) - return "XfixesSelectionNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XFIXES"][0] = NewXfixesSelectionNotifyEvent -} - -// Event definition XfixesCursorNotify (1) -// Size: 32 - -const XfixesCursorNotify = 1 - -type XfixesCursorNotifyEvent struct { - Sequence uint16 - Subtype byte - Window Window - CursorSerial uint32 - Timestamp Timestamp - Name Atom - // padding: 12 bytes -} - -// Event read XfixesCursorNotify -func NewXfixesCursorNotifyEvent(buf []byte) Event { - v := XfixesCursorNotifyEvent{} - b := 1 // don't read event number - - v.Subtype = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - v.CursorSerial = Get32(buf[b:]) - b += 4 - - v.Timestamp = Timestamp(Get32(buf[b:])) - b += 4 - - v.Name = Atom(Get32(buf[b:])) - b += 4 - - b += 12 // padding - - return v -} - -// Event write XfixesCursorNotify -func (v XfixesCursorNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 1 - b += 1 - - buf[b] = v.Subtype - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - Put32(buf[b:], v.CursorSerial) - b += 4 - - Put32(buf[b:], uint32(v.Timestamp)) - b += 4 - - Put32(buf[b:], uint32(v.Name)) - b += 4 - - b += 12 // padding - - return buf -} - -func (v XfixesCursorNotifyEvent) ImplementsEvent() {} - -func (v XfixesCursorNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XfixesCursorNotifyEvent) String() string { - fieldVals := make([]string, 0, 6) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Subtype: %d", v.Subtype)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, sprintf("CursorSerial: %d", v.CursorSerial)) - fieldVals = append(fieldVals, sprintf("Timestamp: %d", v.Timestamp)) - fieldVals = append(fieldVals, sprintf("Name: %d", v.Name)) - return "XfixesCursorNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XFIXES"][1] = NewXfixesCursorNotifyEvent -} - -// Error definition XfixesBadRegion (0) -// Size: 32 - -const BadXfixesBadRegion = 0 - -type XfixesBadRegionError struct { - Sequence uint16 - NiceName string -} - -// Error read XfixesBadRegion -func NewXfixesBadRegionError(buf []byte) Error { - v := XfixesBadRegionError{} - v.NiceName = "XfixesBadRegion" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err XfixesBadRegionError) ImplementsError() {} - -func (err XfixesBadRegionError) SequenceId() uint16 { - return err.Sequence -} - -func (err XfixesBadRegionError) BadId() uint32 { - return 0 -} - -func (err XfixesBadRegionError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadXfixesBadRegion {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["XFIXES"][0] = NewXfixesBadRegionError -} - -// Request XfixesQueryVersion -// size: 12 -type XfixesQueryVersionCookie struct { - *cookie -} - -func (c *Conn) XfixesQueryVersion(ClientMajorVersion uint32, ClientMinorVersion uint32) XfixesQueryVersionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xfixesQueryVersionRequest(ClientMajorVersion, ClientMinorVersion), cookie) - return XfixesQueryVersionCookie{cookie} -} - -func (c *Conn) XfixesQueryVersionUnchecked(ClientMajorVersion uint32, ClientMinorVersion uint32) XfixesQueryVersionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xfixesQueryVersionRequest(ClientMajorVersion, ClientMinorVersion), cookie) - return XfixesQueryVersionCookie{cookie} -} - -// Request reply for XfixesQueryVersion -// size: 32 -type XfixesQueryVersionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - MajorVersion uint32 - MinorVersion uint32 - // padding: 16 bytes -} - -// Waits and reads reply data from request XfixesQueryVersion -func (cook XfixesQueryVersionCookie) Reply() (*XfixesQueryVersionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xfixesQueryVersionReply(buf), nil -} - -// Read reply into structure from buffer for XfixesQueryVersion -func xfixesQueryVersionReply(buf []byte) *XfixesQueryVersionReply { - v := new(XfixesQueryVersionReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.MajorVersion = Get32(buf[b:]) - b += 4 - - v.MinorVersion = Get32(buf[b:]) - b += 4 - - b += 16 // padding - - return v -} - -func (cook XfixesQueryVersionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesQueryVersion -func (c *Conn) xfixesQueryVersionRequest(ClientMajorVersion uint32, ClientMinorVersion uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 0 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], ClientMajorVersion) - b += 4 - - Put32(buf[b:], ClientMinorVersion) - b += 4 - - return buf -} - -// Request XfixesChangeSaveSet -// size: 12 -type XfixesChangeSaveSetCookie struct { - *cookie -} - -// Write request to wire for XfixesChangeSaveSet -func (c *Conn) XfixesChangeSaveSet(Mode byte, Target byte, Map byte, Window Window) XfixesChangeSaveSetCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesChangeSaveSetRequest(Mode, Target, Map, Window), cookie) - return XfixesChangeSaveSetCookie{cookie} -} - -func (c *Conn) XfixesChangeSaveSetChecked(Mode byte, Target byte, Map byte, Window Window) XfixesChangeSaveSetCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesChangeSaveSetRequest(Mode, Target, Map, Window), cookie) - return XfixesChangeSaveSetCookie{cookie} -} - -func (cook XfixesChangeSaveSetCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesChangeSaveSet -func (c *Conn) xfixesChangeSaveSetRequest(Mode byte, Target byte, Map byte, Window Window) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 1 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = Mode - b += 1 - - buf[b] = Target - b += 1 - - buf[b] = Map - b += 1 - - b += 1 // padding - - Put32(buf[b:], uint32(Window)) - b += 4 - - return buf -} - -// Request XfixesSelectSelectionInput -// size: 16 -type XfixesSelectSelectionInputCookie struct { - *cookie -} - -// Write request to wire for XfixesSelectSelectionInput -func (c *Conn) XfixesSelectSelectionInput(Window Window, Selection Atom, EventMask uint32) XfixesSelectSelectionInputCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesSelectSelectionInputRequest(Window, Selection, EventMask), cookie) - return XfixesSelectSelectionInputCookie{cookie} -} - -func (c *Conn) XfixesSelectSelectionInputChecked(Window Window, Selection Atom, EventMask uint32) XfixesSelectSelectionInputCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesSelectSelectionInputRequest(Window, Selection, EventMask), cookie) - return XfixesSelectSelectionInputCookie{cookie} -} - -func (cook XfixesSelectSelectionInputCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesSelectSelectionInput -func (c *Conn) xfixesSelectSelectionInputRequest(Window Window, Selection Atom, EventMask uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 2 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - Put32(buf[b:], uint32(Selection)) - b += 4 - - Put32(buf[b:], EventMask) - b += 4 - - return buf -} - -// Request XfixesSelectCursorInput -// size: 12 -type XfixesSelectCursorInputCookie struct { - *cookie -} - -// Write request to wire for XfixesSelectCursorInput -func (c *Conn) XfixesSelectCursorInput(Window Window, EventMask uint32) XfixesSelectCursorInputCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesSelectCursorInputRequest(Window, EventMask), cookie) - return XfixesSelectCursorInputCookie{cookie} -} - -func (c *Conn) XfixesSelectCursorInputChecked(Window Window, EventMask uint32) XfixesSelectCursorInputCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesSelectCursorInputRequest(Window, EventMask), cookie) - return XfixesSelectCursorInputCookie{cookie} -} - -func (cook XfixesSelectCursorInputCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesSelectCursorInput -func (c *Conn) xfixesSelectCursorInputRequest(Window Window, EventMask uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 3 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - Put32(buf[b:], EventMask) - b += 4 - - return buf -} - -// Request XfixesGetCursorImage -// size: 4 -type XfixesGetCursorImageCookie struct { - *cookie -} - -func (c *Conn) XfixesGetCursorImage() XfixesGetCursorImageCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xfixesGetCursorImageRequest(), cookie) - return XfixesGetCursorImageCookie{cookie} -} - -func (c *Conn) XfixesGetCursorImageUnchecked() XfixesGetCursorImageCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xfixesGetCursorImageRequest(), cookie) - return XfixesGetCursorImageCookie{cookie} -} - -// Request reply for XfixesGetCursorImage -// size: (32 + pad(((int(Width) * int(Height)) * 4))) -type XfixesGetCursorImageReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - X int16 - Y int16 - Width uint16 - Height uint16 - Xhot uint16 - Yhot uint16 - CursorSerial uint32 - // padding: 8 bytes - CursorImage []uint32 // size: pad(((int(Width) * int(Height)) * 4)) -} - -// Waits and reads reply data from request XfixesGetCursorImage -func (cook XfixesGetCursorImageCookie) Reply() (*XfixesGetCursorImageReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xfixesGetCursorImageReply(buf), nil -} - -// Read reply into structure from buffer for XfixesGetCursorImage -func xfixesGetCursorImageReply(buf []byte) *XfixesGetCursorImageReply { - v := new(XfixesGetCursorImageReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.X = int16(Get16(buf[b:])) - b += 2 - - v.Y = int16(Get16(buf[b:])) - b += 2 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - v.Xhot = Get16(buf[b:]) - b += 2 - - v.Yhot = Get16(buf[b:]) - b += 2 - - v.CursorSerial = Get32(buf[b:]) - b += 4 - - b += 8 // padding - - v.CursorImage = make([]uint32, (int(v.Width) * int(v.Height))) - for i := 0; i < int((int(v.Width) * int(v.Height))); i++ { - v.CursorImage[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook XfixesGetCursorImageCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesGetCursorImage -func (c *Conn) xfixesGetCursorImageRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 4 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request XfixesCreateRegion -// size: pad((8 + pad((len(Rectangles) * 8)))) -type XfixesCreateRegionCookie struct { - *cookie -} - -// Write request to wire for XfixesCreateRegion -func (c *Conn) XfixesCreateRegion(Region XfixesRegion, Rectangles []Rectangle) XfixesCreateRegionCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesCreateRegionRequest(Region, Rectangles), cookie) - return XfixesCreateRegionCookie{cookie} -} - -func (c *Conn) XfixesCreateRegionChecked(Region XfixesRegion, Rectangles []Rectangle) XfixesCreateRegionCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesCreateRegionRequest(Region, Rectangles), cookie) - return XfixesCreateRegionCookie{cookie} -} - -func (cook XfixesCreateRegionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesCreateRegion -func (c *Conn) xfixesCreateRegionRequest(Region XfixesRegion, Rectangles []Rectangle) []byte { - size := pad((8 + pad((len(Rectangles) * 8)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 5 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Region)) - b += 4 - - b += RectangleListBytes(buf[b:], Rectangles) - - return buf -} - -// Request XfixesCreateRegionFromBitmap -// size: 12 -type XfixesCreateRegionFromBitmapCookie struct { - *cookie -} - -// Write request to wire for XfixesCreateRegionFromBitmap -func (c *Conn) XfixesCreateRegionFromBitmap(Region XfixesRegion, Bitmap Pixmap) XfixesCreateRegionFromBitmapCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesCreateRegionFromBitmapRequest(Region, Bitmap), cookie) - return XfixesCreateRegionFromBitmapCookie{cookie} -} - -func (c *Conn) XfixesCreateRegionFromBitmapChecked(Region XfixesRegion, Bitmap Pixmap) XfixesCreateRegionFromBitmapCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesCreateRegionFromBitmapRequest(Region, Bitmap), cookie) - return XfixesCreateRegionFromBitmapCookie{cookie} -} - -func (cook XfixesCreateRegionFromBitmapCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesCreateRegionFromBitmap -func (c *Conn) xfixesCreateRegionFromBitmapRequest(Region XfixesRegion, Bitmap Pixmap) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 6 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Region)) - b += 4 - - Put32(buf[b:], uint32(Bitmap)) - b += 4 - - return buf -} - -// Request XfixesCreateRegionFromWindow -// size: 16 -type XfixesCreateRegionFromWindowCookie struct { - *cookie -} - -// Write request to wire for XfixesCreateRegionFromWindow -func (c *Conn) XfixesCreateRegionFromWindow(Region XfixesRegion, Window Window, Kind ShapeKind) XfixesCreateRegionFromWindowCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesCreateRegionFromWindowRequest(Region, Window, Kind), cookie) - return XfixesCreateRegionFromWindowCookie{cookie} -} - -func (c *Conn) XfixesCreateRegionFromWindowChecked(Region XfixesRegion, Window Window, Kind ShapeKind) XfixesCreateRegionFromWindowCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesCreateRegionFromWindowRequest(Region, Window, Kind), cookie) - return XfixesCreateRegionFromWindowCookie{cookie} -} - -func (cook XfixesCreateRegionFromWindowCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesCreateRegionFromWindow -func (c *Conn) xfixesCreateRegionFromWindowRequest(Region XfixesRegion, Window Window, Kind ShapeKind) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 7 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Region)) - b += 4 - - Put32(buf[b:], uint32(Window)) - b += 4 - - buf[b] = byte(Kind) - b += 1 - - b += 3 // padding - - return buf -} - -// Request XfixesCreateRegionFromGC -// size: 12 -type XfixesCreateRegionFromGCCookie struct { - *cookie -} - -// Write request to wire for XfixesCreateRegionFromGC -func (c *Conn) XfixesCreateRegionFromGC(Region XfixesRegion, Gc Gcontext) XfixesCreateRegionFromGCCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesCreateRegionFromGCRequest(Region, Gc), cookie) - return XfixesCreateRegionFromGCCookie{cookie} -} - -func (c *Conn) XfixesCreateRegionFromGCChecked(Region XfixesRegion, Gc Gcontext) XfixesCreateRegionFromGCCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesCreateRegionFromGCRequest(Region, Gc), cookie) - return XfixesCreateRegionFromGCCookie{cookie} -} - -func (cook XfixesCreateRegionFromGCCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesCreateRegionFromGC -func (c *Conn) xfixesCreateRegionFromGCRequest(Region XfixesRegion, Gc Gcontext) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 8 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Region)) - b += 4 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - return buf -} - -// Request XfixesCreateRegionFromPicture -// size: 12 -type XfixesCreateRegionFromPictureCookie struct { - *cookie -} - -// Write request to wire for XfixesCreateRegionFromPicture -func (c *Conn) XfixesCreateRegionFromPicture(Region XfixesRegion, Picture RenderPicture) XfixesCreateRegionFromPictureCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesCreateRegionFromPictureRequest(Region, Picture), cookie) - return XfixesCreateRegionFromPictureCookie{cookie} -} - -func (c *Conn) XfixesCreateRegionFromPictureChecked(Region XfixesRegion, Picture RenderPicture) XfixesCreateRegionFromPictureCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesCreateRegionFromPictureRequest(Region, Picture), cookie) - return XfixesCreateRegionFromPictureCookie{cookie} -} - -func (cook XfixesCreateRegionFromPictureCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesCreateRegionFromPicture -func (c *Conn) xfixesCreateRegionFromPictureRequest(Region XfixesRegion, Picture RenderPicture) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 9 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Region)) - b += 4 - - Put32(buf[b:], uint32(Picture)) - b += 4 - - return buf -} - -// Request XfixesDestroyRegion -// size: 8 -type XfixesDestroyRegionCookie struct { - *cookie -} - -// Write request to wire for XfixesDestroyRegion -func (c *Conn) XfixesDestroyRegion(Region XfixesRegion) XfixesDestroyRegionCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesDestroyRegionRequest(Region), cookie) - return XfixesDestroyRegionCookie{cookie} -} - -func (c *Conn) XfixesDestroyRegionChecked(Region XfixesRegion) XfixesDestroyRegionCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesDestroyRegionRequest(Region), cookie) - return XfixesDestroyRegionCookie{cookie} -} - -func (cook XfixesDestroyRegionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesDestroyRegion -func (c *Conn) xfixesDestroyRegionRequest(Region XfixesRegion) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 10 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Region)) - b += 4 - - return buf -} - -// Request XfixesSetRegion -// size: pad((8 + pad((len(Rectangles) * 8)))) -type XfixesSetRegionCookie struct { - *cookie -} - -// Write request to wire for XfixesSetRegion -func (c *Conn) XfixesSetRegion(Region XfixesRegion, Rectangles []Rectangle) XfixesSetRegionCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesSetRegionRequest(Region, Rectangles), cookie) - return XfixesSetRegionCookie{cookie} -} - -func (c *Conn) XfixesSetRegionChecked(Region XfixesRegion, Rectangles []Rectangle) XfixesSetRegionCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesSetRegionRequest(Region, Rectangles), cookie) - return XfixesSetRegionCookie{cookie} -} - -func (cook XfixesSetRegionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesSetRegion -func (c *Conn) xfixesSetRegionRequest(Region XfixesRegion, Rectangles []Rectangle) []byte { - size := pad((8 + pad((len(Rectangles) * 8)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 11 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Region)) - b += 4 - - b += RectangleListBytes(buf[b:], Rectangles) - - return buf -} - -// Request XfixesCopyRegion -// size: 12 -type XfixesCopyRegionCookie struct { - *cookie -} - -// Write request to wire for XfixesCopyRegion -func (c *Conn) XfixesCopyRegion(Source XfixesRegion, Destination XfixesRegion) XfixesCopyRegionCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesCopyRegionRequest(Source, Destination), cookie) - return XfixesCopyRegionCookie{cookie} -} - -func (c *Conn) XfixesCopyRegionChecked(Source XfixesRegion, Destination XfixesRegion) XfixesCopyRegionCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesCopyRegionRequest(Source, Destination), cookie) - return XfixesCopyRegionCookie{cookie} -} - -func (cook XfixesCopyRegionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesCopyRegion -func (c *Conn) xfixesCopyRegionRequest(Source XfixesRegion, Destination XfixesRegion) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 12 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Source)) - b += 4 - - Put32(buf[b:], uint32(Destination)) - b += 4 - - return buf -} - -// Request XfixesUnionRegion -// size: 16 -type XfixesUnionRegionCookie struct { - *cookie -} - -// Write request to wire for XfixesUnionRegion -func (c *Conn) XfixesUnionRegion(Source1 XfixesRegion, Source2 XfixesRegion, Destination XfixesRegion) XfixesUnionRegionCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesUnionRegionRequest(Source1, Source2, Destination), cookie) - return XfixesUnionRegionCookie{cookie} -} - -func (c *Conn) XfixesUnionRegionChecked(Source1 XfixesRegion, Source2 XfixesRegion, Destination XfixesRegion) XfixesUnionRegionCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesUnionRegionRequest(Source1, Source2, Destination), cookie) - return XfixesUnionRegionCookie{cookie} -} - -func (cook XfixesUnionRegionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesUnionRegion -func (c *Conn) xfixesUnionRegionRequest(Source1 XfixesRegion, Source2 XfixesRegion, Destination XfixesRegion) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 13 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Source1)) - b += 4 - - Put32(buf[b:], uint32(Source2)) - b += 4 - - Put32(buf[b:], uint32(Destination)) - b += 4 - - return buf -} - -// Request XfixesIntersectRegion -// size: 16 -type XfixesIntersectRegionCookie struct { - *cookie -} - -// Write request to wire for XfixesIntersectRegion -func (c *Conn) XfixesIntersectRegion(Source1 XfixesRegion, Source2 XfixesRegion, Destination XfixesRegion) XfixesIntersectRegionCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesIntersectRegionRequest(Source1, Source2, Destination), cookie) - return XfixesIntersectRegionCookie{cookie} -} - -func (c *Conn) XfixesIntersectRegionChecked(Source1 XfixesRegion, Source2 XfixesRegion, Destination XfixesRegion) XfixesIntersectRegionCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesIntersectRegionRequest(Source1, Source2, Destination), cookie) - return XfixesIntersectRegionCookie{cookie} -} - -func (cook XfixesIntersectRegionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesIntersectRegion -func (c *Conn) xfixesIntersectRegionRequest(Source1 XfixesRegion, Source2 XfixesRegion, Destination XfixesRegion) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 14 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Source1)) - b += 4 - - Put32(buf[b:], uint32(Source2)) - b += 4 - - Put32(buf[b:], uint32(Destination)) - b += 4 - - return buf -} - -// Request XfixesSubtractRegion -// size: 16 -type XfixesSubtractRegionCookie struct { - *cookie -} - -// Write request to wire for XfixesSubtractRegion -func (c *Conn) XfixesSubtractRegion(Source1 XfixesRegion, Source2 XfixesRegion, Destination XfixesRegion) XfixesSubtractRegionCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesSubtractRegionRequest(Source1, Source2, Destination), cookie) - return XfixesSubtractRegionCookie{cookie} -} - -func (c *Conn) XfixesSubtractRegionChecked(Source1 XfixesRegion, Source2 XfixesRegion, Destination XfixesRegion) XfixesSubtractRegionCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesSubtractRegionRequest(Source1, Source2, Destination), cookie) - return XfixesSubtractRegionCookie{cookie} -} - -func (cook XfixesSubtractRegionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesSubtractRegion -func (c *Conn) xfixesSubtractRegionRequest(Source1 XfixesRegion, Source2 XfixesRegion, Destination XfixesRegion) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 15 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Source1)) - b += 4 - - Put32(buf[b:], uint32(Source2)) - b += 4 - - Put32(buf[b:], uint32(Destination)) - b += 4 - - return buf -} - -// Request XfixesInvertRegion -// size: 20 -type XfixesInvertRegionCookie struct { - *cookie -} - -// Write request to wire for XfixesInvertRegion -func (c *Conn) XfixesInvertRegion(Source XfixesRegion, Bounds Rectangle, Destination XfixesRegion) XfixesInvertRegionCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesInvertRegionRequest(Source, Bounds, Destination), cookie) - return XfixesInvertRegionCookie{cookie} -} - -func (c *Conn) XfixesInvertRegionChecked(Source XfixesRegion, Bounds Rectangle, Destination XfixesRegion) XfixesInvertRegionCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesInvertRegionRequest(Source, Bounds, Destination), cookie) - return XfixesInvertRegionCookie{cookie} -} - -func (cook XfixesInvertRegionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesInvertRegion -func (c *Conn) xfixesInvertRegionRequest(Source XfixesRegion, Bounds Rectangle, Destination XfixesRegion) []byte { - size := 20 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 16 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Source)) - b += 4 - - { - structBytes := Bounds.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - Put32(buf[b:], uint32(Destination)) - b += 4 - - return buf -} - -// Request XfixesTranslateRegion -// size: 12 -type XfixesTranslateRegionCookie struct { - *cookie -} - -// Write request to wire for XfixesTranslateRegion -func (c *Conn) XfixesTranslateRegion(Region XfixesRegion, Dx int16, Dy int16) XfixesTranslateRegionCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesTranslateRegionRequest(Region, Dx, Dy), cookie) - return XfixesTranslateRegionCookie{cookie} -} - -func (c *Conn) XfixesTranslateRegionChecked(Region XfixesRegion, Dx int16, Dy int16) XfixesTranslateRegionCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesTranslateRegionRequest(Region, Dx, Dy), cookie) - return XfixesTranslateRegionCookie{cookie} -} - -func (cook XfixesTranslateRegionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesTranslateRegion -func (c *Conn) xfixesTranslateRegionRequest(Region XfixesRegion, Dx int16, Dy int16) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 17 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Region)) - b += 4 - - Put16(buf[b:], uint16(Dx)) - b += 2 - - Put16(buf[b:], uint16(Dy)) - b += 2 - - return buf -} - -// Request XfixesRegionExtents -// size: 12 -type XfixesRegionExtentsCookie struct { - *cookie -} - -// Write request to wire for XfixesRegionExtents -func (c *Conn) XfixesRegionExtents(Source XfixesRegion, Destination XfixesRegion) XfixesRegionExtentsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesRegionExtentsRequest(Source, Destination), cookie) - return XfixesRegionExtentsCookie{cookie} -} - -func (c *Conn) XfixesRegionExtentsChecked(Source XfixesRegion, Destination XfixesRegion) XfixesRegionExtentsCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesRegionExtentsRequest(Source, Destination), cookie) - return XfixesRegionExtentsCookie{cookie} -} - -func (cook XfixesRegionExtentsCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesRegionExtents -func (c *Conn) xfixesRegionExtentsRequest(Source XfixesRegion, Destination XfixesRegion) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 18 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Source)) - b += 4 - - Put32(buf[b:], uint32(Destination)) - b += 4 - - return buf -} - -// Request XfixesFetchRegion -// size: 8 -type XfixesFetchRegionCookie struct { - *cookie -} - -func (c *Conn) XfixesFetchRegion(Region XfixesRegion) XfixesFetchRegionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xfixesFetchRegionRequest(Region), cookie) - return XfixesFetchRegionCookie{cookie} -} - -func (c *Conn) XfixesFetchRegionUnchecked(Region XfixesRegion) XfixesFetchRegionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xfixesFetchRegionRequest(Region), cookie) - return XfixesFetchRegionCookie{cookie} -} - -// Request reply for XfixesFetchRegion -// size: (32 + pad(((int(Length) / 2) * 8))) -type XfixesFetchRegionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Extents Rectangle - // padding: 16 bytes - Rectangles []Rectangle // size: pad(((int(Length) / 2) * 8)) -} - -// Waits and reads reply data from request XfixesFetchRegion -func (cook XfixesFetchRegionCookie) Reply() (*XfixesFetchRegionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xfixesFetchRegionReply(buf), nil -} - -// Read reply into structure from buffer for XfixesFetchRegion -func xfixesFetchRegionReply(buf []byte) *XfixesFetchRegionReply { - v := new(XfixesFetchRegionReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Extents = Rectangle{} - b += ReadRectangle(buf[b:], &v.Extents) - - b += 16 // padding - - v.Rectangles = make([]Rectangle, (int(v.Length) / 2)) - b += ReadRectangleList(buf[b:], v.Rectangles) - - return v -} - -func (cook XfixesFetchRegionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesFetchRegion -func (c *Conn) xfixesFetchRegionRequest(Region XfixesRegion) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 19 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Region)) - b += 4 - - return buf -} - -// Request XfixesSetGCClipRegion -// size: 16 -type XfixesSetGCClipRegionCookie struct { - *cookie -} - -// Write request to wire for XfixesSetGCClipRegion -func (c *Conn) XfixesSetGCClipRegion(Gc Gcontext, Region XfixesRegion, XOrigin int16, YOrigin int16) XfixesSetGCClipRegionCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesSetGCClipRegionRequest(Gc, Region, XOrigin, YOrigin), cookie) - return XfixesSetGCClipRegionCookie{cookie} -} - -func (c *Conn) XfixesSetGCClipRegionChecked(Gc Gcontext, Region XfixesRegion, XOrigin int16, YOrigin int16) XfixesSetGCClipRegionCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesSetGCClipRegionRequest(Gc, Region, XOrigin, YOrigin), cookie) - return XfixesSetGCClipRegionCookie{cookie} -} - -func (cook XfixesSetGCClipRegionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesSetGCClipRegion -func (c *Conn) xfixesSetGCClipRegionRequest(Gc Gcontext, Region XfixesRegion, XOrigin int16, YOrigin int16) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 20 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - Put32(buf[b:], uint32(Region)) - b += 4 - - Put16(buf[b:], uint16(XOrigin)) - b += 2 - - Put16(buf[b:], uint16(YOrigin)) - b += 2 - - return buf -} - -// Request XfixesSetWindowShapeRegion -// size: 20 -type XfixesSetWindowShapeRegionCookie struct { - *cookie -} - -// Write request to wire for XfixesSetWindowShapeRegion -func (c *Conn) XfixesSetWindowShapeRegion(Dest Window, DestKind ShapeKind, XOffset int16, YOffset int16, Region XfixesRegion) XfixesSetWindowShapeRegionCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesSetWindowShapeRegionRequest(Dest, DestKind, XOffset, YOffset, Region), cookie) - return XfixesSetWindowShapeRegionCookie{cookie} -} - -func (c *Conn) XfixesSetWindowShapeRegionChecked(Dest Window, DestKind ShapeKind, XOffset int16, YOffset int16, Region XfixesRegion) XfixesSetWindowShapeRegionCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesSetWindowShapeRegionRequest(Dest, DestKind, XOffset, YOffset, Region), cookie) - return XfixesSetWindowShapeRegionCookie{cookie} -} - -func (cook XfixesSetWindowShapeRegionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesSetWindowShapeRegion -func (c *Conn) xfixesSetWindowShapeRegionRequest(Dest Window, DestKind ShapeKind, XOffset int16, YOffset int16, Region XfixesRegion) []byte { - size := 20 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 21 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Dest)) - b += 4 - - buf[b] = byte(DestKind) - b += 1 - - b += 3 // padding - - Put16(buf[b:], uint16(XOffset)) - b += 2 - - Put16(buf[b:], uint16(YOffset)) - b += 2 - - Put32(buf[b:], uint32(Region)) - b += 4 - - return buf -} - -// Request XfixesSetPictureClipRegion -// size: 16 -type XfixesSetPictureClipRegionCookie struct { - *cookie -} - -// Write request to wire for XfixesSetPictureClipRegion -func (c *Conn) XfixesSetPictureClipRegion(Picture RenderPicture, Region XfixesRegion, XOrigin int16, YOrigin int16) XfixesSetPictureClipRegionCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesSetPictureClipRegionRequest(Picture, Region, XOrigin, YOrigin), cookie) - return XfixesSetPictureClipRegionCookie{cookie} -} - -func (c *Conn) XfixesSetPictureClipRegionChecked(Picture RenderPicture, Region XfixesRegion, XOrigin int16, YOrigin int16) XfixesSetPictureClipRegionCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesSetPictureClipRegionRequest(Picture, Region, XOrigin, YOrigin), cookie) - return XfixesSetPictureClipRegionCookie{cookie} -} - -func (cook XfixesSetPictureClipRegionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesSetPictureClipRegion -func (c *Conn) xfixesSetPictureClipRegionRequest(Picture RenderPicture, Region XfixesRegion, XOrigin int16, YOrigin int16) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 22 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Picture)) - b += 4 - - Put32(buf[b:], uint32(Region)) - b += 4 - - Put16(buf[b:], uint16(XOrigin)) - b += 2 - - Put16(buf[b:], uint16(YOrigin)) - b += 2 - - return buf -} - -// Request XfixesSetCursorName -// size: pad((12 + pad((int(Nbytes) * 1)))) -type XfixesSetCursorNameCookie struct { - *cookie -} - -// Write request to wire for XfixesSetCursorName -func (c *Conn) XfixesSetCursorName(Cursor Cursor, Nbytes uint16, Name string) XfixesSetCursorNameCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesSetCursorNameRequest(Cursor, Nbytes, Name), cookie) - return XfixesSetCursorNameCookie{cookie} -} - -func (c *Conn) XfixesSetCursorNameChecked(Cursor Cursor, Nbytes uint16, Name string) XfixesSetCursorNameCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesSetCursorNameRequest(Cursor, Nbytes, Name), cookie) - return XfixesSetCursorNameCookie{cookie} -} - -func (cook XfixesSetCursorNameCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesSetCursorName -func (c *Conn) xfixesSetCursorNameRequest(Cursor Cursor, Nbytes uint16, Name string) []byte { - size := pad((12 + pad((int(Nbytes) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 23 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cursor)) - b += 4 - - Put16(buf[b:], Nbytes) - b += 2 - - b += 2 // padding - - copy(buf[b:], Name[:Nbytes]) - b += pad(int(Nbytes)) - - return buf -} - -// Request XfixesGetCursorName -// size: 8 -type XfixesGetCursorNameCookie struct { - *cookie -} - -func (c *Conn) XfixesGetCursorName(Cursor Cursor) XfixesGetCursorNameCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xfixesGetCursorNameRequest(Cursor), cookie) - return XfixesGetCursorNameCookie{cookie} -} - -func (c *Conn) XfixesGetCursorNameUnchecked(Cursor Cursor) XfixesGetCursorNameCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xfixesGetCursorNameRequest(Cursor), cookie) - return XfixesGetCursorNameCookie{cookie} -} - -// Request reply for XfixesGetCursorName -// size: (32 + pad((int(Nbytes) * 1))) -type XfixesGetCursorNameReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Atom Atom - Nbytes uint16 - // padding: 18 bytes - Name string // size: pad((int(Nbytes) * 1)) -} - -// Waits and reads reply data from request XfixesGetCursorName -func (cook XfixesGetCursorNameCookie) Reply() (*XfixesGetCursorNameReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xfixesGetCursorNameReply(buf), nil -} - -// Read reply into structure from buffer for XfixesGetCursorName -func xfixesGetCursorNameReply(buf []byte) *XfixesGetCursorNameReply { - v := new(XfixesGetCursorNameReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Atom = Atom(Get32(buf[b:])) - b += 4 - - v.Nbytes = Get16(buf[b:]) - b += 2 - - b += 18 // padding - - { - byteString := make([]byte, v.Nbytes) - copy(byteString[:v.Nbytes], buf[b:]) - v.Name = string(byteString) - b += pad(int(v.Nbytes)) - } - - return v -} - -func (cook XfixesGetCursorNameCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesGetCursorName -func (c *Conn) xfixesGetCursorNameRequest(Cursor Cursor) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 24 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cursor)) - b += 4 - - return buf -} - -// Request XfixesGetCursorImageAndName -// size: 4 -type XfixesGetCursorImageAndNameCookie struct { - *cookie -} - -func (c *Conn) XfixesGetCursorImageAndName() XfixesGetCursorImageAndNameCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xfixesGetCursorImageAndNameRequest(), cookie) - return XfixesGetCursorImageAndNameCookie{cookie} -} - -func (c *Conn) XfixesGetCursorImageAndNameUnchecked() XfixesGetCursorImageAndNameCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xfixesGetCursorImageAndNameRequest(), cookie) - return XfixesGetCursorImageAndNameCookie{cookie} -} - -// Request reply for XfixesGetCursorImageAndName -// size: ((32 + pad((int(Nbytes) * 1))) + pad(((int(Width) * int(Height)) * 4))) -type XfixesGetCursorImageAndNameReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - X int16 - Y int16 - Width uint16 - Height uint16 - Xhot uint16 - Yhot uint16 - CursorSerial uint32 - CursorAtom Atom - Nbytes uint16 - // padding: 2 bytes - Name string // size: pad((int(Nbytes) * 1)) - CursorImage []uint32 // size: pad(((int(Width) * int(Height)) * 4)) -} - -// Waits and reads reply data from request XfixesGetCursorImageAndName -func (cook XfixesGetCursorImageAndNameCookie) Reply() (*XfixesGetCursorImageAndNameReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xfixesGetCursorImageAndNameReply(buf), nil -} - -// Read reply into structure from buffer for XfixesGetCursorImageAndName -func xfixesGetCursorImageAndNameReply(buf []byte) *XfixesGetCursorImageAndNameReply { - v := new(XfixesGetCursorImageAndNameReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.X = int16(Get16(buf[b:])) - b += 2 - - v.Y = int16(Get16(buf[b:])) - b += 2 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - v.Xhot = Get16(buf[b:]) - b += 2 - - v.Yhot = Get16(buf[b:]) - b += 2 - - v.CursorSerial = Get32(buf[b:]) - b += 4 - - v.CursorAtom = Atom(Get32(buf[b:])) - b += 4 - - v.Nbytes = Get16(buf[b:]) - b += 2 - - b += 2 // padding - - { - byteString := make([]byte, v.Nbytes) - copy(byteString[:v.Nbytes], buf[b:]) - v.Name = string(byteString) - b += pad(int(v.Nbytes)) - } - - v.CursorImage = make([]uint32, (int(v.Width) * int(v.Height))) - for i := 0; i < int((int(v.Width) * int(v.Height))); i++ { - v.CursorImage[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook XfixesGetCursorImageAndNameCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesGetCursorImageAndName -func (c *Conn) xfixesGetCursorImageAndNameRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 25 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request XfixesChangeCursor -// size: 12 -type XfixesChangeCursorCookie struct { - *cookie -} - -// Write request to wire for XfixesChangeCursor -func (c *Conn) XfixesChangeCursor(Source Cursor, Destination Cursor) XfixesChangeCursorCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesChangeCursorRequest(Source, Destination), cookie) - return XfixesChangeCursorCookie{cookie} -} - -func (c *Conn) XfixesChangeCursorChecked(Source Cursor, Destination Cursor) XfixesChangeCursorCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesChangeCursorRequest(Source, Destination), cookie) - return XfixesChangeCursorCookie{cookie} -} - -func (cook XfixesChangeCursorCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesChangeCursor -func (c *Conn) xfixesChangeCursorRequest(Source Cursor, Destination Cursor) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 26 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Source)) - b += 4 - - Put32(buf[b:], uint32(Destination)) - b += 4 - - return buf -} - -// Request XfixesChangeCursorByName -// size: pad((12 + pad((int(Nbytes) * 1)))) -type XfixesChangeCursorByNameCookie struct { - *cookie -} - -// Write request to wire for XfixesChangeCursorByName -func (c *Conn) XfixesChangeCursorByName(Src Cursor, Nbytes uint16, Name string) XfixesChangeCursorByNameCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesChangeCursorByNameRequest(Src, Nbytes, Name), cookie) - return XfixesChangeCursorByNameCookie{cookie} -} - -func (c *Conn) XfixesChangeCursorByNameChecked(Src Cursor, Nbytes uint16, Name string) XfixesChangeCursorByNameCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesChangeCursorByNameRequest(Src, Nbytes, Name), cookie) - return XfixesChangeCursorByNameCookie{cookie} -} - -func (cook XfixesChangeCursorByNameCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesChangeCursorByName -func (c *Conn) xfixesChangeCursorByNameRequest(Src Cursor, Nbytes uint16, Name string) []byte { - size := pad((12 + pad((int(Nbytes) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 27 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Src)) - b += 4 - - Put16(buf[b:], Nbytes) - b += 2 - - b += 2 // padding - - copy(buf[b:], Name[:Nbytes]) - b += pad(int(Nbytes)) - - return buf -} - -// Request XfixesExpandRegion -// size: 20 -type XfixesExpandRegionCookie struct { - *cookie -} - -// Write request to wire for XfixesExpandRegion -func (c *Conn) XfixesExpandRegion(Source XfixesRegion, Destination XfixesRegion, Left uint16, Right uint16, Top uint16, Bottom uint16) XfixesExpandRegionCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesExpandRegionRequest(Source, Destination, Left, Right, Top, Bottom), cookie) - return XfixesExpandRegionCookie{cookie} -} - -func (c *Conn) XfixesExpandRegionChecked(Source XfixesRegion, Destination XfixesRegion, Left uint16, Right uint16, Top uint16, Bottom uint16) XfixesExpandRegionCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesExpandRegionRequest(Source, Destination, Left, Right, Top, Bottom), cookie) - return XfixesExpandRegionCookie{cookie} -} - -func (cook XfixesExpandRegionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesExpandRegion -func (c *Conn) xfixesExpandRegionRequest(Source XfixesRegion, Destination XfixesRegion, Left uint16, Right uint16, Top uint16, Bottom uint16) []byte { - size := 20 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 28 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Source)) - b += 4 - - Put32(buf[b:], uint32(Destination)) - b += 4 - - Put16(buf[b:], Left) - b += 2 - - Put16(buf[b:], Right) - b += 2 - - Put16(buf[b:], Top) - b += 2 - - Put16(buf[b:], Bottom) - b += 2 - - return buf -} - -// Request XfixesHideCursor -// size: 8 -type XfixesHideCursorCookie struct { - *cookie -} - -// Write request to wire for XfixesHideCursor -func (c *Conn) XfixesHideCursor(Window Window) XfixesHideCursorCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesHideCursorRequest(Window), cookie) - return XfixesHideCursorCookie{cookie} -} - -func (c *Conn) XfixesHideCursorChecked(Window Window) XfixesHideCursorCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesHideCursorRequest(Window), cookie) - return XfixesHideCursorCookie{cookie} -} - -func (cook XfixesHideCursorCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesHideCursor -func (c *Conn) xfixesHideCursorRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 29 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - return buf -} - -// Request XfixesShowCursor -// size: 8 -type XfixesShowCursorCookie struct { - *cookie -} - -// Write request to wire for XfixesShowCursor -func (c *Conn) XfixesShowCursor(Window Window) XfixesShowCursorCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xfixesShowCursorRequest(Window), cookie) - return XfixesShowCursorCookie{cookie} -} - -func (c *Conn) XfixesShowCursorChecked(Window Window) XfixesShowCursorCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xfixesShowCursorRequest(Window), cookie) - return XfixesShowCursorCookie{cookie} -} - -func (cook XfixesShowCursorCookie) Check() error { - return cook.check() -} - -// Write request to wire for XfixesShowCursor -func (c *Conn) xfixesShowCursorRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XFIXES"] - b += 1 - - buf[b] = 30 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - return buf -} diff --git a/nexgb/auto_xinerama.go b/nexgb/auto_xinerama.go deleted file mode 100644 index fc24ae3..0000000 --- a/nexgb/auto_xinerama.go +++ /dev/null @@ -1,655 +0,0 @@ -package xgb - -/* - This file was generated by xinerama.xml on May 10 2012 12:39:34pm EDT. - This file is automatically generated. Edit at your peril! -*/ - -// Imports are not necessary for XGB because everything is -// in one package. They are still listed here for reference. -// import "xproto" - -// XineramaInit must be called before using the XINERAMA extension. -func (c *Conn) XineramaInit() error { - reply, err := c.QueryExtension(8, "XINERAMA").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named XINERAMA could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["XINERAMA"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["XINERAMA"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["XINERAMA"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["XINERAMA"] = make(map[int]newEventFun) - newExtErrorFuncs["XINERAMA"] = make(map[int]newErrorFun) -} - -// Skipping definition for base type 'Int8' - -// Skipping definition for base type 'Card16' - -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - -// Skipping definition for base type 'Float' - -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - -// 'XineramaScreenInfo' struct definition -// Size: 8 -type XineramaScreenInfo struct { - XOrg int16 - YOrg int16 - Width uint16 - Height uint16 -} - -// Struct read XineramaScreenInfo -func ReadXineramaScreenInfo(buf []byte, v *XineramaScreenInfo) int { - b := 0 - - v.XOrg = int16(Get16(buf[b:])) - b += 2 - - v.YOrg = int16(Get16(buf[b:])) - b += 2 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - return b -} - -// Struct list read XineramaScreenInfo -func ReadXineramaScreenInfoList(buf []byte, dest []XineramaScreenInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XineramaScreenInfo{} - b += ReadXineramaScreenInfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XineramaScreenInfo -func (v XineramaScreenInfo) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put16(buf[b:], uint16(v.XOrg)) - b += 2 - - Put16(buf[b:], uint16(v.YOrg)) - b += 2 - - Put16(buf[b:], v.Width) - b += 2 - - Put16(buf[b:], v.Height) - b += 2 - - return buf -} - -// Write struct list XineramaScreenInfo -func XineramaScreenInfoListBytes(buf []byte, list []XineramaScreenInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Request XineramaQueryVersion -// size: 8 -type XineramaQueryVersionCookie struct { - *cookie -} - -func (c *Conn) XineramaQueryVersion(Major byte, Minor byte) XineramaQueryVersionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xineramaQueryVersionRequest(Major, Minor), cookie) - return XineramaQueryVersionCookie{cookie} -} - -func (c *Conn) XineramaQueryVersionUnchecked(Major byte, Minor byte) XineramaQueryVersionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xineramaQueryVersionRequest(Major, Minor), cookie) - return XineramaQueryVersionCookie{cookie} -} - -// Request reply for XineramaQueryVersion -// size: 12 -type XineramaQueryVersionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Major uint16 - Minor uint16 -} - -// Waits and reads reply data from request XineramaQueryVersion -func (cook XineramaQueryVersionCookie) Reply() (*XineramaQueryVersionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xineramaQueryVersionReply(buf), nil -} - -// Read reply into structure from buffer for XineramaQueryVersion -func xineramaQueryVersionReply(buf []byte) *XineramaQueryVersionReply { - v := new(XineramaQueryVersionReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Major = Get16(buf[b:]) - b += 2 - - v.Minor = Get16(buf[b:]) - b += 2 - - return v -} - -func (cook XineramaQueryVersionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XineramaQueryVersion -func (c *Conn) xineramaQueryVersionRequest(Major byte, Minor byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINERAMA"] - b += 1 - - buf[b] = 0 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = Major - b += 1 - - buf[b] = Minor - b += 1 - - return buf -} - -// Request XineramaGetState -// size: 8 -type XineramaGetStateCookie struct { - *cookie -} - -func (c *Conn) XineramaGetState(Window Window) XineramaGetStateCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xineramaGetStateRequest(Window), cookie) - return XineramaGetStateCookie{cookie} -} - -func (c *Conn) XineramaGetStateUnchecked(Window Window) XineramaGetStateCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xineramaGetStateRequest(Window), cookie) - return XineramaGetStateCookie{cookie} -} - -// Request reply for XineramaGetState -// size: 12 -type XineramaGetStateReply struct { - Sequence uint16 - Length uint32 - State byte - Window Window -} - -// Waits and reads reply data from request XineramaGetState -func (cook XineramaGetStateCookie) Reply() (*XineramaGetStateReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xineramaGetStateReply(buf), nil -} - -// Read reply into structure from buffer for XineramaGetState -func xineramaGetStateReply(buf []byte) *XineramaGetStateReply { - v := new(XineramaGetStateReply) - b := 1 // skip reply determinant - - v.State = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - return v -} - -func (cook XineramaGetStateCookie) Check() error { - return cook.check() -} - -// Write request to wire for XineramaGetState -func (c *Conn) xineramaGetStateRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINERAMA"] - b += 1 - - buf[b] = 1 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - return buf -} - -// Request XineramaGetScreenCount -// size: 8 -type XineramaGetScreenCountCookie struct { - *cookie -} - -func (c *Conn) XineramaGetScreenCount(Window Window) XineramaGetScreenCountCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xineramaGetScreenCountRequest(Window), cookie) - return XineramaGetScreenCountCookie{cookie} -} - -func (c *Conn) XineramaGetScreenCountUnchecked(Window Window) XineramaGetScreenCountCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xineramaGetScreenCountRequest(Window), cookie) - return XineramaGetScreenCountCookie{cookie} -} - -// Request reply for XineramaGetScreenCount -// size: 12 -type XineramaGetScreenCountReply struct { - Sequence uint16 - Length uint32 - ScreenCount byte - Window Window -} - -// Waits and reads reply data from request XineramaGetScreenCount -func (cook XineramaGetScreenCountCookie) Reply() (*XineramaGetScreenCountReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xineramaGetScreenCountReply(buf), nil -} - -// Read reply into structure from buffer for XineramaGetScreenCount -func xineramaGetScreenCountReply(buf []byte) *XineramaGetScreenCountReply { - v := new(XineramaGetScreenCountReply) - b := 1 // skip reply determinant - - v.ScreenCount = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - return v -} - -func (cook XineramaGetScreenCountCookie) Check() error { - return cook.check() -} - -// Write request to wire for XineramaGetScreenCount -func (c *Conn) xineramaGetScreenCountRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINERAMA"] - b += 1 - - buf[b] = 2 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - return buf -} - -// Request XineramaGetScreenSize -// size: 12 -type XineramaGetScreenSizeCookie struct { - *cookie -} - -func (c *Conn) XineramaGetScreenSize(Window Window, Screen uint32) XineramaGetScreenSizeCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xineramaGetScreenSizeRequest(Window, Screen), cookie) - return XineramaGetScreenSizeCookie{cookie} -} - -func (c *Conn) XineramaGetScreenSizeUnchecked(Window Window, Screen uint32) XineramaGetScreenSizeCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xineramaGetScreenSizeRequest(Window, Screen), cookie) - return XineramaGetScreenSizeCookie{cookie} -} - -// Request reply for XineramaGetScreenSize -// size: 24 -type XineramaGetScreenSizeReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Width uint32 - Height uint32 - Window Window - Screen uint32 -} - -// Waits and reads reply data from request XineramaGetScreenSize -func (cook XineramaGetScreenSizeCookie) Reply() (*XineramaGetScreenSizeReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xineramaGetScreenSizeReply(buf), nil -} - -// Read reply into structure from buffer for XineramaGetScreenSize -func xineramaGetScreenSizeReply(buf []byte) *XineramaGetScreenSizeReply { - v := new(XineramaGetScreenSizeReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Width = Get32(buf[b:]) - b += 4 - - v.Height = Get32(buf[b:]) - b += 4 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - v.Screen = Get32(buf[b:]) - b += 4 - - return v -} - -func (cook XineramaGetScreenSizeCookie) Check() error { - return cook.check() -} - -// Write request to wire for XineramaGetScreenSize -func (c *Conn) xineramaGetScreenSizeRequest(Window Window, Screen uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINERAMA"] - b += 1 - - buf[b] = 3 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - Put32(buf[b:], Screen) - b += 4 - - return buf -} - -// Request XineramaIsActive -// size: 4 -type XineramaIsActiveCookie struct { - *cookie -} - -func (c *Conn) XineramaIsActive() XineramaIsActiveCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xineramaIsActiveRequest(), cookie) - return XineramaIsActiveCookie{cookie} -} - -func (c *Conn) XineramaIsActiveUnchecked() XineramaIsActiveCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xineramaIsActiveRequest(), cookie) - return XineramaIsActiveCookie{cookie} -} - -// Request reply for XineramaIsActive -// size: 12 -type XineramaIsActiveReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - State uint32 -} - -// Waits and reads reply data from request XineramaIsActive -func (cook XineramaIsActiveCookie) Reply() (*XineramaIsActiveReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xineramaIsActiveReply(buf), nil -} - -// Read reply into structure from buffer for XineramaIsActive -func xineramaIsActiveReply(buf []byte) *XineramaIsActiveReply { - v := new(XineramaIsActiveReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.State = Get32(buf[b:]) - b += 4 - - return v -} - -func (cook XineramaIsActiveCookie) Check() error { - return cook.check() -} - -// Write request to wire for XineramaIsActive -func (c *Conn) xineramaIsActiveRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINERAMA"] - b += 1 - - buf[b] = 4 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request XineramaQueryScreens -// size: 4 -type XineramaQueryScreensCookie struct { - *cookie -} - -func (c *Conn) XineramaQueryScreens() XineramaQueryScreensCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xineramaQueryScreensRequest(), cookie) - return XineramaQueryScreensCookie{cookie} -} - -func (c *Conn) XineramaQueryScreensUnchecked() XineramaQueryScreensCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xineramaQueryScreensRequest(), cookie) - return XineramaQueryScreensCookie{cookie} -} - -// Request reply for XineramaQueryScreens -// size: (32 + pad((int(Number) * 8))) -type XineramaQueryScreensReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Number uint32 - // padding: 20 bytes - ScreenInfo []XineramaScreenInfo // size: pad((int(Number) * 8)) -} - -// Waits and reads reply data from request XineramaQueryScreens -func (cook XineramaQueryScreensCookie) Reply() (*XineramaQueryScreensReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xineramaQueryScreensReply(buf), nil -} - -// Read reply into structure from buffer for XineramaQueryScreens -func xineramaQueryScreensReply(buf []byte) *XineramaQueryScreensReply { - v := new(XineramaQueryScreensReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Number = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.ScreenInfo = make([]XineramaScreenInfo, v.Number) - b += ReadXineramaScreenInfoList(buf[b:], v.ScreenInfo) - - return v -} - -func (cook XineramaQueryScreensCookie) Check() error { - return cook.check() -} - -// Write request to wire for XineramaQueryScreens -func (c *Conn) xineramaQueryScreensRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINERAMA"] - b += 1 - - buf[b] = 5 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} diff --git a/nexgb/auto_xinput.go b/nexgb/auto_xinput.go deleted file mode 100644 index 78142b6..0000000 --- a/nexgb/auto_xinput.go +++ /dev/null @@ -1,7297 +0,0 @@ -package xgb - -/* - This file was generated by xinput.xml on May 10 2012 12:39:34pm EDT. - This file is automatically generated. Edit at your peril! -*/ - -// Imports are not necessary for XGB because everything is -// in one package. They are still listed here for reference. -// import "xproto" - -// XinputInit must be called before using the XInputExtension extension. -func (c *Conn) XinputInit() error { - reply, err := c.QueryExtension(15, "XInputExtension").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named XInputExtension could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["XInputExtension"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["XInputExtension"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["XInputExtension"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["XInputExtension"] = make(map[int]newEventFun) - newExtErrorFuncs["XInputExtension"] = make(map[int]newErrorFun) -} - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - -// Skipping definition for base type 'Int8' - -// Skipping definition for base type 'Card16' - -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - -// Skipping definition for base type 'Float' - -// Skipping definition for base type 'Card8' - -const ( - XinputValuatorModeRelative = 0 - XinputValuatorModeAbsolute = 1 -) - -const ( - XinputPropagateModeAddToList = 0 - XinputPropagateModeDeleteFromList = 1 -) - -const ( - XinputDeviceUseIsXPointer = 0 - XinputDeviceUseIsXKeyboard = 1 - XinputDeviceUseIsXExtensionDevice = 2 - XinputDeviceUseIsXExtensionKeyboard = 3 - XinputDeviceUseIsXExtensionPointer = 4 -) - -const ( - XinputInputClassKey = 0 - XinputInputClassButton = 1 - XinputInputClassValuator = 2 - XinputInputClassFeedback = 3 - XinputInputClassProximity = 4 - XinputInputClassFocus = 5 - XinputInputClassOther = 6 -) - -const ( - XinputDeviceInputModeAsyncThisDevice = 0 - XinputDeviceInputModeSyncThisDevice = 1 - XinputDeviceInputModeReplayThisDevice = 2 - XinputDeviceInputModeAsyncOtherDevices = 3 - XinputDeviceInputModeAsyncAll = 4 - XinputDeviceInputModeSyncAll = 5 -) - -const ( - XinputFeedbackClassKeyboard = 0 - XinputFeedbackClassPointer = 1 - XinputFeedbackClassString = 2 - XinputFeedbackClassInteger = 3 - XinputFeedbackClassLed = 4 - XinputFeedbackClassBell = 5 -) - -type XinputKeyCode byte - -type XinputEventClass uint32 - -// 'XinputDeviceInfo' struct definition -// Size: 8 -type XinputDeviceInfo struct { - DeviceType Atom - DeviceId byte - NumClassInfo byte - DeviceUse byte - // padding: 1 bytes -} - -// Struct read XinputDeviceInfo -func ReadXinputDeviceInfo(buf []byte, v *XinputDeviceInfo) int { - b := 0 - - v.DeviceType = Atom(Get32(buf[b:])) - b += 4 - - v.DeviceId = buf[b] - b += 1 - - v.NumClassInfo = buf[b] - b += 1 - - v.DeviceUse = buf[b] - b += 1 - - b += 1 // padding - - return b -} - -// Struct list read XinputDeviceInfo -func ReadXinputDeviceInfoList(buf []byte, dest []XinputDeviceInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputDeviceInfo{} - b += ReadXinputDeviceInfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputDeviceInfo -func (v XinputDeviceInfo) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put32(buf[b:], uint32(v.DeviceType)) - b += 4 - - buf[b] = v.DeviceId - b += 1 - - buf[b] = v.NumClassInfo - b += 1 - - buf[b] = v.DeviceUse - b += 1 - - b += 1 // padding - - return buf -} - -// Write struct list XinputDeviceInfo -func XinputDeviceInfoListBytes(buf []byte, list []XinputDeviceInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputInputInfo' struct definition -// Size: 2 -type XinputInputInfo struct { - ClassId byte - Len byte -} - -// Struct read XinputInputInfo -func ReadXinputInputInfo(buf []byte, v *XinputInputInfo) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Len = buf[b] - b += 1 - - return b -} - -// Struct list read XinputInputInfo -func ReadXinputInputInfoList(buf []byte, dest []XinputInputInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputInputInfo{} - b += ReadXinputInputInfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputInputInfo -func (v XinputInputInfo) Bytes() []byte { - buf := make([]byte, 2) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Len - b += 1 - - return buf -} - -// Write struct list XinputInputInfo -func XinputInputInfoListBytes(buf []byte, list []XinputInputInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputKeyInfo' struct definition -// Size: 8 -type XinputKeyInfo struct { - ClassId byte - Len byte - MinKeycode XinputKeyCode - MaxKeycode XinputKeyCode - NumKeys uint16 - // padding: 2 bytes -} - -// Struct read XinputKeyInfo -func ReadXinputKeyInfo(buf []byte, v *XinputKeyInfo) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Len = buf[b] - b += 1 - - v.MinKeycode = XinputKeyCode(buf[b]) - b += 1 - - v.MaxKeycode = XinputKeyCode(buf[b]) - b += 1 - - v.NumKeys = Get16(buf[b:]) - b += 2 - - b += 2 // padding - - return b -} - -// Struct list read XinputKeyInfo -func ReadXinputKeyInfoList(buf []byte, dest []XinputKeyInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputKeyInfo{} - b += ReadXinputKeyInfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputKeyInfo -func (v XinputKeyInfo) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Len - b += 1 - - buf[b] = byte(v.MinKeycode) - b += 1 - - buf[b] = byte(v.MaxKeycode) - b += 1 - - Put16(buf[b:], v.NumKeys) - b += 2 - - b += 2 // padding - - return buf -} - -// Write struct list XinputKeyInfo -func XinputKeyInfoListBytes(buf []byte, list []XinputKeyInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputButtonInfo' struct definition -// Size: 4 -type XinputButtonInfo struct { - ClassId byte - Len byte - NumButtons uint16 -} - -// Struct read XinputButtonInfo -func ReadXinputButtonInfo(buf []byte, v *XinputButtonInfo) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Len = buf[b] - b += 1 - - v.NumButtons = Get16(buf[b:]) - b += 2 - - return b -} - -// Struct list read XinputButtonInfo -func ReadXinputButtonInfoList(buf []byte, dest []XinputButtonInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputButtonInfo{} - b += ReadXinputButtonInfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputButtonInfo -func (v XinputButtonInfo) Bytes() []byte { - buf := make([]byte, 4) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Len - b += 1 - - Put16(buf[b:], v.NumButtons) - b += 2 - - return buf -} - -// Write struct list XinputButtonInfo -func XinputButtonInfoListBytes(buf []byte, list []XinputButtonInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputAxisInfo' struct definition -// Size: 12 -type XinputAxisInfo struct { - Resolution uint32 - Minimum int32 - Maximum int32 -} - -// Struct read XinputAxisInfo -func ReadXinputAxisInfo(buf []byte, v *XinputAxisInfo) int { - b := 0 - - v.Resolution = Get32(buf[b:]) - b += 4 - - v.Minimum = int32(Get32(buf[b:])) - b += 4 - - v.Maximum = int32(Get32(buf[b:])) - b += 4 - - return b -} - -// Struct list read XinputAxisInfo -func ReadXinputAxisInfoList(buf []byte, dest []XinputAxisInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputAxisInfo{} - b += ReadXinputAxisInfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputAxisInfo -func (v XinputAxisInfo) Bytes() []byte { - buf := make([]byte, 12) - b := 0 - - Put32(buf[b:], v.Resolution) - b += 4 - - Put32(buf[b:], uint32(v.Minimum)) - b += 4 - - Put32(buf[b:], uint32(v.Maximum)) - b += 4 - - return buf -} - -// Write struct list XinputAxisInfo -func XinputAxisInfoListBytes(buf []byte, list []XinputAxisInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputValuatorInfo' struct definition -// Size: (8 + pad((int(AxesLen) * 12))) -type XinputValuatorInfo struct { - ClassId byte - Len byte - AxesLen byte - Mode byte - MotionSize uint32 - Axes []XinputAxisInfo // size: pad((int(AxesLen) * 12)) -} - -// Struct read XinputValuatorInfo -func ReadXinputValuatorInfo(buf []byte, v *XinputValuatorInfo) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Len = buf[b] - b += 1 - - v.AxesLen = buf[b] - b += 1 - - v.Mode = buf[b] - b += 1 - - v.MotionSize = Get32(buf[b:]) - b += 4 - - v.Axes = make([]XinputAxisInfo, v.AxesLen) - b += ReadXinputAxisInfoList(buf[b:], v.Axes) - - return b -} - -// Struct list read XinputValuatorInfo -func ReadXinputValuatorInfoList(buf []byte, dest []XinputValuatorInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputValuatorInfo{} - b += ReadXinputValuatorInfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputValuatorInfo -func (v XinputValuatorInfo) Bytes() []byte { - buf := make([]byte, (8 + pad((int(v.AxesLen) * 12)))) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Len - b += 1 - - buf[b] = v.AxesLen - b += 1 - - buf[b] = v.Mode - b += 1 - - Put32(buf[b:], v.MotionSize) - b += 4 - - b += XinputAxisInfoListBytes(buf[b:], v.Axes) - - return buf -} - -// Write struct list XinputValuatorInfo -func XinputValuatorInfoListBytes(buf []byte, list []XinputValuatorInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size XinputValuatorInfo -func XinputValuatorInfoListSize(list []XinputValuatorInfo) int { - size := 0 - for _, item := range list { - size += (8 + pad((int(item.AxesLen) * 12))) - } - return size -} - -// 'XinputInputClassInfo' struct definition -// Size: 2 -type XinputInputClassInfo struct { - ClassId byte - EventTypeBase byte -} - -// Struct read XinputInputClassInfo -func ReadXinputInputClassInfo(buf []byte, v *XinputInputClassInfo) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.EventTypeBase = buf[b] - b += 1 - - return b -} - -// Struct list read XinputInputClassInfo -func ReadXinputInputClassInfoList(buf []byte, dest []XinputInputClassInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputInputClassInfo{} - b += ReadXinputInputClassInfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputInputClassInfo -func (v XinputInputClassInfo) Bytes() []byte { - buf := make([]byte, 2) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.EventTypeBase - b += 1 - - return buf -} - -// Write struct list XinputInputClassInfo -func XinputInputClassInfoListBytes(buf []byte, list []XinputInputClassInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputDeviceTimeCoord' struct definition -// Size: 4 -type XinputDeviceTimeCoord struct { - Time Timestamp -} - -// Struct read XinputDeviceTimeCoord -func ReadXinputDeviceTimeCoord(buf []byte, v *XinputDeviceTimeCoord) int { - b := 0 - - v.Time = Timestamp(Get32(buf[b:])) - b += 4 - - return b -} - -// Struct list read XinputDeviceTimeCoord -func ReadXinputDeviceTimeCoordList(buf []byte, dest []XinputDeviceTimeCoord) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputDeviceTimeCoord{} - b += ReadXinputDeviceTimeCoord(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputDeviceTimeCoord -func (v XinputDeviceTimeCoord) Bytes() []byte { - buf := make([]byte, 4) - b := 0 - - Put32(buf[b:], uint32(v.Time)) - b += 4 - - return buf -} - -// Write struct list XinputDeviceTimeCoord -func XinputDeviceTimeCoordListBytes(buf []byte, list []XinputDeviceTimeCoord) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputFeedbackState' struct definition -// Size: 4 -type XinputFeedbackState struct { - ClassId byte - Id byte - Len uint16 -} - -// Struct read XinputFeedbackState -func ReadXinputFeedbackState(buf []byte, v *XinputFeedbackState) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 - - v.Len = Get16(buf[b:]) - b += 2 - - return b -} - -// Struct list read XinputFeedbackState -func ReadXinputFeedbackStateList(buf []byte, dest []XinputFeedbackState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputFeedbackState{} - b += ReadXinputFeedbackState(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputFeedbackState -func (v XinputFeedbackState) Bytes() []byte { - buf := make([]byte, 4) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 - - Put16(buf[b:], v.Len) - b += 2 - - return buf -} - -// Write struct list XinputFeedbackState -func XinputFeedbackStateListBytes(buf []byte, list []XinputFeedbackState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputKbdFeedbackState' struct definition -// Size: 52 -type XinputKbdFeedbackState struct { - ClassId byte - Id byte - Len uint16 - Pitch uint16 - Duration uint16 - LedMask uint32 - LedValues uint32 - GlobalAutoRepeat bool - Click byte - Percent byte - // padding: 1 bytes - AutoRepeats []byte // size: 32 -} - -// Struct read XinputKbdFeedbackState -func ReadXinputKbdFeedbackState(buf []byte, v *XinputKbdFeedbackState) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 - - v.Len = Get16(buf[b:]) - b += 2 - - v.Pitch = Get16(buf[b:]) - b += 2 - - v.Duration = Get16(buf[b:]) - b += 2 - - v.LedMask = Get32(buf[b:]) - b += 4 - - v.LedValues = Get32(buf[b:]) - b += 4 - - if buf[b] == 1 { - v.GlobalAutoRepeat = true - } else { - v.GlobalAutoRepeat = false - } - b += 1 - - v.Click = buf[b] - b += 1 - - v.Percent = buf[b] - b += 1 - - b += 1 // padding - - v.AutoRepeats = make([]byte, 32) - copy(v.AutoRepeats[:32], buf[b:]) - b += pad(int(32)) - - return b -} - -// Struct list read XinputKbdFeedbackState -func ReadXinputKbdFeedbackStateList(buf []byte, dest []XinputKbdFeedbackState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputKbdFeedbackState{} - b += ReadXinputKbdFeedbackState(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputKbdFeedbackState -func (v XinputKbdFeedbackState) Bytes() []byte { - buf := make([]byte, 52) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 - - Put16(buf[b:], v.Len) - b += 2 - - Put16(buf[b:], v.Pitch) - b += 2 - - Put16(buf[b:], v.Duration) - b += 2 - - Put32(buf[b:], v.LedMask) - b += 4 - - Put32(buf[b:], v.LedValues) - b += 4 - - if v.GlobalAutoRepeat { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - buf[b] = v.Click - b += 1 - - buf[b] = v.Percent - b += 1 - - b += 1 // padding - - copy(buf[b:], v.AutoRepeats[:32]) - b += pad(int(32)) - - return buf -} - -// Write struct list XinputKbdFeedbackState -func XinputKbdFeedbackStateListBytes(buf []byte, list []XinputKbdFeedbackState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size XinputKbdFeedbackState -func XinputKbdFeedbackStateListSize(list []XinputKbdFeedbackState) int { - size := 0 - for _ = range list { - size += 52 - } - return size -} - -// 'XinputPtrFeedbackState' struct definition -// Size: 12 -type XinputPtrFeedbackState struct { - ClassId byte - Id byte - Len uint16 - // padding: 2 bytes - AccelNum uint16 - AccelDenom uint16 - Threshold uint16 -} - -// Struct read XinputPtrFeedbackState -func ReadXinputPtrFeedbackState(buf []byte, v *XinputPtrFeedbackState) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 - - v.Len = Get16(buf[b:]) - b += 2 - - b += 2 // padding - - v.AccelNum = Get16(buf[b:]) - b += 2 - - v.AccelDenom = Get16(buf[b:]) - b += 2 - - v.Threshold = Get16(buf[b:]) - b += 2 - - return b -} - -// Struct list read XinputPtrFeedbackState -func ReadXinputPtrFeedbackStateList(buf []byte, dest []XinputPtrFeedbackState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputPtrFeedbackState{} - b += ReadXinputPtrFeedbackState(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputPtrFeedbackState -func (v XinputPtrFeedbackState) Bytes() []byte { - buf := make([]byte, 12) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 - - Put16(buf[b:], v.Len) - b += 2 - - b += 2 // padding - - Put16(buf[b:], v.AccelNum) - b += 2 - - Put16(buf[b:], v.AccelDenom) - b += 2 - - Put16(buf[b:], v.Threshold) - b += 2 - - return buf -} - -// Write struct list XinputPtrFeedbackState -func XinputPtrFeedbackStateListBytes(buf []byte, list []XinputPtrFeedbackState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputIntegerFeedbackState' struct definition -// Size: 16 -type XinputIntegerFeedbackState struct { - ClassId byte - Id byte - Len uint16 - Resolution uint32 - MinValue int32 - MaxValue int32 -} - -// Struct read XinputIntegerFeedbackState -func ReadXinputIntegerFeedbackState(buf []byte, v *XinputIntegerFeedbackState) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 - - v.Len = Get16(buf[b:]) - b += 2 - - v.Resolution = Get32(buf[b:]) - b += 4 - - v.MinValue = int32(Get32(buf[b:])) - b += 4 - - v.MaxValue = int32(Get32(buf[b:])) - b += 4 - - return b -} - -// Struct list read XinputIntegerFeedbackState -func ReadXinputIntegerFeedbackStateList(buf []byte, dest []XinputIntegerFeedbackState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputIntegerFeedbackState{} - b += ReadXinputIntegerFeedbackState(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputIntegerFeedbackState -func (v XinputIntegerFeedbackState) Bytes() []byte { - buf := make([]byte, 16) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 - - Put16(buf[b:], v.Len) - b += 2 - - Put32(buf[b:], v.Resolution) - b += 4 - - Put32(buf[b:], uint32(v.MinValue)) - b += 4 - - Put32(buf[b:], uint32(v.MaxValue)) - b += 4 - - return buf -} - -// Write struct list XinputIntegerFeedbackState -func XinputIntegerFeedbackStateListBytes(buf []byte, list []XinputIntegerFeedbackState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputStringFeedbackState' struct definition -// Size: (8 + pad((int(NumKeysyms) * 4))) -type XinputStringFeedbackState struct { - ClassId byte - Id byte - Len uint16 - MaxSymbols uint16 - NumKeysyms uint16 - Keysyms []Keysym // size: pad((int(NumKeysyms) * 4)) -} - -// Struct read XinputStringFeedbackState -func ReadXinputStringFeedbackState(buf []byte, v *XinputStringFeedbackState) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 - - v.Len = Get16(buf[b:]) - b += 2 - - v.MaxSymbols = Get16(buf[b:]) - b += 2 - - v.NumKeysyms = Get16(buf[b:]) - b += 2 - - v.Keysyms = make([]Keysym, v.NumKeysyms) - for i := 0; i < int(v.NumKeysyms); i++ { - v.Keysyms[i] = Keysym(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return b -} - -// Struct list read XinputStringFeedbackState -func ReadXinputStringFeedbackStateList(buf []byte, dest []XinputStringFeedbackState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputStringFeedbackState{} - b += ReadXinputStringFeedbackState(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputStringFeedbackState -func (v XinputStringFeedbackState) Bytes() []byte { - buf := make([]byte, (8 + pad((int(v.NumKeysyms) * 4)))) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 - - Put16(buf[b:], v.Len) - b += 2 - - Put16(buf[b:], v.MaxSymbols) - b += 2 - - Put16(buf[b:], v.NumKeysyms) - b += 2 - - for i := 0; i < int(v.NumKeysyms); i++ { - Put32(buf[b:], uint32(v.Keysyms[i])) - b += 4 - } - b = pad(b) - - return buf -} - -// Write struct list XinputStringFeedbackState -func XinputStringFeedbackStateListBytes(buf []byte, list []XinputStringFeedbackState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size XinputStringFeedbackState -func XinputStringFeedbackStateListSize(list []XinputStringFeedbackState) int { - size := 0 - for _, item := range list { - size += (8 + pad((int(item.NumKeysyms) * 4))) - } - return size -} - -// 'XinputBellFeedbackState' struct definition -// Size: 12 -type XinputBellFeedbackState struct { - ClassId byte - Id byte - Len uint16 - Percent byte - // padding: 3 bytes - Pitch uint16 - Duration uint16 -} - -// Struct read XinputBellFeedbackState -func ReadXinputBellFeedbackState(buf []byte, v *XinputBellFeedbackState) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 - - v.Len = Get16(buf[b:]) - b += 2 - - v.Percent = buf[b] - b += 1 - - b += 3 // padding - - v.Pitch = Get16(buf[b:]) - b += 2 - - v.Duration = Get16(buf[b:]) - b += 2 - - return b -} - -// Struct list read XinputBellFeedbackState -func ReadXinputBellFeedbackStateList(buf []byte, dest []XinputBellFeedbackState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputBellFeedbackState{} - b += ReadXinputBellFeedbackState(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputBellFeedbackState -func (v XinputBellFeedbackState) Bytes() []byte { - buf := make([]byte, 12) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 - - Put16(buf[b:], v.Len) - b += 2 - - buf[b] = v.Percent - b += 1 - - b += 3 // padding - - Put16(buf[b:], v.Pitch) - b += 2 - - Put16(buf[b:], v.Duration) - b += 2 - - return buf -} - -// Write struct list XinputBellFeedbackState -func XinputBellFeedbackStateListBytes(buf []byte, list []XinputBellFeedbackState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputLedFeedbackState' struct definition -// Size: 12 -type XinputLedFeedbackState struct { - ClassId byte - Id byte - Len uint16 - LedMask uint32 - LedValues uint32 -} - -// Struct read XinputLedFeedbackState -func ReadXinputLedFeedbackState(buf []byte, v *XinputLedFeedbackState) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 - - v.Len = Get16(buf[b:]) - b += 2 - - v.LedMask = Get32(buf[b:]) - b += 4 - - v.LedValues = Get32(buf[b:]) - b += 4 - - return b -} - -// Struct list read XinputLedFeedbackState -func ReadXinputLedFeedbackStateList(buf []byte, dest []XinputLedFeedbackState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputLedFeedbackState{} - b += ReadXinputLedFeedbackState(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputLedFeedbackState -func (v XinputLedFeedbackState) Bytes() []byte { - buf := make([]byte, 12) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 - - Put16(buf[b:], v.Len) - b += 2 - - Put32(buf[b:], v.LedMask) - b += 4 - - Put32(buf[b:], v.LedValues) - b += 4 - - return buf -} - -// Write struct list XinputLedFeedbackState -func XinputLedFeedbackStateListBytes(buf []byte, list []XinputLedFeedbackState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputFeedbackCtl' struct definition -// Size: 4 -type XinputFeedbackCtl struct { - ClassId byte - Id byte - Len uint16 -} - -// Struct read XinputFeedbackCtl -func ReadXinputFeedbackCtl(buf []byte, v *XinputFeedbackCtl) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 - - v.Len = Get16(buf[b:]) - b += 2 - - return b -} - -// Struct list read XinputFeedbackCtl -func ReadXinputFeedbackCtlList(buf []byte, dest []XinputFeedbackCtl) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputFeedbackCtl{} - b += ReadXinputFeedbackCtl(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputFeedbackCtl -func (v XinputFeedbackCtl) Bytes() []byte { - buf := make([]byte, 4) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 - - Put16(buf[b:], v.Len) - b += 2 - - return buf -} - -// Write struct list XinputFeedbackCtl -func XinputFeedbackCtlListBytes(buf []byte, list []XinputFeedbackCtl) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputKbdFeedbackCtl' struct definition -// Size: 20 -type XinputKbdFeedbackCtl struct { - ClassId byte - Id byte - Len uint16 - Key XinputKeyCode - AutoRepeatMode byte - KeyClickPercent int8 - BellPercent int8 - BellPitch int16 - BellDuration int16 - LedMask uint32 - LedValues uint32 -} - -// Struct read XinputKbdFeedbackCtl -func ReadXinputKbdFeedbackCtl(buf []byte, v *XinputKbdFeedbackCtl) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 - - v.Len = Get16(buf[b:]) - b += 2 - - v.Key = XinputKeyCode(buf[b]) - b += 1 - - v.AutoRepeatMode = buf[b] - b += 1 - - v.KeyClickPercent = int8(buf[b]) - b += 1 - - v.BellPercent = int8(buf[b]) - b += 1 - - v.BellPitch = int16(Get16(buf[b:])) - b += 2 - - v.BellDuration = int16(Get16(buf[b:])) - b += 2 - - v.LedMask = Get32(buf[b:]) - b += 4 - - v.LedValues = Get32(buf[b:]) - b += 4 - - return b -} - -// Struct list read XinputKbdFeedbackCtl -func ReadXinputKbdFeedbackCtlList(buf []byte, dest []XinputKbdFeedbackCtl) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputKbdFeedbackCtl{} - b += ReadXinputKbdFeedbackCtl(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputKbdFeedbackCtl -func (v XinputKbdFeedbackCtl) Bytes() []byte { - buf := make([]byte, 20) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 - - Put16(buf[b:], v.Len) - b += 2 - - buf[b] = byte(v.Key) - b += 1 - - buf[b] = v.AutoRepeatMode - b += 1 - - buf[b] = byte(v.KeyClickPercent) - b += 1 - - buf[b] = byte(v.BellPercent) - b += 1 - - Put16(buf[b:], uint16(v.BellPitch)) - b += 2 - - Put16(buf[b:], uint16(v.BellDuration)) - b += 2 - - Put32(buf[b:], v.LedMask) - b += 4 - - Put32(buf[b:], v.LedValues) - b += 4 - - return buf -} - -// Write struct list XinputKbdFeedbackCtl -func XinputKbdFeedbackCtlListBytes(buf []byte, list []XinputKbdFeedbackCtl) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputPtrFeedbackCtl' struct definition -// Size: 12 -type XinputPtrFeedbackCtl struct { - ClassId byte - Id byte - Len uint16 - // padding: 2 bytes - Num int16 - Denom int16 - Threshold int16 -} - -// Struct read XinputPtrFeedbackCtl -func ReadXinputPtrFeedbackCtl(buf []byte, v *XinputPtrFeedbackCtl) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 - - v.Len = Get16(buf[b:]) - b += 2 - - b += 2 // padding - - v.Num = int16(Get16(buf[b:])) - b += 2 - - v.Denom = int16(Get16(buf[b:])) - b += 2 - - v.Threshold = int16(Get16(buf[b:])) - b += 2 - - return b -} - -// Struct list read XinputPtrFeedbackCtl -func ReadXinputPtrFeedbackCtlList(buf []byte, dest []XinputPtrFeedbackCtl) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputPtrFeedbackCtl{} - b += ReadXinputPtrFeedbackCtl(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputPtrFeedbackCtl -func (v XinputPtrFeedbackCtl) Bytes() []byte { - buf := make([]byte, 12) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 - - Put16(buf[b:], v.Len) - b += 2 - - b += 2 // padding - - Put16(buf[b:], uint16(v.Num)) - b += 2 - - Put16(buf[b:], uint16(v.Denom)) - b += 2 - - Put16(buf[b:], uint16(v.Threshold)) - b += 2 - - return buf -} - -// Write struct list XinputPtrFeedbackCtl -func XinputPtrFeedbackCtlListBytes(buf []byte, list []XinputPtrFeedbackCtl) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputIntegerFeedbackCtl' struct definition -// Size: 8 -type XinputIntegerFeedbackCtl struct { - ClassId byte - Id byte - Len uint16 - IntToDisplay int32 -} - -// Struct read XinputIntegerFeedbackCtl -func ReadXinputIntegerFeedbackCtl(buf []byte, v *XinputIntegerFeedbackCtl) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 - - v.Len = Get16(buf[b:]) - b += 2 - - v.IntToDisplay = int32(Get32(buf[b:])) - b += 4 - - return b -} - -// Struct list read XinputIntegerFeedbackCtl -func ReadXinputIntegerFeedbackCtlList(buf []byte, dest []XinputIntegerFeedbackCtl) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputIntegerFeedbackCtl{} - b += ReadXinputIntegerFeedbackCtl(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputIntegerFeedbackCtl -func (v XinputIntegerFeedbackCtl) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 - - Put16(buf[b:], v.Len) - b += 2 - - Put32(buf[b:], uint32(v.IntToDisplay)) - b += 4 - - return buf -} - -// Write struct list XinputIntegerFeedbackCtl -func XinputIntegerFeedbackCtlListBytes(buf []byte, list []XinputIntegerFeedbackCtl) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputStringFeedbackCtl' struct definition -// Size: (8 + pad((int(NumKeysyms) * 4))) -type XinputStringFeedbackCtl struct { - ClassId byte - Id byte - Len uint16 - // padding: 2 bytes - NumKeysyms uint16 - Keysyms []Keysym // size: pad((int(NumKeysyms) * 4)) -} - -// Struct read XinputStringFeedbackCtl -func ReadXinputStringFeedbackCtl(buf []byte, v *XinputStringFeedbackCtl) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 - - v.Len = Get16(buf[b:]) - b += 2 - - b += 2 // padding - - v.NumKeysyms = Get16(buf[b:]) - b += 2 - - v.Keysyms = make([]Keysym, v.NumKeysyms) - for i := 0; i < int(v.NumKeysyms); i++ { - v.Keysyms[i] = Keysym(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return b -} - -// Struct list read XinputStringFeedbackCtl -func ReadXinputStringFeedbackCtlList(buf []byte, dest []XinputStringFeedbackCtl) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputStringFeedbackCtl{} - b += ReadXinputStringFeedbackCtl(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputStringFeedbackCtl -func (v XinputStringFeedbackCtl) Bytes() []byte { - buf := make([]byte, (8 + pad((int(v.NumKeysyms) * 4)))) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 - - Put16(buf[b:], v.Len) - b += 2 - - b += 2 // padding - - Put16(buf[b:], v.NumKeysyms) - b += 2 - - for i := 0; i < int(v.NumKeysyms); i++ { - Put32(buf[b:], uint32(v.Keysyms[i])) - b += 4 - } - b = pad(b) - - return buf -} - -// Write struct list XinputStringFeedbackCtl -func XinputStringFeedbackCtlListBytes(buf []byte, list []XinputStringFeedbackCtl) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size XinputStringFeedbackCtl -func XinputStringFeedbackCtlListSize(list []XinputStringFeedbackCtl) int { - size := 0 - for _, item := range list { - size += (8 + pad((int(item.NumKeysyms) * 4))) - } - return size -} - -// 'XinputBellFeedbackCtl' struct definition -// Size: 12 -type XinputBellFeedbackCtl struct { - ClassId byte - Id byte - Len uint16 - Percent int8 - // padding: 3 bytes - Pitch int16 - Duration int16 -} - -// Struct read XinputBellFeedbackCtl -func ReadXinputBellFeedbackCtl(buf []byte, v *XinputBellFeedbackCtl) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 - - v.Len = Get16(buf[b:]) - b += 2 - - v.Percent = int8(buf[b]) - b += 1 - - b += 3 // padding - - v.Pitch = int16(Get16(buf[b:])) - b += 2 - - v.Duration = int16(Get16(buf[b:])) - b += 2 - - return b -} - -// Struct list read XinputBellFeedbackCtl -func ReadXinputBellFeedbackCtlList(buf []byte, dest []XinputBellFeedbackCtl) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputBellFeedbackCtl{} - b += ReadXinputBellFeedbackCtl(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputBellFeedbackCtl -func (v XinputBellFeedbackCtl) Bytes() []byte { - buf := make([]byte, 12) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 - - Put16(buf[b:], v.Len) - b += 2 - - buf[b] = byte(v.Percent) - b += 1 - - b += 3 // padding - - Put16(buf[b:], uint16(v.Pitch)) - b += 2 - - Put16(buf[b:], uint16(v.Duration)) - b += 2 - - return buf -} - -// Write struct list XinputBellFeedbackCtl -func XinputBellFeedbackCtlListBytes(buf []byte, list []XinputBellFeedbackCtl) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputLedFeedbackCtl' struct definition -// Size: 12 -type XinputLedFeedbackCtl struct { - ClassId byte - Id byte - Len uint16 - LedMask uint32 - LedValues uint32 -} - -// Struct read XinputLedFeedbackCtl -func ReadXinputLedFeedbackCtl(buf []byte, v *XinputLedFeedbackCtl) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Id = buf[b] - b += 1 - - v.Len = Get16(buf[b:]) - b += 2 - - v.LedMask = Get32(buf[b:]) - b += 4 - - v.LedValues = Get32(buf[b:]) - b += 4 - - return b -} - -// Struct list read XinputLedFeedbackCtl -func ReadXinputLedFeedbackCtlList(buf []byte, dest []XinputLedFeedbackCtl) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputLedFeedbackCtl{} - b += ReadXinputLedFeedbackCtl(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputLedFeedbackCtl -func (v XinputLedFeedbackCtl) Bytes() []byte { - buf := make([]byte, 12) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Id - b += 1 - - Put16(buf[b:], v.Len) - b += 2 - - Put32(buf[b:], v.LedMask) - b += 4 - - Put32(buf[b:], v.LedValues) - b += 4 - - return buf -} - -// Write struct list XinputLedFeedbackCtl -func XinputLedFeedbackCtlListBytes(buf []byte, list []XinputLedFeedbackCtl) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputInputState' struct definition -// Size: 3 -type XinputInputState struct { - ClassId byte - Len byte - NumItems byte -} - -// Struct read XinputInputState -func ReadXinputInputState(buf []byte, v *XinputInputState) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Len = buf[b] - b += 1 - - v.NumItems = buf[b] - b += 1 - - return b -} - -// Struct list read XinputInputState -func ReadXinputInputStateList(buf []byte, dest []XinputInputState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputInputState{} - b += ReadXinputInputState(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputInputState -func (v XinputInputState) Bytes() []byte { - buf := make([]byte, 3) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Len - b += 1 - - buf[b] = v.NumItems - b += 1 - - return buf -} - -// Write struct list XinputInputState -func XinputInputStateListBytes(buf []byte, list []XinputInputState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputKeyState' struct definition -// Size: 36 -type XinputKeyState struct { - ClassId byte - Len byte - NumKeys byte - // padding: 1 bytes - Keys []byte // size: 32 -} - -// Struct read XinputKeyState -func ReadXinputKeyState(buf []byte, v *XinputKeyState) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Len = buf[b] - b += 1 - - v.NumKeys = buf[b] - b += 1 - - b += 1 // padding - - v.Keys = make([]byte, 32) - copy(v.Keys[:32], buf[b:]) - b += pad(int(32)) - - return b -} - -// Struct list read XinputKeyState -func ReadXinputKeyStateList(buf []byte, dest []XinputKeyState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputKeyState{} - b += ReadXinputKeyState(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputKeyState -func (v XinputKeyState) Bytes() []byte { - buf := make([]byte, 36) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Len - b += 1 - - buf[b] = v.NumKeys - b += 1 - - b += 1 // padding - - copy(buf[b:], v.Keys[:32]) - b += pad(int(32)) - - return buf -} - -// Write struct list XinputKeyState -func XinputKeyStateListBytes(buf []byte, list []XinputKeyState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size XinputKeyState -func XinputKeyStateListSize(list []XinputKeyState) int { - size := 0 - for _ = range list { - size += 36 - } - return size -} - -// 'XinputButtonState' struct definition -// Size: 36 -type XinputButtonState struct { - ClassId byte - Len byte - NumButtons byte - // padding: 1 bytes - Buttons []byte // size: 32 -} - -// Struct read XinputButtonState -func ReadXinputButtonState(buf []byte, v *XinputButtonState) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Len = buf[b] - b += 1 - - v.NumButtons = buf[b] - b += 1 - - b += 1 // padding - - v.Buttons = make([]byte, 32) - copy(v.Buttons[:32], buf[b:]) - b += pad(int(32)) - - return b -} - -// Struct list read XinputButtonState -func ReadXinputButtonStateList(buf []byte, dest []XinputButtonState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputButtonState{} - b += ReadXinputButtonState(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputButtonState -func (v XinputButtonState) Bytes() []byte { - buf := make([]byte, 36) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Len - b += 1 - - buf[b] = v.NumButtons - b += 1 - - b += 1 // padding - - copy(buf[b:], v.Buttons[:32]) - b += pad(int(32)) - - return buf -} - -// Write struct list XinputButtonState -func XinputButtonStateListBytes(buf []byte, list []XinputButtonState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size XinputButtonState -func XinputButtonStateListSize(list []XinputButtonState) int { - size := 0 - for _ = range list { - size += 36 - } - return size -} - -// 'XinputValuatorState' struct definition -// Size: (4 + pad((int(NumValuators) * 4))) -type XinputValuatorState struct { - ClassId byte - Len byte - NumValuators byte - Mode byte - Valuators []uint32 // size: pad((int(NumValuators) * 4)) -} - -// Struct read XinputValuatorState -func ReadXinputValuatorState(buf []byte, v *XinputValuatorState) int { - b := 0 - - v.ClassId = buf[b] - b += 1 - - v.Len = buf[b] - b += 1 - - v.NumValuators = buf[b] - b += 1 - - v.Mode = buf[b] - b += 1 - - v.Valuators = make([]uint32, v.NumValuators) - for i := 0; i < int(v.NumValuators); i++ { - v.Valuators[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return b -} - -// Struct list read XinputValuatorState -func ReadXinputValuatorStateList(buf []byte, dest []XinputValuatorState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputValuatorState{} - b += ReadXinputValuatorState(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputValuatorState -func (v XinputValuatorState) Bytes() []byte { - buf := make([]byte, (4 + pad((int(v.NumValuators) * 4)))) - b := 0 - - buf[b] = v.ClassId - b += 1 - - buf[b] = v.Len - b += 1 - - buf[b] = v.NumValuators - b += 1 - - buf[b] = v.Mode - b += 1 - - for i := 0; i < int(v.NumValuators); i++ { - Put32(buf[b:], v.Valuators[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Write struct list XinputValuatorState -func XinputValuatorStateListBytes(buf []byte, list []XinputValuatorState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size XinputValuatorState -func XinputValuatorStateListSize(list []XinputValuatorState) int { - size := 0 - for _, item := range list { - size += (4 + pad((int(item.NumValuators) * 4))) - } - return size -} - -// 'XinputDeviceState' struct definition -// Size: 4 -type XinputDeviceState struct { - ControlId uint16 - Len uint16 -} - -// Struct read XinputDeviceState -func ReadXinputDeviceState(buf []byte, v *XinputDeviceState) int { - b := 0 - - v.ControlId = Get16(buf[b:]) - b += 2 - - v.Len = Get16(buf[b:]) - b += 2 - - return b -} - -// Struct list read XinputDeviceState -func ReadXinputDeviceStateList(buf []byte, dest []XinputDeviceState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputDeviceState{} - b += ReadXinputDeviceState(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputDeviceState -func (v XinputDeviceState) Bytes() []byte { - buf := make([]byte, 4) - b := 0 - - Put16(buf[b:], v.ControlId) - b += 2 - - Put16(buf[b:], v.Len) - b += 2 - - return buf -} - -// Write struct list XinputDeviceState -func XinputDeviceStateListBytes(buf []byte, list []XinputDeviceState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputDeviceResolutionState' struct definition -// Size: (((8 + pad((int(NumValuators) * 4))) + pad((int(NumValuators) * 4))) + pad((int(NumValuators) * 4))) -type XinputDeviceResolutionState struct { - ControlId uint16 - Len uint16 - NumValuators uint32 - ResolutionValues []uint32 // size: pad((int(NumValuators) * 4)) - ResolutionMin []uint32 // size: pad((int(NumValuators) * 4)) - ResolutionMax []uint32 // size: pad((int(NumValuators) * 4)) -} - -// Struct read XinputDeviceResolutionState -func ReadXinputDeviceResolutionState(buf []byte, v *XinputDeviceResolutionState) int { - b := 0 - - v.ControlId = Get16(buf[b:]) - b += 2 - - v.Len = Get16(buf[b:]) - b += 2 - - v.NumValuators = Get32(buf[b:]) - b += 4 - - v.ResolutionValues = make([]uint32, v.NumValuators) - for i := 0; i < int(v.NumValuators); i++ { - v.ResolutionValues[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - v.ResolutionMin = make([]uint32, v.NumValuators) - for i := 0; i < int(v.NumValuators); i++ { - v.ResolutionMin[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - v.ResolutionMax = make([]uint32, v.NumValuators) - for i := 0; i < int(v.NumValuators); i++ { - v.ResolutionMax[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return b -} - -// Struct list read XinputDeviceResolutionState -func ReadXinputDeviceResolutionStateList(buf []byte, dest []XinputDeviceResolutionState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputDeviceResolutionState{} - b += ReadXinputDeviceResolutionState(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputDeviceResolutionState -func (v XinputDeviceResolutionState) Bytes() []byte { - buf := make([]byte, (((8 + pad((int(v.NumValuators) * 4))) + pad((int(v.NumValuators) * 4))) + pad((int(v.NumValuators) * 4)))) - b := 0 - - Put16(buf[b:], v.ControlId) - b += 2 - - Put16(buf[b:], v.Len) - b += 2 - - Put32(buf[b:], v.NumValuators) - b += 4 - - for i := 0; i < int(v.NumValuators); i++ { - Put32(buf[b:], v.ResolutionValues[i]) - b += 4 - } - b = pad(b) - - for i := 0; i < int(v.NumValuators); i++ { - Put32(buf[b:], v.ResolutionMin[i]) - b += 4 - } - b = pad(b) - - for i := 0; i < int(v.NumValuators); i++ { - Put32(buf[b:], v.ResolutionMax[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Write struct list XinputDeviceResolutionState -func XinputDeviceResolutionStateListBytes(buf []byte, list []XinputDeviceResolutionState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size XinputDeviceResolutionState -func XinputDeviceResolutionStateListSize(list []XinputDeviceResolutionState) int { - size := 0 - for _, item := range list { - size += (((8 + pad((int(item.NumValuators) * 4))) + pad((int(item.NumValuators) * 4))) + pad((int(item.NumValuators) * 4))) - } - return size -} - -// 'XinputDeviceAbsCalibState' struct definition -// Size: 36 -type XinputDeviceAbsCalibState struct { - ControlId uint16 - Len uint16 - MinX int32 - MaxX int32 - MinY int32 - MaxY int32 - FlipX uint32 - FlipY uint32 - Rotation uint32 - ButtonThreshold uint32 -} - -// Struct read XinputDeviceAbsCalibState -func ReadXinputDeviceAbsCalibState(buf []byte, v *XinputDeviceAbsCalibState) int { - b := 0 - - v.ControlId = Get16(buf[b:]) - b += 2 - - v.Len = Get16(buf[b:]) - b += 2 - - v.MinX = int32(Get32(buf[b:])) - b += 4 - - v.MaxX = int32(Get32(buf[b:])) - b += 4 - - v.MinY = int32(Get32(buf[b:])) - b += 4 - - v.MaxY = int32(Get32(buf[b:])) - b += 4 - - v.FlipX = Get32(buf[b:]) - b += 4 - - v.FlipY = Get32(buf[b:]) - b += 4 - - v.Rotation = Get32(buf[b:]) - b += 4 - - v.ButtonThreshold = Get32(buf[b:]) - b += 4 - - return b -} - -// Struct list read XinputDeviceAbsCalibState -func ReadXinputDeviceAbsCalibStateList(buf []byte, dest []XinputDeviceAbsCalibState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputDeviceAbsCalibState{} - b += ReadXinputDeviceAbsCalibState(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputDeviceAbsCalibState -func (v XinputDeviceAbsCalibState) Bytes() []byte { - buf := make([]byte, 36) - b := 0 - - Put16(buf[b:], v.ControlId) - b += 2 - - Put16(buf[b:], v.Len) - b += 2 - - Put32(buf[b:], uint32(v.MinX)) - b += 4 - - Put32(buf[b:], uint32(v.MaxX)) - b += 4 - - Put32(buf[b:], uint32(v.MinY)) - b += 4 - - Put32(buf[b:], uint32(v.MaxY)) - b += 4 - - Put32(buf[b:], v.FlipX) - b += 4 - - Put32(buf[b:], v.FlipY) - b += 4 - - Put32(buf[b:], v.Rotation) - b += 4 - - Put32(buf[b:], v.ButtonThreshold) - b += 4 - - return buf -} - -// Write struct list XinputDeviceAbsCalibState -func XinputDeviceAbsCalibStateListBytes(buf []byte, list []XinputDeviceAbsCalibState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputDeviceAbsAreaState' struct definition -// Size: 28 -type XinputDeviceAbsAreaState struct { - ControlId uint16 - Len uint16 - OffsetX uint32 - OffsetY uint32 - Width uint32 - Height uint32 - Screen uint32 - Following uint32 -} - -// Struct read XinputDeviceAbsAreaState -func ReadXinputDeviceAbsAreaState(buf []byte, v *XinputDeviceAbsAreaState) int { - b := 0 - - v.ControlId = Get16(buf[b:]) - b += 2 - - v.Len = Get16(buf[b:]) - b += 2 - - v.OffsetX = Get32(buf[b:]) - b += 4 - - v.OffsetY = Get32(buf[b:]) - b += 4 - - v.Width = Get32(buf[b:]) - b += 4 - - v.Height = Get32(buf[b:]) - b += 4 - - v.Screen = Get32(buf[b:]) - b += 4 - - v.Following = Get32(buf[b:]) - b += 4 - - return b -} - -// Struct list read XinputDeviceAbsAreaState -func ReadXinputDeviceAbsAreaStateList(buf []byte, dest []XinputDeviceAbsAreaState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputDeviceAbsAreaState{} - b += ReadXinputDeviceAbsAreaState(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputDeviceAbsAreaState -func (v XinputDeviceAbsAreaState) Bytes() []byte { - buf := make([]byte, 28) - b := 0 - - Put16(buf[b:], v.ControlId) - b += 2 - - Put16(buf[b:], v.Len) - b += 2 - - Put32(buf[b:], v.OffsetX) - b += 4 - - Put32(buf[b:], v.OffsetY) - b += 4 - - Put32(buf[b:], v.Width) - b += 4 - - Put32(buf[b:], v.Height) - b += 4 - - Put32(buf[b:], v.Screen) - b += 4 - - Put32(buf[b:], v.Following) - b += 4 - - return buf -} - -// Write struct list XinputDeviceAbsAreaState -func XinputDeviceAbsAreaStateListBytes(buf []byte, list []XinputDeviceAbsAreaState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputDeviceCoreState' struct definition -// Size: 8 -type XinputDeviceCoreState struct { - ControlId uint16 - Len uint16 - Status byte - Iscore byte - // padding: 2 bytes -} - -// Struct read XinputDeviceCoreState -func ReadXinputDeviceCoreState(buf []byte, v *XinputDeviceCoreState) int { - b := 0 - - v.ControlId = Get16(buf[b:]) - b += 2 - - v.Len = Get16(buf[b:]) - b += 2 - - v.Status = buf[b] - b += 1 - - v.Iscore = buf[b] - b += 1 - - b += 2 // padding - - return b -} - -// Struct list read XinputDeviceCoreState -func ReadXinputDeviceCoreStateList(buf []byte, dest []XinputDeviceCoreState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputDeviceCoreState{} - b += ReadXinputDeviceCoreState(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputDeviceCoreState -func (v XinputDeviceCoreState) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put16(buf[b:], v.ControlId) - b += 2 - - Put16(buf[b:], v.Len) - b += 2 - - buf[b] = v.Status - b += 1 - - buf[b] = v.Iscore - b += 1 - - b += 2 // padding - - return buf -} - -// Write struct list XinputDeviceCoreState -func XinputDeviceCoreStateListBytes(buf []byte, list []XinputDeviceCoreState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputDeviceEnableState' struct definition -// Size: 8 -type XinputDeviceEnableState struct { - ControlId uint16 - Len uint16 - Enable byte - // padding: 3 bytes -} - -// Struct read XinputDeviceEnableState -func ReadXinputDeviceEnableState(buf []byte, v *XinputDeviceEnableState) int { - b := 0 - - v.ControlId = Get16(buf[b:]) - b += 2 - - v.Len = Get16(buf[b:]) - b += 2 - - v.Enable = buf[b] - b += 1 - - b += 3 // padding - - return b -} - -// Struct list read XinputDeviceEnableState -func ReadXinputDeviceEnableStateList(buf []byte, dest []XinputDeviceEnableState) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputDeviceEnableState{} - b += ReadXinputDeviceEnableState(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputDeviceEnableState -func (v XinputDeviceEnableState) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put16(buf[b:], v.ControlId) - b += 2 - - Put16(buf[b:], v.Len) - b += 2 - - buf[b] = v.Enable - b += 1 - - b += 3 // padding - - return buf -} - -// Write struct list XinputDeviceEnableState -func XinputDeviceEnableStateListBytes(buf []byte, list []XinputDeviceEnableState) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputDeviceCtl' struct definition -// Size: 4 -type XinputDeviceCtl struct { - ControlId uint16 - Len uint16 -} - -// Struct read XinputDeviceCtl -func ReadXinputDeviceCtl(buf []byte, v *XinputDeviceCtl) int { - b := 0 - - v.ControlId = Get16(buf[b:]) - b += 2 - - v.Len = Get16(buf[b:]) - b += 2 - - return b -} - -// Struct list read XinputDeviceCtl -func ReadXinputDeviceCtlList(buf []byte, dest []XinputDeviceCtl) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputDeviceCtl{} - b += ReadXinputDeviceCtl(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputDeviceCtl -func (v XinputDeviceCtl) Bytes() []byte { - buf := make([]byte, 4) - b := 0 - - Put16(buf[b:], v.ControlId) - b += 2 - - Put16(buf[b:], v.Len) - b += 2 - - return buf -} - -// Write struct list XinputDeviceCtl -func XinputDeviceCtlListBytes(buf []byte, list []XinputDeviceCtl) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputDeviceResolutionCtl' struct definition -// Size: (6 + pad((int(NumValuators) * 4))) -type XinputDeviceResolutionCtl struct { - ControlId uint16 - Len uint16 - FirstValuator byte - NumValuators byte - ResolutionValues []uint32 // size: pad((int(NumValuators) * 4)) -} - -// Struct read XinputDeviceResolutionCtl -func ReadXinputDeviceResolutionCtl(buf []byte, v *XinputDeviceResolutionCtl) int { - b := 0 - - v.ControlId = Get16(buf[b:]) - b += 2 - - v.Len = Get16(buf[b:]) - b += 2 - - v.FirstValuator = buf[b] - b += 1 - - v.NumValuators = buf[b] - b += 1 - - v.ResolutionValues = make([]uint32, v.NumValuators) - for i := 0; i < int(v.NumValuators); i++ { - v.ResolutionValues[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return b -} - -// Struct list read XinputDeviceResolutionCtl -func ReadXinputDeviceResolutionCtlList(buf []byte, dest []XinputDeviceResolutionCtl) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputDeviceResolutionCtl{} - b += ReadXinputDeviceResolutionCtl(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputDeviceResolutionCtl -func (v XinputDeviceResolutionCtl) Bytes() []byte { - buf := make([]byte, (6 + pad((int(v.NumValuators) * 4)))) - b := 0 - - Put16(buf[b:], v.ControlId) - b += 2 - - Put16(buf[b:], v.Len) - b += 2 - - buf[b] = v.FirstValuator - b += 1 - - buf[b] = v.NumValuators - b += 1 - - for i := 0; i < int(v.NumValuators); i++ { - Put32(buf[b:], v.ResolutionValues[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Write struct list XinputDeviceResolutionCtl -func XinputDeviceResolutionCtlListBytes(buf []byte, list []XinputDeviceResolutionCtl) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size XinputDeviceResolutionCtl -func XinputDeviceResolutionCtlListSize(list []XinputDeviceResolutionCtl) int { - size := 0 - for _, item := range list { - size += (6 + pad((int(item.NumValuators) * 4))) - } - return size -} - -// 'XinputDeviceAbsCalibCtl' struct definition -// Size: 36 -type XinputDeviceAbsCalibCtl struct { - ControlId uint16 - Len uint16 - MinX int32 - MaxX int32 - MinY int32 - MaxY int32 - FlipX uint32 - FlipY uint32 - Rotation uint32 - ButtonThreshold uint32 -} - -// Struct read XinputDeviceAbsCalibCtl -func ReadXinputDeviceAbsCalibCtl(buf []byte, v *XinputDeviceAbsCalibCtl) int { - b := 0 - - v.ControlId = Get16(buf[b:]) - b += 2 - - v.Len = Get16(buf[b:]) - b += 2 - - v.MinX = int32(Get32(buf[b:])) - b += 4 - - v.MaxX = int32(Get32(buf[b:])) - b += 4 - - v.MinY = int32(Get32(buf[b:])) - b += 4 - - v.MaxY = int32(Get32(buf[b:])) - b += 4 - - v.FlipX = Get32(buf[b:]) - b += 4 - - v.FlipY = Get32(buf[b:]) - b += 4 - - v.Rotation = Get32(buf[b:]) - b += 4 - - v.ButtonThreshold = Get32(buf[b:]) - b += 4 - - return b -} - -// Struct list read XinputDeviceAbsCalibCtl -func ReadXinputDeviceAbsCalibCtlList(buf []byte, dest []XinputDeviceAbsCalibCtl) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputDeviceAbsCalibCtl{} - b += ReadXinputDeviceAbsCalibCtl(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputDeviceAbsCalibCtl -func (v XinputDeviceAbsCalibCtl) Bytes() []byte { - buf := make([]byte, 36) - b := 0 - - Put16(buf[b:], v.ControlId) - b += 2 - - Put16(buf[b:], v.Len) - b += 2 - - Put32(buf[b:], uint32(v.MinX)) - b += 4 - - Put32(buf[b:], uint32(v.MaxX)) - b += 4 - - Put32(buf[b:], uint32(v.MinY)) - b += 4 - - Put32(buf[b:], uint32(v.MaxY)) - b += 4 - - Put32(buf[b:], v.FlipX) - b += 4 - - Put32(buf[b:], v.FlipY) - b += 4 - - Put32(buf[b:], v.Rotation) - b += 4 - - Put32(buf[b:], v.ButtonThreshold) - b += 4 - - return buf -} - -// Write struct list XinputDeviceAbsCalibCtl -func XinputDeviceAbsCalibCtlListBytes(buf []byte, list []XinputDeviceAbsCalibCtl) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputDeviceAbsAreaCtrl' struct definition -// Size: 28 -type XinputDeviceAbsAreaCtrl struct { - ControlId uint16 - Len uint16 - OffsetX uint32 - OffsetY uint32 - Width int32 - Height int32 - Screen int32 - Following uint32 -} - -// Struct read XinputDeviceAbsAreaCtrl -func ReadXinputDeviceAbsAreaCtrl(buf []byte, v *XinputDeviceAbsAreaCtrl) int { - b := 0 - - v.ControlId = Get16(buf[b:]) - b += 2 - - v.Len = Get16(buf[b:]) - b += 2 - - v.OffsetX = Get32(buf[b:]) - b += 4 - - v.OffsetY = Get32(buf[b:]) - b += 4 - - v.Width = int32(Get32(buf[b:])) - b += 4 - - v.Height = int32(Get32(buf[b:])) - b += 4 - - v.Screen = int32(Get32(buf[b:])) - b += 4 - - v.Following = Get32(buf[b:]) - b += 4 - - return b -} - -// Struct list read XinputDeviceAbsAreaCtrl -func ReadXinputDeviceAbsAreaCtrlList(buf []byte, dest []XinputDeviceAbsAreaCtrl) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputDeviceAbsAreaCtrl{} - b += ReadXinputDeviceAbsAreaCtrl(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputDeviceAbsAreaCtrl -func (v XinputDeviceAbsAreaCtrl) Bytes() []byte { - buf := make([]byte, 28) - b := 0 - - Put16(buf[b:], v.ControlId) - b += 2 - - Put16(buf[b:], v.Len) - b += 2 - - Put32(buf[b:], v.OffsetX) - b += 4 - - Put32(buf[b:], v.OffsetY) - b += 4 - - Put32(buf[b:], uint32(v.Width)) - b += 4 - - Put32(buf[b:], uint32(v.Height)) - b += 4 - - Put32(buf[b:], uint32(v.Screen)) - b += 4 - - Put32(buf[b:], v.Following) - b += 4 - - return buf -} - -// Write struct list XinputDeviceAbsAreaCtrl -func XinputDeviceAbsAreaCtrlListBytes(buf []byte, list []XinputDeviceAbsAreaCtrl) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputDeviceCoreCtrl' struct definition -// Size: 8 -type XinputDeviceCoreCtrl struct { - ControlId uint16 - Len uint16 - Status byte - // padding: 3 bytes -} - -// Struct read XinputDeviceCoreCtrl -func ReadXinputDeviceCoreCtrl(buf []byte, v *XinputDeviceCoreCtrl) int { - b := 0 - - v.ControlId = Get16(buf[b:]) - b += 2 - - v.Len = Get16(buf[b:]) - b += 2 - - v.Status = buf[b] - b += 1 - - b += 3 // padding - - return b -} - -// Struct list read XinputDeviceCoreCtrl -func ReadXinputDeviceCoreCtrlList(buf []byte, dest []XinputDeviceCoreCtrl) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputDeviceCoreCtrl{} - b += ReadXinputDeviceCoreCtrl(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputDeviceCoreCtrl -func (v XinputDeviceCoreCtrl) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put16(buf[b:], v.ControlId) - b += 2 - - Put16(buf[b:], v.Len) - b += 2 - - buf[b] = v.Status - b += 1 - - b += 3 // padding - - return buf -} - -// Write struct list XinputDeviceCoreCtrl -func XinputDeviceCoreCtrlListBytes(buf []byte, list []XinputDeviceCoreCtrl) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XinputDeviceEnableCtrl' struct definition -// Size: 8 -type XinputDeviceEnableCtrl struct { - ControlId uint16 - Len uint16 - Enable byte - // padding: 3 bytes -} - -// Struct read XinputDeviceEnableCtrl -func ReadXinputDeviceEnableCtrl(buf []byte, v *XinputDeviceEnableCtrl) int { - b := 0 - - v.ControlId = Get16(buf[b:]) - b += 2 - - v.Len = Get16(buf[b:]) - b += 2 - - v.Enable = buf[b] - b += 1 - - b += 3 // padding - - return b -} - -// Struct list read XinputDeviceEnableCtrl -func ReadXinputDeviceEnableCtrlList(buf []byte, dest []XinputDeviceEnableCtrl) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XinputDeviceEnableCtrl{} - b += ReadXinputDeviceEnableCtrl(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XinputDeviceEnableCtrl -func (v XinputDeviceEnableCtrl) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put16(buf[b:], v.ControlId) - b += 2 - - Put16(buf[b:], v.Len) - b += 2 - - buf[b] = v.Enable - b += 1 - - b += 3 // padding - - return buf -} - -// Write struct list XinputDeviceEnableCtrl -func XinputDeviceEnableCtrlListBytes(buf []byte, list []XinputDeviceEnableCtrl) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Event definition XinputDeviceValuator (0) -// Size: 32 - -const XinputDeviceValuator = 0 - -type XinputDeviceValuatorEvent struct { - Sequence uint16 - DeviceId byte - DeviceState uint16 - NumValuators byte - FirstValuator byte - Valuators []int32 // size: 24 -} - -// Event read XinputDeviceValuator -func NewXinputDeviceValuatorEvent(buf []byte) Event { - v := XinputDeviceValuatorEvent{} - b := 1 // don't read event number - - v.DeviceId = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.DeviceState = Get16(buf[b:]) - b += 2 - - v.NumValuators = buf[b] - b += 1 - - v.FirstValuator = buf[b] - b += 1 - - v.Valuators = make([]int32, 6) - for i := 0; i < int(6); i++ { - v.Valuators[i] = int32(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -// Event write XinputDeviceValuator -func (v XinputDeviceValuatorEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 0 - b += 1 - - buf[b] = v.DeviceId - b += 1 - - b += 2 // skip sequence number - - Put16(buf[b:], v.DeviceState) - b += 2 - - buf[b] = v.NumValuators - b += 1 - - buf[b] = v.FirstValuator - b += 1 - - for i := 0; i < int(6); i++ { - Put32(buf[b:], uint32(v.Valuators[i])) - b += 4 - } - b = pad(b) - - return buf -} - -func (v XinputDeviceValuatorEvent) ImplementsEvent() {} - -func (v XinputDeviceValuatorEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XinputDeviceValuatorEvent) String() string { - fieldVals := make([]string, 0, 5) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("DeviceId: %d", v.DeviceId)) - fieldVals = append(fieldVals, sprintf("DeviceState: %d", v.DeviceState)) - fieldVals = append(fieldVals, sprintf("NumValuators: %d", v.NumValuators)) - fieldVals = append(fieldVals, sprintf("FirstValuator: %d", v.FirstValuator)) - return "XinputDeviceValuator {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XInputExtension"][0] = NewXinputDeviceValuatorEvent -} - -// Event definition XinputDeviceKeyPress (1) -// Size: 32 - -const XinputDeviceKeyPress = 1 - -type XinputDeviceKeyPressEvent struct { - Sequence uint16 - Detail byte - Time Timestamp - Root Window - Event Window - Child Window - RootX int16 - RootY int16 - EventX int16 - EventY int16 - State uint16 - SameScreen bool - DeviceId byte -} - -// Event read XinputDeviceKeyPress -func NewXinputDeviceKeyPressEvent(buf []byte) Event { - v := XinputDeviceKeyPressEvent{} - b := 1 // don't read event number - - v.Detail = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Time = Timestamp(Get32(buf[b:])) - b += 4 - - v.Root = Window(Get32(buf[b:])) - b += 4 - - v.Event = Window(Get32(buf[b:])) - b += 4 - - v.Child = Window(Get32(buf[b:])) - b += 4 - - v.RootX = int16(Get16(buf[b:])) - b += 2 - - v.RootY = int16(Get16(buf[b:])) - b += 2 - - v.EventX = int16(Get16(buf[b:])) - b += 2 - - v.EventY = int16(Get16(buf[b:])) - b += 2 - - v.State = Get16(buf[b:]) - b += 2 - - if buf[b] == 1 { - v.SameScreen = true - } else { - v.SameScreen = false - } - b += 1 - - v.DeviceId = buf[b] - b += 1 - - return v -} - -// Event write XinputDeviceKeyPress -func (v XinputDeviceKeyPressEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 1 - b += 1 - - buf[b] = v.Detail - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Time)) - b += 4 - - Put32(buf[b:], uint32(v.Root)) - b += 4 - - Put32(buf[b:], uint32(v.Event)) - b += 4 - - Put32(buf[b:], uint32(v.Child)) - b += 4 - - Put16(buf[b:], uint16(v.RootX)) - b += 2 - - Put16(buf[b:], uint16(v.RootY)) - b += 2 - - Put16(buf[b:], uint16(v.EventX)) - b += 2 - - Put16(buf[b:], uint16(v.EventY)) - b += 2 - - Put16(buf[b:], v.State) - b += 2 - - if v.SameScreen { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - buf[b] = v.DeviceId - b += 1 - - return buf -} - -func (v XinputDeviceKeyPressEvent) ImplementsEvent() {} - -func (v XinputDeviceKeyPressEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XinputDeviceKeyPressEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, sprintf("SameScreen: %t", v.SameScreen)) - fieldVals = append(fieldVals, sprintf("DeviceId: %d", v.DeviceId)) - return "XinputDeviceKeyPress {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XInputExtension"][1] = NewXinputDeviceKeyPressEvent -} - -// Event definition XinputFocusIn (6) -// Size: 32 - -const XinputFocusIn = 6 - -type XinputFocusInEvent struct { - Sequence uint16 - Detail byte - Time Timestamp - Window Window - Mode byte - DeviceId byte - // padding: 18 bytes -} - -// Event read XinputFocusIn -func NewXinputFocusInEvent(buf []byte) Event { - v := XinputFocusInEvent{} - b := 1 // don't read event number - - v.Detail = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Time = Timestamp(Get32(buf[b:])) - b += 4 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - v.Mode = buf[b] - b += 1 - - v.DeviceId = buf[b] - b += 1 - - b += 18 // padding - - return v -} - -// Event write XinputFocusIn -func (v XinputFocusInEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 6 - b += 1 - - buf[b] = v.Detail - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Time)) - b += 4 - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - buf[b] = v.Mode - b += 1 - - buf[b] = v.DeviceId - b += 1 - - b += 18 // padding - - return buf -} - -func (v XinputFocusInEvent) ImplementsEvent() {} - -func (v XinputFocusInEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XinputFocusInEvent) String() string { - fieldVals := make([]string, 0, 6) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, sprintf("Mode: %d", v.Mode)) - fieldVals = append(fieldVals, sprintf("DeviceId: %d", v.DeviceId)) - return "XinputFocusIn {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XInputExtension"][6] = NewXinputFocusInEvent -} - -// Event definition XinputDeviceStateNotify (10) -// Size: 32 - -const XinputDeviceStateNotify = 10 - -type XinputDeviceStateNotifyEvent struct { - Sequence uint16 - DeviceId byte - Time Timestamp - NumKeys byte - NumButtons byte - NumValuators byte - ClassesReported byte - Buttons []byte // size: 4 - Keys []byte // size: 4 - Valuators []uint32 // size: 12 -} - -// Event read XinputDeviceStateNotify -func NewXinputDeviceStateNotifyEvent(buf []byte) Event { - v := XinputDeviceStateNotifyEvent{} - b := 1 // don't read event number - - v.DeviceId = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Time = Timestamp(Get32(buf[b:])) - b += 4 - - v.NumKeys = buf[b] - b += 1 - - v.NumButtons = buf[b] - b += 1 - - v.NumValuators = buf[b] - b += 1 - - v.ClassesReported = buf[b] - b += 1 - - v.Buttons = make([]byte, 4) - copy(v.Buttons[:4], buf[b:]) - b += pad(int(4)) - - v.Keys = make([]byte, 4) - copy(v.Keys[:4], buf[b:]) - b += pad(int(4)) - - v.Valuators = make([]uint32, 3) - for i := 0; i < int(3); i++ { - v.Valuators[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -// Event write XinputDeviceStateNotify -func (v XinputDeviceStateNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 10 - b += 1 - - buf[b] = v.DeviceId - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Time)) - b += 4 - - buf[b] = v.NumKeys - b += 1 - - buf[b] = v.NumButtons - b += 1 - - buf[b] = v.NumValuators - b += 1 - - buf[b] = v.ClassesReported - b += 1 - - copy(buf[b:], v.Buttons[:4]) - b += pad(int(4)) - - copy(buf[b:], v.Keys[:4]) - b += pad(int(4)) - - for i := 0; i < int(3); i++ { - Put32(buf[b:], v.Valuators[i]) - b += 4 - } - b = pad(b) - - return buf -} - -func (v XinputDeviceStateNotifyEvent) ImplementsEvent() {} - -func (v XinputDeviceStateNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XinputDeviceStateNotifyEvent) String() string { - fieldVals := make([]string, 0, 9) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("DeviceId: %d", v.DeviceId)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("NumKeys: %d", v.NumKeys)) - fieldVals = append(fieldVals, sprintf("NumButtons: %d", v.NumButtons)) - fieldVals = append(fieldVals, sprintf("NumValuators: %d", v.NumValuators)) - fieldVals = append(fieldVals, sprintf("ClassesReported: %d", v.ClassesReported)) - return "XinputDeviceStateNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XInputExtension"][10] = NewXinputDeviceStateNotifyEvent -} - -// Event definition XinputDeviceMappingNotify (11) -// Size: 32 - -const XinputDeviceMappingNotify = 11 - -type XinputDeviceMappingNotifyEvent struct { - Sequence uint16 - DeviceId byte - Request byte - FirstKeycode XinputKeyCode - Count byte - // padding: 1 bytes - Time Timestamp - // padding: 20 bytes -} - -// Event read XinputDeviceMappingNotify -func NewXinputDeviceMappingNotifyEvent(buf []byte) Event { - v := XinputDeviceMappingNotifyEvent{} - b := 1 // don't read event number - - v.DeviceId = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Request = buf[b] - b += 1 - - v.FirstKeycode = XinputKeyCode(buf[b]) - b += 1 - - v.Count = buf[b] - b += 1 - - b += 1 // padding - - v.Time = Timestamp(Get32(buf[b:])) - b += 4 - - b += 20 // padding - - return v -} - -// Event write XinputDeviceMappingNotify -func (v XinputDeviceMappingNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 11 - b += 1 - - buf[b] = v.DeviceId - b += 1 - - b += 2 // skip sequence number - - buf[b] = v.Request - b += 1 - - buf[b] = byte(v.FirstKeycode) - b += 1 - - buf[b] = v.Count - b += 1 - - b += 1 // padding - - Put32(buf[b:], uint32(v.Time)) - b += 4 - - b += 20 // padding - - return buf -} - -func (v XinputDeviceMappingNotifyEvent) ImplementsEvent() {} - -func (v XinputDeviceMappingNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XinputDeviceMappingNotifyEvent) String() string { - fieldVals := make([]string, 0, 7) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("DeviceId: %d", v.DeviceId)) - fieldVals = append(fieldVals, sprintf("Request: %d", v.Request)) - fieldVals = append(fieldVals, sprintf("FirstKeycode: %d", v.FirstKeycode)) - fieldVals = append(fieldVals, sprintf("Count: %d", v.Count)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - return "XinputDeviceMappingNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XInputExtension"][11] = NewXinputDeviceMappingNotifyEvent -} - -// Event definition XinputChangeDeviceNotify (12) -// Size: 32 - -const XinputChangeDeviceNotify = 12 - -type XinputChangeDeviceNotifyEvent struct { - Sequence uint16 - DeviceId byte - Time Timestamp - Request byte - // padding: 23 bytes -} - -// Event read XinputChangeDeviceNotify -func NewXinputChangeDeviceNotifyEvent(buf []byte) Event { - v := XinputChangeDeviceNotifyEvent{} - b := 1 // don't read event number - - v.DeviceId = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Time = Timestamp(Get32(buf[b:])) - b += 4 - - v.Request = buf[b] - b += 1 - - b += 23 // padding - - return v -} - -// Event write XinputChangeDeviceNotify -func (v XinputChangeDeviceNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 12 - b += 1 - - buf[b] = v.DeviceId - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Time)) - b += 4 - - buf[b] = v.Request - b += 1 - - b += 23 // padding - - return buf -} - -func (v XinputChangeDeviceNotifyEvent) ImplementsEvent() {} - -func (v XinputChangeDeviceNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XinputChangeDeviceNotifyEvent) String() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("DeviceId: %d", v.DeviceId)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Request: %d", v.Request)) - return "XinputChangeDeviceNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XInputExtension"][12] = NewXinputChangeDeviceNotifyEvent -} - -// Event definition XinputDeviceKeyStateNotify (13) -// Size: 32 - -const XinputDeviceKeyStateNotify = 13 - -type XinputDeviceKeyStateNotifyEvent struct { - Sequence uint16 - DeviceId byte - Keys []byte // size: 28 -} - -// Event read XinputDeviceKeyStateNotify -func NewXinputDeviceKeyStateNotifyEvent(buf []byte) Event { - v := XinputDeviceKeyStateNotifyEvent{} - b := 1 // don't read event number - - v.DeviceId = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Keys = make([]byte, 28) - copy(v.Keys[:28], buf[b:]) - b += pad(int(28)) - - return v -} - -// Event write XinputDeviceKeyStateNotify -func (v XinputDeviceKeyStateNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 13 - b += 1 - - buf[b] = v.DeviceId - b += 1 - - b += 2 // skip sequence number - - copy(buf[b:], v.Keys[:28]) - b += pad(int(28)) - - return buf -} - -func (v XinputDeviceKeyStateNotifyEvent) ImplementsEvent() {} - -func (v XinputDeviceKeyStateNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XinputDeviceKeyStateNotifyEvent) String() string { - fieldVals := make([]string, 0, 2) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("DeviceId: %d", v.DeviceId)) - return "XinputDeviceKeyStateNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XInputExtension"][13] = NewXinputDeviceKeyStateNotifyEvent -} - -// Event definition XinputDeviceButtonStateNotify (14) -// Size: 32 - -const XinputDeviceButtonStateNotify = 14 - -type XinputDeviceButtonStateNotifyEvent struct { - Sequence uint16 - DeviceId byte - Buttons []byte // size: 28 -} - -// Event read XinputDeviceButtonStateNotify -func NewXinputDeviceButtonStateNotifyEvent(buf []byte) Event { - v := XinputDeviceButtonStateNotifyEvent{} - b := 1 // don't read event number - - v.DeviceId = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Buttons = make([]byte, 28) - copy(v.Buttons[:28], buf[b:]) - b += pad(int(28)) - - return v -} - -// Event write XinputDeviceButtonStateNotify -func (v XinputDeviceButtonStateNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 14 - b += 1 - - buf[b] = v.DeviceId - b += 1 - - b += 2 // skip sequence number - - copy(buf[b:], v.Buttons[:28]) - b += pad(int(28)) - - return buf -} - -func (v XinputDeviceButtonStateNotifyEvent) ImplementsEvent() {} - -func (v XinputDeviceButtonStateNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XinputDeviceButtonStateNotifyEvent) String() string { - fieldVals := make([]string, 0, 2) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("DeviceId: %d", v.DeviceId)) - return "XinputDeviceButtonStateNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XInputExtension"][14] = NewXinputDeviceButtonStateNotifyEvent -} - -// Event definition XinputDevicePresenceNotify (15) -// Size: 32 - -const XinputDevicePresenceNotify = 15 - -type XinputDevicePresenceNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Time Timestamp - Devchange byte - DeviceId byte - Control uint16 - // padding: 20 bytes -} - -// Event read XinputDevicePresenceNotify -func NewXinputDevicePresenceNotifyEvent(buf []byte) Event { - v := XinputDevicePresenceNotifyEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Time = Timestamp(Get32(buf[b:])) - b += 4 - - v.Devchange = buf[b] - b += 1 - - v.DeviceId = buf[b] - b += 1 - - v.Control = Get16(buf[b:]) - b += 2 - - b += 20 // padding - - return v -} - -// Event write XinputDevicePresenceNotify -func (v XinputDevicePresenceNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 15 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Time)) - b += 4 - - buf[b] = v.Devchange - b += 1 - - buf[b] = v.DeviceId - b += 1 - - Put16(buf[b:], v.Control) - b += 2 - - b += 20 // padding - - return buf -} - -func (v XinputDevicePresenceNotifyEvent) ImplementsEvent() {} - -func (v XinputDevicePresenceNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XinputDevicePresenceNotifyEvent) String() string { - fieldVals := make([]string, 0, 6) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Devchange: %d", v.Devchange)) - fieldVals = append(fieldVals, sprintf("DeviceId: %d", v.DeviceId)) - fieldVals = append(fieldVals, sprintf("Control: %d", v.Control)) - return "XinputDevicePresenceNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XInputExtension"][15] = NewXinputDevicePresenceNotifyEvent -} - -// EventCopy definition XinputDeviceKeyRelease (2) - -const XinputDeviceKeyRelease = 2 - -type XinputDeviceKeyReleaseEvent XinputDeviceKeyPressEvent - -func NewXinputDeviceKeyReleaseEvent(buf []byte) Event { - return XinputDeviceKeyReleaseEvent(NewXinputDeviceKeyPressEvent(buf).(XinputDeviceKeyPressEvent)) -} - -func (v XinputDeviceKeyReleaseEvent) Bytes() []byte { - return XinputDeviceKeyPressEvent(v).Bytes() -} - -func (v XinputDeviceKeyReleaseEvent) ImplementsEvent() {} - -func (v XinputDeviceKeyReleaseEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XinputDeviceKeyReleaseEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, sprintf("SameScreen: %t", v.SameScreen)) - fieldVals = append(fieldVals, sprintf("DeviceId: %d", v.DeviceId)) - return "XinputDeviceKeyRelease {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XInputExtension"][2] = NewXinputDeviceKeyReleaseEvent -} - -// EventCopy definition XinputDeviceButtonPress (3) - -const XinputDeviceButtonPress = 3 - -type XinputDeviceButtonPressEvent XinputDeviceKeyPressEvent - -func NewXinputDeviceButtonPressEvent(buf []byte) Event { - return XinputDeviceButtonPressEvent(NewXinputDeviceKeyPressEvent(buf).(XinputDeviceKeyPressEvent)) -} - -func (v XinputDeviceButtonPressEvent) Bytes() []byte { - return XinputDeviceKeyPressEvent(v).Bytes() -} - -func (v XinputDeviceButtonPressEvent) ImplementsEvent() {} - -func (v XinputDeviceButtonPressEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XinputDeviceButtonPressEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, sprintf("SameScreen: %t", v.SameScreen)) - fieldVals = append(fieldVals, sprintf("DeviceId: %d", v.DeviceId)) - return "XinputDeviceButtonPress {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XInputExtension"][3] = NewXinputDeviceButtonPressEvent -} - -// EventCopy definition XinputDeviceButtonRelease (4) - -const XinputDeviceButtonRelease = 4 - -type XinputDeviceButtonReleaseEvent XinputDeviceKeyPressEvent - -func NewXinputDeviceButtonReleaseEvent(buf []byte) Event { - return XinputDeviceButtonReleaseEvent(NewXinputDeviceKeyPressEvent(buf).(XinputDeviceKeyPressEvent)) -} - -func (v XinputDeviceButtonReleaseEvent) Bytes() []byte { - return XinputDeviceKeyPressEvent(v).Bytes() -} - -func (v XinputDeviceButtonReleaseEvent) ImplementsEvent() {} - -func (v XinputDeviceButtonReleaseEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XinputDeviceButtonReleaseEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, sprintf("SameScreen: %t", v.SameScreen)) - fieldVals = append(fieldVals, sprintf("DeviceId: %d", v.DeviceId)) - return "XinputDeviceButtonRelease {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XInputExtension"][4] = NewXinputDeviceButtonReleaseEvent -} - -// EventCopy definition XinputDeviceMotionNotify (5) - -const XinputDeviceMotionNotify = 5 - -type XinputDeviceMotionNotifyEvent XinputDeviceKeyPressEvent - -func NewXinputDeviceMotionNotifyEvent(buf []byte) Event { - return XinputDeviceMotionNotifyEvent(NewXinputDeviceKeyPressEvent(buf).(XinputDeviceKeyPressEvent)) -} - -func (v XinputDeviceMotionNotifyEvent) Bytes() []byte { - return XinputDeviceKeyPressEvent(v).Bytes() -} - -func (v XinputDeviceMotionNotifyEvent) ImplementsEvent() {} - -func (v XinputDeviceMotionNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XinputDeviceMotionNotifyEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, sprintf("SameScreen: %t", v.SameScreen)) - fieldVals = append(fieldVals, sprintf("DeviceId: %d", v.DeviceId)) - return "XinputDeviceMotionNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XInputExtension"][5] = NewXinputDeviceMotionNotifyEvent -} - -// EventCopy definition XinputProximityIn (8) - -const XinputProximityIn = 8 - -type XinputProximityInEvent XinputDeviceKeyPressEvent - -func NewXinputProximityInEvent(buf []byte) Event { - return XinputProximityInEvent(NewXinputDeviceKeyPressEvent(buf).(XinputDeviceKeyPressEvent)) -} - -func (v XinputProximityInEvent) Bytes() []byte { - return XinputDeviceKeyPressEvent(v).Bytes() -} - -func (v XinputProximityInEvent) ImplementsEvent() {} - -func (v XinputProximityInEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XinputProximityInEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, sprintf("SameScreen: %t", v.SameScreen)) - fieldVals = append(fieldVals, sprintf("DeviceId: %d", v.DeviceId)) - return "XinputProximityIn {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XInputExtension"][8] = NewXinputProximityInEvent -} - -// EventCopy definition XinputProximityOut (9) - -const XinputProximityOut = 9 - -type XinputProximityOutEvent XinputDeviceKeyPressEvent - -func NewXinputProximityOutEvent(buf []byte) Event { - return XinputProximityOutEvent(NewXinputDeviceKeyPressEvent(buf).(XinputDeviceKeyPressEvent)) -} - -func (v XinputProximityOutEvent) Bytes() []byte { - return XinputDeviceKeyPressEvent(v).Bytes() -} - -func (v XinputProximityOutEvent) ImplementsEvent() {} - -func (v XinputProximityOutEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XinputProximityOutEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, sprintf("SameScreen: %t", v.SameScreen)) - fieldVals = append(fieldVals, sprintf("DeviceId: %d", v.DeviceId)) - return "XinputProximityOut {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XInputExtension"][9] = NewXinputProximityOutEvent -} - -// EventCopy definition XinputFocusOut (7) - -const XinputFocusOut = 7 - -type XinputFocusOutEvent XinputFocusInEvent - -func NewXinputFocusOutEvent(buf []byte) Event { - return XinputFocusOutEvent(NewXinputFocusInEvent(buf).(XinputFocusInEvent)) -} - -func (v XinputFocusOutEvent) Bytes() []byte { - return XinputFocusInEvent(v).Bytes() -} - -func (v XinputFocusOutEvent) ImplementsEvent() {} - -func (v XinputFocusOutEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XinputFocusOutEvent) String() string { - fieldVals := make([]string, 0, 6) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, sprintf("Mode: %d", v.Mode)) - fieldVals = append(fieldVals, sprintf("DeviceId: %d", v.DeviceId)) - return "XinputFocusOut {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XInputExtension"][7] = NewXinputFocusOutEvent -} - -// Error definition XinputDevice (0) -// Size: 32 - -const BadXinputDevice = 0 - -type XinputDeviceError struct { - Sequence uint16 - NiceName string -} - -// Error read XinputDevice -func NewXinputDeviceError(buf []byte) Error { - v := XinputDeviceError{} - v.NiceName = "XinputDevice" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err XinputDeviceError) ImplementsError() {} - -func (err XinputDeviceError) SequenceId() uint16 { - return err.Sequence -} - -func (err XinputDeviceError) BadId() uint32 { - return 0 -} - -func (err XinputDeviceError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadXinputDevice {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["XInputExtension"][0] = NewXinputDeviceError -} - -// Error definition XinputEvent (1) -// Size: 32 - -const BadXinputEvent = 1 - -type XinputEventError struct { - Sequence uint16 - NiceName string -} - -// Error read XinputEvent -func NewXinputEventError(buf []byte) Error { - v := XinputEventError{} - v.NiceName = "XinputEvent" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err XinputEventError) ImplementsError() {} - -func (err XinputEventError) SequenceId() uint16 { - return err.Sequence -} - -func (err XinputEventError) BadId() uint32 { - return 0 -} - -func (err XinputEventError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadXinputEvent {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["XInputExtension"][1] = NewXinputEventError -} - -// Error definition XinputMode (2) -// Size: 32 - -const BadXinputMode = 2 - -type XinputModeError struct { - Sequence uint16 - NiceName string -} - -// Error read XinputMode -func NewXinputModeError(buf []byte) Error { - v := XinputModeError{} - v.NiceName = "XinputMode" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err XinputModeError) ImplementsError() {} - -func (err XinputModeError) SequenceId() uint16 { - return err.Sequence -} - -func (err XinputModeError) BadId() uint32 { - return 0 -} - -func (err XinputModeError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadXinputMode {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["XInputExtension"][2] = NewXinputModeError -} - -// Error definition XinputDeviceBusy (3) -// Size: 32 - -const BadXinputDeviceBusy = 3 - -type XinputDeviceBusyError struct { - Sequence uint16 - NiceName string -} - -// Error read XinputDeviceBusy -func NewXinputDeviceBusyError(buf []byte) Error { - v := XinputDeviceBusyError{} - v.NiceName = "XinputDeviceBusy" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err XinputDeviceBusyError) ImplementsError() {} - -func (err XinputDeviceBusyError) SequenceId() uint16 { - return err.Sequence -} - -func (err XinputDeviceBusyError) BadId() uint32 { - return 0 -} - -func (err XinputDeviceBusyError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadXinputDeviceBusy {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["XInputExtension"][3] = NewXinputDeviceBusyError -} - -// Error definition XinputClass (4) -// Size: 32 - -const BadXinputClass = 4 - -type XinputClassError struct { - Sequence uint16 - NiceName string -} - -// Error read XinputClass -func NewXinputClassError(buf []byte) Error { - v := XinputClassError{} - v.NiceName = "XinputClass" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err XinputClassError) ImplementsError() {} - -func (err XinputClassError) SequenceId() uint16 { - return err.Sequence -} - -func (err XinputClassError) BadId() uint32 { - return 0 -} - -func (err XinputClassError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadXinputClass {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["XInputExtension"][4] = NewXinputClassError -} - -// Request XinputGetExtensionVersion -// size: pad((8 + pad((int(NameLen) * 1)))) -type XinputGetExtensionVersionCookie struct { - *cookie -} - -func (c *Conn) XinputGetExtensionVersion(NameLen uint16, Name string) XinputGetExtensionVersionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputGetExtensionVersionRequest(NameLen, Name), cookie) - return XinputGetExtensionVersionCookie{cookie} -} - -func (c *Conn) XinputGetExtensionVersionUnchecked(NameLen uint16, Name string) XinputGetExtensionVersionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputGetExtensionVersionRequest(NameLen, Name), cookie) - return XinputGetExtensionVersionCookie{cookie} -} - -// Request reply for XinputGetExtensionVersion -// size: 32 -type XinputGetExtensionVersionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ServerMajor uint16 - ServerMinor uint16 - Present bool - // padding: 19 bytes -} - -// Waits and reads reply data from request XinputGetExtensionVersion -func (cook XinputGetExtensionVersionCookie) Reply() (*XinputGetExtensionVersionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputGetExtensionVersionReply(buf), nil -} - -// Read reply into structure from buffer for XinputGetExtensionVersion -func xinputGetExtensionVersionReply(buf []byte) *XinputGetExtensionVersionReply { - v := new(XinputGetExtensionVersionReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.ServerMajor = Get16(buf[b:]) - b += 2 - - v.ServerMinor = Get16(buf[b:]) - b += 2 - - if buf[b] == 1 { - v.Present = true - } else { - v.Present = false - } - b += 1 - - b += 19 // padding - - return v -} - -func (cook XinputGetExtensionVersionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputGetExtensionVersion -func (c *Conn) xinputGetExtensionVersionRequest(NameLen uint16, Name string) []byte { - size := pad((8 + pad((int(NameLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 1 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], NameLen) - b += 2 - - b += 2 // padding - - copy(buf[b:], Name[:NameLen]) - b += pad(int(NameLen)) - - return buf -} - -// Request XinputListInputDevices -// size: 4 -type XinputListInputDevicesCookie struct { - *cookie -} - -func (c *Conn) XinputListInputDevices() XinputListInputDevicesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputListInputDevicesRequest(), cookie) - return XinputListInputDevicesCookie{cookie} -} - -func (c *Conn) XinputListInputDevicesUnchecked() XinputListInputDevicesCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputListInputDevicesRequest(), cookie) - return XinputListInputDevicesCookie{cookie} -} - -// Request reply for XinputListInputDevices -// size: (32 + pad((int(DevicesLen) * 8))) -type XinputListInputDevicesReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - DevicesLen byte - // padding: 23 bytes - Devices []XinputDeviceInfo // size: pad((int(DevicesLen) * 8)) -} - -// Waits and reads reply data from request XinputListInputDevices -func (cook XinputListInputDevicesCookie) Reply() (*XinputListInputDevicesReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputListInputDevicesReply(buf), nil -} - -// Read reply into structure from buffer for XinputListInputDevices -func xinputListInputDevicesReply(buf []byte) *XinputListInputDevicesReply { - v := new(XinputListInputDevicesReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.DevicesLen = buf[b] - b += 1 - - b += 23 // padding - - v.Devices = make([]XinputDeviceInfo, v.DevicesLen) - b += ReadXinputDeviceInfoList(buf[b:], v.Devices) - - return v -} - -func (cook XinputListInputDevicesCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputListInputDevices -func (c *Conn) xinputListInputDevicesRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 2 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request XinputOpenDevice -// size: 8 -type XinputOpenDeviceCookie struct { - *cookie -} - -func (c *Conn) XinputOpenDevice(DeviceId byte) XinputOpenDeviceCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputOpenDeviceRequest(DeviceId), cookie) - return XinputOpenDeviceCookie{cookie} -} - -func (c *Conn) XinputOpenDeviceUnchecked(DeviceId byte) XinputOpenDeviceCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputOpenDeviceRequest(DeviceId), cookie) - return XinputOpenDeviceCookie{cookie} -} - -// Request reply for XinputOpenDevice -// size: (32 + pad((int(NumClasses) * 2))) -type XinputOpenDeviceReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumClasses byte - // padding: 23 bytes - ClassInfo []XinputInputClassInfo // size: pad((int(NumClasses) * 2)) -} - -// Waits and reads reply data from request XinputOpenDevice -func (cook XinputOpenDeviceCookie) Reply() (*XinputOpenDeviceReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputOpenDeviceReply(buf), nil -} - -// Read reply into structure from buffer for XinputOpenDevice -func xinputOpenDeviceReply(buf []byte) *XinputOpenDeviceReply { - v := new(XinputOpenDeviceReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.NumClasses = buf[b] - b += 1 - - b += 23 // padding - - v.ClassInfo = make([]XinputInputClassInfo, v.NumClasses) - b += ReadXinputInputClassInfoList(buf[b:], v.ClassInfo) - - return v -} - -func (cook XinputOpenDeviceCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputOpenDevice -func (c *Conn) xinputOpenDeviceRequest(DeviceId byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 3 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = DeviceId - b += 1 - - b += 3 // padding - - return buf -} - -// Request XinputCloseDevice -// size: 8 -type XinputCloseDeviceCookie struct { - *cookie -} - -// Write request to wire for XinputCloseDevice -func (c *Conn) XinputCloseDevice(DeviceId byte) XinputCloseDeviceCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xinputCloseDeviceRequest(DeviceId), cookie) - return XinputCloseDeviceCookie{cookie} -} - -func (c *Conn) XinputCloseDeviceChecked(DeviceId byte) XinputCloseDeviceCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xinputCloseDeviceRequest(DeviceId), cookie) - return XinputCloseDeviceCookie{cookie} -} - -func (cook XinputCloseDeviceCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputCloseDevice -func (c *Conn) xinputCloseDeviceRequest(DeviceId byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 4 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = DeviceId - b += 1 - - b += 3 // padding - - return buf -} - -// Request XinputSetDeviceMode -// size: 8 -type XinputSetDeviceModeCookie struct { - *cookie -} - -func (c *Conn) XinputSetDeviceMode(DeviceId byte, Mode byte) XinputSetDeviceModeCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputSetDeviceModeRequest(DeviceId, Mode), cookie) - return XinputSetDeviceModeCookie{cookie} -} - -func (c *Conn) XinputSetDeviceModeUnchecked(DeviceId byte, Mode byte) XinputSetDeviceModeCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputSetDeviceModeRequest(DeviceId, Mode), cookie) - return XinputSetDeviceModeCookie{cookie} -} - -// Request reply for XinputSetDeviceMode -// size: 32 -type XinputSetDeviceModeReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Status byte - // padding: 23 bytes -} - -// Waits and reads reply data from request XinputSetDeviceMode -func (cook XinputSetDeviceModeCookie) Reply() (*XinputSetDeviceModeReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputSetDeviceModeReply(buf), nil -} - -// Read reply into structure from buffer for XinputSetDeviceMode -func xinputSetDeviceModeReply(buf []byte) *XinputSetDeviceModeReply { - v := new(XinputSetDeviceModeReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Status = buf[b] - b += 1 - - b += 23 // padding - - return v -} - -func (cook XinputSetDeviceModeCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputSetDeviceMode -func (c *Conn) xinputSetDeviceModeRequest(DeviceId byte, Mode byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 5 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = DeviceId - b += 1 - - buf[b] = Mode - b += 1 - - b += 2 // padding - - return buf -} - -// Request XinputSelectExtensionEvent -// size: pad((12 + pad((int(NumClasses) * 4)))) -type XinputSelectExtensionEventCookie struct { - *cookie -} - -// Write request to wire for XinputSelectExtensionEvent -func (c *Conn) XinputSelectExtensionEvent(Window Window, NumClasses uint16, Classes []XinputEventClass) XinputSelectExtensionEventCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xinputSelectExtensionEventRequest(Window, NumClasses, Classes), cookie) - return XinputSelectExtensionEventCookie{cookie} -} - -func (c *Conn) XinputSelectExtensionEventChecked(Window Window, NumClasses uint16, Classes []XinputEventClass) XinputSelectExtensionEventCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xinputSelectExtensionEventRequest(Window, NumClasses, Classes), cookie) - return XinputSelectExtensionEventCookie{cookie} -} - -func (cook XinputSelectExtensionEventCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputSelectExtensionEvent -func (c *Conn) xinputSelectExtensionEventRequest(Window Window, NumClasses uint16, Classes []XinputEventClass) []byte { - size := pad((12 + pad((int(NumClasses) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 6 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - Put16(buf[b:], NumClasses) - b += 2 - - b += 2 // padding - - for i := 0; i < int(NumClasses); i++ { - Put32(buf[b:], uint32(Classes[i])) - b += 4 - } - b = pad(b) - - return buf -} - -// Request XinputGetSelectedExtensionEvents -// size: 8 -type XinputGetSelectedExtensionEventsCookie struct { - *cookie -} - -func (c *Conn) XinputGetSelectedExtensionEvents(Window Window) XinputGetSelectedExtensionEventsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputGetSelectedExtensionEventsRequest(Window), cookie) - return XinputGetSelectedExtensionEventsCookie{cookie} -} - -func (c *Conn) XinputGetSelectedExtensionEventsUnchecked(Window Window) XinputGetSelectedExtensionEventsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputGetSelectedExtensionEventsRequest(Window), cookie) - return XinputGetSelectedExtensionEventsCookie{cookie} -} - -// Request reply for XinputGetSelectedExtensionEvents -// size: ((32 + pad((int(NumThisClasses) * 4))) + pad((int(NumAllClasses) * 4))) -type XinputGetSelectedExtensionEventsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumThisClasses uint16 - NumAllClasses uint16 - // padding: 20 bytes - ThisClasses []XinputEventClass // size: pad((int(NumThisClasses) * 4)) - AllClasses []XinputEventClass // size: pad((int(NumAllClasses) * 4)) -} - -// Waits and reads reply data from request XinputGetSelectedExtensionEvents -func (cook XinputGetSelectedExtensionEventsCookie) Reply() (*XinputGetSelectedExtensionEventsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputGetSelectedExtensionEventsReply(buf), nil -} - -// Read reply into structure from buffer for XinputGetSelectedExtensionEvents -func xinputGetSelectedExtensionEventsReply(buf []byte) *XinputGetSelectedExtensionEventsReply { - v := new(XinputGetSelectedExtensionEventsReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.NumThisClasses = Get16(buf[b:]) - b += 2 - - v.NumAllClasses = Get16(buf[b:]) - b += 2 - - b += 20 // padding - - v.ThisClasses = make([]XinputEventClass, v.NumThisClasses) - for i := 0; i < int(v.NumThisClasses); i++ { - v.ThisClasses[i] = XinputEventClass(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - v.AllClasses = make([]XinputEventClass, v.NumAllClasses) - for i := 0; i < int(v.NumAllClasses); i++ { - v.AllClasses[i] = XinputEventClass(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook XinputGetSelectedExtensionEventsCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputGetSelectedExtensionEvents -func (c *Conn) xinputGetSelectedExtensionEventsRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 7 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - return buf -} - -// Request XinputChangeDeviceDontPropagateList -// size: pad((12 + pad((int(NumClasses) * 4)))) -type XinputChangeDeviceDontPropagateListCookie struct { - *cookie -} - -// Write request to wire for XinputChangeDeviceDontPropagateList -func (c *Conn) XinputChangeDeviceDontPropagateList(Window Window, NumClasses uint16, Mode byte, Classes []XinputEventClass) XinputChangeDeviceDontPropagateListCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xinputChangeDeviceDontPropagateListRequest(Window, NumClasses, Mode, Classes), cookie) - return XinputChangeDeviceDontPropagateListCookie{cookie} -} - -func (c *Conn) XinputChangeDeviceDontPropagateListChecked(Window Window, NumClasses uint16, Mode byte, Classes []XinputEventClass) XinputChangeDeviceDontPropagateListCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xinputChangeDeviceDontPropagateListRequest(Window, NumClasses, Mode, Classes), cookie) - return XinputChangeDeviceDontPropagateListCookie{cookie} -} - -func (cook XinputChangeDeviceDontPropagateListCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputChangeDeviceDontPropagateList -func (c *Conn) xinputChangeDeviceDontPropagateListRequest(Window Window, NumClasses uint16, Mode byte, Classes []XinputEventClass) []byte { - size := pad((12 + pad((int(NumClasses) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 8 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - Put16(buf[b:], NumClasses) - b += 2 - - buf[b] = Mode - b += 1 - - b += 1 // padding - - for i := 0; i < int(NumClasses); i++ { - Put32(buf[b:], uint32(Classes[i])) - b += 4 - } - b = pad(b) - - return buf -} - -// Request XinputGetDeviceDontPropagateList -// size: 8 -type XinputGetDeviceDontPropagateListCookie struct { - *cookie -} - -func (c *Conn) XinputGetDeviceDontPropagateList(Window Window) XinputGetDeviceDontPropagateListCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputGetDeviceDontPropagateListRequest(Window), cookie) - return XinputGetDeviceDontPropagateListCookie{cookie} -} - -func (c *Conn) XinputGetDeviceDontPropagateListUnchecked(Window Window) XinputGetDeviceDontPropagateListCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputGetDeviceDontPropagateListRequest(Window), cookie) - return XinputGetDeviceDontPropagateListCookie{cookie} -} - -// Request reply for XinputGetDeviceDontPropagateList -// size: (32 + pad((int(NumClasses) * 4))) -type XinputGetDeviceDontPropagateListReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumClasses uint16 - // padding: 22 bytes - Classes []XinputEventClass // size: pad((int(NumClasses) * 4)) -} - -// Waits and reads reply data from request XinputGetDeviceDontPropagateList -func (cook XinputGetDeviceDontPropagateListCookie) Reply() (*XinputGetDeviceDontPropagateListReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputGetDeviceDontPropagateListReply(buf), nil -} - -// Read reply into structure from buffer for XinputGetDeviceDontPropagateList -func xinputGetDeviceDontPropagateListReply(buf []byte) *XinputGetDeviceDontPropagateListReply { - v := new(XinputGetDeviceDontPropagateListReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.NumClasses = Get16(buf[b:]) - b += 2 - - b += 22 // padding - - v.Classes = make([]XinputEventClass, v.NumClasses) - for i := 0; i < int(v.NumClasses); i++ { - v.Classes[i] = XinputEventClass(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook XinputGetDeviceDontPropagateListCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputGetDeviceDontPropagateList -func (c *Conn) xinputGetDeviceDontPropagateListRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 9 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - return buf -} - -// Request XinputGetDeviceMotionEvents -// size: 16 -type XinputGetDeviceMotionEventsCookie struct { - *cookie -} - -func (c *Conn) XinputGetDeviceMotionEvents(Start Timestamp, Stop Timestamp, DeviceId byte) XinputGetDeviceMotionEventsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputGetDeviceMotionEventsRequest(Start, Stop, DeviceId), cookie) - return XinputGetDeviceMotionEventsCookie{cookie} -} - -func (c *Conn) XinputGetDeviceMotionEventsUnchecked(Start Timestamp, Stop Timestamp, DeviceId byte) XinputGetDeviceMotionEventsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputGetDeviceMotionEventsRequest(Start, Stop, DeviceId), cookie) - return XinputGetDeviceMotionEventsCookie{cookie} -} - -// Request reply for XinputGetDeviceMotionEvents -// size: 32 -type XinputGetDeviceMotionEventsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumCoords uint32 - NumAxes byte - DeviceMode byte - // padding: 18 bytes -} - -// Waits and reads reply data from request XinputGetDeviceMotionEvents -func (cook XinputGetDeviceMotionEventsCookie) Reply() (*XinputGetDeviceMotionEventsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputGetDeviceMotionEventsReply(buf), nil -} - -// Read reply into structure from buffer for XinputGetDeviceMotionEvents -func xinputGetDeviceMotionEventsReply(buf []byte) *XinputGetDeviceMotionEventsReply { - v := new(XinputGetDeviceMotionEventsReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.NumCoords = Get32(buf[b:]) - b += 4 - - v.NumAxes = buf[b] - b += 1 - - v.DeviceMode = buf[b] - b += 1 - - b += 18 // padding - - return v -} - -func (cook XinputGetDeviceMotionEventsCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputGetDeviceMotionEvents -func (c *Conn) xinputGetDeviceMotionEventsRequest(Start Timestamp, Stop Timestamp, DeviceId byte) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 10 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Start)) - b += 4 - - Put32(buf[b:], uint32(Stop)) - b += 4 - - buf[b] = DeviceId - b += 1 - - return buf -} - -// Request XinputChangeKeyboardDevice -// size: 8 -type XinputChangeKeyboardDeviceCookie struct { - *cookie -} - -func (c *Conn) XinputChangeKeyboardDevice(DeviceId byte) XinputChangeKeyboardDeviceCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputChangeKeyboardDeviceRequest(DeviceId), cookie) - return XinputChangeKeyboardDeviceCookie{cookie} -} - -func (c *Conn) XinputChangeKeyboardDeviceUnchecked(DeviceId byte) XinputChangeKeyboardDeviceCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputChangeKeyboardDeviceRequest(DeviceId), cookie) - return XinputChangeKeyboardDeviceCookie{cookie} -} - -// Request reply for XinputChangeKeyboardDevice -// size: 32 -type XinputChangeKeyboardDeviceReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Status byte - // padding: 23 bytes -} - -// Waits and reads reply data from request XinputChangeKeyboardDevice -func (cook XinputChangeKeyboardDeviceCookie) Reply() (*XinputChangeKeyboardDeviceReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputChangeKeyboardDeviceReply(buf), nil -} - -// Read reply into structure from buffer for XinputChangeKeyboardDevice -func xinputChangeKeyboardDeviceReply(buf []byte) *XinputChangeKeyboardDeviceReply { - v := new(XinputChangeKeyboardDeviceReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Status = buf[b] - b += 1 - - b += 23 // padding - - return v -} - -func (cook XinputChangeKeyboardDeviceCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputChangeKeyboardDevice -func (c *Conn) xinputChangeKeyboardDeviceRequest(DeviceId byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 11 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = DeviceId - b += 1 - - b += 3 // padding - - return buf -} - -// Request XinputChangePointerDevice -// size: 8 -type XinputChangePointerDeviceCookie struct { - *cookie -} - -func (c *Conn) XinputChangePointerDevice(XAxis byte, YAxis byte, DeviceId byte) XinputChangePointerDeviceCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputChangePointerDeviceRequest(XAxis, YAxis, DeviceId), cookie) - return XinputChangePointerDeviceCookie{cookie} -} - -func (c *Conn) XinputChangePointerDeviceUnchecked(XAxis byte, YAxis byte, DeviceId byte) XinputChangePointerDeviceCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputChangePointerDeviceRequest(XAxis, YAxis, DeviceId), cookie) - return XinputChangePointerDeviceCookie{cookie} -} - -// Request reply for XinputChangePointerDevice -// size: 32 -type XinputChangePointerDeviceReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Status byte - // padding: 23 bytes -} - -// Waits and reads reply data from request XinputChangePointerDevice -func (cook XinputChangePointerDeviceCookie) Reply() (*XinputChangePointerDeviceReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputChangePointerDeviceReply(buf), nil -} - -// Read reply into structure from buffer for XinputChangePointerDevice -func xinputChangePointerDeviceReply(buf []byte) *XinputChangePointerDeviceReply { - v := new(XinputChangePointerDeviceReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Status = buf[b] - b += 1 - - b += 23 // padding - - return v -} - -func (cook XinputChangePointerDeviceCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputChangePointerDevice -func (c *Conn) xinputChangePointerDeviceRequest(XAxis byte, YAxis byte, DeviceId byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 12 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = XAxis - b += 1 - - buf[b] = YAxis - b += 1 - - buf[b] = DeviceId - b += 1 - - b += 1 // padding - - return buf -} - -// Request XinputGrabDevice -// size: pad((20 + pad((int(NumClasses) * 4)))) -type XinputGrabDeviceCookie struct { - *cookie -} - -func (c *Conn) XinputGrabDevice(GrabWindow Window, Time Timestamp, NumClasses uint16, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, DeviceId byte, Classes []XinputEventClass) XinputGrabDeviceCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputGrabDeviceRequest(GrabWindow, Time, NumClasses, ThisDeviceMode, OtherDeviceMode, OwnerEvents, DeviceId, Classes), cookie) - return XinputGrabDeviceCookie{cookie} -} - -func (c *Conn) XinputGrabDeviceUnchecked(GrabWindow Window, Time Timestamp, NumClasses uint16, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, DeviceId byte, Classes []XinputEventClass) XinputGrabDeviceCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputGrabDeviceRequest(GrabWindow, Time, NumClasses, ThisDeviceMode, OtherDeviceMode, OwnerEvents, DeviceId, Classes), cookie) - return XinputGrabDeviceCookie{cookie} -} - -// Request reply for XinputGrabDevice -// size: 32 -type XinputGrabDeviceReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Status byte - // padding: 23 bytes -} - -// Waits and reads reply data from request XinputGrabDevice -func (cook XinputGrabDeviceCookie) Reply() (*XinputGrabDeviceReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputGrabDeviceReply(buf), nil -} - -// Read reply into structure from buffer for XinputGrabDevice -func xinputGrabDeviceReply(buf []byte) *XinputGrabDeviceReply { - v := new(XinputGrabDeviceReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Status = buf[b] - b += 1 - - b += 23 // padding - - return v -} - -func (cook XinputGrabDeviceCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputGrabDevice -func (c *Conn) xinputGrabDeviceRequest(GrabWindow Window, Time Timestamp, NumClasses uint16, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, DeviceId byte, Classes []XinputEventClass) []byte { - size := pad((20 + pad((int(NumClasses) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 13 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(GrabWindow)) - b += 4 - - Put32(buf[b:], uint32(Time)) - b += 4 - - Put16(buf[b:], NumClasses) - b += 2 - - buf[b] = ThisDeviceMode - b += 1 - - buf[b] = OtherDeviceMode - b += 1 - - if OwnerEvents { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - buf[b] = DeviceId - b += 1 - - b += 2 // padding - - for i := 0; i < int(NumClasses); i++ { - Put32(buf[b:], uint32(Classes[i])) - b += 4 - } - b = pad(b) - - return buf -} - -// Request XinputUngrabDevice -// size: 12 -type XinputUngrabDeviceCookie struct { - *cookie -} - -// Write request to wire for XinputUngrabDevice -func (c *Conn) XinputUngrabDevice(Time Timestamp, DeviceId byte) XinputUngrabDeviceCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xinputUngrabDeviceRequest(Time, DeviceId), cookie) - return XinputUngrabDeviceCookie{cookie} -} - -func (c *Conn) XinputUngrabDeviceChecked(Time Timestamp, DeviceId byte) XinputUngrabDeviceCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xinputUngrabDeviceRequest(Time, DeviceId), cookie) - return XinputUngrabDeviceCookie{cookie} -} - -func (cook XinputUngrabDeviceCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputUngrabDevice -func (c *Conn) xinputUngrabDeviceRequest(Time Timestamp, DeviceId byte) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 14 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Time)) - b += 4 - - buf[b] = DeviceId - b += 1 - - return buf -} - -// Request XinputGrabDeviceKey -// size: pad((20 + pad((int(NumClasses) * 4)))) -type XinputGrabDeviceKeyCookie struct { - *cookie -} - -// Write request to wire for XinputGrabDeviceKey -func (c *Conn) XinputGrabDeviceKey(GrabWindow Window, NumClasses uint16, Modifiers uint16, ModifierDevice byte, GrabbedDevice byte, Key byte, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, Classes []XinputEventClass) XinputGrabDeviceKeyCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xinputGrabDeviceKeyRequest(GrabWindow, NumClasses, Modifiers, ModifierDevice, GrabbedDevice, Key, ThisDeviceMode, OtherDeviceMode, OwnerEvents, Classes), cookie) - return XinputGrabDeviceKeyCookie{cookie} -} - -func (c *Conn) XinputGrabDeviceKeyChecked(GrabWindow Window, NumClasses uint16, Modifiers uint16, ModifierDevice byte, GrabbedDevice byte, Key byte, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, Classes []XinputEventClass) XinputGrabDeviceKeyCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xinputGrabDeviceKeyRequest(GrabWindow, NumClasses, Modifiers, ModifierDevice, GrabbedDevice, Key, ThisDeviceMode, OtherDeviceMode, OwnerEvents, Classes), cookie) - return XinputGrabDeviceKeyCookie{cookie} -} - -func (cook XinputGrabDeviceKeyCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputGrabDeviceKey -func (c *Conn) xinputGrabDeviceKeyRequest(GrabWindow Window, NumClasses uint16, Modifiers uint16, ModifierDevice byte, GrabbedDevice byte, Key byte, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, Classes []XinputEventClass) []byte { - size := pad((20 + pad((int(NumClasses) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 15 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(GrabWindow)) - b += 4 - - Put16(buf[b:], NumClasses) - b += 2 - - Put16(buf[b:], Modifiers) - b += 2 - - buf[b] = ModifierDevice - b += 1 - - buf[b] = GrabbedDevice - b += 1 - - buf[b] = Key - b += 1 - - buf[b] = ThisDeviceMode - b += 1 - - buf[b] = OtherDeviceMode - b += 1 - - if OwnerEvents { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 2 // padding - - for i := 0; i < int(NumClasses); i++ { - Put32(buf[b:], uint32(Classes[i])) - b += 4 - } - b = pad(b) - - return buf -} - -// Request XinputUngrabDeviceKey -// size: 16 -type XinputUngrabDeviceKeyCookie struct { - *cookie -} - -// Write request to wire for XinputUngrabDeviceKey -func (c *Conn) XinputUngrabDeviceKey(GrabWindow Window, Modifiers uint16, ModifierDevice byte, Key byte, GrabbedDevice byte) XinputUngrabDeviceKeyCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xinputUngrabDeviceKeyRequest(GrabWindow, Modifiers, ModifierDevice, Key, GrabbedDevice), cookie) - return XinputUngrabDeviceKeyCookie{cookie} -} - -func (c *Conn) XinputUngrabDeviceKeyChecked(GrabWindow Window, Modifiers uint16, ModifierDevice byte, Key byte, GrabbedDevice byte) XinputUngrabDeviceKeyCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xinputUngrabDeviceKeyRequest(GrabWindow, Modifiers, ModifierDevice, Key, GrabbedDevice), cookie) - return XinputUngrabDeviceKeyCookie{cookie} -} - -func (cook XinputUngrabDeviceKeyCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputUngrabDeviceKey -func (c *Conn) xinputUngrabDeviceKeyRequest(GrabWindow Window, Modifiers uint16, ModifierDevice byte, Key byte, GrabbedDevice byte) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 16 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(GrabWindow)) - b += 4 - - Put16(buf[b:], Modifiers) - b += 2 - - buf[b] = ModifierDevice - b += 1 - - buf[b] = Key - b += 1 - - buf[b] = GrabbedDevice - b += 1 - - return buf -} - -// Request XinputGrabDeviceButton -// size: pad((20 + pad((int(NumClasses) * 4)))) -type XinputGrabDeviceButtonCookie struct { - *cookie -} - -// Write request to wire for XinputGrabDeviceButton -func (c *Conn) XinputGrabDeviceButton(GrabWindow Window, GrabbedDevice byte, ModifierDevice byte, NumClasses uint16, Modifiers uint16, ThisDeviceMode byte, OtherDeviceMode byte, Button byte, OwnerEvents byte, Classes []XinputEventClass) XinputGrabDeviceButtonCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xinputGrabDeviceButtonRequest(GrabWindow, GrabbedDevice, ModifierDevice, NumClasses, Modifiers, ThisDeviceMode, OtherDeviceMode, Button, OwnerEvents, Classes), cookie) - return XinputGrabDeviceButtonCookie{cookie} -} - -func (c *Conn) XinputGrabDeviceButtonChecked(GrabWindow Window, GrabbedDevice byte, ModifierDevice byte, NumClasses uint16, Modifiers uint16, ThisDeviceMode byte, OtherDeviceMode byte, Button byte, OwnerEvents byte, Classes []XinputEventClass) XinputGrabDeviceButtonCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xinputGrabDeviceButtonRequest(GrabWindow, GrabbedDevice, ModifierDevice, NumClasses, Modifiers, ThisDeviceMode, OtherDeviceMode, Button, OwnerEvents, Classes), cookie) - return XinputGrabDeviceButtonCookie{cookie} -} - -func (cook XinputGrabDeviceButtonCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputGrabDeviceButton -func (c *Conn) xinputGrabDeviceButtonRequest(GrabWindow Window, GrabbedDevice byte, ModifierDevice byte, NumClasses uint16, Modifiers uint16, ThisDeviceMode byte, OtherDeviceMode byte, Button byte, OwnerEvents byte, Classes []XinputEventClass) []byte { - size := pad((20 + pad((int(NumClasses) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 17 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(GrabWindow)) - b += 4 - - buf[b] = GrabbedDevice - b += 1 - - buf[b] = ModifierDevice - b += 1 - - Put16(buf[b:], NumClasses) - b += 2 - - Put16(buf[b:], Modifiers) - b += 2 - - buf[b] = ThisDeviceMode - b += 1 - - buf[b] = OtherDeviceMode - b += 1 - - buf[b] = Button - b += 1 - - buf[b] = OwnerEvents - b += 1 - - b += 2 // padding - - for i := 0; i < int(NumClasses); i++ { - Put32(buf[b:], uint32(Classes[i])) - b += 4 - } - b = pad(b) - - return buf -} - -// Request XinputUngrabDeviceButton -// size: 16 -type XinputUngrabDeviceButtonCookie struct { - *cookie -} - -// Write request to wire for XinputUngrabDeviceButton -func (c *Conn) XinputUngrabDeviceButton(GrabWindow Window, Modifiers uint16, ModifierDevice byte, Button byte, GrabbedDevice byte) XinputUngrabDeviceButtonCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xinputUngrabDeviceButtonRequest(GrabWindow, Modifiers, ModifierDevice, Button, GrabbedDevice), cookie) - return XinputUngrabDeviceButtonCookie{cookie} -} - -func (c *Conn) XinputUngrabDeviceButtonChecked(GrabWindow Window, Modifiers uint16, ModifierDevice byte, Button byte, GrabbedDevice byte) XinputUngrabDeviceButtonCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xinputUngrabDeviceButtonRequest(GrabWindow, Modifiers, ModifierDevice, Button, GrabbedDevice), cookie) - return XinputUngrabDeviceButtonCookie{cookie} -} - -func (cook XinputUngrabDeviceButtonCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputUngrabDeviceButton -func (c *Conn) xinputUngrabDeviceButtonRequest(GrabWindow Window, Modifiers uint16, ModifierDevice byte, Button byte, GrabbedDevice byte) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 18 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(GrabWindow)) - b += 4 - - Put16(buf[b:], Modifiers) - b += 2 - - buf[b] = ModifierDevice - b += 1 - - buf[b] = Button - b += 1 - - buf[b] = GrabbedDevice - b += 1 - - return buf -} - -// Request XinputAllowDeviceEvents -// size: 12 -type XinputAllowDeviceEventsCookie struct { - *cookie -} - -// Write request to wire for XinputAllowDeviceEvents -func (c *Conn) XinputAllowDeviceEvents(Time Timestamp, Mode byte, DeviceId byte) XinputAllowDeviceEventsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xinputAllowDeviceEventsRequest(Time, Mode, DeviceId), cookie) - return XinputAllowDeviceEventsCookie{cookie} -} - -func (c *Conn) XinputAllowDeviceEventsChecked(Time Timestamp, Mode byte, DeviceId byte) XinputAllowDeviceEventsCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xinputAllowDeviceEventsRequest(Time, Mode, DeviceId), cookie) - return XinputAllowDeviceEventsCookie{cookie} -} - -func (cook XinputAllowDeviceEventsCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputAllowDeviceEvents -func (c *Conn) xinputAllowDeviceEventsRequest(Time Timestamp, Mode byte, DeviceId byte) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 19 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Time)) - b += 4 - - buf[b] = Mode - b += 1 - - buf[b] = DeviceId - b += 1 - - return buf -} - -// Request XinputGetDeviceFocus -// size: 8 -type XinputGetDeviceFocusCookie struct { - *cookie -} - -func (c *Conn) XinputGetDeviceFocus(DeviceId byte) XinputGetDeviceFocusCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputGetDeviceFocusRequest(DeviceId), cookie) - return XinputGetDeviceFocusCookie{cookie} -} - -func (c *Conn) XinputGetDeviceFocusUnchecked(DeviceId byte) XinputGetDeviceFocusCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputGetDeviceFocusRequest(DeviceId), cookie) - return XinputGetDeviceFocusCookie{cookie} -} - -// Request reply for XinputGetDeviceFocus -// size: 32 -type XinputGetDeviceFocusReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Focus Window - Time Timestamp - RevertTo byte - // padding: 15 bytes -} - -// Waits and reads reply data from request XinputGetDeviceFocus -func (cook XinputGetDeviceFocusCookie) Reply() (*XinputGetDeviceFocusReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputGetDeviceFocusReply(buf), nil -} - -// Read reply into structure from buffer for XinputGetDeviceFocus -func xinputGetDeviceFocusReply(buf []byte) *XinputGetDeviceFocusReply { - v := new(XinputGetDeviceFocusReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Focus = Window(Get32(buf[b:])) - b += 4 - - v.Time = Timestamp(Get32(buf[b:])) - b += 4 - - v.RevertTo = buf[b] - b += 1 - - b += 15 // padding - - return v -} - -func (cook XinputGetDeviceFocusCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputGetDeviceFocus -func (c *Conn) xinputGetDeviceFocusRequest(DeviceId byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 20 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = DeviceId - b += 1 - - b += 3 // padding - - return buf -} - -// Request XinputSetDeviceFocus -// size: 16 -type XinputSetDeviceFocusCookie struct { - *cookie -} - -// Write request to wire for XinputSetDeviceFocus -func (c *Conn) XinputSetDeviceFocus(Focus Window, Time Timestamp, RevertTo byte, DeviceId byte) XinputSetDeviceFocusCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xinputSetDeviceFocusRequest(Focus, Time, RevertTo, DeviceId), cookie) - return XinputSetDeviceFocusCookie{cookie} -} - -func (c *Conn) XinputSetDeviceFocusChecked(Focus Window, Time Timestamp, RevertTo byte, DeviceId byte) XinputSetDeviceFocusCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xinputSetDeviceFocusRequest(Focus, Time, RevertTo, DeviceId), cookie) - return XinputSetDeviceFocusCookie{cookie} -} - -func (cook XinputSetDeviceFocusCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputSetDeviceFocus -func (c *Conn) xinputSetDeviceFocusRequest(Focus Window, Time Timestamp, RevertTo byte, DeviceId byte) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 21 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Focus)) - b += 4 - - Put32(buf[b:], uint32(Time)) - b += 4 - - buf[b] = RevertTo - b += 1 - - buf[b] = DeviceId - b += 1 - - return buf -} - -// Request XinputGetFeedbackControl -// size: 8 -type XinputGetFeedbackControlCookie struct { - *cookie -} - -func (c *Conn) XinputGetFeedbackControl(DeviceId byte) XinputGetFeedbackControlCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputGetFeedbackControlRequest(DeviceId), cookie) - return XinputGetFeedbackControlCookie{cookie} -} - -func (c *Conn) XinputGetFeedbackControlUnchecked(DeviceId byte) XinputGetFeedbackControlCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputGetFeedbackControlRequest(DeviceId), cookie) - return XinputGetFeedbackControlCookie{cookie} -} - -// Request reply for XinputGetFeedbackControl -// size: 32 -type XinputGetFeedbackControlReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumFeedback uint16 - // padding: 22 bytes -} - -// Waits and reads reply data from request XinputGetFeedbackControl -func (cook XinputGetFeedbackControlCookie) Reply() (*XinputGetFeedbackControlReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputGetFeedbackControlReply(buf), nil -} - -// Read reply into structure from buffer for XinputGetFeedbackControl -func xinputGetFeedbackControlReply(buf []byte) *XinputGetFeedbackControlReply { - v := new(XinputGetFeedbackControlReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.NumFeedback = Get16(buf[b:]) - b += 2 - - b += 22 // padding - - return v -} - -func (cook XinputGetFeedbackControlCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputGetFeedbackControl -func (c *Conn) xinputGetFeedbackControlRequest(DeviceId byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 22 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = DeviceId - b += 1 - - b += 3 // padding - - return buf -} - -// Request XinputGetDeviceKeyMapping -// size: 8 -type XinputGetDeviceKeyMappingCookie struct { - *cookie -} - -func (c *Conn) XinputGetDeviceKeyMapping(DeviceId byte, FirstKeycode XinputKeyCode, Count byte) XinputGetDeviceKeyMappingCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputGetDeviceKeyMappingRequest(DeviceId, FirstKeycode, Count), cookie) - return XinputGetDeviceKeyMappingCookie{cookie} -} - -func (c *Conn) XinputGetDeviceKeyMappingUnchecked(DeviceId byte, FirstKeycode XinputKeyCode, Count byte) XinputGetDeviceKeyMappingCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputGetDeviceKeyMappingRequest(DeviceId, FirstKeycode, Count), cookie) - return XinputGetDeviceKeyMappingCookie{cookie} -} - -// Request reply for XinputGetDeviceKeyMapping -// size: (32 + pad((int(Length) * 4))) -type XinputGetDeviceKeyMappingReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - KeysymsPerKeycode byte - // padding: 23 bytes - Keysyms []Keysym // size: pad((int(Length) * 4)) -} - -// Waits and reads reply data from request XinputGetDeviceKeyMapping -func (cook XinputGetDeviceKeyMappingCookie) Reply() (*XinputGetDeviceKeyMappingReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputGetDeviceKeyMappingReply(buf), nil -} - -// Read reply into structure from buffer for XinputGetDeviceKeyMapping -func xinputGetDeviceKeyMappingReply(buf []byte) *XinputGetDeviceKeyMappingReply { - v := new(XinputGetDeviceKeyMappingReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.KeysymsPerKeycode = buf[b] - b += 1 - - b += 23 // padding - - v.Keysyms = make([]Keysym, v.Length) - for i := 0; i < int(v.Length); i++ { - v.Keysyms[i] = Keysym(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook XinputGetDeviceKeyMappingCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputGetDeviceKeyMapping -func (c *Conn) xinputGetDeviceKeyMappingRequest(DeviceId byte, FirstKeycode XinputKeyCode, Count byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 24 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = DeviceId - b += 1 - - buf[b] = byte(FirstKeycode) - b += 1 - - buf[b] = Count - b += 1 - - return buf -} - -// Request XinputChangeDeviceKeyMapping -// size: pad((8 + pad(((int(KeycodeCount) * int(KeysymsPerKeycode)) * 4)))) -type XinputChangeDeviceKeyMappingCookie struct { - *cookie -} - -// Write request to wire for XinputChangeDeviceKeyMapping -func (c *Conn) XinputChangeDeviceKeyMapping(DeviceId byte, FirstKeycode XinputKeyCode, KeysymsPerKeycode byte, KeycodeCount byte, Keysyms []Keysym) XinputChangeDeviceKeyMappingCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xinputChangeDeviceKeyMappingRequest(DeviceId, FirstKeycode, KeysymsPerKeycode, KeycodeCount, Keysyms), cookie) - return XinputChangeDeviceKeyMappingCookie{cookie} -} - -func (c *Conn) XinputChangeDeviceKeyMappingChecked(DeviceId byte, FirstKeycode XinputKeyCode, KeysymsPerKeycode byte, KeycodeCount byte, Keysyms []Keysym) XinputChangeDeviceKeyMappingCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xinputChangeDeviceKeyMappingRequest(DeviceId, FirstKeycode, KeysymsPerKeycode, KeycodeCount, Keysyms), cookie) - return XinputChangeDeviceKeyMappingCookie{cookie} -} - -func (cook XinputChangeDeviceKeyMappingCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputChangeDeviceKeyMapping -func (c *Conn) xinputChangeDeviceKeyMappingRequest(DeviceId byte, FirstKeycode XinputKeyCode, KeysymsPerKeycode byte, KeycodeCount byte, Keysyms []Keysym) []byte { - size := pad((8 + pad(((int(KeycodeCount) * int(KeysymsPerKeycode)) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 25 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = DeviceId - b += 1 - - buf[b] = byte(FirstKeycode) - b += 1 - - buf[b] = KeysymsPerKeycode - b += 1 - - buf[b] = KeycodeCount - b += 1 - - for i := 0; i < int((int(KeycodeCount) * int(KeysymsPerKeycode))); i++ { - Put32(buf[b:], uint32(Keysyms[i])) - b += 4 - } - b = pad(b) - - return buf -} - -// Request XinputGetDeviceModifierMapping -// size: 8 -type XinputGetDeviceModifierMappingCookie struct { - *cookie -} - -func (c *Conn) XinputGetDeviceModifierMapping(DeviceId byte) XinputGetDeviceModifierMappingCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputGetDeviceModifierMappingRequest(DeviceId), cookie) - return XinputGetDeviceModifierMappingCookie{cookie} -} - -func (c *Conn) XinputGetDeviceModifierMappingUnchecked(DeviceId byte) XinputGetDeviceModifierMappingCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputGetDeviceModifierMappingRequest(DeviceId), cookie) - return XinputGetDeviceModifierMappingCookie{cookie} -} - -// Request reply for XinputGetDeviceModifierMapping -// size: (32 + pad(((int(KeycodesPerModifier) * 8) * 1))) -type XinputGetDeviceModifierMappingReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - KeycodesPerModifier byte - // padding: 23 bytes - Keymaps []byte // size: pad(((int(KeycodesPerModifier) * 8) * 1)) -} - -// Waits and reads reply data from request XinputGetDeviceModifierMapping -func (cook XinputGetDeviceModifierMappingCookie) Reply() (*XinputGetDeviceModifierMappingReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputGetDeviceModifierMappingReply(buf), nil -} - -// Read reply into structure from buffer for XinputGetDeviceModifierMapping -func xinputGetDeviceModifierMappingReply(buf []byte) *XinputGetDeviceModifierMappingReply { - v := new(XinputGetDeviceModifierMappingReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.KeycodesPerModifier = buf[b] - b += 1 - - b += 23 // padding - - v.Keymaps = make([]byte, (int(v.KeycodesPerModifier) * 8)) - copy(v.Keymaps[:(int(v.KeycodesPerModifier)*8)], buf[b:]) - b += pad(int((int(v.KeycodesPerModifier) * 8))) - - return v -} - -func (cook XinputGetDeviceModifierMappingCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputGetDeviceModifierMapping -func (c *Conn) xinputGetDeviceModifierMappingRequest(DeviceId byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 26 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = DeviceId - b += 1 - - b += 3 // padding - - return buf -} - -// Request XinputSetDeviceModifierMapping -// size: pad((7 + pad(((int(KeycodesPerModifier) * 8) * 1)))) -type XinputSetDeviceModifierMappingCookie struct { - *cookie -} - -func (c *Conn) XinputSetDeviceModifierMapping(DeviceId byte, KeycodesPerModifier byte, Keymaps []byte) XinputSetDeviceModifierMappingCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputSetDeviceModifierMappingRequest(DeviceId, KeycodesPerModifier, Keymaps), cookie) - return XinputSetDeviceModifierMappingCookie{cookie} -} - -func (c *Conn) XinputSetDeviceModifierMappingUnchecked(DeviceId byte, KeycodesPerModifier byte, Keymaps []byte) XinputSetDeviceModifierMappingCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputSetDeviceModifierMappingRequest(DeviceId, KeycodesPerModifier, Keymaps), cookie) - return XinputSetDeviceModifierMappingCookie{cookie} -} - -// Request reply for XinputSetDeviceModifierMapping -// size: 32 -type XinputSetDeviceModifierMappingReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Status byte - // padding: 23 bytes -} - -// Waits and reads reply data from request XinputSetDeviceModifierMapping -func (cook XinputSetDeviceModifierMappingCookie) Reply() (*XinputSetDeviceModifierMappingReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputSetDeviceModifierMappingReply(buf), nil -} - -// Read reply into structure from buffer for XinputSetDeviceModifierMapping -func xinputSetDeviceModifierMappingReply(buf []byte) *XinputSetDeviceModifierMappingReply { - v := new(XinputSetDeviceModifierMappingReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Status = buf[b] - b += 1 - - b += 23 // padding - - return v -} - -func (cook XinputSetDeviceModifierMappingCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputSetDeviceModifierMapping -func (c *Conn) xinputSetDeviceModifierMappingRequest(DeviceId byte, KeycodesPerModifier byte, Keymaps []byte) []byte { - size := pad((7 + pad(((int(KeycodesPerModifier) * 8) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 27 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = DeviceId - b += 1 - - buf[b] = KeycodesPerModifier - b += 1 - - b += 1 // padding - - copy(buf[b:], Keymaps[:(int(KeycodesPerModifier)*8)]) - b += pad(int((int(KeycodesPerModifier) * 8))) - - return buf -} - -// Request XinputGetDeviceButtonMapping -// size: 8 -type XinputGetDeviceButtonMappingCookie struct { - *cookie -} - -func (c *Conn) XinputGetDeviceButtonMapping(DeviceId byte) XinputGetDeviceButtonMappingCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputGetDeviceButtonMappingRequest(DeviceId), cookie) - return XinputGetDeviceButtonMappingCookie{cookie} -} - -func (c *Conn) XinputGetDeviceButtonMappingUnchecked(DeviceId byte) XinputGetDeviceButtonMappingCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputGetDeviceButtonMappingRequest(DeviceId), cookie) - return XinputGetDeviceButtonMappingCookie{cookie} -} - -// Request reply for XinputGetDeviceButtonMapping -// size: (32 + pad((int(MapSize) * 1))) -type XinputGetDeviceButtonMappingReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - MapSize byte - // padding: 23 bytes - Map []byte // size: pad((int(MapSize) * 1)) -} - -// Waits and reads reply data from request XinputGetDeviceButtonMapping -func (cook XinputGetDeviceButtonMappingCookie) Reply() (*XinputGetDeviceButtonMappingReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputGetDeviceButtonMappingReply(buf), nil -} - -// Read reply into structure from buffer for XinputGetDeviceButtonMapping -func xinputGetDeviceButtonMappingReply(buf []byte) *XinputGetDeviceButtonMappingReply { - v := new(XinputGetDeviceButtonMappingReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.MapSize = buf[b] - b += 1 - - b += 23 // padding - - v.Map = make([]byte, v.MapSize) - copy(v.Map[:v.MapSize], buf[b:]) - b += pad(int(v.MapSize)) - - return v -} - -func (cook XinputGetDeviceButtonMappingCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputGetDeviceButtonMapping -func (c *Conn) xinputGetDeviceButtonMappingRequest(DeviceId byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 28 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = DeviceId - b += 1 - - b += 3 // padding - - return buf -} - -// Request XinputSetDeviceButtonMapping -// size: pad((8 + pad((int(MapSize) * 1)))) -type XinputSetDeviceButtonMappingCookie struct { - *cookie -} - -func (c *Conn) XinputSetDeviceButtonMapping(DeviceId byte, MapSize byte, Map []byte) XinputSetDeviceButtonMappingCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputSetDeviceButtonMappingRequest(DeviceId, MapSize, Map), cookie) - return XinputSetDeviceButtonMappingCookie{cookie} -} - -func (c *Conn) XinputSetDeviceButtonMappingUnchecked(DeviceId byte, MapSize byte, Map []byte) XinputSetDeviceButtonMappingCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputSetDeviceButtonMappingRequest(DeviceId, MapSize, Map), cookie) - return XinputSetDeviceButtonMappingCookie{cookie} -} - -// Request reply for XinputSetDeviceButtonMapping -// size: 32 -type XinputSetDeviceButtonMappingReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Status byte - // padding: 23 bytes -} - -// Waits and reads reply data from request XinputSetDeviceButtonMapping -func (cook XinputSetDeviceButtonMappingCookie) Reply() (*XinputSetDeviceButtonMappingReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputSetDeviceButtonMappingReply(buf), nil -} - -// Read reply into structure from buffer for XinputSetDeviceButtonMapping -func xinputSetDeviceButtonMappingReply(buf []byte) *XinputSetDeviceButtonMappingReply { - v := new(XinputSetDeviceButtonMappingReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Status = buf[b] - b += 1 - - b += 23 // padding - - return v -} - -func (cook XinputSetDeviceButtonMappingCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputSetDeviceButtonMapping -func (c *Conn) xinputSetDeviceButtonMappingRequest(DeviceId byte, MapSize byte, Map []byte) []byte { - size := pad((8 + pad((int(MapSize) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 29 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = DeviceId - b += 1 - - buf[b] = MapSize - b += 1 - - b += 2 // padding - - copy(buf[b:], Map[:MapSize]) - b += pad(int(MapSize)) - - return buf -} - -// Request XinputQueryDeviceState -// size: 8 -type XinputQueryDeviceStateCookie struct { - *cookie -} - -func (c *Conn) XinputQueryDeviceState(DeviceId byte) XinputQueryDeviceStateCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputQueryDeviceStateRequest(DeviceId), cookie) - return XinputQueryDeviceStateCookie{cookie} -} - -func (c *Conn) XinputQueryDeviceStateUnchecked(DeviceId byte) XinputQueryDeviceStateCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputQueryDeviceStateRequest(DeviceId), cookie) - return XinputQueryDeviceStateCookie{cookie} -} - -// Request reply for XinputQueryDeviceState -// size: 32 -type XinputQueryDeviceStateReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumClasses byte - // padding: 23 bytes -} - -// Waits and reads reply data from request XinputQueryDeviceState -func (cook XinputQueryDeviceStateCookie) Reply() (*XinputQueryDeviceStateReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputQueryDeviceStateReply(buf), nil -} - -// Read reply into structure from buffer for XinputQueryDeviceState -func xinputQueryDeviceStateReply(buf []byte) *XinputQueryDeviceStateReply { - v := new(XinputQueryDeviceStateReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.NumClasses = buf[b] - b += 1 - - b += 23 // padding - - return v -} - -func (cook XinputQueryDeviceStateCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputQueryDeviceState -func (c *Conn) xinputQueryDeviceStateRequest(DeviceId byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 30 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = DeviceId - b += 1 - - b += 3 // padding - - return buf -} - -// Request XinputSendExtensionEvent -// size: pad(((16 + pad(((int(NumEvents) * 32) * 1))) + pad((int(NumClasses) * 4)))) -type XinputSendExtensionEventCookie struct { - *cookie -} - -// Write request to wire for XinputSendExtensionEvent -func (c *Conn) XinputSendExtensionEvent(Destination Window, DeviceId byte, Propagate bool, NumClasses uint16, NumEvents byte, Events string, Classes []XinputEventClass) XinputSendExtensionEventCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xinputSendExtensionEventRequest(Destination, DeviceId, Propagate, NumClasses, NumEvents, Events, Classes), cookie) - return XinputSendExtensionEventCookie{cookie} -} - -func (c *Conn) XinputSendExtensionEventChecked(Destination Window, DeviceId byte, Propagate bool, NumClasses uint16, NumEvents byte, Events string, Classes []XinputEventClass) XinputSendExtensionEventCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xinputSendExtensionEventRequest(Destination, DeviceId, Propagate, NumClasses, NumEvents, Events, Classes), cookie) - return XinputSendExtensionEventCookie{cookie} -} - -func (cook XinputSendExtensionEventCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputSendExtensionEvent -func (c *Conn) xinputSendExtensionEventRequest(Destination Window, DeviceId byte, Propagate bool, NumClasses uint16, NumEvents byte, Events string, Classes []XinputEventClass) []byte { - size := pad(((16 + pad(((int(NumEvents) * 32) * 1))) + pad((int(NumClasses) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 31 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Destination)) - b += 4 - - buf[b] = DeviceId - b += 1 - - if Propagate { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - Put16(buf[b:], NumClasses) - b += 2 - - buf[b] = NumEvents - b += 1 - - b += 3 // padding - - copy(buf[b:], Events[:(int(NumEvents)*32)]) - b += pad(int((int(NumEvents) * 32))) - - for i := 0; i < int(NumClasses); i++ { - Put32(buf[b:], uint32(Classes[i])) - b += 4 - } - b = pad(b) - - return buf -} - -// Request XinputDeviceBell -// size: 8 -type XinputDeviceBellCookie struct { - *cookie -} - -// Write request to wire for XinputDeviceBell -func (c *Conn) XinputDeviceBell(DeviceId byte, FeedbackId byte, FeedbackClass byte, Percent int8) XinputDeviceBellCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xinputDeviceBellRequest(DeviceId, FeedbackId, FeedbackClass, Percent), cookie) - return XinputDeviceBellCookie{cookie} -} - -func (c *Conn) XinputDeviceBellChecked(DeviceId byte, FeedbackId byte, FeedbackClass byte, Percent int8) XinputDeviceBellCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xinputDeviceBellRequest(DeviceId, FeedbackId, FeedbackClass, Percent), cookie) - return XinputDeviceBellCookie{cookie} -} - -func (cook XinputDeviceBellCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputDeviceBell -func (c *Conn) xinputDeviceBellRequest(DeviceId byte, FeedbackId byte, FeedbackClass byte, Percent int8) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 32 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = DeviceId - b += 1 - - buf[b] = FeedbackId - b += 1 - - buf[b] = FeedbackClass - b += 1 - - buf[b] = byte(Percent) - b += 1 - - return buf -} - -// Request XinputSetDeviceValuators -// size: pad((8 + pad((int(NumValuators) * 4)))) -type XinputSetDeviceValuatorsCookie struct { - *cookie -} - -func (c *Conn) XinputSetDeviceValuators(DeviceId byte, FirstValuator byte, NumValuators byte, Valuators []int32) XinputSetDeviceValuatorsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputSetDeviceValuatorsRequest(DeviceId, FirstValuator, NumValuators, Valuators), cookie) - return XinputSetDeviceValuatorsCookie{cookie} -} - -func (c *Conn) XinputSetDeviceValuatorsUnchecked(DeviceId byte, FirstValuator byte, NumValuators byte, Valuators []int32) XinputSetDeviceValuatorsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputSetDeviceValuatorsRequest(DeviceId, FirstValuator, NumValuators, Valuators), cookie) - return XinputSetDeviceValuatorsCookie{cookie} -} - -// Request reply for XinputSetDeviceValuators -// size: 32 -type XinputSetDeviceValuatorsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Status byte - // padding: 23 bytes -} - -// Waits and reads reply data from request XinputSetDeviceValuators -func (cook XinputSetDeviceValuatorsCookie) Reply() (*XinputSetDeviceValuatorsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputSetDeviceValuatorsReply(buf), nil -} - -// Read reply into structure from buffer for XinputSetDeviceValuators -func xinputSetDeviceValuatorsReply(buf []byte) *XinputSetDeviceValuatorsReply { - v := new(XinputSetDeviceValuatorsReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Status = buf[b] - b += 1 - - b += 23 // padding - - return v -} - -func (cook XinputSetDeviceValuatorsCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputSetDeviceValuators -func (c *Conn) xinputSetDeviceValuatorsRequest(DeviceId byte, FirstValuator byte, NumValuators byte, Valuators []int32) []byte { - size := pad((8 + pad((int(NumValuators) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 33 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = DeviceId - b += 1 - - buf[b] = FirstValuator - b += 1 - - buf[b] = NumValuators - b += 1 - - b += 1 // padding - - for i := 0; i < int(NumValuators); i++ { - Put32(buf[b:], uint32(Valuators[i])) - b += 4 - } - b = pad(b) - - return buf -} - -// Request XinputGetDeviceControl -// size: 8 -type XinputGetDeviceControlCookie struct { - *cookie -} - -func (c *Conn) XinputGetDeviceControl(ControlId uint16, DeviceId byte) XinputGetDeviceControlCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xinputGetDeviceControlRequest(ControlId, DeviceId), cookie) - return XinputGetDeviceControlCookie{cookie} -} - -func (c *Conn) XinputGetDeviceControlUnchecked(ControlId uint16, DeviceId byte) XinputGetDeviceControlCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xinputGetDeviceControlRequest(ControlId, DeviceId), cookie) - return XinputGetDeviceControlCookie{cookie} -} - -// Request reply for XinputGetDeviceControl -// size: 32 -type XinputGetDeviceControlReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Status byte - // padding: 23 bytes -} - -// Waits and reads reply data from request XinputGetDeviceControl -func (cook XinputGetDeviceControlCookie) Reply() (*XinputGetDeviceControlReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xinputGetDeviceControlReply(buf), nil -} - -// Read reply into structure from buffer for XinputGetDeviceControl -func xinputGetDeviceControlReply(buf []byte) *XinputGetDeviceControlReply { - v := new(XinputGetDeviceControlReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Status = buf[b] - b += 1 - - b += 23 // padding - - return v -} - -func (cook XinputGetDeviceControlCookie) Check() error { - return cook.check() -} - -// Write request to wire for XinputGetDeviceControl -func (c *Conn) xinputGetDeviceControlRequest(ControlId uint16, DeviceId byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINPUTEXTENSION"] - b += 1 - - buf[b] = 34 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], ControlId) - b += 2 - - buf[b] = DeviceId - b += 1 - - b += 1 // padding - - return buf -} diff --git a/nexgb/auto_xprint.go b/nexgb/auto_xprint.go deleted file mode 100644 index cab145e..0000000 --- a/nexgb/auto_xprint.go +++ /dev/null @@ -1,2210 +0,0 @@ -package xgb - -/* - This file was generated by xprint.xml on May 10 2012 12:39:34pm EDT. - This file is automatically generated. Edit at your peril! -*/ - -// Imports are not necessary for XGB because everything is -// in one package. They are still listed here for reference. -// import "xproto" - -// XprintInit must be called before using the XpExtension extension. -func (c *Conn) XprintInit() error { - reply, err := c.QueryExtension(11, "XpExtension").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named XpExtension could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["XpExtension"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["XpExtension"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["XpExtension"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["XpExtension"] = make(map[int]newEventFun) - newExtErrorFuncs["XpExtension"] = make(map[int]newErrorFun) -} - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - -// Skipping definition for base type 'Int8' - -// Skipping definition for base type 'Card16' - -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - -// Skipping definition for base type 'Float' - -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -const ( - XprintGetDocFinished = 0 - XprintGetDocSecondConsumer = 1 -) - -const ( - XprintEvMaskNoEventMask = 0 - XprintEvMaskPrintMask = 1 - XprintEvMaskAttributeMask = 2 -) - -const ( - XprintDetailStartJobNotify = 1 - XprintDetailEndJobNotify = 2 - XprintDetailStartDocNotify = 3 - XprintDetailEndDocNotify = 4 - XprintDetailStartPageNotify = 5 - XprintDetailEndPageNotify = 6 -) - -const ( - XprintAttrJobAttr = 1 - XprintAttrDocAttr = 2 - XprintAttrPageAttr = 3 - XprintAttrPrinterAttr = 4 - XprintAttrServerAttr = 5 - XprintAttrMediumAttr = 6 - XprintAttrSpoolerAttr = 7 -) - -type XprintPcontext uint32 - -func (c *Conn) NewXprintPcontextId() (XprintPcontext, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return XprintPcontext(id), nil -} - -type XprintString8 byte - -// 'XprintPrinter' struct definition -// Size: (((4 + pad((int(NameLen) * 1))) + 4) + pad((int(DescLen) * 1))) -type XprintPrinter struct { - NameLen uint32 - Name []XprintString8 // size: pad((int(NameLen) * 1)) - DescLen uint32 - Description []XprintString8 // size: pad((int(DescLen) * 1)) -} - -// Struct read XprintPrinter -func ReadXprintPrinter(buf []byte, v *XprintPrinter) int { - b := 0 - - v.NameLen = Get32(buf[b:]) - b += 4 - - v.Name = make([]XprintString8, v.NameLen) - for i := 0; i < int(v.NameLen); i++ { - v.Name[i] = XprintString8(buf[b]) - b += 1 - } - b = pad(b) - - v.DescLen = Get32(buf[b:]) - b += 4 - - v.Description = make([]XprintString8, v.DescLen) - for i := 0; i < int(v.DescLen); i++ { - v.Description[i] = XprintString8(buf[b]) - b += 1 - } - b = pad(b) - - return b -} - -// Struct list read XprintPrinter -func ReadXprintPrinterList(buf []byte, dest []XprintPrinter) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XprintPrinter{} - b += ReadXprintPrinter(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XprintPrinter -func (v XprintPrinter) Bytes() []byte { - buf := make([]byte, (((4 + pad((int(v.NameLen) * 1))) + 4) + pad((int(v.DescLen) * 1)))) - b := 0 - - Put32(buf[b:], v.NameLen) - b += 4 - - for i := 0; i < int(v.NameLen); i++ { - buf[b] = byte(v.Name[i]) - b += 1 - } - b = pad(b) - - Put32(buf[b:], v.DescLen) - b += 4 - - for i := 0; i < int(v.DescLen); i++ { - buf[b] = byte(v.Description[i]) - b += 1 - } - b = pad(b) - - return buf -} - -// Write struct list XprintPrinter -func XprintPrinterListBytes(buf []byte, list []XprintPrinter) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size XprintPrinter -func XprintPrinterListSize(list []XprintPrinter) int { - size := 0 - for _, item := range list { - size += (((4 + pad((int(item.NameLen) * 1))) + 4) + pad((int(item.DescLen) * 1))) - } - return size -} - -// Event definition XprintNotify (0) -// Size: 32 - -const XprintNotify = 0 - -type XprintNotifyEvent struct { - Sequence uint16 - Detail byte - Context XprintPcontext - Cancel bool -} - -// Event read XprintNotify -func NewXprintNotifyEvent(buf []byte) Event { - v := XprintNotifyEvent{} - b := 1 // don't read event number - - v.Detail = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Context = XprintPcontext(Get32(buf[b:])) - b += 4 - - if buf[b] == 1 { - v.Cancel = true - } else { - v.Cancel = false - } - b += 1 - - return v -} - -// Event write XprintNotify -func (v XprintNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 0 - b += 1 - - buf[b] = v.Detail - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Context)) - b += 4 - - if v.Cancel { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - return buf -} - -func (v XprintNotifyEvent) ImplementsEvent() {} - -func (v XprintNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XprintNotifyEvent) String() string { - fieldVals := make([]string, 0, 3) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Context: %d", v.Context)) - fieldVals = append(fieldVals, sprintf("Cancel: %t", v.Cancel)) - return "XprintNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XpExtension"][0] = NewXprintNotifyEvent -} - -// Event definition XprintAttributNotify (1) -// Size: 32 - -const XprintAttributNotify = 1 - -type XprintAttributNotifyEvent struct { - Sequence uint16 - Detail byte - Context XprintPcontext -} - -// Event read XprintAttributNotify -func NewXprintAttributNotifyEvent(buf []byte) Event { - v := XprintAttributNotifyEvent{} - b := 1 // don't read event number - - v.Detail = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Context = XprintPcontext(Get32(buf[b:])) - b += 4 - - return v -} - -// Event write XprintAttributNotify -func (v XprintAttributNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 1 - b += 1 - - buf[b] = v.Detail - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Context)) - b += 4 - - return buf -} - -func (v XprintAttributNotifyEvent) ImplementsEvent() {} - -func (v XprintAttributNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XprintAttributNotifyEvent) String() string { - fieldVals := make([]string, 0, 2) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Context: %d", v.Context)) - return "XprintAttributNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XpExtension"][1] = NewXprintAttributNotifyEvent -} - -// Error definition XprintBadContext (0) -// Size: 32 - -const BadXprintBadContext = 0 - -type XprintBadContextError struct { - Sequence uint16 - NiceName string -} - -// Error read XprintBadContext -func NewXprintBadContextError(buf []byte) Error { - v := XprintBadContextError{} - v.NiceName = "XprintBadContext" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err XprintBadContextError) ImplementsError() {} - -func (err XprintBadContextError) SequenceId() uint16 { - return err.Sequence -} - -func (err XprintBadContextError) BadId() uint32 { - return 0 -} - -func (err XprintBadContextError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadXprintBadContext {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["XpExtension"][0] = NewXprintBadContextError -} - -// Error definition XprintBadSequence (1) -// Size: 32 - -const BadXprintBadSequence = 1 - -type XprintBadSequenceError struct { - Sequence uint16 - NiceName string -} - -// Error read XprintBadSequence -func NewXprintBadSequenceError(buf []byte) Error { - v := XprintBadSequenceError{} - v.NiceName = "XprintBadSequence" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err XprintBadSequenceError) ImplementsError() {} - -func (err XprintBadSequenceError) SequenceId() uint16 { - return err.Sequence -} - -func (err XprintBadSequenceError) BadId() uint32 { - return 0 -} - -func (err XprintBadSequenceError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadXprintBadSequence {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["XpExtension"][1] = NewXprintBadSequenceError -} - -// Request XprintPrintQueryVersion -// size: 4 -type XprintPrintQueryVersionCookie struct { - *cookie -} - -func (c *Conn) XprintPrintQueryVersion() XprintPrintQueryVersionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xprintPrintQueryVersionRequest(), cookie) - return XprintPrintQueryVersionCookie{cookie} -} - -func (c *Conn) XprintPrintQueryVersionUnchecked() XprintPrintQueryVersionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xprintPrintQueryVersionRequest(), cookie) - return XprintPrintQueryVersionCookie{cookie} -} - -// Request reply for XprintPrintQueryVersion -// size: 12 -type XprintPrintQueryVersionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - MajorVersion uint16 - MinorVersion uint16 -} - -// Waits and reads reply data from request XprintPrintQueryVersion -func (cook XprintPrintQueryVersionCookie) Reply() (*XprintPrintQueryVersionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xprintPrintQueryVersionReply(buf), nil -} - -// Read reply into structure from buffer for XprintPrintQueryVersion -func xprintPrintQueryVersionReply(buf []byte) *XprintPrintQueryVersionReply { - v := new(XprintPrintQueryVersionReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.MajorVersion = Get16(buf[b:]) - b += 2 - - v.MinorVersion = Get16(buf[b:]) - b += 2 - - return v -} - -func (cook XprintPrintQueryVersionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintQueryVersion -func (c *Conn) xprintPrintQueryVersionRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 0 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request XprintPrintGetPrinterList -// size: pad(((12 + pad((int(PrinterNameLen) * 1))) + pad((int(LocaleLen) * 1)))) -type XprintPrintGetPrinterListCookie struct { - *cookie -} - -func (c *Conn) XprintPrintGetPrinterList(PrinterNameLen uint32, LocaleLen uint32, PrinterName []XprintString8, Locale []XprintString8) XprintPrintGetPrinterListCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xprintPrintGetPrinterListRequest(PrinterNameLen, LocaleLen, PrinterName, Locale), cookie) - return XprintPrintGetPrinterListCookie{cookie} -} - -func (c *Conn) XprintPrintGetPrinterListUnchecked(PrinterNameLen uint32, LocaleLen uint32, PrinterName []XprintString8, Locale []XprintString8) XprintPrintGetPrinterListCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xprintPrintGetPrinterListRequest(PrinterNameLen, LocaleLen, PrinterName, Locale), cookie) - return XprintPrintGetPrinterListCookie{cookie} -} - -// Request reply for XprintPrintGetPrinterList -// size: (32 + XprintPrinterListSize(Printers)) -type XprintPrintGetPrinterListReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ListCount uint32 - // padding: 20 bytes - Printers []XprintPrinter // size: XprintPrinterListSize(Printers) -} - -// Waits and reads reply data from request XprintPrintGetPrinterList -func (cook XprintPrintGetPrinterListCookie) Reply() (*XprintPrintGetPrinterListReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xprintPrintGetPrinterListReply(buf), nil -} - -// Read reply into structure from buffer for XprintPrintGetPrinterList -func xprintPrintGetPrinterListReply(buf []byte) *XprintPrintGetPrinterListReply { - v := new(XprintPrintGetPrinterListReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.ListCount = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Printers = make([]XprintPrinter, v.ListCount) - b += ReadXprintPrinterList(buf[b:], v.Printers) - - return v -} - -func (cook XprintPrintGetPrinterListCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintGetPrinterList -func (c *Conn) xprintPrintGetPrinterListRequest(PrinterNameLen uint32, LocaleLen uint32, PrinterName []XprintString8, Locale []XprintString8) []byte { - size := pad(((12 + pad((int(PrinterNameLen) * 1))) + pad((int(LocaleLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 1 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], PrinterNameLen) - b += 4 - - Put32(buf[b:], LocaleLen) - b += 4 - - for i := 0; i < int(PrinterNameLen); i++ { - buf[b] = byte(PrinterName[i]) - b += 1 - } - b = pad(b) - - for i := 0; i < int(LocaleLen); i++ { - buf[b] = byte(Locale[i]) - b += 1 - } - b = pad(b) - - return buf -} - -// Request XprintPrintRehashPrinterList -// size: 4 -type XprintPrintRehashPrinterListCookie struct { - *cookie -} - -// Write request to wire for XprintPrintRehashPrinterList -func (c *Conn) XprintPrintRehashPrinterList() XprintPrintRehashPrinterListCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xprintPrintRehashPrinterListRequest(), cookie) - return XprintPrintRehashPrinterListCookie{cookie} -} - -func (c *Conn) XprintPrintRehashPrinterListChecked() XprintPrintRehashPrinterListCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xprintPrintRehashPrinterListRequest(), cookie) - return XprintPrintRehashPrinterListCookie{cookie} -} - -func (cook XprintPrintRehashPrinterListCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintRehashPrinterList -func (c *Conn) xprintPrintRehashPrinterListRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 20 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request XprintCreateContext -// size: pad(((16 + pad((int(PrinterNameLen) * 1))) + pad((int(LocaleLen) * 1)))) -type XprintCreateContextCookie struct { - *cookie -} - -// Write request to wire for XprintCreateContext -func (c *Conn) XprintCreateContext(ContextId uint32, PrinterNameLen uint32, LocaleLen uint32, PrinterName []XprintString8, Locale []XprintString8) XprintCreateContextCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xprintCreateContextRequest(ContextId, PrinterNameLen, LocaleLen, PrinterName, Locale), cookie) - return XprintCreateContextCookie{cookie} -} - -func (c *Conn) XprintCreateContextChecked(ContextId uint32, PrinterNameLen uint32, LocaleLen uint32, PrinterName []XprintString8, Locale []XprintString8) XprintCreateContextCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xprintCreateContextRequest(ContextId, PrinterNameLen, LocaleLen, PrinterName, Locale), cookie) - return XprintCreateContextCookie{cookie} -} - -func (cook XprintCreateContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintCreateContext -func (c *Conn) xprintCreateContextRequest(ContextId uint32, PrinterNameLen uint32, LocaleLen uint32, PrinterName []XprintString8, Locale []XprintString8) []byte { - size := pad(((16 + pad((int(PrinterNameLen) * 1))) + pad((int(LocaleLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 2 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], ContextId) - b += 4 - - Put32(buf[b:], PrinterNameLen) - b += 4 - - Put32(buf[b:], LocaleLen) - b += 4 - - for i := 0; i < int(PrinterNameLen); i++ { - buf[b] = byte(PrinterName[i]) - b += 1 - } - b = pad(b) - - for i := 0; i < int(LocaleLen); i++ { - buf[b] = byte(Locale[i]) - b += 1 - } - b = pad(b) - - return buf -} - -// Request XprintPrintSetContext -// size: 8 -type XprintPrintSetContextCookie struct { - *cookie -} - -// Write request to wire for XprintPrintSetContext -func (c *Conn) XprintPrintSetContext(Context uint32) XprintPrintSetContextCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xprintPrintSetContextRequest(Context), cookie) - return XprintPrintSetContextCookie{cookie} -} - -func (c *Conn) XprintPrintSetContextChecked(Context uint32) XprintPrintSetContextCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xprintPrintSetContextRequest(Context), cookie) - return XprintPrintSetContextCookie{cookie} -} - -func (cook XprintPrintSetContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintSetContext -func (c *Conn) xprintPrintSetContextRequest(Context uint32) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 3 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Context) - b += 4 - - return buf -} - -// Request XprintPrintGetContext -// size: 4 -type XprintPrintGetContextCookie struct { - *cookie -} - -func (c *Conn) XprintPrintGetContext() XprintPrintGetContextCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xprintPrintGetContextRequest(), cookie) - return XprintPrintGetContextCookie{cookie} -} - -func (c *Conn) XprintPrintGetContextUnchecked() XprintPrintGetContextCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xprintPrintGetContextRequest(), cookie) - return XprintPrintGetContextCookie{cookie} -} - -// Request reply for XprintPrintGetContext -// size: 12 -type XprintPrintGetContextReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Context uint32 -} - -// Waits and reads reply data from request XprintPrintGetContext -func (cook XprintPrintGetContextCookie) Reply() (*XprintPrintGetContextReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xprintPrintGetContextReply(buf), nil -} - -// Read reply into structure from buffer for XprintPrintGetContext -func xprintPrintGetContextReply(buf []byte) *XprintPrintGetContextReply { - v := new(XprintPrintGetContextReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Context = Get32(buf[b:]) - b += 4 - - return v -} - -func (cook XprintPrintGetContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintGetContext -func (c *Conn) xprintPrintGetContextRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 4 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request XprintPrintDestroyContext -// size: 8 -type XprintPrintDestroyContextCookie struct { - *cookie -} - -// Write request to wire for XprintPrintDestroyContext -func (c *Conn) XprintPrintDestroyContext(Context uint32) XprintPrintDestroyContextCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xprintPrintDestroyContextRequest(Context), cookie) - return XprintPrintDestroyContextCookie{cookie} -} - -func (c *Conn) XprintPrintDestroyContextChecked(Context uint32) XprintPrintDestroyContextCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xprintPrintDestroyContextRequest(Context), cookie) - return XprintPrintDestroyContextCookie{cookie} -} - -func (cook XprintPrintDestroyContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintDestroyContext -func (c *Conn) xprintPrintDestroyContextRequest(Context uint32) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 5 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Context) - b += 4 - - return buf -} - -// Request XprintPrintGetScreenOfContext -// size: 4 -type XprintPrintGetScreenOfContextCookie struct { - *cookie -} - -func (c *Conn) XprintPrintGetScreenOfContext() XprintPrintGetScreenOfContextCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xprintPrintGetScreenOfContextRequest(), cookie) - return XprintPrintGetScreenOfContextCookie{cookie} -} - -func (c *Conn) XprintPrintGetScreenOfContextUnchecked() XprintPrintGetScreenOfContextCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xprintPrintGetScreenOfContextRequest(), cookie) - return XprintPrintGetScreenOfContextCookie{cookie} -} - -// Request reply for XprintPrintGetScreenOfContext -// size: 12 -type XprintPrintGetScreenOfContextReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Root Window -} - -// Waits and reads reply data from request XprintPrintGetScreenOfContext -func (cook XprintPrintGetScreenOfContextCookie) Reply() (*XprintPrintGetScreenOfContextReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xprintPrintGetScreenOfContextReply(buf), nil -} - -// Read reply into structure from buffer for XprintPrintGetScreenOfContext -func xprintPrintGetScreenOfContextReply(buf []byte) *XprintPrintGetScreenOfContextReply { - v := new(XprintPrintGetScreenOfContextReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Root = Window(Get32(buf[b:])) - b += 4 - - return v -} - -func (cook XprintPrintGetScreenOfContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintGetScreenOfContext -func (c *Conn) xprintPrintGetScreenOfContextRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 6 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request XprintPrintStartJob -// size: 8 -type XprintPrintStartJobCookie struct { - *cookie -} - -// Write request to wire for XprintPrintStartJob -func (c *Conn) XprintPrintStartJob(OutputMode byte) XprintPrintStartJobCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xprintPrintStartJobRequest(OutputMode), cookie) - return XprintPrintStartJobCookie{cookie} -} - -func (c *Conn) XprintPrintStartJobChecked(OutputMode byte) XprintPrintStartJobCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xprintPrintStartJobRequest(OutputMode), cookie) - return XprintPrintStartJobCookie{cookie} -} - -func (cook XprintPrintStartJobCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintStartJob -func (c *Conn) xprintPrintStartJobRequest(OutputMode byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 7 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = OutputMode - b += 1 - - return buf -} - -// Request XprintPrintEndJob -// size: 8 -type XprintPrintEndJobCookie struct { - *cookie -} - -// Write request to wire for XprintPrintEndJob -func (c *Conn) XprintPrintEndJob(Cancel bool) XprintPrintEndJobCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xprintPrintEndJobRequest(Cancel), cookie) - return XprintPrintEndJobCookie{cookie} -} - -func (c *Conn) XprintPrintEndJobChecked(Cancel bool) XprintPrintEndJobCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xprintPrintEndJobRequest(Cancel), cookie) - return XprintPrintEndJobCookie{cookie} -} - -func (cook XprintPrintEndJobCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintEndJob -func (c *Conn) xprintPrintEndJobRequest(Cancel bool) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 8 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - if Cancel { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - return buf -} - -// Request XprintPrintStartDoc -// size: 8 -type XprintPrintStartDocCookie struct { - *cookie -} - -// Write request to wire for XprintPrintStartDoc -func (c *Conn) XprintPrintStartDoc(DriverMode byte) XprintPrintStartDocCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xprintPrintStartDocRequest(DriverMode), cookie) - return XprintPrintStartDocCookie{cookie} -} - -func (c *Conn) XprintPrintStartDocChecked(DriverMode byte) XprintPrintStartDocCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xprintPrintStartDocRequest(DriverMode), cookie) - return XprintPrintStartDocCookie{cookie} -} - -func (cook XprintPrintStartDocCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintStartDoc -func (c *Conn) xprintPrintStartDocRequest(DriverMode byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 9 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = DriverMode - b += 1 - - return buf -} - -// Request XprintPrintEndDoc -// size: 8 -type XprintPrintEndDocCookie struct { - *cookie -} - -// Write request to wire for XprintPrintEndDoc -func (c *Conn) XprintPrintEndDoc(Cancel bool) XprintPrintEndDocCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xprintPrintEndDocRequest(Cancel), cookie) - return XprintPrintEndDocCookie{cookie} -} - -func (c *Conn) XprintPrintEndDocChecked(Cancel bool) XprintPrintEndDocCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xprintPrintEndDocRequest(Cancel), cookie) - return XprintPrintEndDocCookie{cookie} -} - -func (cook XprintPrintEndDocCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintEndDoc -func (c *Conn) xprintPrintEndDocRequest(Cancel bool) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 10 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - if Cancel { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - return buf -} - -// Request XprintPrintPutDocumentData -// size: pad((((16 + pad((int(LenData) * 1))) + pad((len(DocFormat) * 1))) + pad((len(Options) * 1)))) -type XprintPrintPutDocumentDataCookie struct { - *cookie -} - -// Write request to wire for XprintPrintPutDocumentData -func (c *Conn) XprintPrintPutDocumentData(Drawable Drawable, LenData uint32, LenFmt uint16, LenOptions uint16, Data []byte, DocFormat []XprintString8, Options []XprintString8) XprintPrintPutDocumentDataCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xprintPrintPutDocumentDataRequest(Drawable, LenData, LenFmt, LenOptions, Data, DocFormat, Options), cookie) - return XprintPrintPutDocumentDataCookie{cookie} -} - -func (c *Conn) XprintPrintPutDocumentDataChecked(Drawable Drawable, LenData uint32, LenFmt uint16, LenOptions uint16, Data []byte, DocFormat []XprintString8, Options []XprintString8) XprintPrintPutDocumentDataCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xprintPrintPutDocumentDataRequest(Drawable, LenData, LenFmt, LenOptions, Data, DocFormat, Options), cookie) - return XprintPrintPutDocumentDataCookie{cookie} -} - -func (cook XprintPrintPutDocumentDataCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintPutDocumentData -func (c *Conn) xprintPrintPutDocumentDataRequest(Drawable Drawable, LenData uint32, LenFmt uint16, LenOptions uint16, Data []byte, DocFormat []XprintString8, Options []XprintString8) []byte { - size := pad((((16 + pad((int(LenData) * 1))) + pad((len(DocFormat) * 1))) + pad((len(Options) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 11 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], LenData) - b += 4 - - Put16(buf[b:], LenFmt) - b += 2 - - Put16(buf[b:], LenOptions) - b += 2 - - copy(buf[b:], Data[:LenData]) - b += pad(int(LenData)) - - for i := 0; i < int(len(DocFormat)); i++ { - buf[b] = byte(DocFormat[i]) - b += 1 - } - b = pad(b) - - for i := 0; i < int(len(Options)); i++ { - buf[b] = byte(Options[i]) - b += 1 - } - b = pad(b) - - return buf -} - -// Request XprintPrintGetDocumentData -// size: 12 -type XprintPrintGetDocumentDataCookie struct { - *cookie -} - -func (c *Conn) XprintPrintGetDocumentData(Context XprintPcontext, MaxBytes uint32) XprintPrintGetDocumentDataCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xprintPrintGetDocumentDataRequest(Context, MaxBytes), cookie) - return XprintPrintGetDocumentDataCookie{cookie} -} - -func (c *Conn) XprintPrintGetDocumentDataUnchecked(Context XprintPcontext, MaxBytes uint32) XprintPrintGetDocumentDataCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xprintPrintGetDocumentDataRequest(Context, MaxBytes), cookie) - return XprintPrintGetDocumentDataCookie{cookie} -} - -// Request reply for XprintPrintGetDocumentData -// size: (32 + pad((int(DataLen) * 1))) -type XprintPrintGetDocumentDataReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - StatusCode uint32 - FinishedFlag uint32 - DataLen uint32 - // padding: 12 bytes - Data []byte // size: pad((int(DataLen) * 1)) -} - -// Waits and reads reply data from request XprintPrintGetDocumentData -func (cook XprintPrintGetDocumentDataCookie) Reply() (*XprintPrintGetDocumentDataReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xprintPrintGetDocumentDataReply(buf), nil -} - -// Read reply into structure from buffer for XprintPrintGetDocumentData -func xprintPrintGetDocumentDataReply(buf []byte) *XprintPrintGetDocumentDataReply { - v := new(XprintPrintGetDocumentDataReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.StatusCode = Get32(buf[b:]) - b += 4 - - v.FinishedFlag = Get32(buf[b:]) - b += 4 - - v.DataLen = Get32(buf[b:]) - b += 4 - - b += 12 // padding - - v.Data = make([]byte, v.DataLen) - copy(v.Data[:v.DataLen], buf[b:]) - b += pad(int(v.DataLen)) - - return v -} - -func (cook XprintPrintGetDocumentDataCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintGetDocumentData -func (c *Conn) xprintPrintGetDocumentDataRequest(Context XprintPcontext, MaxBytes uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 12 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Context)) - b += 4 - - Put32(buf[b:], MaxBytes) - b += 4 - - return buf -} - -// Request XprintPrintStartPage -// size: 8 -type XprintPrintStartPageCookie struct { - *cookie -} - -// Write request to wire for XprintPrintStartPage -func (c *Conn) XprintPrintStartPage(Window Window) XprintPrintStartPageCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xprintPrintStartPageRequest(Window), cookie) - return XprintPrintStartPageCookie{cookie} -} - -func (c *Conn) XprintPrintStartPageChecked(Window Window) XprintPrintStartPageCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xprintPrintStartPageRequest(Window), cookie) - return XprintPrintStartPageCookie{cookie} -} - -func (cook XprintPrintStartPageCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintStartPage -func (c *Conn) xprintPrintStartPageRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 13 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - return buf -} - -// Request XprintPrintEndPage -// size: 8 -type XprintPrintEndPageCookie struct { - *cookie -} - -// Write request to wire for XprintPrintEndPage -func (c *Conn) XprintPrintEndPage(Cancel bool) XprintPrintEndPageCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xprintPrintEndPageRequest(Cancel), cookie) - return XprintPrintEndPageCookie{cookie} -} - -func (c *Conn) XprintPrintEndPageChecked(Cancel bool) XprintPrintEndPageCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xprintPrintEndPageRequest(Cancel), cookie) - return XprintPrintEndPageCookie{cookie} -} - -func (cook XprintPrintEndPageCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintEndPage -func (c *Conn) xprintPrintEndPageRequest(Cancel bool) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 14 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - if Cancel { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 3 // padding - - return buf -} - -// Request XprintPrintSelectInput -// size: pad((8 + (4 + pad((4 * popCount(int(EventMask))))))) -type XprintPrintSelectInputCookie struct { - *cookie -} - -// Write request to wire for XprintPrintSelectInput -func (c *Conn) XprintPrintSelectInput(Context XprintPcontext, EventMask uint32, EventList []uint32) XprintPrintSelectInputCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xprintPrintSelectInputRequest(Context, EventMask, EventList), cookie) - return XprintPrintSelectInputCookie{cookie} -} - -func (c *Conn) XprintPrintSelectInputChecked(Context XprintPcontext, EventMask uint32, EventList []uint32) XprintPrintSelectInputCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xprintPrintSelectInputRequest(Context, EventMask, EventList), cookie) - return XprintPrintSelectInputCookie{cookie} -} - -func (cook XprintPrintSelectInputCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintSelectInput -func (c *Conn) xprintPrintSelectInputRequest(Context XprintPcontext, EventMask uint32, EventList []uint32) []byte { - size := pad((8 + (4 + pad((4 * popCount(int(EventMask))))))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 15 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Context)) - b += 4 - - Put32(buf[b:], EventMask) - b += 4 - for i := 0; i < popCount(int(EventMask)); i++ { - Put32(buf[b:], EventList[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Request XprintPrintInputSelected -// size: 8 -type XprintPrintInputSelectedCookie struct { - *cookie -} - -func (c *Conn) XprintPrintInputSelected(Context XprintPcontext) XprintPrintInputSelectedCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xprintPrintInputSelectedRequest(Context), cookie) - return XprintPrintInputSelectedCookie{cookie} -} - -func (c *Conn) XprintPrintInputSelectedUnchecked(Context XprintPcontext) XprintPrintInputSelectedCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xprintPrintInputSelectedRequest(Context), cookie) - return XprintPrintInputSelectedCookie{cookie} -} - -// Request reply for XprintPrintInputSelected -// size: ((8 + (4 + pad((4 * popCount(int(EventMask)))))) + (4 + pad((4 * popCount(int(AllEventsMask)))))) -type XprintPrintInputSelectedReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - EventMask uint32 - EventList []uint32 - AllEventsMask uint32 - AllEventsList []uint32 -} - -// Waits and reads reply data from request XprintPrintInputSelected -func (cook XprintPrintInputSelectedCookie) Reply() (*XprintPrintInputSelectedReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xprintPrintInputSelectedReply(buf), nil -} - -// Read reply into structure from buffer for XprintPrintInputSelected -func xprintPrintInputSelectedReply(buf []byte) *XprintPrintInputSelectedReply { - v := new(XprintPrintInputSelectedReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.EventMask = Get32(buf[b:]) - b += 4 - - v.EventList = make([]uint32, popCount(int(v.EventMask))) - for i := 0; i < popCount(int(v.EventMask)); i++ { - v.EventList[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - v.AllEventsMask = Get32(buf[b:]) - b += 4 - - v.AllEventsList = make([]uint32, popCount(int(v.AllEventsMask))) - for i := 0; i < popCount(int(v.AllEventsMask)); i++ { - v.AllEventsList[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook XprintPrintInputSelectedCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintInputSelected -func (c *Conn) xprintPrintInputSelectedRequest(Context XprintPcontext) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 16 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Context)) - b += 4 - - return buf -} - -// Request XprintPrintGetAttributes -// size: 12 -type XprintPrintGetAttributesCookie struct { - *cookie -} - -func (c *Conn) XprintPrintGetAttributes(Context XprintPcontext, Pool byte) XprintPrintGetAttributesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xprintPrintGetAttributesRequest(Context, Pool), cookie) - return XprintPrintGetAttributesCookie{cookie} -} - -func (c *Conn) XprintPrintGetAttributesUnchecked(Context XprintPcontext, Pool byte) XprintPrintGetAttributesCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xprintPrintGetAttributesRequest(Context, Pool), cookie) - return XprintPrintGetAttributesCookie{cookie} -} - -// Request reply for XprintPrintGetAttributes -// size: 33 -type XprintPrintGetAttributesReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - StringLen uint32 - // padding: 20 bytes - Attributes XprintString8 -} - -// Waits and reads reply data from request XprintPrintGetAttributes -func (cook XprintPrintGetAttributesCookie) Reply() (*XprintPrintGetAttributesReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xprintPrintGetAttributesReply(buf), nil -} - -// Read reply into structure from buffer for XprintPrintGetAttributes -func xprintPrintGetAttributesReply(buf []byte) *XprintPrintGetAttributesReply { - v := new(XprintPrintGetAttributesReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.StringLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Attributes = XprintString8(buf[b]) - b += 1 - - return v -} - -func (cook XprintPrintGetAttributesCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintGetAttributes -func (c *Conn) xprintPrintGetAttributesRequest(Context XprintPcontext, Pool byte) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 17 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Context)) - b += 4 - - buf[b] = Pool - b += 1 - - b += 3 // padding - - return buf -} - -// Request XprintPrintGetOneAttributes -// size: pad((16 + pad((int(NameLen) * 1)))) -type XprintPrintGetOneAttributesCookie struct { - *cookie -} - -func (c *Conn) XprintPrintGetOneAttributes(Context XprintPcontext, NameLen uint32, Pool byte, Name []XprintString8) XprintPrintGetOneAttributesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xprintPrintGetOneAttributesRequest(Context, NameLen, Pool, Name), cookie) - return XprintPrintGetOneAttributesCookie{cookie} -} - -func (c *Conn) XprintPrintGetOneAttributesUnchecked(Context XprintPcontext, NameLen uint32, Pool byte, Name []XprintString8) XprintPrintGetOneAttributesCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xprintPrintGetOneAttributesRequest(Context, NameLen, Pool, Name), cookie) - return XprintPrintGetOneAttributesCookie{cookie} -} - -// Request reply for XprintPrintGetOneAttributes -// size: (32 + pad((int(ValueLen) * 1))) -type XprintPrintGetOneAttributesReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ValueLen uint32 - // padding: 20 bytes - Value []XprintString8 // size: pad((int(ValueLen) * 1)) -} - -// Waits and reads reply data from request XprintPrintGetOneAttributes -func (cook XprintPrintGetOneAttributesCookie) Reply() (*XprintPrintGetOneAttributesReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xprintPrintGetOneAttributesReply(buf), nil -} - -// Read reply into structure from buffer for XprintPrintGetOneAttributes -func xprintPrintGetOneAttributesReply(buf []byte) *XprintPrintGetOneAttributesReply { - v := new(XprintPrintGetOneAttributesReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.ValueLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Value = make([]XprintString8, v.ValueLen) - for i := 0; i < int(v.ValueLen); i++ { - v.Value[i] = XprintString8(buf[b]) - b += 1 - } - b = pad(b) - - return v -} - -func (cook XprintPrintGetOneAttributesCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintGetOneAttributes -func (c *Conn) xprintPrintGetOneAttributesRequest(Context XprintPcontext, NameLen uint32, Pool byte, Name []XprintString8) []byte { - size := pad((16 + pad((int(NameLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 19 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Context)) - b += 4 - - Put32(buf[b:], NameLen) - b += 4 - - buf[b] = Pool - b += 1 - - b += 3 // padding - - for i := 0; i < int(NameLen); i++ { - buf[b] = byte(Name[i]) - b += 1 - } - b = pad(b) - - return buf -} - -// Request XprintPrintSetAttributes -// size: pad((16 + pad((len(Attributes) * 1)))) -type XprintPrintSetAttributesCookie struct { - *cookie -} - -// Write request to wire for XprintPrintSetAttributes -func (c *Conn) XprintPrintSetAttributes(Context XprintPcontext, StringLen uint32, Pool byte, Rule byte, Attributes []XprintString8) XprintPrintSetAttributesCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xprintPrintSetAttributesRequest(Context, StringLen, Pool, Rule, Attributes), cookie) - return XprintPrintSetAttributesCookie{cookie} -} - -func (c *Conn) XprintPrintSetAttributesChecked(Context XprintPcontext, StringLen uint32, Pool byte, Rule byte, Attributes []XprintString8) XprintPrintSetAttributesCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xprintPrintSetAttributesRequest(Context, StringLen, Pool, Rule, Attributes), cookie) - return XprintPrintSetAttributesCookie{cookie} -} - -func (cook XprintPrintSetAttributesCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintSetAttributes -func (c *Conn) xprintPrintSetAttributesRequest(Context XprintPcontext, StringLen uint32, Pool byte, Rule byte, Attributes []XprintString8) []byte { - size := pad((16 + pad((len(Attributes) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 18 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Context)) - b += 4 - - Put32(buf[b:], StringLen) - b += 4 - - buf[b] = Pool - b += 1 - - buf[b] = Rule - b += 1 - - b += 2 // padding - - for i := 0; i < int(len(Attributes)); i++ { - buf[b] = byte(Attributes[i]) - b += 1 - } - b = pad(b) - - return buf -} - -// Request XprintPrintGetPageDimensions -// size: 8 -type XprintPrintGetPageDimensionsCookie struct { - *cookie -} - -func (c *Conn) XprintPrintGetPageDimensions(Context XprintPcontext) XprintPrintGetPageDimensionsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xprintPrintGetPageDimensionsRequest(Context), cookie) - return XprintPrintGetPageDimensionsCookie{cookie} -} - -func (c *Conn) XprintPrintGetPageDimensionsUnchecked(Context XprintPcontext) XprintPrintGetPageDimensionsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xprintPrintGetPageDimensionsRequest(Context), cookie) - return XprintPrintGetPageDimensionsCookie{cookie} -} - -// Request reply for XprintPrintGetPageDimensions -// size: 20 -type XprintPrintGetPageDimensionsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Width uint16 - Height uint16 - OffsetX uint16 - OffsetY uint16 - ReproducibleWidth uint16 - ReproducibleHeight uint16 -} - -// Waits and reads reply data from request XprintPrintGetPageDimensions -func (cook XprintPrintGetPageDimensionsCookie) Reply() (*XprintPrintGetPageDimensionsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xprintPrintGetPageDimensionsReply(buf), nil -} - -// Read reply into structure from buffer for XprintPrintGetPageDimensions -func xprintPrintGetPageDimensionsReply(buf []byte) *XprintPrintGetPageDimensionsReply { - v := new(XprintPrintGetPageDimensionsReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - v.OffsetX = Get16(buf[b:]) - b += 2 - - v.OffsetY = Get16(buf[b:]) - b += 2 - - v.ReproducibleWidth = Get16(buf[b:]) - b += 2 - - v.ReproducibleHeight = Get16(buf[b:]) - b += 2 - - return v -} - -func (cook XprintPrintGetPageDimensionsCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintGetPageDimensions -func (c *Conn) xprintPrintGetPageDimensionsRequest(Context XprintPcontext) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 21 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Context)) - b += 4 - - return buf -} - -// Request XprintPrintQueryScreens -// size: 4 -type XprintPrintQueryScreensCookie struct { - *cookie -} - -func (c *Conn) XprintPrintQueryScreens() XprintPrintQueryScreensCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xprintPrintQueryScreensRequest(), cookie) - return XprintPrintQueryScreensCookie{cookie} -} - -func (c *Conn) XprintPrintQueryScreensUnchecked() XprintPrintQueryScreensCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xprintPrintQueryScreensRequest(), cookie) - return XprintPrintQueryScreensCookie{cookie} -} - -// Request reply for XprintPrintQueryScreens -// size: (32 + pad((int(ListCount) * 4))) -type XprintPrintQueryScreensReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ListCount uint32 - // padding: 20 bytes - Roots []Window // size: pad((int(ListCount) * 4)) -} - -// Waits and reads reply data from request XprintPrintQueryScreens -func (cook XprintPrintQueryScreensCookie) Reply() (*XprintPrintQueryScreensReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xprintPrintQueryScreensReply(buf), nil -} - -// Read reply into structure from buffer for XprintPrintQueryScreens -func xprintPrintQueryScreensReply(buf []byte) *XprintPrintQueryScreensReply { - v := new(XprintPrintQueryScreensReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.ListCount = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Roots = make([]Window, v.ListCount) - for i := 0; i < int(v.ListCount); i++ { - v.Roots[i] = Window(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook XprintPrintQueryScreensCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintQueryScreens -func (c *Conn) xprintPrintQueryScreensRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 22 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request XprintPrintSetImageResolution -// size: 12 -type XprintPrintSetImageResolutionCookie struct { - *cookie -} - -func (c *Conn) XprintPrintSetImageResolution(Context XprintPcontext, ImageResolution uint16) XprintPrintSetImageResolutionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xprintPrintSetImageResolutionRequest(Context, ImageResolution), cookie) - return XprintPrintSetImageResolutionCookie{cookie} -} - -func (c *Conn) XprintPrintSetImageResolutionUnchecked(Context XprintPcontext, ImageResolution uint16) XprintPrintSetImageResolutionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xprintPrintSetImageResolutionRequest(Context, ImageResolution), cookie) - return XprintPrintSetImageResolutionCookie{cookie} -} - -// Request reply for XprintPrintSetImageResolution -// size: 10 -type XprintPrintSetImageResolutionReply struct { - Sequence uint16 - Length uint32 - Status bool - PreviousResolutions uint16 -} - -// Waits and reads reply data from request XprintPrintSetImageResolution -func (cook XprintPrintSetImageResolutionCookie) Reply() (*XprintPrintSetImageResolutionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xprintPrintSetImageResolutionReply(buf), nil -} - -// Read reply into structure from buffer for XprintPrintSetImageResolution -func xprintPrintSetImageResolutionReply(buf []byte) *XprintPrintSetImageResolutionReply { - v := new(XprintPrintSetImageResolutionReply) - b := 1 // skip reply determinant - - if buf[b] == 1 { - v.Status = true - } else { - v.Status = false - } - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.PreviousResolutions = Get16(buf[b:]) - b += 2 - - return v -} - -func (cook XprintPrintSetImageResolutionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintSetImageResolution -func (c *Conn) xprintPrintSetImageResolutionRequest(Context XprintPcontext, ImageResolution uint16) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 23 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Context)) - b += 4 - - Put16(buf[b:], ImageResolution) - b += 2 - - return buf -} - -// Request XprintPrintGetImageResolution -// size: 8 -type XprintPrintGetImageResolutionCookie struct { - *cookie -} - -func (c *Conn) XprintPrintGetImageResolution(Context XprintPcontext) XprintPrintGetImageResolutionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xprintPrintGetImageResolutionRequest(Context), cookie) - return XprintPrintGetImageResolutionCookie{cookie} -} - -func (c *Conn) XprintPrintGetImageResolutionUnchecked(Context XprintPcontext) XprintPrintGetImageResolutionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xprintPrintGetImageResolutionRequest(Context), cookie) - return XprintPrintGetImageResolutionCookie{cookie} -} - -// Request reply for XprintPrintGetImageResolution -// size: 10 -type XprintPrintGetImageResolutionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ImageResolution uint16 -} - -// Waits and reads reply data from request XprintPrintGetImageResolution -func (cook XprintPrintGetImageResolutionCookie) Reply() (*XprintPrintGetImageResolutionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xprintPrintGetImageResolutionReply(buf), nil -} - -// Read reply into structure from buffer for XprintPrintGetImageResolution -func xprintPrintGetImageResolutionReply(buf []byte) *XprintPrintGetImageResolutionReply { - v := new(XprintPrintGetImageResolutionReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.ImageResolution = Get16(buf[b:]) - b += 2 - - return v -} - -func (cook XprintPrintGetImageResolutionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XprintPrintGetImageResolution -func (c *Conn) xprintPrintGetImageResolutionRequest(Context XprintPcontext) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XPEXTENSION"] - b += 1 - - buf[b] = 24 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Context)) - b += 4 - - return buf -} diff --git a/nexgb/auto_xproto.go b/nexgb/auto_xproto.go deleted file mode 100644 index 8bd39b3..0000000 --- a/nexgb/auto_xproto.go +++ /dev/null @@ -1,14490 +0,0 @@ -package xgb - -/* - This file was generated by xproto.xml on May 10 2012 12:39:34pm EDT. - This file is automatically generated. Edit at your peril! -*/ - -// Skipping definition for base type 'Int8' - -// Skipping definition for base type 'Card16' - -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - -// Skipping definition for base type 'Float' - -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - -const ( - VisualClassStaticGray = 0 - VisualClassGrayScale = 1 - VisualClassStaticColor = 2 - VisualClassPseudoColor = 3 - VisualClassTrueColor = 4 - VisualClassDirectColor = 5 -) - -const ( - EventMaskNoEvent = 0 - EventMaskKeyPress = 1 - EventMaskKeyRelease = 2 - EventMaskButtonPress = 4 - EventMaskButtonRelease = 8 - EventMaskEnterWindow = 16 - EventMaskLeaveWindow = 32 - EventMaskPointerMotion = 64 - EventMaskPointerMotionHint = 128 - EventMaskButton1Motion = 256 - EventMaskButton2Motion = 512 - EventMaskButton3Motion = 1024 - EventMaskButton4Motion = 2048 - EventMaskButton5Motion = 4096 - EventMaskButtonMotion = 8192 - EventMaskKeymapState = 16384 - EventMaskExposure = 32768 - EventMaskVisibilityChange = 65536 - EventMaskStructureNotify = 131072 - EventMaskResizeRedirect = 262144 - EventMaskSubstructureNotify = 524288 - EventMaskSubstructureRedirect = 1048576 - EventMaskFocusChange = 2097152 - EventMaskPropertyChange = 4194304 - EventMaskColorMapChange = 8388608 - EventMaskOwnerGrabButton = 16777216 -) - -const ( - BackingStoreNotUseful = 0 - BackingStoreWhenMapped = 1 - BackingStoreAlways = 2 -) - -const ( - ImageOrderLSBFirst = 0 - ImageOrderMSBFirst = 1 -) - -const ( - ModMaskShift = 1 - ModMaskLock = 2 - ModMaskControl = 4 - ModMask1 = 8 - ModMask2 = 16 - ModMask3 = 32 - ModMask4 = 64 - ModMask5 = 128 - ModMaskAny = 32768 -) - -const ( - KeyButMaskShift = 1 - KeyButMaskLock = 2 - KeyButMaskControl = 4 - KeyButMaskMod1 = 8 - KeyButMaskMod2 = 16 - KeyButMaskMod3 = 32 - KeyButMaskMod4 = 64 - KeyButMaskMod5 = 128 - KeyButMaskButton1 = 256 - KeyButMaskButton2 = 512 - KeyButMaskButton3 = 1024 - KeyButMaskButton4 = 2048 - KeyButMaskButton5 = 4096 -) - -const ( - WindowNone = 0 -) - -const ( - ButtonMask1 = 256 - ButtonMask2 = 512 - ButtonMask3 = 1024 - ButtonMask4 = 2048 - ButtonMask5 = 4096 - ButtonMaskAny = 32768 -) - -const ( - MotionNormal = 0 - MotionHint = 1 -) - -const ( - NotifyDetailAncestor = 0 - NotifyDetailVirtual = 1 - NotifyDetailInferior = 2 - NotifyDetailNonlinear = 3 - NotifyDetailNonlinearVirtual = 4 - NotifyDetailPointer = 5 - NotifyDetailPointerRoot = 6 - NotifyDetailNone = 7 -) - -const ( - NotifyModeNormal = 0 - NotifyModeGrab = 1 - NotifyModeUngrab = 2 - NotifyModeWhileGrabbed = 3 -) - -const ( - VisibilityUnobscured = 0 - VisibilityPartiallyObscured = 1 - VisibilityFullyObscured = 2 -) - -const ( - PlaceOnTop = 0 - PlaceOnBottom = 1 -) - -const ( - PropertyNewValue = 0 - PropertyDelete = 1 -) - -const ( - TimeCurrentTime = 0 -) - -const ( - AtomNone = 0 - AtomAny = 0 - AtomPrimary = 1 - AtomSecondary = 2 - AtomArc = 3 - AtomAtom = 4 - AtomBitmap = 5 - AtomCardinal = 6 - AtomColormap = 7 - AtomCursor = 8 - AtomCutBuffer0 = 9 - AtomCutBuffer1 = 10 - AtomCutBuffer2 = 11 - AtomCutBuffer3 = 12 - AtomCutBuffer4 = 13 - AtomCutBuffer5 = 14 - AtomCutBuffer6 = 15 - AtomCutBuffer7 = 16 - AtomDrawable = 17 - AtomFont = 18 - AtomInteger = 19 - AtomPixmap = 20 - AtomPoint = 21 - AtomRectangle = 22 - AtomResourceManager = 23 - AtomRgbColorMap = 24 - AtomRgbBestMap = 25 - AtomRgbBlueMap = 26 - AtomRgbDefaultMap = 27 - AtomRgbGrayMap = 28 - AtomRgbGreenMap = 29 - AtomRgbRedMap = 30 - AtomString = 31 - AtomVisualid = 32 - AtomWindow = 33 - AtomWmCommand = 34 - AtomWmHints = 35 - AtomWmClientMachine = 36 - AtomWmIconName = 37 - AtomWmIconSize = 38 - AtomWmName = 39 - AtomWmNormalHints = 40 - AtomWmSizeHints = 41 - AtomWmZoomHints = 42 - AtomMinSpace = 43 - AtomNormSpace = 44 - AtomMaxSpace = 45 - AtomEndSpace = 46 - AtomSuperscriptX = 47 - AtomSuperscriptY = 48 - AtomSubscriptX = 49 - AtomSubscriptY = 50 - AtomUnderlinePosition = 51 - AtomUnderlineThickness = 52 - AtomStrikeoutAscent = 53 - AtomStrikeoutDescent = 54 - AtomItalicAngle = 55 - AtomXHeight = 56 - AtomQuadWidth = 57 - AtomWeight = 58 - AtomPointSize = 59 - AtomResolution = 60 - AtomCopyright = 61 - AtomNotice = 62 - AtomFontName = 63 - AtomFamilyName = 64 - AtomFullName = 65 - AtomCapHeight = 66 - AtomWmClass = 67 - AtomWmTransientFor = 68 -) - -const ( - ColormapStateUninstalled = 0 - ColormapStateInstalled = 1 -) - -const ( - ColormapNone = 0 -) - -const ( - MappingModifier = 0 - MappingKeyboard = 1 - MappingPointer = 2 -) - -const ( - WindowClassCopyFromParent = 0 - WindowClassInputOutput = 1 - WindowClassInputOnly = 2 -) - -const ( - CwBackPixmap = 1 - CwBackPixel = 2 - CwBorderPixmap = 4 - CwBorderPixel = 8 - CwBitGravity = 16 - CwWinGravity = 32 - CwBackingStore = 64 - CwBackingPlanes = 128 - CwBackingPixel = 256 - CwOverrideRedirect = 512 - CwSaveUnder = 1024 - CwEventMask = 2048 - CwDontPropagate = 4096 - CwColormap = 8192 - CwCursor = 16384 -) - -const ( - BackPixmapNone = 0 - BackPixmapParentRelative = 1 -) - -const ( - GravityBitForget = 0 - GravityWinUnmap = 0 - GravityNorthWest = 1 - GravityNorth = 2 - GravityNorthEast = 3 - GravityWest = 4 - GravityCenter = 5 - GravityEast = 6 - GravitySouthWest = 7 - GravitySouth = 8 - GravitySouthEast = 9 - GravityStatic = 10 -) - -const ( - MapStateUnmapped = 0 - MapStateUnviewable = 1 - MapStateViewable = 2 -) - -const ( - SetModeInsert = 0 - SetModeDelete = 1 -) - -const ( - ConfigWindowX = 1 - ConfigWindowY = 2 - ConfigWindowWidth = 4 - ConfigWindowHeight = 8 - ConfigWindowBorderWidth = 16 - ConfigWindowSibling = 32 - ConfigWindowStackMode = 64 -) - -const ( - StackModeAbove = 0 - StackModeBelow = 1 - StackModeTopIf = 2 - StackModeBottomIf = 3 - StackModeOpposite = 4 -) - -const ( - CirculateRaiseLowest = 0 - CirculateLowerHighest = 1 -) - -const ( - PropModeReplace = 0 - PropModePrepend = 1 - PropModeAppend = 2 -) - -const ( - GetPropertyTypeAny = 0 -) - -const ( - SendEventDestPointerWindow = 0 - SendEventDestItemFocus = 1 -) - -const ( - GrabModeSync = 0 - GrabModeAsync = 1 -) - -const ( - GrabStatusSuccess = 0 - GrabStatusAlreadyGrabbed = 1 - GrabStatusInvalidTime = 2 - GrabStatusNotViewable = 3 - GrabStatusFrozen = 4 -) - -const ( - CursorNone = 0 -) - -const ( - ButtonIndexAny = 0 - ButtonIndex1 = 1 - ButtonIndex2 = 2 - ButtonIndex3 = 3 - ButtonIndex4 = 4 - ButtonIndex5 = 5 -) - -const ( - GrabAny = 0 -) - -const ( - AllowAsyncPointer = 0 - AllowSyncPointer = 1 - AllowReplayPointer = 2 - AllowAsyncKeyboard = 3 - AllowSyncKeyboard = 4 - AllowReplayKeyboard = 5 - AllowAsyncBoth = 6 - AllowSyncBoth = 7 -) - -const ( - InputFocusNone = 0 - InputFocusPointerRoot = 1 - InputFocusParent = 2 - InputFocusFollowKeyboard = 3 -) - -const ( - FontDrawLeftToRight = 0 - FontDrawRightToLeft = 1 -) - -const ( - GcFunction = 1 - GcPlaneMask = 2 - GcForeground = 4 - GcBackground = 8 - GcLineWidth = 16 - GcLineStyle = 32 - GcCapStyle = 64 - GcJoinStyle = 128 - GcFillStyle = 256 - GcFillRule = 512 - GcTile = 1024 - GcStipple = 2048 - GcTileStippleOriginX = 4096 - GcTileStippleOriginY = 8192 - GcFont = 16384 - GcSubwindowMode = 32768 - GcGraphicsExposures = 65536 - GcClipOriginX = 131072 - GcClipOriginY = 262144 - GcClipMask = 524288 - GcDashOffset = 1048576 - GcDashList = 2097152 - GcArcMode = 4194304 -) - -const ( - GxClear = 0 - GxAnd = 1 - GxAndReverse = 2 - GxCopy = 3 - GxAndInverted = 4 - GxNoop = 5 - GxXor = 6 - GxOr = 7 - GxNor = 8 - GxEquiv = 9 - GxInvert = 10 - GxOrReverse = 11 - GxCopyInverted = 12 - GxOrInverted = 13 - GxNand = 14 - GxSet = 15 -) - -const ( - LineStyleSolid = 0 - LineStyleOnOffDash = 1 - LineStyleDoubleDash = 2 -) - -const ( - CapStyleNotLast = 0 - CapStyleButt = 1 - CapStyleRound = 2 - CapStyleProjecting = 3 -) - -const ( - JoinStyleMiter = 0 - JoinStyleRound = 1 - JoinStyleBevel = 2 -) - -const ( - FillStyleSolid = 0 - FillStyleTiled = 1 - FillStyleStippled = 2 - FillStyleOpaqueStippled = 3 -) - -const ( - FillRuleEvenOdd = 0 - FillRuleWinding = 1 -) - -const ( - SubwindowModeClipByChildren = 0 - SubwindowModeIncludeInferiors = 1 -) - -const ( - ArcModeChord = 0 - ArcModePieSlice = 1 -) - -const ( - ClipOrderingUnsorted = 0 - ClipOrderingYSorted = 1 - ClipOrderingYXSorted = 2 - ClipOrderingYXBanded = 3 -) - -const ( - CoordModeOrigin = 0 - CoordModePrevious = 1 -) - -const ( - PolyShapeComplex = 0 - PolyShapeNonconvex = 1 - PolyShapeConvex = 2 -) - -const ( - ImageFormatXYBitmap = 0 - ImageFormatXYPixmap = 1 - ImageFormatZPixmap = 2 -) - -const ( - ColormapAllocNone = 0 - ColormapAllocAll = 1 -) - -const ( - ColorFlagRed = 1 - ColorFlagGreen = 2 - ColorFlagBlue = 4 -) - -const ( - PixmapNone = 0 -) - -const ( - FontNone = 0 -) - -const ( - QueryShapeOfLargestCursor = 0 - QueryShapeOfFastestTile = 1 - QueryShapeOfFastestStipple = 2 -) - -const ( - KbKeyClickPercent = 1 - KbBellPercent = 2 - KbBellPitch = 4 - KbBellDuration = 8 - KbLed = 16 - KbLedMode = 32 - KbKey = 64 - KbAutoRepeatMode = 128 -) - -const ( - LedModeOff = 0 - LedModeOn = 1 -) - -const ( - AutoRepeatModeOff = 0 - AutoRepeatModeOn = 1 - AutoRepeatModeDefault = 2 -) - -const ( - BlankingNotPreferred = 0 - BlankingPreferred = 1 - BlankingDefault = 2 -) - -const ( - ExposuresNotAllowed = 0 - ExposuresAllowed = 1 - ExposuresDefault = 2 -) - -const ( - HostModeInsert = 0 - HostModeDelete = 1 -) - -const ( - FamilyInternet = 0 - FamilyDECnet = 1 - FamilyChaos = 2 - FamilyServerInterpreted = 5 - FamilyInternet6 = 6 -) - -const ( - AccessControlDisable = 0 - AccessControlEnable = 1 -) - -const ( - CloseDownDestroyAll = 0 - CloseDownRetainPermanent = 1 - CloseDownRetainTemporary = 2 -) - -const ( - KillAllTemporary = 0 -) - -const ( - ScreenSaverReset = 0 - ScreenSaverActive = 1 -) - -const ( - MappingStatusSuccess = 0 - MappingStatusBusy = 1 - MappingStatusFailure = 2 -) - -const ( - MapIndexShift = 0 - MapIndexLock = 1 - MapIndexControl = 2 - MapIndex1 = 3 - MapIndex2 = 4 - MapIndex3 = 5 - MapIndex4 = 6 - MapIndex5 = 7 -) - -type Window uint32 - -func (c *Conn) NewWindowId() (Window, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Window(id), nil -} - -type Pixmap uint32 - -func (c *Conn) NewPixmapId() (Pixmap, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Pixmap(id), nil -} - -type Cursor uint32 - -func (c *Conn) NewCursorId() (Cursor, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Cursor(id), nil -} - -type Font uint32 - -func (c *Conn) NewFontId() (Font, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Font(id), nil -} - -type Gcontext uint32 - -func (c *Conn) NewGcontextId() (Gcontext, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Gcontext(id), nil -} - -type Colormap uint32 - -func (c *Conn) NewColormapId() (Colormap, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Colormap(id), nil -} - -type Atom uint32 - -func (c *Conn) NewAtomId() (Atom, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Atom(id), nil -} - -type Drawable uint32 - -func (c *Conn) NewDrawableId() (Drawable, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Drawable(id), nil -} - -type Fontable uint32 - -func (c *Conn) NewFontableId() (Fontable, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Fontable(id), nil -} - -type Visualid uint32 - -type Timestamp uint32 - -type Keysym uint32 - -type Keycode byte - -type Button byte - -// 'Char2b' struct definition -// Size: 2 -type Char2b struct { - Byte1 byte - Byte2 byte -} - -// Struct read Char2b -func ReadChar2b(buf []byte, v *Char2b) int { - b := 0 - - v.Byte1 = buf[b] - b += 1 - - v.Byte2 = buf[b] - b += 1 - - return b -} - -// Struct list read Char2b -func ReadChar2bList(buf []byte, dest []Char2b) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Char2b{} - b += ReadChar2b(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write Char2b -func (v Char2b) Bytes() []byte { - buf := make([]byte, 2) - b := 0 - - buf[b] = v.Byte1 - b += 1 - - buf[b] = v.Byte2 - b += 1 - - return buf -} - -// Write struct list Char2b -func Char2bListBytes(buf []byte, list []Char2b) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'Point' struct definition -// Size: 4 -type Point struct { - X int16 - Y int16 -} - -// Struct read Point -func ReadPoint(buf []byte, v *Point) int { - b := 0 - - v.X = int16(Get16(buf[b:])) - b += 2 - - v.Y = int16(Get16(buf[b:])) - b += 2 - - return b -} - -// Struct list read Point -func ReadPointList(buf []byte, dest []Point) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Point{} - b += ReadPoint(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write Point -func (v Point) Bytes() []byte { - buf := make([]byte, 4) - b := 0 - - Put16(buf[b:], uint16(v.X)) - b += 2 - - Put16(buf[b:], uint16(v.Y)) - b += 2 - - return buf -} - -// Write struct list Point -func PointListBytes(buf []byte, list []Point) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'Rectangle' struct definition -// Size: 8 -type Rectangle struct { - X int16 - Y int16 - Width uint16 - Height uint16 -} - -// Struct read Rectangle -func ReadRectangle(buf []byte, v *Rectangle) int { - b := 0 - - v.X = int16(Get16(buf[b:])) - b += 2 - - v.Y = int16(Get16(buf[b:])) - b += 2 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - return b -} - -// Struct list read Rectangle -func ReadRectangleList(buf []byte, dest []Rectangle) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Rectangle{} - b += ReadRectangle(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write Rectangle -func (v Rectangle) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put16(buf[b:], uint16(v.X)) - b += 2 - - Put16(buf[b:], uint16(v.Y)) - b += 2 - - Put16(buf[b:], v.Width) - b += 2 - - Put16(buf[b:], v.Height) - b += 2 - - return buf -} - -// Write struct list Rectangle -func RectangleListBytes(buf []byte, list []Rectangle) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'Arc' struct definition -// Size: 12 -type Arc struct { - X int16 - Y int16 - Width uint16 - Height uint16 - Angle1 int16 - Angle2 int16 -} - -// Struct read Arc -func ReadArc(buf []byte, v *Arc) int { - b := 0 - - v.X = int16(Get16(buf[b:])) - b += 2 - - v.Y = int16(Get16(buf[b:])) - b += 2 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - v.Angle1 = int16(Get16(buf[b:])) - b += 2 - - v.Angle2 = int16(Get16(buf[b:])) - b += 2 - - return b -} - -// Struct list read Arc -func ReadArcList(buf []byte, dest []Arc) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Arc{} - b += ReadArc(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write Arc -func (v Arc) Bytes() []byte { - buf := make([]byte, 12) - b := 0 - - Put16(buf[b:], uint16(v.X)) - b += 2 - - Put16(buf[b:], uint16(v.Y)) - b += 2 - - Put16(buf[b:], v.Width) - b += 2 - - Put16(buf[b:], v.Height) - b += 2 - - Put16(buf[b:], uint16(v.Angle1)) - b += 2 - - Put16(buf[b:], uint16(v.Angle2)) - b += 2 - - return buf -} - -// Write struct list Arc -func ArcListBytes(buf []byte, list []Arc) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'Format' struct definition -// Size: 8 -type Format struct { - Depth byte - BitsPerPixel byte - ScanlinePad byte - // padding: 5 bytes -} - -// Struct read Format -func ReadFormat(buf []byte, v *Format) int { - b := 0 - - v.Depth = buf[b] - b += 1 - - v.BitsPerPixel = buf[b] - b += 1 - - v.ScanlinePad = buf[b] - b += 1 - - b += 5 // padding - - return b -} - -// Struct list read Format -func ReadFormatList(buf []byte, dest []Format) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Format{} - b += ReadFormat(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write Format -func (v Format) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - buf[b] = v.Depth - b += 1 - - buf[b] = v.BitsPerPixel - b += 1 - - buf[b] = v.ScanlinePad - b += 1 - - b += 5 // padding - - return buf -} - -// Write struct list Format -func FormatListBytes(buf []byte, list []Format) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'VisualInfo' struct definition -// Size: 24 -type VisualInfo struct { - VisualId Visualid - Class byte - BitsPerRgbValue byte - ColormapEntries uint16 - RedMask uint32 - GreenMask uint32 - BlueMask uint32 - // padding: 4 bytes -} - -// Struct read VisualInfo -func ReadVisualInfo(buf []byte, v *VisualInfo) int { - b := 0 - - v.VisualId = Visualid(Get32(buf[b:])) - b += 4 - - v.Class = buf[b] - b += 1 - - v.BitsPerRgbValue = buf[b] - b += 1 - - v.ColormapEntries = Get16(buf[b:]) - b += 2 - - v.RedMask = Get32(buf[b:]) - b += 4 - - v.GreenMask = Get32(buf[b:]) - b += 4 - - v.BlueMask = Get32(buf[b:]) - b += 4 - - b += 4 // padding - - return b -} - -// Struct list read VisualInfo -func ReadVisualInfoList(buf []byte, dest []VisualInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = VisualInfo{} - b += ReadVisualInfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write VisualInfo -func (v VisualInfo) Bytes() []byte { - buf := make([]byte, 24) - b := 0 - - Put32(buf[b:], uint32(v.VisualId)) - b += 4 - - buf[b] = v.Class - b += 1 - - buf[b] = v.BitsPerRgbValue - b += 1 - - Put16(buf[b:], v.ColormapEntries) - b += 2 - - Put32(buf[b:], v.RedMask) - b += 4 - - Put32(buf[b:], v.GreenMask) - b += 4 - - Put32(buf[b:], v.BlueMask) - b += 4 - - b += 4 // padding - - return buf -} - -// Write struct list VisualInfo -func VisualInfoListBytes(buf []byte, list []VisualInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'DepthInfo' struct definition -// Size: (8 + pad((int(VisualsLen) * 24))) -type DepthInfo struct { - Depth byte - // padding: 1 bytes - VisualsLen uint16 - // padding: 4 bytes - Visuals []VisualInfo // size: pad((int(VisualsLen) * 24)) -} - -// Struct read DepthInfo -func ReadDepthInfo(buf []byte, v *DepthInfo) int { - b := 0 - - v.Depth = buf[b] - b += 1 - - b += 1 // padding - - v.VisualsLen = Get16(buf[b:]) - b += 2 - - b += 4 // padding - - v.Visuals = make([]VisualInfo, v.VisualsLen) - b += ReadVisualInfoList(buf[b:], v.Visuals) - - return b -} - -// Struct list read DepthInfo -func ReadDepthInfoList(buf []byte, dest []DepthInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = DepthInfo{} - b += ReadDepthInfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write DepthInfo -func (v DepthInfo) Bytes() []byte { - buf := make([]byte, (8 + pad((int(v.VisualsLen) * 24)))) - b := 0 - - buf[b] = v.Depth - b += 1 - - b += 1 // padding - - Put16(buf[b:], v.VisualsLen) - b += 2 - - b += 4 // padding - - b += VisualInfoListBytes(buf[b:], v.Visuals) - - return buf -} - -// Write struct list DepthInfo -func DepthInfoListBytes(buf []byte, list []DepthInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size DepthInfo -func DepthInfoListSize(list []DepthInfo) int { - size := 0 - for _, item := range list { - size += (8 + pad((int(item.VisualsLen) * 24))) - } - return size -} - -// 'ScreenInfo' struct definition -// Size: (40 + DepthInfoListSize(AllowedDepths)) -type ScreenInfo struct { - Root Window - DefaultColormap Colormap - WhitePixel uint32 - BlackPixel uint32 - CurrentInputMasks uint32 - WidthInPixels uint16 - HeightInPixels uint16 - WidthInMillimeters uint16 - HeightInMillimeters uint16 - MinInstalledMaps uint16 - MaxInstalledMaps uint16 - RootVisual Visualid - BackingStores byte - SaveUnders bool - RootDepth byte - AllowedDepthsLen byte - AllowedDepths []DepthInfo // size: DepthInfoListSize(AllowedDepths) -} - -// Struct read ScreenInfo -func ReadScreenInfo(buf []byte, v *ScreenInfo) int { - b := 0 - - v.Root = Window(Get32(buf[b:])) - b += 4 - - v.DefaultColormap = Colormap(Get32(buf[b:])) - b += 4 - - v.WhitePixel = Get32(buf[b:]) - b += 4 - - v.BlackPixel = Get32(buf[b:]) - b += 4 - - v.CurrentInputMasks = Get32(buf[b:]) - b += 4 - - v.WidthInPixels = Get16(buf[b:]) - b += 2 - - v.HeightInPixels = Get16(buf[b:]) - b += 2 - - v.WidthInMillimeters = Get16(buf[b:]) - b += 2 - - v.HeightInMillimeters = Get16(buf[b:]) - b += 2 - - v.MinInstalledMaps = Get16(buf[b:]) - b += 2 - - v.MaxInstalledMaps = Get16(buf[b:]) - b += 2 - - v.RootVisual = Visualid(Get32(buf[b:])) - b += 4 - - v.BackingStores = buf[b] - b += 1 - - if buf[b] == 1 { - v.SaveUnders = true - } else { - v.SaveUnders = false - } - b += 1 - - v.RootDepth = buf[b] - b += 1 - - v.AllowedDepthsLen = buf[b] - b += 1 - - v.AllowedDepths = make([]DepthInfo, v.AllowedDepthsLen) - b += ReadDepthInfoList(buf[b:], v.AllowedDepths) - - return b -} - -// Struct list read ScreenInfo -func ReadScreenInfoList(buf []byte, dest []ScreenInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = ScreenInfo{} - b += ReadScreenInfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write ScreenInfo -func (v ScreenInfo) Bytes() []byte { - buf := make([]byte, (40 + DepthInfoListSize(v.AllowedDepths))) - b := 0 - - Put32(buf[b:], uint32(v.Root)) - b += 4 - - Put32(buf[b:], uint32(v.DefaultColormap)) - b += 4 - - Put32(buf[b:], v.WhitePixel) - b += 4 - - Put32(buf[b:], v.BlackPixel) - b += 4 - - Put32(buf[b:], v.CurrentInputMasks) - b += 4 - - Put16(buf[b:], v.WidthInPixels) - b += 2 - - Put16(buf[b:], v.HeightInPixels) - b += 2 - - Put16(buf[b:], v.WidthInMillimeters) - b += 2 - - Put16(buf[b:], v.HeightInMillimeters) - b += 2 - - Put16(buf[b:], v.MinInstalledMaps) - b += 2 - - Put16(buf[b:], v.MaxInstalledMaps) - b += 2 - - Put32(buf[b:], uint32(v.RootVisual)) - b += 4 - - buf[b] = v.BackingStores - b += 1 - - if v.SaveUnders { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - buf[b] = v.RootDepth - b += 1 - - buf[b] = v.AllowedDepthsLen - b += 1 - - b += DepthInfoListBytes(buf[b:], v.AllowedDepths) - - return buf -} - -// Write struct list ScreenInfo -func ScreenInfoListBytes(buf []byte, list []ScreenInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size ScreenInfo -func ScreenInfoListSize(list []ScreenInfo) int { - size := 0 - for _, item := range list { - size += (40 + DepthInfoListSize(item.AllowedDepths)) - } - return size -} - -// 'SetupRequest' struct definition -// Size: ((12 + pad((int(AuthorizationProtocolNameLen) * 1))) + pad((int(AuthorizationProtocolDataLen) * 1))) -type SetupRequest struct { - ByteOrder byte - // padding: 1 bytes - ProtocolMajorVersion uint16 - ProtocolMinorVersion uint16 - AuthorizationProtocolNameLen uint16 - AuthorizationProtocolDataLen uint16 - // padding: 2 bytes - AuthorizationProtocolName string // size: pad((int(AuthorizationProtocolNameLen) * 1)) - AuthorizationProtocolData string // size: pad((int(AuthorizationProtocolDataLen) * 1)) -} - -// Struct read SetupRequest -func ReadSetupRequest(buf []byte, v *SetupRequest) int { - b := 0 - - v.ByteOrder = buf[b] - b += 1 - - b += 1 // padding - - v.ProtocolMajorVersion = Get16(buf[b:]) - b += 2 - - v.ProtocolMinorVersion = Get16(buf[b:]) - b += 2 - - v.AuthorizationProtocolNameLen = Get16(buf[b:]) - b += 2 - - v.AuthorizationProtocolDataLen = Get16(buf[b:]) - b += 2 - - b += 2 // padding - - { - byteString := make([]byte, v.AuthorizationProtocolNameLen) - copy(byteString[:v.AuthorizationProtocolNameLen], buf[b:]) - v.AuthorizationProtocolName = string(byteString) - b += pad(int(v.AuthorizationProtocolNameLen)) - } - - { - byteString := make([]byte, v.AuthorizationProtocolDataLen) - copy(byteString[:v.AuthorizationProtocolDataLen], buf[b:]) - v.AuthorizationProtocolData = string(byteString) - b += pad(int(v.AuthorizationProtocolDataLen)) - } - - return b -} - -// Struct list read SetupRequest -func ReadSetupRequestList(buf []byte, dest []SetupRequest) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = SetupRequest{} - b += ReadSetupRequest(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write SetupRequest -func (v SetupRequest) Bytes() []byte { - buf := make([]byte, ((12 + pad((int(v.AuthorizationProtocolNameLen) * 1))) + pad((int(v.AuthorizationProtocolDataLen) * 1)))) - b := 0 - - buf[b] = v.ByteOrder - b += 1 - - b += 1 // padding - - Put16(buf[b:], v.ProtocolMajorVersion) - b += 2 - - Put16(buf[b:], v.ProtocolMinorVersion) - b += 2 - - Put16(buf[b:], v.AuthorizationProtocolNameLen) - b += 2 - - Put16(buf[b:], v.AuthorizationProtocolDataLen) - b += 2 - - b += 2 // padding - - copy(buf[b:], v.AuthorizationProtocolName[:v.AuthorizationProtocolNameLen]) - b += pad(int(v.AuthorizationProtocolNameLen)) - - copy(buf[b:], v.AuthorizationProtocolData[:v.AuthorizationProtocolDataLen]) - b += pad(int(v.AuthorizationProtocolDataLen)) - - return buf -} - -// Write struct list SetupRequest -func SetupRequestListBytes(buf []byte, list []SetupRequest) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size SetupRequest -func SetupRequestListSize(list []SetupRequest) int { - size := 0 - for _, item := range list { - size += ((12 + pad((int(item.AuthorizationProtocolNameLen) * 1))) + pad((int(item.AuthorizationProtocolDataLen) * 1))) - } - return size -} - -// 'SetupFailed' struct definition -// Size: (8 + pad((int(ReasonLen) * 1))) -type SetupFailed struct { - Status byte - ReasonLen byte - ProtocolMajorVersion uint16 - ProtocolMinorVersion uint16 - Length uint16 - Reason string // size: pad((int(ReasonLen) * 1)) -} - -// Struct read SetupFailed -func ReadSetupFailed(buf []byte, v *SetupFailed) int { - b := 0 - - v.Status = buf[b] - b += 1 - - v.ReasonLen = buf[b] - b += 1 - - v.ProtocolMajorVersion = Get16(buf[b:]) - b += 2 - - v.ProtocolMinorVersion = Get16(buf[b:]) - b += 2 - - v.Length = Get16(buf[b:]) - b += 2 - - { - byteString := make([]byte, v.ReasonLen) - copy(byteString[:v.ReasonLen], buf[b:]) - v.Reason = string(byteString) - b += pad(int(v.ReasonLen)) - } - - return b -} - -// Struct list read SetupFailed -func ReadSetupFailedList(buf []byte, dest []SetupFailed) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = SetupFailed{} - b += ReadSetupFailed(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write SetupFailed -func (v SetupFailed) Bytes() []byte { - buf := make([]byte, (8 + pad((int(v.ReasonLen) * 1)))) - b := 0 - - buf[b] = v.Status - b += 1 - - buf[b] = v.ReasonLen - b += 1 - - Put16(buf[b:], v.ProtocolMajorVersion) - b += 2 - - Put16(buf[b:], v.ProtocolMinorVersion) - b += 2 - - Put16(buf[b:], v.Length) - b += 2 - - copy(buf[b:], v.Reason[:v.ReasonLen]) - b += pad(int(v.ReasonLen)) - - return buf -} - -// Write struct list SetupFailed -func SetupFailedListBytes(buf []byte, list []SetupFailed) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size SetupFailed -func SetupFailedListSize(list []SetupFailed) int { - size := 0 - for _, item := range list { - size += (8 + pad((int(item.ReasonLen) * 1))) - } - return size -} - -// 'SetupAuthenticate' struct definition -// Size: (8 + pad(((int(Length) * 4) * 1))) -type SetupAuthenticate struct { - Status byte - // padding: 5 bytes - Length uint16 - Reason string // size: pad(((int(Length) * 4) * 1)) -} - -// Struct read SetupAuthenticate -func ReadSetupAuthenticate(buf []byte, v *SetupAuthenticate) int { - b := 0 - - v.Status = buf[b] - b += 1 - - b += 5 // padding - - v.Length = Get16(buf[b:]) - b += 2 - - { - byteString := make([]byte, (int(v.Length) * 4)) - copy(byteString[:(int(v.Length)*4)], buf[b:]) - v.Reason = string(byteString) - b += pad(int((int(v.Length) * 4))) - } - - return b -} - -// Struct list read SetupAuthenticate -func ReadSetupAuthenticateList(buf []byte, dest []SetupAuthenticate) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = SetupAuthenticate{} - b += ReadSetupAuthenticate(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write SetupAuthenticate -func (v SetupAuthenticate) Bytes() []byte { - buf := make([]byte, (8 + pad(((int(v.Length) * 4) * 1)))) - b := 0 - - buf[b] = v.Status - b += 1 - - b += 5 // padding - - Put16(buf[b:], v.Length) - b += 2 - - copy(buf[b:], v.Reason[:(int(v.Length)*4)]) - b += pad(int((int(v.Length) * 4))) - - return buf -} - -// Write struct list SetupAuthenticate -func SetupAuthenticateListBytes(buf []byte, list []SetupAuthenticate) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size SetupAuthenticate -func SetupAuthenticateListSize(list []SetupAuthenticate) int { - size := 0 - for _, item := range list { - size += (8 + pad(((int(item.Length) * 4) * 1))) - } - return size -} - -// 'SetupInfo' struct definition -// Size: (((40 + pad((int(VendorLen) * 1))) + pad((int(PixmapFormatsLen) * 8))) + ScreenInfoListSize(Roots)) -type SetupInfo struct { - Status byte - // padding: 1 bytes - ProtocolMajorVersion uint16 - ProtocolMinorVersion uint16 - Length uint16 - ReleaseNumber uint32 - ResourceIdBase uint32 - ResourceIdMask uint32 - MotionBufferSize uint32 - VendorLen uint16 - MaximumRequestLength uint16 - RootsLen byte - PixmapFormatsLen byte - ImageByteOrder byte - BitmapFormatBitOrder byte - BitmapFormatScanlineUnit byte - BitmapFormatScanlinePad byte - MinKeycode Keycode - MaxKeycode Keycode - // padding: 4 bytes - Vendor string // size: pad((int(VendorLen) * 1)) - PixmapFormats []Format // size: pad((int(PixmapFormatsLen) * 8)) - Roots []ScreenInfo // size: ScreenInfoListSize(Roots) -} - -// Struct read SetupInfo -func ReadSetupInfo(buf []byte, v *SetupInfo) int { - b := 0 - - v.Status = buf[b] - b += 1 - - b += 1 // padding - - v.ProtocolMajorVersion = Get16(buf[b:]) - b += 2 - - v.ProtocolMinorVersion = Get16(buf[b:]) - b += 2 - - v.Length = Get16(buf[b:]) - b += 2 - - v.ReleaseNumber = Get32(buf[b:]) - b += 4 - - v.ResourceIdBase = Get32(buf[b:]) - b += 4 - - v.ResourceIdMask = Get32(buf[b:]) - b += 4 - - v.MotionBufferSize = Get32(buf[b:]) - b += 4 - - v.VendorLen = Get16(buf[b:]) - b += 2 - - v.MaximumRequestLength = Get16(buf[b:]) - b += 2 - - v.RootsLen = buf[b] - b += 1 - - v.PixmapFormatsLen = buf[b] - b += 1 - - v.ImageByteOrder = buf[b] - b += 1 - - v.BitmapFormatBitOrder = buf[b] - b += 1 - - v.BitmapFormatScanlineUnit = buf[b] - b += 1 - - v.BitmapFormatScanlinePad = buf[b] - b += 1 - - v.MinKeycode = Keycode(buf[b]) - b += 1 - - v.MaxKeycode = Keycode(buf[b]) - b += 1 - - b += 4 // padding - - { - byteString := make([]byte, v.VendorLen) - copy(byteString[:v.VendorLen], buf[b:]) - v.Vendor = string(byteString) - b += pad(int(v.VendorLen)) - } - - v.PixmapFormats = make([]Format, v.PixmapFormatsLen) - b += ReadFormatList(buf[b:], v.PixmapFormats) - - v.Roots = make([]ScreenInfo, v.RootsLen) - b += ReadScreenInfoList(buf[b:], v.Roots) - - return b -} - -// Struct list read SetupInfo -func ReadSetupInfoList(buf []byte, dest []SetupInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = SetupInfo{} - b += ReadSetupInfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write SetupInfo -func (v SetupInfo) Bytes() []byte { - buf := make([]byte, (((40 + pad((int(v.VendorLen) * 1))) + pad((int(v.PixmapFormatsLen) * 8))) + ScreenInfoListSize(v.Roots))) - b := 0 - - buf[b] = v.Status - b += 1 - - b += 1 // padding - - Put16(buf[b:], v.ProtocolMajorVersion) - b += 2 - - Put16(buf[b:], v.ProtocolMinorVersion) - b += 2 - - Put16(buf[b:], v.Length) - b += 2 - - Put32(buf[b:], v.ReleaseNumber) - b += 4 - - Put32(buf[b:], v.ResourceIdBase) - b += 4 - - Put32(buf[b:], v.ResourceIdMask) - b += 4 - - Put32(buf[b:], v.MotionBufferSize) - b += 4 - - Put16(buf[b:], v.VendorLen) - b += 2 - - Put16(buf[b:], v.MaximumRequestLength) - b += 2 - - buf[b] = v.RootsLen - b += 1 - - buf[b] = v.PixmapFormatsLen - b += 1 - - buf[b] = v.ImageByteOrder - b += 1 - - buf[b] = v.BitmapFormatBitOrder - b += 1 - - buf[b] = v.BitmapFormatScanlineUnit - b += 1 - - buf[b] = v.BitmapFormatScanlinePad - b += 1 - - buf[b] = byte(v.MinKeycode) - b += 1 - - buf[b] = byte(v.MaxKeycode) - b += 1 - - b += 4 // padding - - copy(buf[b:], v.Vendor[:v.VendorLen]) - b += pad(int(v.VendorLen)) - - b += FormatListBytes(buf[b:], v.PixmapFormats) - - b += ScreenInfoListBytes(buf[b:], v.Roots) - - return buf -} - -// Write struct list SetupInfo -func SetupInfoListBytes(buf []byte, list []SetupInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size SetupInfo -func SetupInfoListSize(list []SetupInfo) int { - size := 0 - for _, item := range list { - size += (((40 + pad((int(item.VendorLen) * 1))) + pad((int(item.PixmapFormatsLen) * 8))) + ScreenInfoListSize(item.Roots)) - } - return size -} - -// 'Timecoord' struct definition -// Size: 8 -type Timecoord struct { - Time Timestamp - X int16 - Y int16 -} - -// Struct read Timecoord -func ReadTimecoord(buf []byte, v *Timecoord) int { - b := 0 - - v.Time = Timestamp(Get32(buf[b:])) - b += 4 - - v.X = int16(Get16(buf[b:])) - b += 2 - - v.Y = int16(Get16(buf[b:])) - b += 2 - - return b -} - -// Struct list read Timecoord -func ReadTimecoordList(buf []byte, dest []Timecoord) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Timecoord{} - b += ReadTimecoord(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write Timecoord -func (v Timecoord) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put32(buf[b:], uint32(v.Time)) - b += 4 - - Put16(buf[b:], uint16(v.X)) - b += 2 - - Put16(buf[b:], uint16(v.Y)) - b += 2 - - return buf -} - -// Write struct list Timecoord -func TimecoordListBytes(buf []byte, list []Timecoord) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'Fontprop' struct definition -// Size: 8 -type Fontprop struct { - Name Atom - Value uint32 -} - -// Struct read Fontprop -func ReadFontprop(buf []byte, v *Fontprop) int { - b := 0 - - v.Name = Atom(Get32(buf[b:])) - b += 4 - - v.Value = Get32(buf[b:]) - b += 4 - - return b -} - -// Struct list read Fontprop -func ReadFontpropList(buf []byte, dest []Fontprop) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Fontprop{} - b += ReadFontprop(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write Fontprop -func (v Fontprop) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put32(buf[b:], uint32(v.Name)) - b += 4 - - Put32(buf[b:], v.Value) - b += 4 - - return buf -} - -// Write struct list Fontprop -func FontpropListBytes(buf []byte, list []Fontprop) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'Charinfo' struct definition -// Size: 12 -type Charinfo struct { - LeftSideBearing int16 - RightSideBearing int16 - CharacterWidth int16 - Ascent int16 - Descent int16 - Attributes uint16 -} - -// Struct read Charinfo -func ReadCharinfo(buf []byte, v *Charinfo) int { - b := 0 - - v.LeftSideBearing = int16(Get16(buf[b:])) - b += 2 - - v.RightSideBearing = int16(Get16(buf[b:])) - b += 2 - - v.CharacterWidth = int16(Get16(buf[b:])) - b += 2 - - v.Ascent = int16(Get16(buf[b:])) - b += 2 - - v.Descent = int16(Get16(buf[b:])) - b += 2 - - v.Attributes = Get16(buf[b:]) - b += 2 - - return b -} - -// Struct list read Charinfo -func ReadCharinfoList(buf []byte, dest []Charinfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Charinfo{} - b += ReadCharinfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write Charinfo -func (v Charinfo) Bytes() []byte { - buf := make([]byte, 12) - b := 0 - - Put16(buf[b:], uint16(v.LeftSideBearing)) - b += 2 - - Put16(buf[b:], uint16(v.RightSideBearing)) - b += 2 - - Put16(buf[b:], uint16(v.CharacterWidth)) - b += 2 - - Put16(buf[b:], uint16(v.Ascent)) - b += 2 - - Put16(buf[b:], uint16(v.Descent)) - b += 2 - - Put16(buf[b:], v.Attributes) - b += 2 - - return buf -} - -// Write struct list Charinfo -func CharinfoListBytes(buf []byte, list []Charinfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'Str' struct definition -// Size: (1 + pad((int(NameLen) * 1))) -type Str struct { - NameLen byte - Name string // size: pad((int(NameLen) * 1)) -} - -// Struct read Str -func ReadStr(buf []byte, v *Str) int { - b := 0 - - v.NameLen = buf[b] - b += 1 - - { - byteString := make([]byte, v.NameLen) - copy(byteString[:v.NameLen], buf[b:]) - v.Name = string(byteString) - b += pad(int(v.NameLen)) - } - - return b -} - -// Struct list read Str -func ReadStrList(buf []byte, dest []Str) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Str{} - b += ReadStr(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write Str -func (v Str) Bytes() []byte { - buf := make([]byte, (1 + pad((int(v.NameLen) * 1)))) - b := 0 - - buf[b] = v.NameLen - b += 1 - - copy(buf[b:], v.Name[:v.NameLen]) - b += pad(int(v.NameLen)) - - return buf -} - -// Write struct list Str -func StrListBytes(buf []byte, list []Str) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size Str -func StrListSize(list []Str) int { - size := 0 - for _, item := range list { - size += (1 + pad((int(item.NameLen) * 1))) - } - return size -} - -// 'Segment' struct definition -// Size: 8 -type Segment struct { - X1 int16 - Y1 int16 - X2 int16 - Y2 int16 -} - -// Struct read Segment -func ReadSegment(buf []byte, v *Segment) int { - b := 0 - - v.X1 = int16(Get16(buf[b:])) - b += 2 - - v.Y1 = int16(Get16(buf[b:])) - b += 2 - - v.X2 = int16(Get16(buf[b:])) - b += 2 - - v.Y2 = int16(Get16(buf[b:])) - b += 2 - - return b -} - -// Struct list read Segment -func ReadSegmentList(buf []byte, dest []Segment) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Segment{} - b += ReadSegment(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write Segment -func (v Segment) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put16(buf[b:], uint16(v.X1)) - b += 2 - - Put16(buf[b:], uint16(v.Y1)) - b += 2 - - Put16(buf[b:], uint16(v.X2)) - b += 2 - - Put16(buf[b:], uint16(v.Y2)) - b += 2 - - return buf -} - -// Write struct list Segment -func SegmentListBytes(buf []byte, list []Segment) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'Coloritem' struct definition -// Size: 12 -type Coloritem struct { - Pixel uint32 - Red uint16 - Green uint16 - Blue uint16 - Flags byte - // padding: 1 bytes -} - -// Struct read Coloritem -func ReadColoritem(buf []byte, v *Coloritem) int { - b := 0 - - v.Pixel = Get32(buf[b:]) - b += 4 - - v.Red = Get16(buf[b:]) - b += 2 - - v.Green = Get16(buf[b:]) - b += 2 - - v.Blue = Get16(buf[b:]) - b += 2 - - v.Flags = buf[b] - b += 1 - - b += 1 // padding - - return b -} - -// Struct list read Coloritem -func ReadColoritemList(buf []byte, dest []Coloritem) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Coloritem{} - b += ReadColoritem(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write Coloritem -func (v Coloritem) Bytes() []byte { - buf := make([]byte, 12) - b := 0 - - Put32(buf[b:], v.Pixel) - b += 4 - - Put16(buf[b:], v.Red) - b += 2 - - Put16(buf[b:], v.Green) - b += 2 - - Put16(buf[b:], v.Blue) - b += 2 - - buf[b] = v.Flags - b += 1 - - b += 1 // padding - - return buf -} - -// Write struct list Coloritem -func ColoritemListBytes(buf []byte, list []Coloritem) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'Rgb' struct definition -// Size: 8 -type Rgb struct { - Red uint16 - Green uint16 - Blue uint16 - // padding: 2 bytes -} - -// Struct read Rgb -func ReadRgb(buf []byte, v *Rgb) int { - b := 0 - - v.Red = Get16(buf[b:]) - b += 2 - - v.Green = Get16(buf[b:]) - b += 2 - - v.Blue = Get16(buf[b:]) - b += 2 - - b += 2 // padding - - return b -} - -// Struct list read Rgb -func ReadRgbList(buf []byte, dest []Rgb) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Rgb{} - b += ReadRgb(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write Rgb -func (v Rgb) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put16(buf[b:], v.Red) - b += 2 - - Put16(buf[b:], v.Green) - b += 2 - - Put16(buf[b:], v.Blue) - b += 2 - - b += 2 // padding - - return buf -} - -// Write struct list Rgb -func RgbListBytes(buf []byte, list []Rgb) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'Host' struct definition -// Size: (4 + pad((int(AddressLen) * 1))) -type Host struct { - Family byte - // padding: 1 bytes - AddressLen uint16 - Address []byte // size: pad((int(AddressLen) * 1)) -} - -// Struct read Host -func ReadHost(buf []byte, v *Host) int { - b := 0 - - v.Family = buf[b] - b += 1 - - b += 1 // padding - - v.AddressLen = Get16(buf[b:]) - b += 2 - - v.Address = make([]byte, v.AddressLen) - copy(v.Address[:v.AddressLen], buf[b:]) - b += pad(int(v.AddressLen)) - - return b -} - -// Struct list read Host -func ReadHostList(buf []byte, dest []Host) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Host{} - b += ReadHost(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write Host -func (v Host) Bytes() []byte { - buf := make([]byte, (4 + pad((int(v.AddressLen) * 1)))) - b := 0 - - buf[b] = v.Family - b += 1 - - b += 1 // padding - - Put16(buf[b:], v.AddressLen) - b += 2 - - copy(buf[b:], v.Address[:v.AddressLen]) - b += pad(int(v.AddressLen)) - - return buf -} - -// Write struct list Host -func HostListBytes(buf []byte, list []Host) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size Host -func HostListSize(list []Host) int { - size := 0 - for _, item := range list { - size += (4 + pad((int(item.AddressLen) * 1))) - } - return size -} - -// Union definition ClientMessageDataUnion -// Note that to *create* a Union, you should *never* create -// this struct directly (unless you know what you're doing). -// Instead use one of the following constructors for 'ClientMessageDataUnion': -// NewClientMessageDataUnionData8(Data8 []byte) ClientMessageDataUnion -// NewClientMessageDataUnionData16(Data16 []uint16) ClientMessageDataUnion -// NewClientMessageDataUnionData32(Data32 []uint32) ClientMessageDataUnion -type ClientMessageDataUnion struct { - Data8 []byte // size: 20 - Data16 []uint16 // size: 20 - Data32 []uint32 // size: 20 -} - -// Union constructor for ClientMessageDataUnion for field Data8. -func NewClientMessageDataUnionData8(Data8 []byte) ClientMessageDataUnion { - var b int - buf := make([]byte, 20) - - copy(buf[b:], Data8[:20]) - b += pad(int(20)) - - // Create the Union type - v := ClientMessageDataUnion{} - - // Now copy buf into all fields - - b = 0 // always read the same bytes - v.Data8 = make([]byte, 20) - copy(v.Data8[:20], buf[b:]) - b += pad(int(20)) - - b = 0 // always read the same bytes - v.Data16 = make([]uint16, 10) - for i := 0; i < int(10); i++ { - v.Data16[i] = Get16(buf[b:]) - b += 2 - } - b = pad(b) - - b = 0 // always read the same bytes - v.Data32 = make([]uint32, 5) - for i := 0; i < int(5); i++ { - v.Data32[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -// Union constructor for ClientMessageDataUnion for field Data16. -func NewClientMessageDataUnionData16(Data16 []uint16) ClientMessageDataUnion { - var b int - buf := make([]byte, 20) - - for i := 0; i < int(10); i++ { - Put16(buf[b:], Data16[i]) - b += 2 - } - b = pad(b) - - // Create the Union type - v := ClientMessageDataUnion{} - - // Now copy buf into all fields - - b = 0 // always read the same bytes - v.Data8 = make([]byte, 20) - copy(v.Data8[:20], buf[b:]) - b += pad(int(20)) - - b = 0 // always read the same bytes - v.Data16 = make([]uint16, 10) - for i := 0; i < int(10); i++ { - v.Data16[i] = Get16(buf[b:]) - b += 2 - } - b = pad(b) - - b = 0 // always read the same bytes - v.Data32 = make([]uint32, 5) - for i := 0; i < int(5); i++ { - v.Data32[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -// Union constructor for ClientMessageDataUnion for field Data32. -func NewClientMessageDataUnionData32(Data32 []uint32) ClientMessageDataUnion { - var b int - buf := make([]byte, 20) - - for i := 0; i < int(5); i++ { - Put32(buf[b:], Data32[i]) - b += 4 - } - b = pad(b) - - // Create the Union type - v := ClientMessageDataUnion{} - - // Now copy buf into all fields - - b = 0 // always read the same bytes - v.Data8 = make([]byte, 20) - copy(v.Data8[:20], buf[b:]) - b += pad(int(20)) - - b = 0 // always read the same bytes - v.Data16 = make([]uint16, 10) - for i := 0; i < int(10); i++ { - v.Data16[i] = Get16(buf[b:]) - b += 2 - } - b = pad(b) - - b = 0 // always read the same bytes - v.Data32 = make([]uint32, 5) - for i := 0; i < int(5); i++ { - v.Data32[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -// Union read ClientMessageDataUnion -func ReadClientMessageDataUnion(buf []byte, v *ClientMessageDataUnion) int { - var b int - - b = 0 // re-read the same bytes - v.Data8 = make([]byte, 20) - copy(v.Data8[:20], buf[b:]) - b += pad(int(20)) - - b = 0 // re-read the same bytes - v.Data16 = make([]uint16, 10) - for i := 0; i < int(10); i++ { - v.Data16[i] = Get16(buf[b:]) - b += 2 - } - b = pad(b) - - b = 0 // re-read the same bytes - v.Data32 = make([]uint32, 5) - for i := 0; i < int(5); i++ { - v.Data32[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return 20 -} - -// Union list read ClientMessageDataUnion -func ReadClientMessageDataUnionList(buf []byte, dest []ClientMessageDataUnion) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = ClientMessageDataUnion{} - b += ReadClientMessageDataUnion(buf[b:], &dest[i]) - } - return pad(b) -} - -// Union write ClientMessageDataUnion -// Each field in a union must contain the same data. -// So simply pick the first field and write that to the wire. -func (v ClientMessageDataUnion) Bytes() []byte { - buf := make([]byte, 20) - b := 0 - - copy(buf[b:], v.Data8[:20]) - b += pad(int(20)) - return buf -} - -// Union list write ClientMessageDataUnion -func ClientMessageDataUnionListBytes(buf []byte, list []ClientMessageDataUnion) int { - b := 0 - var unionBytes []byte - for _, item := range list { - unionBytes = item.Bytes() - copy(buf[b:], unionBytes) - b += pad(len(unionBytes)) - } - return b -} - -// Event definition KeyPress (2) -// Size: 32 - -const KeyPress = 2 - -type KeyPressEvent struct { - Sequence uint16 - Detail Keycode - Time Timestamp - Root Window - Event Window - Child Window - RootX int16 - RootY int16 - EventX int16 - EventY int16 - State uint16 - SameScreen bool - // padding: 1 bytes -} - -// Event read KeyPress -func NewKeyPressEvent(buf []byte) Event { - v := KeyPressEvent{} - b := 1 // don't read event number - - v.Detail = Keycode(buf[b]) - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Time = Timestamp(Get32(buf[b:])) - b += 4 - - v.Root = Window(Get32(buf[b:])) - b += 4 - - v.Event = Window(Get32(buf[b:])) - b += 4 - - v.Child = Window(Get32(buf[b:])) - b += 4 - - v.RootX = int16(Get16(buf[b:])) - b += 2 - - v.RootY = int16(Get16(buf[b:])) - b += 2 - - v.EventX = int16(Get16(buf[b:])) - b += 2 - - v.EventY = int16(Get16(buf[b:])) - b += 2 - - v.State = Get16(buf[b:]) - b += 2 - - if buf[b] == 1 { - v.SameScreen = true - } else { - v.SameScreen = false - } - b += 1 - - b += 1 // padding - - return v -} - -// Event write KeyPress -func (v KeyPressEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 2 - b += 1 - - buf[b] = byte(v.Detail) - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Time)) - b += 4 - - Put32(buf[b:], uint32(v.Root)) - b += 4 - - Put32(buf[b:], uint32(v.Event)) - b += 4 - - Put32(buf[b:], uint32(v.Child)) - b += 4 - - Put16(buf[b:], uint16(v.RootX)) - b += 2 - - Put16(buf[b:], uint16(v.RootY)) - b += 2 - - Put16(buf[b:], uint16(v.EventX)) - b += 2 - - Put16(buf[b:], uint16(v.EventY)) - b += 2 - - Put16(buf[b:], v.State) - b += 2 - - if v.SameScreen { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 1 // padding - - return buf -} - -func (v KeyPressEvent) ImplementsEvent() {} - -func (v KeyPressEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v KeyPressEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, sprintf("SameScreen: %t", v.SameScreen)) - return "KeyPress {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[2] = NewKeyPressEvent -} - -// Event definition ButtonPress (4) -// Size: 32 - -const ButtonPress = 4 - -type ButtonPressEvent struct { - Sequence uint16 - Detail Button - Time Timestamp - Root Window - Event Window - Child Window - RootX int16 - RootY int16 - EventX int16 - EventY int16 - State uint16 - SameScreen bool - // padding: 1 bytes -} - -// Event read ButtonPress -func NewButtonPressEvent(buf []byte) Event { - v := ButtonPressEvent{} - b := 1 // don't read event number - - v.Detail = Button(buf[b]) - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Time = Timestamp(Get32(buf[b:])) - b += 4 - - v.Root = Window(Get32(buf[b:])) - b += 4 - - v.Event = Window(Get32(buf[b:])) - b += 4 - - v.Child = Window(Get32(buf[b:])) - b += 4 - - v.RootX = int16(Get16(buf[b:])) - b += 2 - - v.RootY = int16(Get16(buf[b:])) - b += 2 - - v.EventX = int16(Get16(buf[b:])) - b += 2 - - v.EventY = int16(Get16(buf[b:])) - b += 2 - - v.State = Get16(buf[b:]) - b += 2 - - if buf[b] == 1 { - v.SameScreen = true - } else { - v.SameScreen = false - } - b += 1 - - b += 1 // padding - - return v -} - -// Event write ButtonPress -func (v ButtonPressEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 4 - b += 1 - - buf[b] = byte(v.Detail) - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Time)) - b += 4 - - Put32(buf[b:], uint32(v.Root)) - b += 4 - - Put32(buf[b:], uint32(v.Event)) - b += 4 - - Put32(buf[b:], uint32(v.Child)) - b += 4 - - Put16(buf[b:], uint16(v.RootX)) - b += 2 - - Put16(buf[b:], uint16(v.RootY)) - b += 2 - - Put16(buf[b:], uint16(v.EventX)) - b += 2 - - Put16(buf[b:], uint16(v.EventY)) - b += 2 - - Put16(buf[b:], v.State) - b += 2 - - if v.SameScreen { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 1 // padding - - return buf -} - -func (v ButtonPressEvent) ImplementsEvent() {} - -func (v ButtonPressEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v ButtonPressEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, sprintf("SameScreen: %t", v.SameScreen)) - return "ButtonPress {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[4] = NewButtonPressEvent -} - -// Event definition MotionNotify (6) -// Size: 32 - -const MotionNotify = 6 - -type MotionNotifyEvent struct { - Sequence uint16 - Detail byte - Time Timestamp - Root Window - Event Window - Child Window - RootX int16 - RootY int16 - EventX int16 - EventY int16 - State uint16 - SameScreen bool - // padding: 1 bytes -} - -// Event read MotionNotify -func NewMotionNotifyEvent(buf []byte) Event { - v := MotionNotifyEvent{} - b := 1 // don't read event number - - v.Detail = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Time = Timestamp(Get32(buf[b:])) - b += 4 - - v.Root = Window(Get32(buf[b:])) - b += 4 - - v.Event = Window(Get32(buf[b:])) - b += 4 - - v.Child = Window(Get32(buf[b:])) - b += 4 - - v.RootX = int16(Get16(buf[b:])) - b += 2 - - v.RootY = int16(Get16(buf[b:])) - b += 2 - - v.EventX = int16(Get16(buf[b:])) - b += 2 - - v.EventY = int16(Get16(buf[b:])) - b += 2 - - v.State = Get16(buf[b:]) - b += 2 - - if buf[b] == 1 { - v.SameScreen = true - } else { - v.SameScreen = false - } - b += 1 - - b += 1 // padding - - return v -} - -// Event write MotionNotify -func (v MotionNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 6 - b += 1 - - buf[b] = v.Detail - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Time)) - b += 4 - - Put32(buf[b:], uint32(v.Root)) - b += 4 - - Put32(buf[b:], uint32(v.Event)) - b += 4 - - Put32(buf[b:], uint32(v.Child)) - b += 4 - - Put16(buf[b:], uint16(v.RootX)) - b += 2 - - Put16(buf[b:], uint16(v.RootY)) - b += 2 - - Put16(buf[b:], uint16(v.EventX)) - b += 2 - - Put16(buf[b:], uint16(v.EventY)) - b += 2 - - Put16(buf[b:], v.State) - b += 2 - - if v.SameScreen { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 1 // padding - - return buf -} - -func (v MotionNotifyEvent) ImplementsEvent() {} - -func (v MotionNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v MotionNotifyEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, sprintf("SameScreen: %t", v.SameScreen)) - return "MotionNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[6] = NewMotionNotifyEvent -} - -// Event definition EnterNotify (7) -// Size: 32 - -const EnterNotify = 7 - -type EnterNotifyEvent struct { - Sequence uint16 - Detail byte - Time Timestamp - Root Window - Event Window - Child Window - RootX int16 - RootY int16 - EventX int16 - EventY int16 - State uint16 - Mode byte - SameScreenFocus byte -} - -// Event read EnterNotify -func NewEnterNotifyEvent(buf []byte) Event { - v := EnterNotifyEvent{} - b := 1 // don't read event number - - v.Detail = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Time = Timestamp(Get32(buf[b:])) - b += 4 - - v.Root = Window(Get32(buf[b:])) - b += 4 - - v.Event = Window(Get32(buf[b:])) - b += 4 - - v.Child = Window(Get32(buf[b:])) - b += 4 - - v.RootX = int16(Get16(buf[b:])) - b += 2 - - v.RootY = int16(Get16(buf[b:])) - b += 2 - - v.EventX = int16(Get16(buf[b:])) - b += 2 - - v.EventY = int16(Get16(buf[b:])) - b += 2 - - v.State = Get16(buf[b:]) - b += 2 - - v.Mode = buf[b] - b += 1 - - v.SameScreenFocus = buf[b] - b += 1 - - return v -} - -// Event write EnterNotify -func (v EnterNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 7 - b += 1 - - buf[b] = v.Detail - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Time)) - b += 4 - - Put32(buf[b:], uint32(v.Root)) - b += 4 - - Put32(buf[b:], uint32(v.Event)) - b += 4 - - Put32(buf[b:], uint32(v.Child)) - b += 4 - - Put16(buf[b:], uint16(v.RootX)) - b += 2 - - Put16(buf[b:], uint16(v.RootY)) - b += 2 - - Put16(buf[b:], uint16(v.EventX)) - b += 2 - - Put16(buf[b:], uint16(v.EventY)) - b += 2 - - Put16(buf[b:], v.State) - b += 2 - - buf[b] = v.Mode - b += 1 - - buf[b] = v.SameScreenFocus - b += 1 - - return buf -} - -func (v EnterNotifyEvent) ImplementsEvent() {} - -func (v EnterNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v EnterNotifyEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, sprintf("Mode: %d", v.Mode)) - fieldVals = append(fieldVals, sprintf("SameScreenFocus: %d", v.SameScreenFocus)) - return "EnterNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[7] = NewEnterNotifyEvent -} - -// Event definition FocusIn (9) -// Size: 32 - -const FocusIn = 9 - -type FocusInEvent struct { - Sequence uint16 - Detail byte - Event Window - Mode byte - // padding: 3 bytes -} - -// Event read FocusIn -func NewFocusInEvent(buf []byte) Event { - v := FocusInEvent{} - b := 1 // don't read event number - - v.Detail = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Event = Window(Get32(buf[b:])) - b += 4 - - v.Mode = buf[b] - b += 1 - - b += 3 // padding - - return v -} - -// Event write FocusIn -func (v FocusInEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 9 - b += 1 - - buf[b] = v.Detail - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Event)) - b += 4 - - buf[b] = v.Mode - b += 1 - - b += 3 // padding - - return buf -} - -func (v FocusInEvent) ImplementsEvent() {} - -func (v FocusInEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v FocusInEvent) String() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Mode: %d", v.Mode)) - return "FocusIn {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[9] = NewFocusInEvent -} - -// Event definition KeymapNotify (11) -// Size: 32 - -const KeymapNotify = 11 - -type KeymapNotifyEvent struct { - Keys []byte // size: 32 -} - -// Event read KeymapNotify -func NewKeymapNotifyEvent(buf []byte) Event { - v := KeymapNotifyEvent{} - b := 1 // don't read event number - - v.Keys = make([]byte, 31) - copy(v.Keys[:31], buf[b:]) - b += pad(int(31)) - - return v -} - -// Event write KeymapNotify -func (v KeymapNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 11 - b += 1 - - copy(buf[b:], v.Keys[:31]) - b += pad(int(31)) - - return buf -} - -func (v KeymapNotifyEvent) ImplementsEvent() {} - -func (v KeymapNotifyEvent) SequenceId() uint16 { - return uint16(0) -} - -func (v KeymapNotifyEvent) String() string { - fieldVals := make([]string, 0, 1) - return "KeymapNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[11] = NewKeymapNotifyEvent -} - -// Event definition Expose (12) -// Size: 32 - -const Expose = 12 - -type ExposeEvent struct { - Sequence uint16 - // padding: 1 bytes - Window Window - X uint16 - Y uint16 - Width uint16 - Height uint16 - Count uint16 - // padding: 2 bytes -} - -// Event read Expose -func NewExposeEvent(buf []byte) Event { - v := ExposeEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - v.X = Get16(buf[b:]) - b += 2 - - v.Y = Get16(buf[b:]) - b += 2 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - v.Count = Get16(buf[b:]) - b += 2 - - b += 2 // padding - - return v -} - -// Event write Expose -func (v ExposeEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 12 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - Put16(buf[b:], v.X) - b += 2 - - Put16(buf[b:], v.Y) - b += 2 - - Put16(buf[b:], v.Width) - b += 2 - - Put16(buf[b:], v.Height) - b += 2 - - Put16(buf[b:], v.Count) - b += 2 - - b += 2 // padding - - return buf -} - -func (v ExposeEvent) ImplementsEvent() {} - -func (v ExposeEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v ExposeEvent) String() string { - fieldVals := make([]string, 0, 8) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, sprintf("X: %d", v.X)) - fieldVals = append(fieldVals, sprintf("Y: %d", v.Y)) - fieldVals = append(fieldVals, sprintf("Width: %d", v.Width)) - fieldVals = append(fieldVals, sprintf("Height: %d", v.Height)) - fieldVals = append(fieldVals, sprintf("Count: %d", v.Count)) - return "Expose {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[12] = NewExposeEvent -} - -// Event definition GraphicsExposure (13) -// Size: 32 - -const GraphicsExposure = 13 - -type GraphicsExposureEvent struct { - Sequence uint16 - // padding: 1 bytes - Drawable Drawable - X uint16 - Y uint16 - Width uint16 - Height uint16 - MinorOpcode uint16 - Count uint16 - MajorOpcode byte - // padding: 3 bytes -} - -// Event read GraphicsExposure -func NewGraphicsExposureEvent(buf []byte) Event { - v := GraphicsExposureEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Drawable = Drawable(Get32(buf[b:])) - b += 4 - - v.X = Get16(buf[b:]) - b += 2 - - v.Y = Get16(buf[b:]) - b += 2 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - v.MinorOpcode = Get16(buf[b:]) - b += 2 - - v.Count = Get16(buf[b:]) - b += 2 - - v.MajorOpcode = buf[b] - b += 1 - - b += 3 // padding - - return v -} - -// Event write GraphicsExposure -func (v GraphicsExposureEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 13 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Drawable)) - b += 4 - - Put16(buf[b:], v.X) - b += 2 - - Put16(buf[b:], v.Y) - b += 2 - - Put16(buf[b:], v.Width) - b += 2 - - Put16(buf[b:], v.Height) - b += 2 - - Put16(buf[b:], v.MinorOpcode) - b += 2 - - Put16(buf[b:], v.Count) - b += 2 - - buf[b] = v.MajorOpcode - b += 1 - - b += 3 // padding - - return buf -} - -func (v GraphicsExposureEvent) ImplementsEvent() {} - -func (v GraphicsExposureEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v GraphicsExposureEvent) String() string { - fieldVals := make([]string, 0, 10) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Drawable: %d", v.Drawable)) - fieldVals = append(fieldVals, sprintf("X: %d", v.X)) - fieldVals = append(fieldVals, sprintf("Y: %d", v.Y)) - fieldVals = append(fieldVals, sprintf("Width: %d", v.Width)) - fieldVals = append(fieldVals, sprintf("Height: %d", v.Height)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", v.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("Count: %d", v.Count)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", v.MajorOpcode)) - return "GraphicsExposure {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[13] = NewGraphicsExposureEvent -} - -// Event definition NoExposure (14) -// Size: 32 - -const NoExposure = 14 - -type NoExposureEvent struct { - Sequence uint16 - // padding: 1 bytes - Drawable Drawable - MinorOpcode uint16 - MajorOpcode byte - // padding: 1 bytes -} - -// Event read NoExposure -func NewNoExposureEvent(buf []byte) Event { - v := NoExposureEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Drawable = Drawable(Get32(buf[b:])) - b += 4 - - v.MinorOpcode = Get16(buf[b:]) - b += 2 - - v.MajorOpcode = buf[b] - b += 1 - - b += 1 // padding - - return v -} - -// Event write NoExposure -func (v NoExposureEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 14 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Drawable)) - b += 4 - - Put16(buf[b:], v.MinorOpcode) - b += 2 - - buf[b] = v.MajorOpcode - b += 1 - - b += 1 // padding - - return buf -} - -func (v NoExposureEvent) ImplementsEvent() {} - -func (v NoExposureEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v NoExposureEvent) String() string { - fieldVals := make([]string, 0, 5) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Drawable: %d", v.Drawable)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", v.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", v.MajorOpcode)) - return "NoExposure {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[14] = NewNoExposureEvent -} - -// Event definition VisibilityNotify (15) -// Size: 32 - -const VisibilityNotify = 15 - -type VisibilityNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Window Window - State byte - // padding: 3 bytes -} - -// Event read VisibilityNotify -func NewVisibilityNotifyEvent(buf []byte) Event { - v := VisibilityNotifyEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - v.State = buf[b] - b += 1 - - b += 3 // padding - - return v -} - -// Event write VisibilityNotify -func (v VisibilityNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 15 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - buf[b] = v.State - b += 1 - - b += 3 // padding - - return buf -} - -func (v VisibilityNotifyEvent) ImplementsEvent() {} - -func (v VisibilityNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v VisibilityNotifyEvent) String() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, sprintf("State: %d", v.State)) - return "VisibilityNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[15] = NewVisibilityNotifyEvent -} - -// Event definition CreateNotify (16) -// Size: 32 - -const CreateNotify = 16 - -type CreateNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Parent Window - Window Window - X int16 - Y int16 - Width uint16 - Height uint16 - BorderWidth uint16 - OverrideRedirect bool - // padding: 1 bytes -} - -// Event read CreateNotify -func NewCreateNotifyEvent(buf []byte) Event { - v := CreateNotifyEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Parent = Window(Get32(buf[b:])) - b += 4 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - v.X = int16(Get16(buf[b:])) - b += 2 - - v.Y = int16(Get16(buf[b:])) - b += 2 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - v.BorderWidth = Get16(buf[b:]) - b += 2 - - if buf[b] == 1 { - v.OverrideRedirect = true - } else { - v.OverrideRedirect = false - } - b += 1 - - b += 1 // padding - - return v -} - -// Event write CreateNotify -func (v CreateNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 16 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Parent)) - b += 4 - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - Put16(buf[b:], uint16(v.X)) - b += 2 - - Put16(buf[b:], uint16(v.Y)) - b += 2 - - Put16(buf[b:], v.Width) - b += 2 - - Put16(buf[b:], v.Height) - b += 2 - - Put16(buf[b:], v.BorderWidth) - b += 2 - - if v.OverrideRedirect { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 1 // padding - - return buf -} - -func (v CreateNotifyEvent) ImplementsEvent() {} - -func (v CreateNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v CreateNotifyEvent) String() string { - fieldVals := make([]string, 0, 10) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Parent: %d", v.Parent)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, sprintf("X: %d", v.X)) - fieldVals = append(fieldVals, sprintf("Y: %d", v.Y)) - fieldVals = append(fieldVals, sprintf("Width: %d", v.Width)) - fieldVals = append(fieldVals, sprintf("Height: %d", v.Height)) - fieldVals = append(fieldVals, sprintf("BorderWidth: %d", v.BorderWidth)) - fieldVals = append(fieldVals, sprintf("OverrideRedirect: %t", v.OverrideRedirect)) - return "CreateNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[16] = NewCreateNotifyEvent -} - -// Event definition DestroyNotify (17) -// Size: 32 - -const DestroyNotify = 17 - -type DestroyNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Event Window - Window Window -} - -// Event read DestroyNotify -func NewDestroyNotifyEvent(buf []byte) Event { - v := DestroyNotifyEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Event = Window(Get32(buf[b:])) - b += 4 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - return v -} - -// Event write DestroyNotify -func (v DestroyNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 17 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Event)) - b += 4 - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - return buf -} - -func (v DestroyNotifyEvent) ImplementsEvent() {} - -func (v DestroyNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v DestroyNotifyEvent) String() string { - fieldVals := make([]string, 0, 3) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - return "DestroyNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[17] = NewDestroyNotifyEvent -} - -// Event definition UnmapNotify (18) -// Size: 32 - -const UnmapNotify = 18 - -type UnmapNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Event Window - Window Window - FromConfigure bool - // padding: 3 bytes -} - -// Event read UnmapNotify -func NewUnmapNotifyEvent(buf []byte) Event { - v := UnmapNotifyEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Event = Window(Get32(buf[b:])) - b += 4 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - if buf[b] == 1 { - v.FromConfigure = true - } else { - v.FromConfigure = false - } - b += 1 - - b += 3 // padding - - return v -} - -// Event write UnmapNotify -func (v UnmapNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 18 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Event)) - b += 4 - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - if v.FromConfigure { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 3 // padding - - return buf -} - -func (v UnmapNotifyEvent) ImplementsEvent() {} - -func (v UnmapNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v UnmapNotifyEvent) String() string { - fieldVals := make([]string, 0, 5) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, sprintf("FromConfigure: %t", v.FromConfigure)) - return "UnmapNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[18] = NewUnmapNotifyEvent -} - -// Event definition MapNotify (19) -// Size: 32 - -const MapNotify = 19 - -type MapNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Event Window - Window Window - OverrideRedirect bool - // padding: 3 bytes -} - -// Event read MapNotify -func NewMapNotifyEvent(buf []byte) Event { - v := MapNotifyEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Event = Window(Get32(buf[b:])) - b += 4 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - if buf[b] == 1 { - v.OverrideRedirect = true - } else { - v.OverrideRedirect = false - } - b += 1 - - b += 3 // padding - - return v -} - -// Event write MapNotify -func (v MapNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 19 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Event)) - b += 4 - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - if v.OverrideRedirect { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 3 // padding - - return buf -} - -func (v MapNotifyEvent) ImplementsEvent() {} - -func (v MapNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v MapNotifyEvent) String() string { - fieldVals := make([]string, 0, 5) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, sprintf("OverrideRedirect: %t", v.OverrideRedirect)) - return "MapNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[19] = NewMapNotifyEvent -} - -// Event definition MapRequest (20) -// Size: 32 - -const MapRequest = 20 - -type MapRequestEvent struct { - Sequence uint16 - // padding: 1 bytes - Parent Window - Window Window -} - -// Event read MapRequest -func NewMapRequestEvent(buf []byte) Event { - v := MapRequestEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Parent = Window(Get32(buf[b:])) - b += 4 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - return v -} - -// Event write MapRequest -func (v MapRequestEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 20 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Parent)) - b += 4 - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - return buf -} - -func (v MapRequestEvent) ImplementsEvent() {} - -func (v MapRequestEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v MapRequestEvent) String() string { - fieldVals := make([]string, 0, 3) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Parent: %d", v.Parent)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - return "MapRequest {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[20] = NewMapRequestEvent -} - -// Event definition ReparentNotify (21) -// Size: 32 - -const ReparentNotify = 21 - -type ReparentNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Event Window - Window Window - Parent Window - X int16 - Y int16 - OverrideRedirect bool - // padding: 3 bytes -} - -// Event read ReparentNotify -func NewReparentNotifyEvent(buf []byte) Event { - v := ReparentNotifyEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Event = Window(Get32(buf[b:])) - b += 4 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - v.Parent = Window(Get32(buf[b:])) - b += 4 - - v.X = int16(Get16(buf[b:])) - b += 2 - - v.Y = int16(Get16(buf[b:])) - b += 2 - - if buf[b] == 1 { - v.OverrideRedirect = true - } else { - v.OverrideRedirect = false - } - b += 1 - - b += 3 // padding - - return v -} - -// Event write ReparentNotify -func (v ReparentNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 21 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Event)) - b += 4 - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - Put32(buf[b:], uint32(v.Parent)) - b += 4 - - Put16(buf[b:], uint16(v.X)) - b += 2 - - Put16(buf[b:], uint16(v.Y)) - b += 2 - - if v.OverrideRedirect { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 3 // padding - - return buf -} - -func (v ReparentNotifyEvent) ImplementsEvent() {} - -func (v ReparentNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v ReparentNotifyEvent) String() string { - fieldVals := make([]string, 0, 8) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, sprintf("Parent: %d", v.Parent)) - fieldVals = append(fieldVals, sprintf("X: %d", v.X)) - fieldVals = append(fieldVals, sprintf("Y: %d", v.Y)) - fieldVals = append(fieldVals, sprintf("OverrideRedirect: %t", v.OverrideRedirect)) - return "ReparentNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[21] = NewReparentNotifyEvent -} - -// Event definition ConfigureNotify (22) -// Size: 32 - -const ConfigureNotify = 22 - -type ConfigureNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Event Window - Window Window - AboveSibling Window - X int16 - Y int16 - Width uint16 - Height uint16 - BorderWidth uint16 - OverrideRedirect bool - // padding: 1 bytes -} - -// Event read ConfigureNotify -func NewConfigureNotifyEvent(buf []byte) Event { - v := ConfigureNotifyEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Event = Window(Get32(buf[b:])) - b += 4 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - v.AboveSibling = Window(Get32(buf[b:])) - b += 4 - - v.X = int16(Get16(buf[b:])) - b += 2 - - v.Y = int16(Get16(buf[b:])) - b += 2 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - v.BorderWidth = Get16(buf[b:]) - b += 2 - - if buf[b] == 1 { - v.OverrideRedirect = true - } else { - v.OverrideRedirect = false - } - b += 1 - - b += 1 // padding - - return v -} - -// Event write ConfigureNotify -func (v ConfigureNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 22 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Event)) - b += 4 - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - Put32(buf[b:], uint32(v.AboveSibling)) - b += 4 - - Put16(buf[b:], uint16(v.X)) - b += 2 - - Put16(buf[b:], uint16(v.Y)) - b += 2 - - Put16(buf[b:], v.Width) - b += 2 - - Put16(buf[b:], v.Height) - b += 2 - - Put16(buf[b:], v.BorderWidth) - b += 2 - - if v.OverrideRedirect { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 1 // padding - - return buf -} - -func (v ConfigureNotifyEvent) ImplementsEvent() {} - -func (v ConfigureNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v ConfigureNotifyEvent) String() string { - fieldVals := make([]string, 0, 11) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, sprintf("AboveSibling: %d", v.AboveSibling)) - fieldVals = append(fieldVals, sprintf("X: %d", v.X)) - fieldVals = append(fieldVals, sprintf("Y: %d", v.Y)) - fieldVals = append(fieldVals, sprintf("Width: %d", v.Width)) - fieldVals = append(fieldVals, sprintf("Height: %d", v.Height)) - fieldVals = append(fieldVals, sprintf("BorderWidth: %d", v.BorderWidth)) - fieldVals = append(fieldVals, sprintf("OverrideRedirect: %t", v.OverrideRedirect)) - return "ConfigureNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[22] = NewConfigureNotifyEvent -} - -// Event definition ConfigureRequest (23) -// Size: 32 - -const ConfigureRequest = 23 - -type ConfigureRequestEvent struct { - Sequence uint16 - StackMode byte - Parent Window - Window Window - Sibling Window - X int16 - Y int16 - Width uint16 - Height uint16 - BorderWidth uint16 - ValueMask uint16 -} - -// Event read ConfigureRequest -func NewConfigureRequestEvent(buf []byte) Event { - v := ConfigureRequestEvent{} - b := 1 // don't read event number - - v.StackMode = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Parent = Window(Get32(buf[b:])) - b += 4 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - v.Sibling = Window(Get32(buf[b:])) - b += 4 - - v.X = int16(Get16(buf[b:])) - b += 2 - - v.Y = int16(Get16(buf[b:])) - b += 2 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - v.BorderWidth = Get16(buf[b:]) - b += 2 - - v.ValueMask = Get16(buf[b:]) - b += 2 - - return v -} - -// Event write ConfigureRequest -func (v ConfigureRequestEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 23 - b += 1 - - buf[b] = v.StackMode - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Parent)) - b += 4 - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - Put32(buf[b:], uint32(v.Sibling)) - b += 4 - - Put16(buf[b:], uint16(v.X)) - b += 2 - - Put16(buf[b:], uint16(v.Y)) - b += 2 - - Put16(buf[b:], v.Width) - b += 2 - - Put16(buf[b:], v.Height) - b += 2 - - Put16(buf[b:], v.BorderWidth) - b += 2 - - Put16(buf[b:], v.ValueMask) - b += 2 - - return buf -} - -func (v ConfigureRequestEvent) ImplementsEvent() {} - -func (v ConfigureRequestEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v ConfigureRequestEvent) String() string { - fieldVals := make([]string, 0, 10) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("StackMode: %d", v.StackMode)) - fieldVals = append(fieldVals, sprintf("Parent: %d", v.Parent)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, sprintf("Sibling: %d", v.Sibling)) - fieldVals = append(fieldVals, sprintf("X: %d", v.X)) - fieldVals = append(fieldVals, sprintf("Y: %d", v.Y)) - fieldVals = append(fieldVals, sprintf("Width: %d", v.Width)) - fieldVals = append(fieldVals, sprintf("Height: %d", v.Height)) - fieldVals = append(fieldVals, sprintf("BorderWidth: %d", v.BorderWidth)) - fieldVals = append(fieldVals, sprintf("ValueMask: %d", v.ValueMask)) - return "ConfigureRequest {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[23] = NewConfigureRequestEvent -} - -// Event definition GravityNotify (24) -// Size: 32 - -const GravityNotify = 24 - -type GravityNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Event Window - Window Window - X int16 - Y int16 -} - -// Event read GravityNotify -func NewGravityNotifyEvent(buf []byte) Event { - v := GravityNotifyEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Event = Window(Get32(buf[b:])) - b += 4 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - v.X = int16(Get16(buf[b:])) - b += 2 - - v.Y = int16(Get16(buf[b:])) - b += 2 - - return v -} - -// Event write GravityNotify -func (v GravityNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 24 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Event)) - b += 4 - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - Put16(buf[b:], uint16(v.X)) - b += 2 - - Put16(buf[b:], uint16(v.Y)) - b += 2 - - return buf -} - -func (v GravityNotifyEvent) ImplementsEvent() {} - -func (v GravityNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v GravityNotifyEvent) String() string { - fieldVals := make([]string, 0, 5) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, sprintf("X: %d", v.X)) - fieldVals = append(fieldVals, sprintf("Y: %d", v.Y)) - return "GravityNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[24] = NewGravityNotifyEvent -} - -// Event definition ResizeRequest (25) -// Size: 32 - -const ResizeRequest = 25 - -type ResizeRequestEvent struct { - Sequence uint16 - // padding: 1 bytes - Window Window - Width uint16 - Height uint16 -} - -// Event read ResizeRequest -func NewResizeRequestEvent(buf []byte) Event { - v := ResizeRequestEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - return v -} - -// Event write ResizeRequest -func (v ResizeRequestEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 25 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - Put16(buf[b:], v.Width) - b += 2 - - Put16(buf[b:], v.Height) - b += 2 - - return buf -} - -func (v ResizeRequestEvent) ImplementsEvent() {} - -func (v ResizeRequestEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v ResizeRequestEvent) String() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, sprintf("Width: %d", v.Width)) - fieldVals = append(fieldVals, sprintf("Height: %d", v.Height)) - return "ResizeRequest {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[25] = NewResizeRequestEvent -} - -// Event definition CirculateNotify (26) -// Size: 32 - -const CirculateNotify = 26 - -type CirculateNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Event Window - Window Window - // padding: 4 bytes - Place byte - // padding: 3 bytes -} - -// Event read CirculateNotify -func NewCirculateNotifyEvent(buf []byte) Event { - v := CirculateNotifyEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Event = Window(Get32(buf[b:])) - b += 4 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - b += 4 // padding - - v.Place = buf[b] - b += 1 - - b += 3 // padding - - return v -} - -// Event write CirculateNotify -func (v CirculateNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 26 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Event)) - b += 4 - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - b += 4 // padding - - buf[b] = v.Place - b += 1 - - b += 3 // padding - - return buf -} - -func (v CirculateNotifyEvent) ImplementsEvent() {} - -func (v CirculateNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v CirculateNotifyEvent) String() string { - fieldVals := make([]string, 0, 6) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, sprintf("Place: %d", v.Place)) - return "CirculateNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[26] = NewCirculateNotifyEvent -} - -// Event definition PropertyNotify (28) -// Size: 32 - -const PropertyNotify = 28 - -type PropertyNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Window Window - Atom Atom - Time Timestamp - State byte - // padding: 3 bytes -} - -// Event read PropertyNotify -func NewPropertyNotifyEvent(buf []byte) Event { - v := PropertyNotifyEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - v.Atom = Atom(Get32(buf[b:])) - b += 4 - - v.Time = Timestamp(Get32(buf[b:])) - b += 4 - - v.State = buf[b] - b += 1 - - b += 3 // padding - - return v -} - -// Event write PropertyNotify -func (v PropertyNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 28 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - Put32(buf[b:], uint32(v.Atom)) - b += 4 - - Put32(buf[b:], uint32(v.Time)) - b += 4 - - buf[b] = v.State - b += 1 - - b += 3 // padding - - return buf -} - -func (v PropertyNotifyEvent) ImplementsEvent() {} - -func (v PropertyNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v PropertyNotifyEvent) String() string { - fieldVals := make([]string, 0, 6) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, sprintf("Atom: %d", v.Atom)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("State: %d", v.State)) - return "PropertyNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[28] = NewPropertyNotifyEvent -} - -// Event definition SelectionClear (29) -// Size: 32 - -const SelectionClear = 29 - -type SelectionClearEvent struct { - Sequence uint16 - // padding: 1 bytes - Time Timestamp - Owner Window - Selection Atom -} - -// Event read SelectionClear -func NewSelectionClearEvent(buf []byte) Event { - v := SelectionClearEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Time = Timestamp(Get32(buf[b:])) - b += 4 - - v.Owner = Window(Get32(buf[b:])) - b += 4 - - v.Selection = Atom(Get32(buf[b:])) - b += 4 - - return v -} - -// Event write SelectionClear -func (v SelectionClearEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 29 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Time)) - b += 4 - - Put32(buf[b:], uint32(v.Owner)) - b += 4 - - Put32(buf[b:], uint32(v.Selection)) - b += 4 - - return buf -} - -func (v SelectionClearEvent) ImplementsEvent() {} - -func (v SelectionClearEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v SelectionClearEvent) String() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Owner: %d", v.Owner)) - fieldVals = append(fieldVals, sprintf("Selection: %d", v.Selection)) - return "SelectionClear {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[29] = NewSelectionClearEvent -} - -// Event definition SelectionRequest (30) -// Size: 32 - -const SelectionRequest = 30 - -type SelectionRequestEvent struct { - Sequence uint16 - // padding: 1 bytes - Time Timestamp - Owner Window - Requestor Window - Selection Atom - Target Atom - Property Atom -} - -// Event read SelectionRequest -func NewSelectionRequestEvent(buf []byte) Event { - v := SelectionRequestEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Time = Timestamp(Get32(buf[b:])) - b += 4 - - v.Owner = Window(Get32(buf[b:])) - b += 4 - - v.Requestor = Window(Get32(buf[b:])) - b += 4 - - v.Selection = Atom(Get32(buf[b:])) - b += 4 - - v.Target = Atom(Get32(buf[b:])) - b += 4 - - v.Property = Atom(Get32(buf[b:])) - b += 4 - - return v -} - -// Event write SelectionRequest -func (v SelectionRequestEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 30 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Time)) - b += 4 - - Put32(buf[b:], uint32(v.Owner)) - b += 4 - - Put32(buf[b:], uint32(v.Requestor)) - b += 4 - - Put32(buf[b:], uint32(v.Selection)) - b += 4 - - Put32(buf[b:], uint32(v.Target)) - b += 4 - - Put32(buf[b:], uint32(v.Property)) - b += 4 - - return buf -} - -func (v SelectionRequestEvent) ImplementsEvent() {} - -func (v SelectionRequestEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v SelectionRequestEvent) String() string { - fieldVals := make([]string, 0, 7) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Owner: %d", v.Owner)) - fieldVals = append(fieldVals, sprintf("Requestor: %d", v.Requestor)) - fieldVals = append(fieldVals, sprintf("Selection: %d", v.Selection)) - fieldVals = append(fieldVals, sprintf("Target: %d", v.Target)) - fieldVals = append(fieldVals, sprintf("Property: %d", v.Property)) - return "SelectionRequest {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[30] = NewSelectionRequestEvent -} - -// Event definition SelectionNotify (31) -// Size: 32 - -const SelectionNotify = 31 - -type SelectionNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Time Timestamp - Requestor Window - Selection Atom - Target Atom - Property Atom -} - -// Event read SelectionNotify -func NewSelectionNotifyEvent(buf []byte) Event { - v := SelectionNotifyEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Time = Timestamp(Get32(buf[b:])) - b += 4 - - v.Requestor = Window(Get32(buf[b:])) - b += 4 - - v.Selection = Atom(Get32(buf[b:])) - b += 4 - - v.Target = Atom(Get32(buf[b:])) - b += 4 - - v.Property = Atom(Get32(buf[b:])) - b += 4 - - return v -} - -// Event write SelectionNotify -func (v SelectionNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 31 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Time)) - b += 4 - - Put32(buf[b:], uint32(v.Requestor)) - b += 4 - - Put32(buf[b:], uint32(v.Selection)) - b += 4 - - Put32(buf[b:], uint32(v.Target)) - b += 4 - - Put32(buf[b:], uint32(v.Property)) - b += 4 - - return buf -} - -func (v SelectionNotifyEvent) ImplementsEvent() {} - -func (v SelectionNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v SelectionNotifyEvent) String() string { - fieldVals := make([]string, 0, 6) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Requestor: %d", v.Requestor)) - fieldVals = append(fieldVals, sprintf("Selection: %d", v.Selection)) - fieldVals = append(fieldVals, sprintf("Target: %d", v.Target)) - fieldVals = append(fieldVals, sprintf("Property: %d", v.Property)) - return "SelectionNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[31] = NewSelectionNotifyEvent -} - -// Event definition ColormapNotify (32) -// Size: 32 - -const ColormapNotify = 32 - -type ColormapNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Window Window - Colormap Colormap - New bool - State byte - // padding: 2 bytes -} - -// Event read ColormapNotify -func NewColormapNotifyEvent(buf []byte) Event { - v := ColormapNotifyEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - v.Colormap = Colormap(Get32(buf[b:])) - b += 4 - - if buf[b] == 1 { - v.New = true - } else { - v.New = false - } - b += 1 - - v.State = buf[b] - b += 1 - - b += 2 // padding - - return v -} - -// Event write ColormapNotify -func (v ColormapNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 32 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - Put32(buf[b:], uint32(v.Colormap)) - b += 4 - - if v.New { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - buf[b] = v.State - b += 1 - - b += 2 // padding - - return buf -} - -func (v ColormapNotifyEvent) ImplementsEvent() {} - -func (v ColormapNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v ColormapNotifyEvent) String() string { - fieldVals := make([]string, 0, 6) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, sprintf("Colormap: %d", v.Colormap)) - fieldVals = append(fieldVals, sprintf("New: %t", v.New)) - fieldVals = append(fieldVals, sprintf("State: %d", v.State)) - return "ColormapNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[32] = NewColormapNotifyEvent -} - -// Event definition ClientMessage (33) -// Size: 32 - -const ClientMessage = 33 - -type ClientMessageEvent struct { - Sequence uint16 - Format byte - Window Window - Type Atom - Data ClientMessageDataUnion -} - -// Event read ClientMessage -func NewClientMessageEvent(buf []byte) Event { - v := ClientMessageEvent{} - b := 1 // don't read event number - - v.Format = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Window = Window(Get32(buf[b:])) - b += 4 - - v.Type = Atom(Get32(buf[b:])) - b += 4 - - v.Data = ClientMessageDataUnion{} - b += ReadClientMessageDataUnion(buf[b:], &v.Data) - - return v -} - -// Event write ClientMessage -func (v ClientMessageEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 33 - b += 1 - - buf[b] = v.Format - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Window)) - b += 4 - - Put32(buf[b:], uint32(v.Type)) - b += 4 - - { - unionBytes := v.Data.Bytes() - copy(buf[b:], unionBytes) - b += pad(len(unionBytes)) - } - - return buf -} - -func (v ClientMessageEvent) ImplementsEvent() {} - -func (v ClientMessageEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v ClientMessageEvent) String() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Format: %d", v.Format)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, sprintf("Type: %d", v.Type)) - return "ClientMessage {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[33] = NewClientMessageEvent -} - -// Event definition MappingNotify (34) -// Size: 32 - -const MappingNotify = 34 - -type MappingNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Request byte - FirstKeycode Keycode - Count byte - // padding: 1 bytes -} - -// Event read MappingNotify -func NewMappingNotifyEvent(buf []byte) Event { - v := MappingNotifyEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Request = buf[b] - b += 1 - - v.FirstKeycode = Keycode(buf[b]) - b += 1 - - v.Count = buf[b] - b += 1 - - b += 1 // padding - - return v -} - -// Event write MappingNotify -func (v MappingNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 34 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - buf[b] = v.Request - b += 1 - - buf[b] = byte(v.FirstKeycode) - b += 1 - - buf[b] = v.Count - b += 1 - - b += 1 // padding - - return buf -} - -func (v MappingNotifyEvent) ImplementsEvent() {} - -func (v MappingNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v MappingNotifyEvent) String() string { - fieldVals := make([]string, 0, 5) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Request: %d", v.Request)) - fieldVals = append(fieldVals, sprintf("FirstKeycode: %d", v.FirstKeycode)) - fieldVals = append(fieldVals, sprintf("Count: %d", v.Count)) - return "MappingNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[34] = NewMappingNotifyEvent -} - -// EventCopy definition KeyRelease (3) - -const KeyRelease = 3 - -type KeyReleaseEvent KeyPressEvent - -func NewKeyReleaseEvent(buf []byte) Event { - return KeyReleaseEvent(NewKeyPressEvent(buf).(KeyPressEvent)) -} - -func (v KeyReleaseEvent) Bytes() []byte { - return KeyPressEvent(v).Bytes() -} - -func (v KeyReleaseEvent) ImplementsEvent() {} - -func (v KeyReleaseEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v KeyReleaseEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, sprintf("SameScreen: %t", v.SameScreen)) - return "KeyRelease {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[3] = NewKeyReleaseEvent -} - -// EventCopy definition ButtonRelease (5) - -const ButtonRelease = 5 - -type ButtonReleaseEvent ButtonPressEvent - -func NewButtonReleaseEvent(buf []byte) Event { - return ButtonReleaseEvent(NewButtonPressEvent(buf).(ButtonPressEvent)) -} - -func (v ButtonReleaseEvent) Bytes() []byte { - return ButtonPressEvent(v).Bytes() -} - -func (v ButtonReleaseEvent) ImplementsEvent() {} - -func (v ButtonReleaseEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v ButtonReleaseEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, sprintf("SameScreen: %t", v.SameScreen)) - return "ButtonRelease {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[5] = NewButtonReleaseEvent -} - -// EventCopy definition LeaveNotify (8) - -const LeaveNotify = 8 - -type LeaveNotifyEvent EnterNotifyEvent - -func NewLeaveNotifyEvent(buf []byte) Event { - return LeaveNotifyEvent(NewEnterNotifyEvent(buf).(EnterNotifyEvent)) -} - -func (v LeaveNotifyEvent) Bytes() []byte { - return EnterNotifyEvent(v).Bytes() -} - -func (v LeaveNotifyEvent) ImplementsEvent() {} - -func (v LeaveNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v LeaveNotifyEvent) String() string { - fieldVals := make([]string, 0, 12) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Root: %d", v.Root)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Child: %d", v.Child)) - fieldVals = append(fieldVals, sprintf("RootX: %d", v.RootX)) - fieldVals = append(fieldVals, sprintf("RootY: %d", v.RootY)) - fieldVals = append(fieldVals, sprintf("EventX: %d", v.EventX)) - fieldVals = append(fieldVals, sprintf("EventY: %d", v.EventY)) - fieldVals = append(fieldVals, sprintf("State: %d", v.State)) - fieldVals = append(fieldVals, sprintf("Mode: %d", v.Mode)) - fieldVals = append(fieldVals, sprintf("SameScreenFocus: %d", v.SameScreenFocus)) - return "LeaveNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[8] = NewLeaveNotifyEvent -} - -// EventCopy definition FocusOut (10) - -const FocusOut = 10 - -type FocusOutEvent FocusInEvent - -func NewFocusOutEvent(buf []byte) Event { - return FocusOutEvent(NewFocusInEvent(buf).(FocusInEvent)) -} - -func (v FocusOutEvent) Bytes() []byte { - return FocusInEvent(v).Bytes() -} - -func (v FocusOutEvent) ImplementsEvent() {} - -func (v FocusOutEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v FocusOutEvent) String() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Detail: %d", v.Detail)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Mode: %d", v.Mode)) - return "FocusOut {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[10] = NewFocusOutEvent -} - -// EventCopy definition CirculateRequest (27) - -const CirculateRequest = 27 - -type CirculateRequestEvent CirculateNotifyEvent - -func NewCirculateRequestEvent(buf []byte) Event { - return CirculateRequestEvent(NewCirculateNotifyEvent(buf).(CirculateNotifyEvent)) -} - -func (v CirculateRequestEvent) Bytes() []byte { - return CirculateNotifyEvent(v).Bytes() -} - -func (v CirculateRequestEvent) ImplementsEvent() {} - -func (v CirculateRequestEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v CirculateRequestEvent) String() string { - fieldVals := make([]string, 0, 6) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Event: %d", v.Event)) - fieldVals = append(fieldVals, sprintf("Window: %d", v.Window)) - fieldVals = append(fieldVals, sprintf("Place: %d", v.Place)) - return "CirculateRequest {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newEventFuncs[27] = NewCirculateRequestEvent -} - -// Error definition Request (1) -// Size: 32 - -const BadRequest = 1 - -type RequestError struct { - Sequence uint16 - NiceName string - BadValue uint32 - MinorOpcode uint16 - MajorOpcode byte - // padding: 1 bytes -} - -// Error read Request -func NewRequestError(buf []byte) Error { - v := RequestError{} - v.NiceName = "Request" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.BadValue = Get32(buf[b:]) - b += 4 - - v.MinorOpcode = Get16(buf[b:]) - b += 2 - - v.MajorOpcode = buf[b] - b += 1 - - b += 1 // padding - - return v -} - -func (err RequestError) ImplementsError() {} - -func (err RequestError) SequenceId() uint16 { - return err.Sequence -} - -func (err RequestError) BadId() uint32 { - return err.BadValue -} - -func (err RequestError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadRequest {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newErrorFuncs[1] = NewRequestError -} - -// Error definition Value (2) -// Size: 32 - -const BadValue = 2 - -type ValueError struct { - Sequence uint16 - NiceName string - BadValue uint32 - MinorOpcode uint16 - MajorOpcode byte - // padding: 1 bytes -} - -// Error read Value -func NewValueError(buf []byte) Error { - v := ValueError{} - v.NiceName = "Value" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.BadValue = Get32(buf[b:]) - b += 4 - - v.MinorOpcode = Get16(buf[b:]) - b += 2 - - v.MajorOpcode = buf[b] - b += 1 - - b += 1 // padding - - return v -} - -func (err ValueError) ImplementsError() {} - -func (err ValueError) SequenceId() uint16 { - return err.Sequence -} - -func (err ValueError) BadId() uint32 { - return err.BadValue -} - -func (err ValueError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadValue {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newErrorFuncs[2] = NewValueError -} - -// ErrorCopy definition Window (3) - -const BadWindow = 3 - -type WindowError ValueError - -func NewWindowError(buf []byte) Error { - v := WindowError(NewValueError(buf).(ValueError)) - v.NiceName = "Window" - return v -} - -func (err WindowError) ImplementsError() {} - -func (err WindowError) SequenceId() uint16 { - return err.Sequence -} - -func (err WindowError) BadId() uint32 { - return err.BadValue -} - -func (err WindowError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadWindow {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newErrorFuncs[3] = NewWindowError -} - -// ErrorCopy definition Pixmap (4) - -const BadPixmap = 4 - -type PixmapError ValueError - -func NewPixmapError(buf []byte) Error { - v := PixmapError(NewValueError(buf).(ValueError)) - v.NiceName = "Pixmap" - return v -} - -func (err PixmapError) ImplementsError() {} - -func (err PixmapError) SequenceId() uint16 { - return err.Sequence -} - -func (err PixmapError) BadId() uint32 { - return err.BadValue -} - -func (err PixmapError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadPixmap {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newErrorFuncs[4] = NewPixmapError -} - -// ErrorCopy definition Atom (5) - -const BadAtom = 5 - -type AtomError ValueError - -func NewAtomError(buf []byte) Error { - v := AtomError(NewValueError(buf).(ValueError)) - v.NiceName = "Atom" - return v -} - -func (err AtomError) ImplementsError() {} - -func (err AtomError) SequenceId() uint16 { - return err.Sequence -} - -func (err AtomError) BadId() uint32 { - return err.BadValue -} - -func (err AtomError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadAtom {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newErrorFuncs[5] = NewAtomError -} - -// ErrorCopy definition Cursor (6) - -const BadCursor = 6 - -type CursorError ValueError - -func NewCursorError(buf []byte) Error { - v := CursorError(NewValueError(buf).(ValueError)) - v.NiceName = "Cursor" - return v -} - -func (err CursorError) ImplementsError() {} - -func (err CursorError) SequenceId() uint16 { - return err.Sequence -} - -func (err CursorError) BadId() uint32 { - return err.BadValue -} - -func (err CursorError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadCursor {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newErrorFuncs[6] = NewCursorError -} - -// ErrorCopy definition Font (7) - -const BadFont = 7 - -type FontError ValueError - -func NewFontError(buf []byte) Error { - v := FontError(NewValueError(buf).(ValueError)) - v.NiceName = "Font" - return v -} - -func (err FontError) ImplementsError() {} - -func (err FontError) SequenceId() uint16 { - return err.Sequence -} - -func (err FontError) BadId() uint32 { - return err.BadValue -} - -func (err FontError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadFont {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newErrorFuncs[7] = NewFontError -} - -// ErrorCopy definition Match (8) - -const BadMatch = 8 - -type MatchError RequestError - -func NewMatchError(buf []byte) Error { - v := MatchError(NewRequestError(buf).(RequestError)) - v.NiceName = "Match" - return v -} - -func (err MatchError) ImplementsError() {} - -func (err MatchError) SequenceId() uint16 { - return err.Sequence -} - -func (err MatchError) BadId() uint32 { - return err.BadValue -} - -func (err MatchError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadMatch {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newErrorFuncs[8] = NewMatchError -} - -// ErrorCopy definition Drawable (9) - -const BadDrawable = 9 - -type DrawableError ValueError - -func NewDrawableError(buf []byte) Error { - v := DrawableError(NewValueError(buf).(ValueError)) - v.NiceName = "Drawable" - return v -} - -func (err DrawableError) ImplementsError() {} - -func (err DrawableError) SequenceId() uint16 { - return err.Sequence -} - -func (err DrawableError) BadId() uint32 { - return err.BadValue -} - -func (err DrawableError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadDrawable {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newErrorFuncs[9] = NewDrawableError -} - -// ErrorCopy definition Access (10) - -const BadAccess = 10 - -type AccessError RequestError - -func NewAccessError(buf []byte) Error { - v := AccessError(NewRequestError(buf).(RequestError)) - v.NiceName = "Access" - return v -} - -func (err AccessError) ImplementsError() {} - -func (err AccessError) SequenceId() uint16 { - return err.Sequence -} - -func (err AccessError) BadId() uint32 { - return err.BadValue -} - -func (err AccessError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadAccess {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newErrorFuncs[10] = NewAccessError -} - -// ErrorCopy definition Alloc (11) - -const BadAlloc = 11 - -type AllocError RequestError - -func NewAllocError(buf []byte) Error { - v := AllocError(NewRequestError(buf).(RequestError)) - v.NiceName = "Alloc" - return v -} - -func (err AllocError) ImplementsError() {} - -func (err AllocError) SequenceId() uint16 { - return err.Sequence -} - -func (err AllocError) BadId() uint32 { - return err.BadValue -} - -func (err AllocError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadAlloc {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newErrorFuncs[11] = NewAllocError -} - -// ErrorCopy definition Colormap (12) - -const BadColormap = 12 - -type ColormapError ValueError - -func NewColormapError(buf []byte) Error { - v := ColormapError(NewValueError(buf).(ValueError)) - v.NiceName = "Colormap" - return v -} - -func (err ColormapError) ImplementsError() {} - -func (err ColormapError) SequenceId() uint16 { - return err.Sequence -} - -func (err ColormapError) BadId() uint32 { - return err.BadValue -} - -func (err ColormapError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadColormap {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newErrorFuncs[12] = NewColormapError -} - -// ErrorCopy definition GContext (13) - -const BadGContext = 13 - -type GContextError ValueError - -func NewGContextError(buf []byte) Error { - v := GContextError(NewValueError(buf).(ValueError)) - v.NiceName = "GContext" - return v -} - -func (err GContextError) ImplementsError() {} - -func (err GContextError) SequenceId() uint16 { - return err.Sequence -} - -func (err GContextError) BadId() uint32 { - return err.BadValue -} - -func (err GContextError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadGContext {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newErrorFuncs[13] = NewGContextError -} - -// ErrorCopy definition IDChoice (14) - -const BadIDChoice = 14 - -type IDChoiceError ValueError - -func NewIDChoiceError(buf []byte) Error { - v := IDChoiceError(NewValueError(buf).(ValueError)) - v.NiceName = "IDChoice" - return v -} - -func (err IDChoiceError) ImplementsError() {} - -func (err IDChoiceError) SequenceId() uint16 { - return err.Sequence -} - -func (err IDChoiceError) BadId() uint32 { - return err.BadValue -} - -func (err IDChoiceError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadIDChoice {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newErrorFuncs[14] = NewIDChoiceError -} - -// ErrorCopy definition Name (15) - -const BadName = 15 - -type NameError RequestError - -func NewNameError(buf []byte) Error { - v := NameError(NewRequestError(buf).(RequestError)) - v.NiceName = "Name" - return v -} - -func (err NameError) ImplementsError() {} - -func (err NameError) SequenceId() uint16 { - return err.Sequence -} - -func (err NameError) BadId() uint32 { - return err.BadValue -} - -func (err NameError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadName {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newErrorFuncs[15] = NewNameError -} - -// ErrorCopy definition Length (16) - -const BadLength = 16 - -type LengthError RequestError - -func NewLengthError(buf []byte) Error { - v := LengthError(NewRequestError(buf).(RequestError)) - v.NiceName = "Length" - return v -} - -func (err LengthError) ImplementsError() {} - -func (err LengthError) SequenceId() uint16 { - return err.Sequence -} - -func (err LengthError) BadId() uint32 { - return err.BadValue -} - -func (err LengthError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadLength {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newErrorFuncs[16] = NewLengthError -} - -// ErrorCopy definition Implementation (17) - -const BadImplementation = 17 - -type ImplementationError RequestError - -func NewImplementationError(buf []byte) Error { - v := ImplementationError(NewRequestError(buf).(RequestError)) - v.NiceName = "Implementation" - return v -} - -func (err ImplementationError) ImplementsError() {} - -func (err ImplementationError) SequenceId() uint16 { - return err.Sequence -} - -func (err ImplementationError) BadId() uint32 { - return err.BadValue -} - -func (err ImplementationError) Error() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - fieldVals = append(fieldVals, sprintf("BadValue: %d", err.BadValue)) - fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) - fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) - return "BadImplementation {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newErrorFuncs[17] = NewImplementationError -} - -// Request CreateWindow -// size: pad((28 + (4 + pad((4 * popCount(int(ValueMask))))))) -type CreateWindowCookie struct { - *cookie -} - -// Write request to wire for CreateWindow -func (c *Conn) CreateWindow(Depth byte, Wid Window, Parent Window, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class uint16, Visual Visualid, ValueMask uint32, ValueList []uint32) CreateWindowCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.createWindowRequest(Depth, Wid, Parent, X, Y, Width, Height, BorderWidth, Class, Visual, ValueMask, ValueList), cookie) - return CreateWindowCookie{cookie} -} - -func (c *Conn) CreateWindowChecked(Depth byte, Wid Window, Parent Window, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class uint16, Visual Visualid, ValueMask uint32, ValueList []uint32) CreateWindowCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.createWindowRequest(Depth, Wid, Parent, X, Y, Width, Height, BorderWidth, Class, Visual, ValueMask, ValueList), cookie) - return CreateWindowCookie{cookie} -} - -func (cook CreateWindowCookie) Check() error { - return cook.check() -} - -// Write request to wire for CreateWindow -func (c *Conn) createWindowRequest(Depth byte, Wid Window, Parent Window, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class uint16, Visual Visualid, ValueMask uint32, ValueList []uint32) []byte { - size := pad((28 + (4 + pad((4 * popCount(int(ValueMask))))))) - b := 0 - buf := make([]byte, size) - - buf[b] = 1 // request opcode - b += 1 - - buf[b] = Depth - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Wid)) - b += 4 - - Put32(buf[b:], uint32(Parent)) - b += 4 - - Put16(buf[b:], uint16(X)) - b += 2 - - Put16(buf[b:], uint16(Y)) - b += 2 - - Put16(buf[b:], Width) - b += 2 - - Put16(buf[b:], Height) - b += 2 - - Put16(buf[b:], BorderWidth) - b += 2 - - Put16(buf[b:], Class) - b += 2 - - Put32(buf[b:], uint32(Visual)) - b += 4 - - Put32(buf[b:], ValueMask) - b += 4 - for i := 0; i < popCount(int(ValueMask)); i++ { - Put32(buf[b:], ValueList[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Request ChangeWindowAttributes -// size: pad((8 + (4 + pad((4 * popCount(int(ValueMask))))))) -type ChangeWindowAttributesCookie struct { - *cookie -} - -// Write request to wire for ChangeWindowAttributes -func (c *Conn) ChangeWindowAttributes(Window Window, ValueMask uint32, ValueList []uint32) ChangeWindowAttributesCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.changeWindowAttributesRequest(Window, ValueMask, ValueList), cookie) - return ChangeWindowAttributesCookie{cookie} -} - -func (c *Conn) ChangeWindowAttributesChecked(Window Window, ValueMask uint32, ValueList []uint32) ChangeWindowAttributesCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.changeWindowAttributesRequest(Window, ValueMask, ValueList), cookie) - return ChangeWindowAttributesCookie{cookie} -} - -func (cook ChangeWindowAttributesCookie) Check() error { - return cook.check() -} - -// Write request to wire for ChangeWindowAttributes -func (c *Conn) changeWindowAttributesRequest(Window Window, ValueMask uint32, ValueList []uint32) []byte { - size := pad((8 + (4 + pad((4 * popCount(int(ValueMask))))))) - b := 0 - buf := make([]byte, size) - - buf[b] = 2 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - Put32(buf[b:], ValueMask) - b += 4 - for i := 0; i < popCount(int(ValueMask)); i++ { - Put32(buf[b:], ValueList[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Request GetWindowAttributes -// size: 8 -type GetWindowAttributesCookie struct { - *cookie -} - -func (c *Conn) GetWindowAttributes(Window Window) GetWindowAttributesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.getWindowAttributesRequest(Window), cookie) - return GetWindowAttributesCookie{cookie} -} - -func (c *Conn) GetWindowAttributesUnchecked(Window Window) GetWindowAttributesCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.getWindowAttributesRequest(Window), cookie) - return GetWindowAttributesCookie{cookie} -} - -// Request reply for GetWindowAttributes -// size: 44 -type GetWindowAttributesReply struct { - Sequence uint16 - Length uint32 - BackingStore byte - Visual Visualid - Class uint16 - BitGravity byte - WinGravity byte - BackingPlanes uint32 - BackingPixel uint32 - SaveUnder bool - MapIsInstalled bool - MapState byte - OverrideRedirect bool - Colormap Colormap - AllEventMasks uint32 - YourEventMask uint32 - DoNotPropagateMask uint16 - // padding: 2 bytes -} - -// Waits and reads reply data from request GetWindowAttributes -func (cook GetWindowAttributesCookie) Reply() (*GetWindowAttributesReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getWindowAttributesReply(buf), nil -} - -// Read reply into structure from buffer for GetWindowAttributes -func getWindowAttributesReply(buf []byte) *GetWindowAttributesReply { - v := new(GetWindowAttributesReply) - b := 1 // skip reply determinant - - v.BackingStore = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Visual = Visualid(Get32(buf[b:])) - b += 4 - - v.Class = Get16(buf[b:]) - b += 2 - - v.BitGravity = buf[b] - b += 1 - - v.WinGravity = buf[b] - b += 1 - - v.BackingPlanes = Get32(buf[b:]) - b += 4 - - v.BackingPixel = Get32(buf[b:]) - b += 4 - - if buf[b] == 1 { - v.SaveUnder = true - } else { - v.SaveUnder = false - } - b += 1 - - if buf[b] == 1 { - v.MapIsInstalled = true - } else { - v.MapIsInstalled = false - } - b += 1 - - v.MapState = buf[b] - b += 1 - - if buf[b] == 1 { - v.OverrideRedirect = true - } else { - v.OverrideRedirect = false - } - b += 1 - - v.Colormap = Colormap(Get32(buf[b:])) - b += 4 - - v.AllEventMasks = Get32(buf[b:]) - b += 4 - - v.YourEventMask = Get32(buf[b:]) - b += 4 - - v.DoNotPropagateMask = Get16(buf[b:]) - b += 2 - - b += 2 // padding - - return v -} - -func (cook GetWindowAttributesCookie) Check() error { - return cook.check() -} - -// Write request to wire for GetWindowAttributes -func (c *Conn) getWindowAttributesRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 3 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - return buf -} - -// Request DestroyWindow -// size: 8 -type DestroyWindowCookie struct { - *cookie -} - -// Write request to wire for DestroyWindow -func (c *Conn) DestroyWindow(Window Window) DestroyWindowCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.destroyWindowRequest(Window), cookie) - return DestroyWindowCookie{cookie} -} - -func (c *Conn) DestroyWindowChecked(Window Window) DestroyWindowCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.destroyWindowRequest(Window), cookie) - return DestroyWindowCookie{cookie} -} - -func (cook DestroyWindowCookie) Check() error { - return cook.check() -} - -// Write request to wire for DestroyWindow -func (c *Conn) destroyWindowRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 4 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - return buf -} - -// Request DestroySubwindows -// size: 8 -type DestroySubwindowsCookie struct { - *cookie -} - -// Write request to wire for DestroySubwindows -func (c *Conn) DestroySubwindows(Window Window) DestroySubwindowsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.destroySubwindowsRequest(Window), cookie) - return DestroySubwindowsCookie{cookie} -} - -func (c *Conn) DestroySubwindowsChecked(Window Window) DestroySubwindowsCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.destroySubwindowsRequest(Window), cookie) - return DestroySubwindowsCookie{cookie} -} - -func (cook DestroySubwindowsCookie) Check() error { - return cook.check() -} - -// Write request to wire for DestroySubwindows -func (c *Conn) destroySubwindowsRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 5 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - return buf -} - -// Request ChangeSaveSet -// size: 8 -type ChangeSaveSetCookie struct { - *cookie -} - -// Write request to wire for ChangeSaveSet -func (c *Conn) ChangeSaveSet(Mode byte, Window Window) ChangeSaveSetCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.changeSaveSetRequest(Mode, Window), cookie) - return ChangeSaveSetCookie{cookie} -} - -func (c *Conn) ChangeSaveSetChecked(Mode byte, Window Window) ChangeSaveSetCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.changeSaveSetRequest(Mode, Window), cookie) - return ChangeSaveSetCookie{cookie} -} - -func (cook ChangeSaveSetCookie) Check() error { - return cook.check() -} - -// Write request to wire for ChangeSaveSet -func (c *Conn) changeSaveSetRequest(Mode byte, Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 6 // request opcode - b += 1 - - buf[b] = Mode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - return buf -} - -// Request ReparentWindow -// size: 16 -type ReparentWindowCookie struct { - *cookie -} - -// Write request to wire for ReparentWindow -func (c *Conn) ReparentWindow(Window Window, Parent Window, X int16, Y int16) ReparentWindowCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.reparentWindowRequest(Window, Parent, X, Y), cookie) - return ReparentWindowCookie{cookie} -} - -func (c *Conn) ReparentWindowChecked(Window Window, Parent Window, X int16, Y int16) ReparentWindowCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.reparentWindowRequest(Window, Parent, X, Y), cookie) - return ReparentWindowCookie{cookie} -} - -func (cook ReparentWindowCookie) Check() error { - return cook.check() -} - -// Write request to wire for ReparentWindow -func (c *Conn) reparentWindowRequest(Window Window, Parent Window, X int16, Y int16) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = 7 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - Put32(buf[b:], uint32(Parent)) - b += 4 - - Put16(buf[b:], uint16(X)) - b += 2 - - Put16(buf[b:], uint16(Y)) - b += 2 - - return buf -} - -// Request MapWindow -// size: 8 -type MapWindowCookie struct { - *cookie -} - -// Write request to wire for MapWindow -func (c *Conn) MapWindow(Window Window) MapWindowCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.mapWindowRequest(Window), cookie) - return MapWindowCookie{cookie} -} - -func (c *Conn) MapWindowChecked(Window Window) MapWindowCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.mapWindowRequest(Window), cookie) - return MapWindowCookie{cookie} -} - -func (cook MapWindowCookie) Check() error { - return cook.check() -} - -// Write request to wire for MapWindow -func (c *Conn) mapWindowRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 8 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - return buf -} - -// Request MapSubwindows -// size: 8 -type MapSubwindowsCookie struct { - *cookie -} - -// Write request to wire for MapSubwindows -func (c *Conn) MapSubwindows(Window Window) MapSubwindowsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.mapSubwindowsRequest(Window), cookie) - return MapSubwindowsCookie{cookie} -} - -func (c *Conn) MapSubwindowsChecked(Window Window) MapSubwindowsCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.mapSubwindowsRequest(Window), cookie) - return MapSubwindowsCookie{cookie} -} - -func (cook MapSubwindowsCookie) Check() error { - return cook.check() -} - -// Write request to wire for MapSubwindows -func (c *Conn) mapSubwindowsRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 9 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - return buf -} - -// Request UnmapWindow -// size: 8 -type UnmapWindowCookie struct { - *cookie -} - -// Write request to wire for UnmapWindow -func (c *Conn) UnmapWindow(Window Window) UnmapWindowCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.unmapWindowRequest(Window), cookie) - return UnmapWindowCookie{cookie} -} - -func (c *Conn) UnmapWindowChecked(Window Window) UnmapWindowCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.unmapWindowRequest(Window), cookie) - return UnmapWindowCookie{cookie} -} - -func (cook UnmapWindowCookie) Check() error { - return cook.check() -} - -// Write request to wire for UnmapWindow -func (c *Conn) unmapWindowRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 10 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - return buf -} - -// Request UnmapSubwindows -// size: 8 -type UnmapSubwindowsCookie struct { - *cookie -} - -// Write request to wire for UnmapSubwindows -func (c *Conn) UnmapSubwindows(Window Window) UnmapSubwindowsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.unmapSubwindowsRequest(Window), cookie) - return UnmapSubwindowsCookie{cookie} -} - -func (c *Conn) UnmapSubwindowsChecked(Window Window) UnmapSubwindowsCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.unmapSubwindowsRequest(Window), cookie) - return UnmapSubwindowsCookie{cookie} -} - -func (cook UnmapSubwindowsCookie) Check() error { - return cook.check() -} - -// Write request to wire for UnmapSubwindows -func (c *Conn) unmapSubwindowsRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 11 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - return buf -} - -// Request ConfigureWindow -// size: pad((10 + (2 + pad((4 * popCount(int(ValueMask))))))) -type ConfigureWindowCookie struct { - *cookie -} - -// Write request to wire for ConfigureWindow -func (c *Conn) ConfigureWindow(Window Window, ValueMask uint16, ValueList []uint32) ConfigureWindowCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.configureWindowRequest(Window, ValueMask, ValueList), cookie) - return ConfigureWindowCookie{cookie} -} - -func (c *Conn) ConfigureWindowChecked(Window Window, ValueMask uint16, ValueList []uint32) ConfigureWindowCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.configureWindowRequest(Window, ValueMask, ValueList), cookie) - return ConfigureWindowCookie{cookie} -} - -func (cook ConfigureWindowCookie) Check() error { - return cook.check() -} - -// Write request to wire for ConfigureWindow -func (c *Conn) configureWindowRequest(Window Window, ValueMask uint16, ValueList []uint32) []byte { - size := pad((10 + (2 + pad((4 * popCount(int(ValueMask))))))) - b := 0 - buf := make([]byte, size) - - buf[b] = 12 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - Put16(buf[b:], ValueMask) - b += 2 - - b += 2 // padding - - for i := 0; i < popCount(int(ValueMask)); i++ { - Put32(buf[b:], ValueList[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Request CirculateWindow -// size: 8 -type CirculateWindowCookie struct { - *cookie -} - -// Write request to wire for CirculateWindow -func (c *Conn) CirculateWindow(Direction byte, Window Window) CirculateWindowCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.circulateWindowRequest(Direction, Window), cookie) - return CirculateWindowCookie{cookie} -} - -func (c *Conn) CirculateWindowChecked(Direction byte, Window Window) CirculateWindowCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.circulateWindowRequest(Direction, Window), cookie) - return CirculateWindowCookie{cookie} -} - -func (cook CirculateWindowCookie) Check() error { - return cook.check() -} - -// Write request to wire for CirculateWindow -func (c *Conn) circulateWindowRequest(Direction byte, Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 13 // request opcode - b += 1 - - buf[b] = Direction - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - return buf -} - -// Request GetGeometry -// size: 8 -type GetGeometryCookie struct { - *cookie -} - -func (c *Conn) GetGeometry(Drawable Drawable) GetGeometryCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.getGeometryRequest(Drawable), cookie) - return GetGeometryCookie{cookie} -} - -func (c *Conn) GetGeometryUnchecked(Drawable Drawable) GetGeometryCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.getGeometryRequest(Drawable), cookie) - return GetGeometryCookie{cookie} -} - -// Request reply for GetGeometry -// size: 24 -type GetGeometryReply struct { - Sequence uint16 - Length uint32 - Depth byte - Root Window - X int16 - Y int16 - Width uint16 - Height uint16 - BorderWidth uint16 - // padding: 2 bytes -} - -// Waits and reads reply data from request GetGeometry -func (cook GetGeometryCookie) Reply() (*GetGeometryReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getGeometryReply(buf), nil -} - -// Read reply into structure from buffer for GetGeometry -func getGeometryReply(buf []byte) *GetGeometryReply { - v := new(GetGeometryReply) - b := 1 // skip reply determinant - - v.Depth = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Root = Window(Get32(buf[b:])) - b += 4 - - v.X = int16(Get16(buf[b:])) - b += 2 - - v.Y = int16(Get16(buf[b:])) - b += 2 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - v.BorderWidth = Get16(buf[b:]) - b += 2 - - b += 2 // padding - - return v -} - -func (cook GetGeometryCookie) Check() error { - return cook.check() -} - -// Write request to wire for GetGeometry -func (c *Conn) getGeometryRequest(Drawable Drawable) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 14 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - return buf -} - -// Request QueryTree -// size: 8 -type QueryTreeCookie struct { - *cookie -} - -func (c *Conn) QueryTree(Window Window) QueryTreeCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.queryTreeRequest(Window), cookie) - return QueryTreeCookie{cookie} -} - -func (c *Conn) QueryTreeUnchecked(Window Window) QueryTreeCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.queryTreeRequest(Window), cookie) - return QueryTreeCookie{cookie} -} - -// Request reply for QueryTree -// size: (32 + pad((int(ChildrenLen) * 4))) -type QueryTreeReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Root Window - Parent Window - ChildrenLen uint16 - // padding: 14 bytes - Children []Window // size: pad((int(ChildrenLen) * 4)) -} - -// Waits and reads reply data from request QueryTree -func (cook QueryTreeCookie) Reply() (*QueryTreeReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return queryTreeReply(buf), nil -} - -// Read reply into structure from buffer for QueryTree -func queryTreeReply(buf []byte) *QueryTreeReply { - v := new(QueryTreeReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Root = Window(Get32(buf[b:])) - b += 4 - - v.Parent = Window(Get32(buf[b:])) - b += 4 - - v.ChildrenLen = Get16(buf[b:]) - b += 2 - - b += 14 // padding - - v.Children = make([]Window, v.ChildrenLen) - for i := 0; i < int(v.ChildrenLen); i++ { - v.Children[i] = Window(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook QueryTreeCookie) Check() error { - return cook.check() -} - -// Write request to wire for QueryTree -func (c *Conn) queryTreeRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 15 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - return buf -} - -// Request InternAtom -// size: pad((8 + pad((int(NameLen) * 1)))) -type InternAtomCookie struct { - *cookie -} - -func (c *Conn) InternAtom(OnlyIfExists bool, NameLen uint16, Name string) InternAtomCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.internAtomRequest(OnlyIfExists, NameLen, Name), cookie) - return InternAtomCookie{cookie} -} - -func (c *Conn) InternAtomUnchecked(OnlyIfExists bool, NameLen uint16, Name string) InternAtomCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.internAtomRequest(OnlyIfExists, NameLen, Name), cookie) - return InternAtomCookie{cookie} -} - -// Request reply for InternAtom -// size: 12 -type InternAtomReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Atom Atom -} - -// Waits and reads reply data from request InternAtom -func (cook InternAtomCookie) Reply() (*InternAtomReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return internAtomReply(buf), nil -} - -// Read reply into structure from buffer for InternAtom -func internAtomReply(buf []byte) *InternAtomReply { - v := new(InternAtomReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Atom = Atom(Get32(buf[b:])) - b += 4 - - return v -} - -func (cook InternAtomCookie) Check() error { - return cook.check() -} - -// Write request to wire for InternAtom -func (c *Conn) internAtomRequest(OnlyIfExists bool, NameLen uint16, Name string) []byte { - size := pad((8 + pad((int(NameLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 16 // request opcode - b += 1 - - if OnlyIfExists { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], NameLen) - b += 2 - - b += 2 // padding - - copy(buf[b:], Name[:NameLen]) - b += pad(int(NameLen)) - - return buf -} - -// Request GetAtomName -// size: 8 -type GetAtomNameCookie struct { - *cookie -} - -func (c *Conn) GetAtomName(Atom Atom) GetAtomNameCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.getAtomNameRequest(Atom), cookie) - return GetAtomNameCookie{cookie} -} - -func (c *Conn) GetAtomNameUnchecked(Atom Atom) GetAtomNameCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.getAtomNameRequest(Atom), cookie) - return GetAtomNameCookie{cookie} -} - -// Request reply for GetAtomName -// size: (32 + pad((int(NameLen) * 1))) -type GetAtomNameReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NameLen uint16 - // padding: 22 bytes - Name string // size: pad((int(NameLen) * 1)) -} - -// Waits and reads reply data from request GetAtomName -func (cook GetAtomNameCookie) Reply() (*GetAtomNameReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getAtomNameReply(buf), nil -} - -// Read reply into structure from buffer for GetAtomName -func getAtomNameReply(buf []byte) *GetAtomNameReply { - v := new(GetAtomNameReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.NameLen = Get16(buf[b:]) - b += 2 - - b += 22 // padding - - { - byteString := make([]byte, v.NameLen) - copy(byteString[:v.NameLen], buf[b:]) - v.Name = string(byteString) - b += pad(int(v.NameLen)) - } - - return v -} - -func (cook GetAtomNameCookie) Check() error { - return cook.check() -} - -// Write request to wire for GetAtomName -func (c *Conn) getAtomNameRequest(Atom Atom) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 17 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Atom)) - b += 4 - - return buf -} - -// Request ChangeProperty -// size: pad((24 + pad((((int(DataLen) * int(Format)) / 8) * 1)))) -type ChangePropertyCookie struct { - *cookie -} - -// Write request to wire for ChangeProperty -func (c *Conn) ChangeProperty(Mode byte, Window Window, Property Atom, Type Atom, Format byte, DataLen uint32, Data []byte) ChangePropertyCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.changePropertyRequest(Mode, Window, Property, Type, Format, DataLen, Data), cookie) - return ChangePropertyCookie{cookie} -} - -func (c *Conn) ChangePropertyChecked(Mode byte, Window Window, Property Atom, Type Atom, Format byte, DataLen uint32, Data []byte) ChangePropertyCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.changePropertyRequest(Mode, Window, Property, Type, Format, DataLen, Data), cookie) - return ChangePropertyCookie{cookie} -} - -func (cook ChangePropertyCookie) Check() error { - return cook.check() -} - -// Write request to wire for ChangeProperty -func (c *Conn) changePropertyRequest(Mode byte, Window Window, Property Atom, Type Atom, Format byte, DataLen uint32, Data []byte) []byte { - size := pad((24 + pad((((int(DataLen) * int(Format)) / 8) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 18 // request opcode - b += 1 - - buf[b] = Mode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - Put32(buf[b:], uint32(Property)) - b += 4 - - Put32(buf[b:], uint32(Type)) - b += 4 - - buf[b] = Format - b += 1 - - b += 3 // padding - - Put32(buf[b:], DataLen) - b += 4 - - copy(buf[b:], Data[:((int(DataLen)*int(Format))/8)]) - b += pad(int(((int(DataLen) * int(Format)) / 8))) - - return buf -} - -// Request DeleteProperty -// size: 12 -type DeletePropertyCookie struct { - *cookie -} - -// Write request to wire for DeleteProperty -func (c *Conn) DeleteProperty(Window Window, Property Atom) DeletePropertyCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.deletePropertyRequest(Window, Property), cookie) - return DeletePropertyCookie{cookie} -} - -func (c *Conn) DeletePropertyChecked(Window Window, Property Atom) DeletePropertyCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.deletePropertyRequest(Window, Property), cookie) - return DeletePropertyCookie{cookie} -} - -func (cook DeletePropertyCookie) Check() error { - return cook.check() -} - -// Write request to wire for DeleteProperty -func (c *Conn) deletePropertyRequest(Window Window, Property Atom) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = 19 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - Put32(buf[b:], uint32(Property)) - b += 4 - - return buf -} - -// Request GetProperty -// size: 24 -type GetPropertyCookie struct { - *cookie -} - -func (c *Conn) GetProperty(Delete bool, Window Window, Property Atom, Type Atom, LongOffset uint32, LongLength uint32) GetPropertyCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.getPropertyRequest(Delete, Window, Property, Type, LongOffset, LongLength), cookie) - return GetPropertyCookie{cookie} -} - -func (c *Conn) GetPropertyUnchecked(Delete bool, Window Window, Property Atom, Type Atom, LongOffset uint32, LongLength uint32) GetPropertyCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.getPropertyRequest(Delete, Window, Property, Type, LongOffset, LongLength), cookie) - return GetPropertyCookie{cookie} -} - -// Request reply for GetProperty -// size: (32 + pad(((int(ValueLen) * (int(Format) / 8)) * 1))) -type GetPropertyReply struct { - Sequence uint16 - Length uint32 - Format byte - Type Atom - BytesAfter uint32 - ValueLen uint32 - // padding: 12 bytes - Value []byte // size: pad(((int(ValueLen) * (int(Format) / 8)) * 1)) -} - -// Waits and reads reply data from request GetProperty -func (cook GetPropertyCookie) Reply() (*GetPropertyReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getPropertyReply(buf), nil -} - -// Read reply into structure from buffer for GetProperty -func getPropertyReply(buf []byte) *GetPropertyReply { - v := new(GetPropertyReply) - b := 1 // skip reply determinant - - v.Format = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Type = Atom(Get32(buf[b:])) - b += 4 - - v.BytesAfter = Get32(buf[b:]) - b += 4 - - v.ValueLen = Get32(buf[b:]) - b += 4 - - b += 12 // padding - - v.Value = make([]byte, (int(v.ValueLen) * (int(v.Format) / 8))) - copy(v.Value[:(int(v.ValueLen)*(int(v.Format)/8))], buf[b:]) - b += pad(int((int(v.ValueLen) * (int(v.Format) / 8)))) - - return v -} - -func (cook GetPropertyCookie) Check() error { - return cook.check() -} - -// Write request to wire for GetProperty -func (c *Conn) getPropertyRequest(Delete bool, Window Window, Property Atom, Type Atom, LongOffset uint32, LongLength uint32) []byte { - size := 24 - b := 0 - buf := make([]byte, size) - - buf[b] = 20 // request opcode - b += 1 - - if Delete { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - Put32(buf[b:], uint32(Property)) - b += 4 - - Put32(buf[b:], uint32(Type)) - b += 4 - - Put32(buf[b:], LongOffset) - b += 4 - - Put32(buf[b:], LongLength) - b += 4 - - return buf -} - -// Request ListProperties -// size: 8 -type ListPropertiesCookie struct { - *cookie -} - -func (c *Conn) ListProperties(Window Window) ListPropertiesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.listPropertiesRequest(Window), cookie) - return ListPropertiesCookie{cookie} -} - -func (c *Conn) ListPropertiesUnchecked(Window Window) ListPropertiesCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.listPropertiesRequest(Window), cookie) - return ListPropertiesCookie{cookie} -} - -// Request reply for ListProperties -// size: (32 + pad((int(AtomsLen) * 4))) -type ListPropertiesReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - AtomsLen uint16 - // padding: 22 bytes - Atoms []Atom // size: pad((int(AtomsLen) * 4)) -} - -// Waits and reads reply data from request ListProperties -func (cook ListPropertiesCookie) Reply() (*ListPropertiesReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return listPropertiesReply(buf), nil -} - -// Read reply into structure from buffer for ListProperties -func listPropertiesReply(buf []byte) *ListPropertiesReply { - v := new(ListPropertiesReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.AtomsLen = Get16(buf[b:]) - b += 2 - - b += 22 // padding - - v.Atoms = make([]Atom, v.AtomsLen) - for i := 0; i < int(v.AtomsLen); i++ { - v.Atoms[i] = Atom(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook ListPropertiesCookie) Check() error { - return cook.check() -} - -// Write request to wire for ListProperties -func (c *Conn) listPropertiesRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 21 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - return buf -} - -// Request SetSelectionOwner -// size: 16 -type SetSelectionOwnerCookie struct { - *cookie -} - -// Write request to wire for SetSelectionOwner -func (c *Conn) SetSelectionOwner(Owner Window, Selection Atom, Time Timestamp) SetSelectionOwnerCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.setSelectionOwnerRequest(Owner, Selection, Time), cookie) - return SetSelectionOwnerCookie{cookie} -} - -func (c *Conn) SetSelectionOwnerChecked(Owner Window, Selection Atom, Time Timestamp) SetSelectionOwnerCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.setSelectionOwnerRequest(Owner, Selection, Time), cookie) - return SetSelectionOwnerCookie{cookie} -} - -func (cook SetSelectionOwnerCookie) Check() error { - return cook.check() -} - -// Write request to wire for SetSelectionOwner -func (c *Conn) setSelectionOwnerRequest(Owner Window, Selection Atom, Time Timestamp) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = 22 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Owner)) - b += 4 - - Put32(buf[b:], uint32(Selection)) - b += 4 - - Put32(buf[b:], uint32(Time)) - b += 4 - - return buf -} - -// Request GetSelectionOwner -// size: 8 -type GetSelectionOwnerCookie struct { - *cookie -} - -func (c *Conn) GetSelectionOwner(Selection Atom) GetSelectionOwnerCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.getSelectionOwnerRequest(Selection), cookie) - return GetSelectionOwnerCookie{cookie} -} - -func (c *Conn) GetSelectionOwnerUnchecked(Selection Atom) GetSelectionOwnerCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.getSelectionOwnerRequest(Selection), cookie) - return GetSelectionOwnerCookie{cookie} -} - -// Request reply for GetSelectionOwner -// size: 12 -type GetSelectionOwnerReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Owner Window -} - -// Waits and reads reply data from request GetSelectionOwner -func (cook GetSelectionOwnerCookie) Reply() (*GetSelectionOwnerReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getSelectionOwnerReply(buf), nil -} - -// Read reply into structure from buffer for GetSelectionOwner -func getSelectionOwnerReply(buf []byte) *GetSelectionOwnerReply { - v := new(GetSelectionOwnerReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Owner = Window(Get32(buf[b:])) - b += 4 - - return v -} - -func (cook GetSelectionOwnerCookie) Check() error { - return cook.check() -} - -// Write request to wire for GetSelectionOwner -func (c *Conn) getSelectionOwnerRequest(Selection Atom) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 23 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Selection)) - b += 4 - - return buf -} - -// Request ConvertSelection -// size: 24 -type ConvertSelectionCookie struct { - *cookie -} - -// Write request to wire for ConvertSelection -func (c *Conn) ConvertSelection(Requestor Window, Selection Atom, Target Atom, Property Atom, Time Timestamp) ConvertSelectionCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.convertSelectionRequest(Requestor, Selection, Target, Property, Time), cookie) - return ConvertSelectionCookie{cookie} -} - -func (c *Conn) ConvertSelectionChecked(Requestor Window, Selection Atom, Target Atom, Property Atom, Time Timestamp) ConvertSelectionCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.convertSelectionRequest(Requestor, Selection, Target, Property, Time), cookie) - return ConvertSelectionCookie{cookie} -} - -func (cook ConvertSelectionCookie) Check() error { - return cook.check() -} - -// Write request to wire for ConvertSelection -func (c *Conn) convertSelectionRequest(Requestor Window, Selection Atom, Target Atom, Property Atom, Time Timestamp) []byte { - size := 24 - b := 0 - buf := make([]byte, size) - - buf[b] = 24 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Requestor)) - b += 4 - - Put32(buf[b:], uint32(Selection)) - b += 4 - - Put32(buf[b:], uint32(Target)) - b += 4 - - Put32(buf[b:], uint32(Property)) - b += 4 - - Put32(buf[b:], uint32(Time)) - b += 4 - - return buf -} - -// Request SendEvent -// size: 44 -type SendEventCookie struct { - *cookie -} - -// Write request to wire for SendEvent -func (c *Conn) SendEvent(Propagate bool, Destination Window, EventMask uint32, Event string) SendEventCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.sendEventRequest(Propagate, Destination, EventMask, Event), cookie) - return SendEventCookie{cookie} -} - -func (c *Conn) SendEventChecked(Propagate bool, Destination Window, EventMask uint32, Event string) SendEventCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.sendEventRequest(Propagate, Destination, EventMask, Event), cookie) - return SendEventCookie{cookie} -} - -func (cook SendEventCookie) Check() error { - return cook.check() -} - -// Write request to wire for SendEvent -func (c *Conn) sendEventRequest(Propagate bool, Destination Window, EventMask uint32, Event string) []byte { - size := 44 - b := 0 - buf := make([]byte, size) - - buf[b] = 25 // request opcode - b += 1 - - if Propagate { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Destination)) - b += 4 - - Put32(buf[b:], EventMask) - b += 4 - - copy(buf[b:], Event[:32]) - b += pad(int(32)) - - return buf -} - -// Request GrabPointer -// size: 24 -type GrabPointerCookie struct { - *cookie -} - -func (c *Conn) GrabPointer(OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Time Timestamp) GrabPointerCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.grabPointerRequest(OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Time), cookie) - return GrabPointerCookie{cookie} -} - -func (c *Conn) GrabPointerUnchecked(OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Time Timestamp) GrabPointerCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.grabPointerRequest(OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Time), cookie) - return GrabPointerCookie{cookie} -} - -// Request reply for GrabPointer -// size: 8 -type GrabPointerReply struct { - Sequence uint16 - Length uint32 - Status byte -} - -// Waits and reads reply data from request GrabPointer -func (cook GrabPointerCookie) Reply() (*GrabPointerReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return grabPointerReply(buf), nil -} - -// Read reply into structure from buffer for GrabPointer -func grabPointerReply(buf []byte) *GrabPointerReply { - v := new(GrabPointerReply) - b := 1 // skip reply determinant - - v.Status = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - return v -} - -func (cook GrabPointerCookie) Check() error { - return cook.check() -} - -// Write request to wire for GrabPointer -func (c *Conn) grabPointerRequest(OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Time Timestamp) []byte { - size := 24 - b := 0 - buf := make([]byte, size) - - buf[b] = 26 // request opcode - b += 1 - - if OwnerEvents { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(GrabWindow)) - b += 4 - - Put16(buf[b:], EventMask) - b += 2 - - buf[b] = PointerMode - b += 1 - - buf[b] = KeyboardMode - b += 1 - - Put32(buf[b:], uint32(ConfineTo)) - b += 4 - - Put32(buf[b:], uint32(Cursor)) - b += 4 - - Put32(buf[b:], uint32(Time)) - b += 4 - - return buf -} - -// Request UngrabPointer -// size: 8 -type UngrabPointerCookie struct { - *cookie -} - -// Write request to wire for UngrabPointer -func (c *Conn) UngrabPointer(Time Timestamp) UngrabPointerCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.ungrabPointerRequest(Time), cookie) - return UngrabPointerCookie{cookie} -} - -func (c *Conn) UngrabPointerChecked(Time Timestamp) UngrabPointerCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.ungrabPointerRequest(Time), cookie) - return UngrabPointerCookie{cookie} -} - -func (cook UngrabPointerCookie) Check() error { - return cook.check() -} - -// Write request to wire for UngrabPointer -func (c *Conn) ungrabPointerRequest(Time Timestamp) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 27 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Time)) - b += 4 - - return buf -} - -// Request GrabButton -// size: 24 -type GrabButtonCookie struct { - *cookie -} - -// Write request to wire for GrabButton -func (c *Conn) GrabButton(OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Button byte, Modifiers uint16) GrabButtonCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.grabButtonRequest(OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Button, Modifiers), cookie) - return GrabButtonCookie{cookie} -} - -func (c *Conn) GrabButtonChecked(OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Button byte, Modifiers uint16) GrabButtonCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.grabButtonRequest(OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Button, Modifiers), cookie) - return GrabButtonCookie{cookie} -} - -func (cook GrabButtonCookie) Check() error { - return cook.check() -} - -// Write request to wire for GrabButton -func (c *Conn) grabButtonRequest(OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Button byte, Modifiers uint16) []byte { - size := 24 - b := 0 - buf := make([]byte, size) - - buf[b] = 28 // request opcode - b += 1 - - if OwnerEvents { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(GrabWindow)) - b += 4 - - Put16(buf[b:], EventMask) - b += 2 - - buf[b] = PointerMode - b += 1 - - buf[b] = KeyboardMode - b += 1 - - Put32(buf[b:], uint32(ConfineTo)) - b += 4 - - Put32(buf[b:], uint32(Cursor)) - b += 4 - - buf[b] = Button - b += 1 - - b += 1 // padding - - Put16(buf[b:], Modifiers) - b += 2 - - return buf -} - -// Request UngrabButton -// size: 12 -type UngrabButtonCookie struct { - *cookie -} - -// Write request to wire for UngrabButton -func (c *Conn) UngrabButton(Button byte, GrabWindow Window, Modifiers uint16) UngrabButtonCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.ungrabButtonRequest(Button, GrabWindow, Modifiers), cookie) - return UngrabButtonCookie{cookie} -} - -func (c *Conn) UngrabButtonChecked(Button byte, GrabWindow Window, Modifiers uint16) UngrabButtonCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.ungrabButtonRequest(Button, GrabWindow, Modifiers), cookie) - return UngrabButtonCookie{cookie} -} - -func (cook UngrabButtonCookie) Check() error { - return cook.check() -} - -// Write request to wire for UngrabButton -func (c *Conn) ungrabButtonRequest(Button byte, GrabWindow Window, Modifiers uint16) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = 29 // request opcode - b += 1 - - buf[b] = Button - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(GrabWindow)) - b += 4 - - Put16(buf[b:], Modifiers) - b += 2 - - b += 2 // padding - - return buf -} - -// Request ChangeActivePointerGrab -// size: 16 -type ChangeActivePointerGrabCookie struct { - *cookie -} - -// Write request to wire for ChangeActivePointerGrab -func (c *Conn) ChangeActivePointerGrab(Cursor Cursor, Time Timestamp, EventMask uint16) ChangeActivePointerGrabCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.changeActivePointerGrabRequest(Cursor, Time, EventMask), cookie) - return ChangeActivePointerGrabCookie{cookie} -} - -func (c *Conn) ChangeActivePointerGrabChecked(Cursor Cursor, Time Timestamp, EventMask uint16) ChangeActivePointerGrabCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.changeActivePointerGrabRequest(Cursor, Time, EventMask), cookie) - return ChangeActivePointerGrabCookie{cookie} -} - -func (cook ChangeActivePointerGrabCookie) Check() error { - return cook.check() -} - -// Write request to wire for ChangeActivePointerGrab -func (c *Conn) changeActivePointerGrabRequest(Cursor Cursor, Time Timestamp, EventMask uint16) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = 30 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cursor)) - b += 4 - - Put32(buf[b:], uint32(Time)) - b += 4 - - Put16(buf[b:], EventMask) - b += 2 - - b += 2 // padding - - return buf -} - -// Request GrabKeyboard -// size: 16 -type GrabKeyboardCookie struct { - *cookie -} - -func (c *Conn) GrabKeyboard(OwnerEvents bool, GrabWindow Window, Time Timestamp, PointerMode byte, KeyboardMode byte) GrabKeyboardCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.grabKeyboardRequest(OwnerEvents, GrabWindow, Time, PointerMode, KeyboardMode), cookie) - return GrabKeyboardCookie{cookie} -} - -func (c *Conn) GrabKeyboardUnchecked(OwnerEvents bool, GrabWindow Window, Time Timestamp, PointerMode byte, KeyboardMode byte) GrabKeyboardCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.grabKeyboardRequest(OwnerEvents, GrabWindow, Time, PointerMode, KeyboardMode), cookie) - return GrabKeyboardCookie{cookie} -} - -// Request reply for GrabKeyboard -// size: 8 -type GrabKeyboardReply struct { - Sequence uint16 - Length uint32 - Status byte -} - -// Waits and reads reply data from request GrabKeyboard -func (cook GrabKeyboardCookie) Reply() (*GrabKeyboardReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return grabKeyboardReply(buf), nil -} - -// Read reply into structure from buffer for GrabKeyboard -func grabKeyboardReply(buf []byte) *GrabKeyboardReply { - v := new(GrabKeyboardReply) - b := 1 // skip reply determinant - - v.Status = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - return v -} - -func (cook GrabKeyboardCookie) Check() error { - return cook.check() -} - -// Write request to wire for GrabKeyboard -func (c *Conn) grabKeyboardRequest(OwnerEvents bool, GrabWindow Window, Time Timestamp, PointerMode byte, KeyboardMode byte) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = 31 // request opcode - b += 1 - - if OwnerEvents { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(GrabWindow)) - b += 4 - - Put32(buf[b:], uint32(Time)) - b += 4 - - buf[b] = PointerMode - b += 1 - - buf[b] = KeyboardMode - b += 1 - - b += 2 // padding - - return buf -} - -// Request UngrabKeyboard -// size: 8 -type UngrabKeyboardCookie struct { - *cookie -} - -// Write request to wire for UngrabKeyboard -func (c *Conn) UngrabKeyboard(Time Timestamp) UngrabKeyboardCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.ungrabKeyboardRequest(Time), cookie) - return UngrabKeyboardCookie{cookie} -} - -func (c *Conn) UngrabKeyboardChecked(Time Timestamp) UngrabKeyboardCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.ungrabKeyboardRequest(Time), cookie) - return UngrabKeyboardCookie{cookie} -} - -func (cook UngrabKeyboardCookie) Check() error { - return cook.check() -} - -// Write request to wire for UngrabKeyboard -func (c *Conn) ungrabKeyboardRequest(Time Timestamp) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 32 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Time)) - b += 4 - - return buf -} - -// Request GrabKey -// size: 16 -type GrabKeyCookie struct { - *cookie -} - -// Write request to wire for GrabKey -func (c *Conn) GrabKey(OwnerEvents bool, GrabWindow Window, Modifiers uint16, Key Keycode, PointerMode byte, KeyboardMode byte) GrabKeyCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.grabKeyRequest(OwnerEvents, GrabWindow, Modifiers, Key, PointerMode, KeyboardMode), cookie) - return GrabKeyCookie{cookie} -} - -func (c *Conn) GrabKeyChecked(OwnerEvents bool, GrabWindow Window, Modifiers uint16, Key Keycode, PointerMode byte, KeyboardMode byte) GrabKeyCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.grabKeyRequest(OwnerEvents, GrabWindow, Modifiers, Key, PointerMode, KeyboardMode), cookie) - return GrabKeyCookie{cookie} -} - -func (cook GrabKeyCookie) Check() error { - return cook.check() -} - -// Write request to wire for GrabKey -func (c *Conn) grabKeyRequest(OwnerEvents bool, GrabWindow Window, Modifiers uint16, Key Keycode, PointerMode byte, KeyboardMode byte) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = 33 // request opcode - b += 1 - - if OwnerEvents { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(GrabWindow)) - b += 4 - - Put16(buf[b:], Modifiers) - b += 2 - - buf[b] = byte(Key) - b += 1 - - buf[b] = PointerMode - b += 1 - - buf[b] = KeyboardMode - b += 1 - - b += 3 // padding - - return buf -} - -// Request UngrabKey -// size: 12 -type UngrabKeyCookie struct { - *cookie -} - -// Write request to wire for UngrabKey -func (c *Conn) UngrabKey(Key Keycode, GrabWindow Window, Modifiers uint16) UngrabKeyCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.ungrabKeyRequest(Key, GrabWindow, Modifiers), cookie) - return UngrabKeyCookie{cookie} -} - -func (c *Conn) UngrabKeyChecked(Key Keycode, GrabWindow Window, Modifiers uint16) UngrabKeyCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.ungrabKeyRequest(Key, GrabWindow, Modifiers), cookie) - return UngrabKeyCookie{cookie} -} - -func (cook UngrabKeyCookie) Check() error { - return cook.check() -} - -// Write request to wire for UngrabKey -func (c *Conn) ungrabKeyRequest(Key Keycode, GrabWindow Window, Modifiers uint16) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = 34 // request opcode - b += 1 - - buf[b] = byte(Key) - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(GrabWindow)) - b += 4 - - Put16(buf[b:], Modifiers) - b += 2 - - b += 2 // padding - - return buf -} - -// Request AllowEvents -// size: 8 -type AllowEventsCookie struct { - *cookie -} - -// Write request to wire for AllowEvents -func (c *Conn) AllowEvents(Mode byte, Time Timestamp) AllowEventsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.allowEventsRequest(Mode, Time), cookie) - return AllowEventsCookie{cookie} -} - -func (c *Conn) AllowEventsChecked(Mode byte, Time Timestamp) AllowEventsCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.allowEventsRequest(Mode, Time), cookie) - return AllowEventsCookie{cookie} -} - -func (cook AllowEventsCookie) Check() error { - return cook.check() -} - -// Write request to wire for AllowEvents -func (c *Conn) allowEventsRequest(Mode byte, Time Timestamp) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 35 // request opcode - b += 1 - - buf[b] = Mode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Time)) - b += 4 - - return buf -} - -// Request GrabServer -// size: 4 -type GrabServerCookie struct { - *cookie -} - -// Write request to wire for GrabServer -func (c *Conn) GrabServer() GrabServerCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.grabServerRequest(), cookie) - return GrabServerCookie{cookie} -} - -func (c *Conn) GrabServerChecked() GrabServerCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.grabServerRequest(), cookie) - return GrabServerCookie{cookie} -} - -func (cook GrabServerCookie) Check() error { - return cook.check() -} - -// Write request to wire for GrabServer -func (c *Conn) grabServerRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 36 // request opcode - b += 1 - - b += 1 // padding - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request UngrabServer -// size: 4 -type UngrabServerCookie struct { - *cookie -} - -// Write request to wire for UngrabServer -func (c *Conn) UngrabServer() UngrabServerCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.ungrabServerRequest(), cookie) - return UngrabServerCookie{cookie} -} - -func (c *Conn) UngrabServerChecked() UngrabServerCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.ungrabServerRequest(), cookie) - return UngrabServerCookie{cookie} -} - -func (cook UngrabServerCookie) Check() error { - return cook.check() -} - -// Write request to wire for UngrabServer -func (c *Conn) ungrabServerRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 37 // request opcode - b += 1 - - b += 1 // padding - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request QueryPointer -// size: 8 -type QueryPointerCookie struct { - *cookie -} - -func (c *Conn) QueryPointer(Window Window) QueryPointerCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.queryPointerRequest(Window), cookie) - return QueryPointerCookie{cookie} -} - -func (c *Conn) QueryPointerUnchecked(Window Window) QueryPointerCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.queryPointerRequest(Window), cookie) - return QueryPointerCookie{cookie} -} - -// Request reply for QueryPointer -// size: 28 -type QueryPointerReply struct { - Sequence uint16 - Length uint32 - SameScreen bool - Root Window - Child Window - RootX int16 - RootY int16 - WinX int16 - WinY int16 - Mask uint16 - // padding: 2 bytes -} - -// Waits and reads reply data from request QueryPointer -func (cook QueryPointerCookie) Reply() (*QueryPointerReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return queryPointerReply(buf), nil -} - -// Read reply into structure from buffer for QueryPointer -func queryPointerReply(buf []byte) *QueryPointerReply { - v := new(QueryPointerReply) - b := 1 // skip reply determinant - - if buf[b] == 1 { - v.SameScreen = true - } else { - v.SameScreen = false - } - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Root = Window(Get32(buf[b:])) - b += 4 - - v.Child = Window(Get32(buf[b:])) - b += 4 - - v.RootX = int16(Get16(buf[b:])) - b += 2 - - v.RootY = int16(Get16(buf[b:])) - b += 2 - - v.WinX = int16(Get16(buf[b:])) - b += 2 - - v.WinY = int16(Get16(buf[b:])) - b += 2 - - v.Mask = Get16(buf[b:]) - b += 2 - - b += 2 // padding - - return v -} - -func (cook QueryPointerCookie) Check() error { - return cook.check() -} - -// Write request to wire for QueryPointer -func (c *Conn) queryPointerRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 38 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - return buf -} - -// Request GetMotionEvents -// size: 16 -type GetMotionEventsCookie struct { - *cookie -} - -func (c *Conn) GetMotionEvents(Window Window, Start Timestamp, Stop Timestamp) GetMotionEventsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.getMotionEventsRequest(Window, Start, Stop), cookie) - return GetMotionEventsCookie{cookie} -} - -func (c *Conn) GetMotionEventsUnchecked(Window Window, Start Timestamp, Stop Timestamp) GetMotionEventsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.getMotionEventsRequest(Window, Start, Stop), cookie) - return GetMotionEventsCookie{cookie} -} - -// Request reply for GetMotionEvents -// size: (32 + pad((int(EventsLen) * 8))) -type GetMotionEventsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - EventsLen uint32 - // padding: 20 bytes - Events []Timecoord // size: pad((int(EventsLen) * 8)) -} - -// Waits and reads reply data from request GetMotionEvents -func (cook GetMotionEventsCookie) Reply() (*GetMotionEventsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getMotionEventsReply(buf), nil -} - -// Read reply into structure from buffer for GetMotionEvents -func getMotionEventsReply(buf []byte) *GetMotionEventsReply { - v := new(GetMotionEventsReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.EventsLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Events = make([]Timecoord, v.EventsLen) - b += ReadTimecoordList(buf[b:], v.Events) - - return v -} - -func (cook GetMotionEventsCookie) Check() error { - return cook.check() -} - -// Write request to wire for GetMotionEvents -func (c *Conn) getMotionEventsRequest(Window Window, Start Timestamp, Stop Timestamp) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = 39 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - Put32(buf[b:], uint32(Start)) - b += 4 - - Put32(buf[b:], uint32(Stop)) - b += 4 - - return buf -} - -// Request TranslateCoordinates -// size: 16 -type TranslateCoordinatesCookie struct { - *cookie -} - -func (c *Conn) TranslateCoordinates(SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16) TranslateCoordinatesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.translateCoordinatesRequest(SrcWindow, DstWindow, SrcX, SrcY), cookie) - return TranslateCoordinatesCookie{cookie} -} - -func (c *Conn) TranslateCoordinatesUnchecked(SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16) TranslateCoordinatesCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.translateCoordinatesRequest(SrcWindow, DstWindow, SrcX, SrcY), cookie) - return TranslateCoordinatesCookie{cookie} -} - -// Request reply for TranslateCoordinates -// size: 16 -type TranslateCoordinatesReply struct { - Sequence uint16 - Length uint32 - SameScreen bool - Child Window - DstX int16 - DstY int16 -} - -// Waits and reads reply data from request TranslateCoordinates -func (cook TranslateCoordinatesCookie) Reply() (*TranslateCoordinatesReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return translateCoordinatesReply(buf), nil -} - -// Read reply into structure from buffer for TranslateCoordinates -func translateCoordinatesReply(buf []byte) *TranslateCoordinatesReply { - v := new(TranslateCoordinatesReply) - b := 1 // skip reply determinant - - if buf[b] == 1 { - v.SameScreen = true - } else { - v.SameScreen = false - } - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Child = Window(Get32(buf[b:])) - b += 4 - - v.DstX = int16(Get16(buf[b:])) - b += 2 - - v.DstY = int16(Get16(buf[b:])) - b += 2 - - return v -} - -func (cook TranslateCoordinatesCookie) Check() error { - return cook.check() -} - -// Write request to wire for TranslateCoordinates -func (c *Conn) translateCoordinatesRequest(SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = 40 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(SrcWindow)) - b += 4 - - Put32(buf[b:], uint32(DstWindow)) - b += 4 - - Put16(buf[b:], uint16(SrcX)) - b += 2 - - Put16(buf[b:], uint16(SrcY)) - b += 2 - - return buf -} - -// Request WarpPointer -// size: 24 -type WarpPointerCookie struct { - *cookie -} - -// Write request to wire for WarpPointer -func (c *Conn) WarpPointer(SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16) WarpPointerCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.warpPointerRequest(SrcWindow, DstWindow, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY), cookie) - return WarpPointerCookie{cookie} -} - -func (c *Conn) WarpPointerChecked(SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16) WarpPointerCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.warpPointerRequest(SrcWindow, DstWindow, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY), cookie) - return WarpPointerCookie{cookie} -} - -func (cook WarpPointerCookie) Check() error { - return cook.check() -} - -// Write request to wire for WarpPointer -func (c *Conn) warpPointerRequest(SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16) []byte { - size := 24 - b := 0 - buf := make([]byte, size) - - buf[b] = 41 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(SrcWindow)) - b += 4 - - Put32(buf[b:], uint32(DstWindow)) - b += 4 - - Put16(buf[b:], uint16(SrcX)) - b += 2 - - Put16(buf[b:], uint16(SrcY)) - b += 2 - - Put16(buf[b:], SrcWidth) - b += 2 - - Put16(buf[b:], SrcHeight) - b += 2 - - Put16(buf[b:], uint16(DstX)) - b += 2 - - Put16(buf[b:], uint16(DstY)) - b += 2 - - return buf -} - -// Request SetInputFocus -// size: 12 -type SetInputFocusCookie struct { - *cookie -} - -// Write request to wire for SetInputFocus -func (c *Conn) SetInputFocus(RevertTo byte, Focus Window, Time Timestamp) SetInputFocusCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.setInputFocusRequest(RevertTo, Focus, Time), cookie) - return SetInputFocusCookie{cookie} -} - -func (c *Conn) SetInputFocusChecked(RevertTo byte, Focus Window, Time Timestamp) SetInputFocusCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.setInputFocusRequest(RevertTo, Focus, Time), cookie) - return SetInputFocusCookie{cookie} -} - -func (cook SetInputFocusCookie) Check() error { - return cook.check() -} - -// Write request to wire for SetInputFocus -func (c *Conn) setInputFocusRequest(RevertTo byte, Focus Window, Time Timestamp) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = 42 // request opcode - b += 1 - - buf[b] = RevertTo - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Focus)) - b += 4 - - Put32(buf[b:], uint32(Time)) - b += 4 - - return buf -} - -// Request GetInputFocus -// size: 4 -type GetInputFocusCookie struct { - *cookie -} - -func (c *Conn) GetInputFocus() GetInputFocusCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.getInputFocusRequest(), cookie) - return GetInputFocusCookie{cookie} -} - -func (c *Conn) GetInputFocusUnchecked() GetInputFocusCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.getInputFocusRequest(), cookie) - return GetInputFocusCookie{cookie} -} - -// Request reply for GetInputFocus -// size: 12 -type GetInputFocusReply struct { - Sequence uint16 - Length uint32 - RevertTo byte - Focus Window -} - -// Waits and reads reply data from request GetInputFocus -func (cook GetInputFocusCookie) Reply() (*GetInputFocusReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getInputFocusReply(buf), nil -} - -// Read reply into structure from buffer for GetInputFocus -func getInputFocusReply(buf []byte) *GetInputFocusReply { - v := new(GetInputFocusReply) - b := 1 // skip reply determinant - - v.RevertTo = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Focus = Window(Get32(buf[b:])) - b += 4 - - return v -} - -func (cook GetInputFocusCookie) Check() error { - return cook.check() -} - -// Write request to wire for GetInputFocus -func (c *Conn) getInputFocusRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 43 // request opcode - b += 1 - - b += 1 // padding - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request QueryKeymap -// size: 4 -type QueryKeymapCookie struct { - *cookie -} - -func (c *Conn) QueryKeymap() QueryKeymapCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.queryKeymapRequest(), cookie) - return QueryKeymapCookie{cookie} -} - -func (c *Conn) QueryKeymapUnchecked() QueryKeymapCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.queryKeymapRequest(), cookie) - return QueryKeymapCookie{cookie} -} - -// Request reply for QueryKeymap -// size: 40 -type QueryKeymapReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Keys []byte // size: 32 -} - -// Waits and reads reply data from request QueryKeymap -func (cook QueryKeymapCookie) Reply() (*QueryKeymapReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return queryKeymapReply(buf), nil -} - -// Read reply into structure from buffer for QueryKeymap -func queryKeymapReply(buf []byte) *QueryKeymapReply { - v := new(QueryKeymapReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Keys = make([]byte, 32) - copy(v.Keys[:32], buf[b:]) - b += pad(int(32)) - - return v -} - -func (cook QueryKeymapCookie) Check() error { - return cook.check() -} - -// Write request to wire for QueryKeymap -func (c *Conn) queryKeymapRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 44 // request opcode - b += 1 - - b += 1 // padding - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request OpenFont -// size: pad((12 + pad((int(NameLen) * 1)))) -type OpenFontCookie struct { - *cookie -} - -// Write request to wire for OpenFont -func (c *Conn) OpenFont(Fid Font, NameLen uint16, Name string) OpenFontCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.openFontRequest(Fid, NameLen, Name), cookie) - return OpenFontCookie{cookie} -} - -func (c *Conn) OpenFontChecked(Fid Font, NameLen uint16, Name string) OpenFontCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.openFontRequest(Fid, NameLen, Name), cookie) - return OpenFontCookie{cookie} -} - -func (cook OpenFontCookie) Check() error { - return cook.check() -} - -// Write request to wire for OpenFont -func (c *Conn) openFontRequest(Fid Font, NameLen uint16, Name string) []byte { - size := pad((12 + pad((int(NameLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 45 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Fid)) - b += 4 - - Put16(buf[b:], NameLen) - b += 2 - - b += 2 // padding - - copy(buf[b:], Name[:NameLen]) - b += pad(int(NameLen)) - - return buf -} - -// Request CloseFont -// size: 8 -type CloseFontCookie struct { - *cookie -} - -// Write request to wire for CloseFont -func (c *Conn) CloseFont(Font Font) CloseFontCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.closeFontRequest(Font), cookie) - return CloseFontCookie{cookie} -} - -func (c *Conn) CloseFontChecked(Font Font) CloseFontCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.closeFontRequest(Font), cookie) - return CloseFontCookie{cookie} -} - -func (cook CloseFontCookie) Check() error { - return cook.check() -} - -// Write request to wire for CloseFont -func (c *Conn) closeFontRequest(Font Font) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 46 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Font)) - b += 4 - - return buf -} - -// Request QueryFont -// size: 8 -type QueryFontCookie struct { - *cookie -} - -func (c *Conn) QueryFont(Font Fontable) QueryFontCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.queryFontRequest(Font), cookie) - return QueryFontCookie{cookie} -} - -func (c *Conn) QueryFontUnchecked(Font Fontable) QueryFontCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.queryFontRequest(Font), cookie) - return QueryFontCookie{cookie} -} - -// Request reply for QueryFont -// size: ((60 + pad((int(PropertiesLen) * 8))) + pad((int(CharInfosLen) * 12))) -type QueryFontReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - MinBounds Charinfo - // padding: 4 bytes - MaxBounds Charinfo - // padding: 4 bytes - MinCharOrByte2 uint16 - MaxCharOrByte2 uint16 - DefaultChar uint16 - PropertiesLen uint16 - DrawDirection byte - MinByte1 byte - MaxByte1 byte - AllCharsExist bool - FontAscent int16 - FontDescent int16 - CharInfosLen uint32 - Properties []Fontprop // size: pad((int(PropertiesLen) * 8)) - CharInfos []Charinfo // size: pad((int(CharInfosLen) * 12)) -} - -// Waits and reads reply data from request QueryFont -func (cook QueryFontCookie) Reply() (*QueryFontReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return queryFontReply(buf), nil -} - -// Read reply into structure from buffer for QueryFont -func queryFontReply(buf []byte) *QueryFontReply { - v := new(QueryFontReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.MinBounds = Charinfo{} - b += ReadCharinfo(buf[b:], &v.MinBounds) - - b += 4 // padding - - v.MaxBounds = Charinfo{} - b += ReadCharinfo(buf[b:], &v.MaxBounds) - - b += 4 // padding - - v.MinCharOrByte2 = Get16(buf[b:]) - b += 2 - - v.MaxCharOrByte2 = Get16(buf[b:]) - b += 2 - - v.DefaultChar = Get16(buf[b:]) - b += 2 - - v.PropertiesLen = Get16(buf[b:]) - b += 2 - - v.DrawDirection = buf[b] - b += 1 - - v.MinByte1 = buf[b] - b += 1 - - v.MaxByte1 = buf[b] - b += 1 - - if buf[b] == 1 { - v.AllCharsExist = true - } else { - v.AllCharsExist = false - } - b += 1 - - v.FontAscent = int16(Get16(buf[b:])) - b += 2 - - v.FontDescent = int16(Get16(buf[b:])) - b += 2 - - v.CharInfosLen = Get32(buf[b:]) - b += 4 - - v.Properties = make([]Fontprop, v.PropertiesLen) - b += ReadFontpropList(buf[b:], v.Properties) - - v.CharInfos = make([]Charinfo, v.CharInfosLen) - b += ReadCharinfoList(buf[b:], v.CharInfos) - - return v -} - -func (cook QueryFontCookie) Check() error { - return cook.check() -} - -// Write request to wire for QueryFont -func (c *Conn) queryFontRequest(Font Fontable) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 47 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Font)) - b += 4 - - return buf -} - -// Request QueryTextExtents -// size: pad((8 + pad((len(String) * 2)))) -type QueryTextExtentsCookie struct { - *cookie -} - -func (c *Conn) QueryTextExtents(Font Fontable, String []Char2b, StringLen uint16) QueryTextExtentsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.queryTextExtentsRequest(Font, String, StringLen), cookie) - return QueryTextExtentsCookie{cookie} -} - -func (c *Conn) QueryTextExtentsUnchecked(Font Fontable, String []Char2b, StringLen uint16) QueryTextExtentsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.queryTextExtentsRequest(Font, String, StringLen), cookie) - return QueryTextExtentsCookie{cookie} -} - -// Request reply for QueryTextExtents -// size: 28 -type QueryTextExtentsReply struct { - Sequence uint16 - Length uint32 - DrawDirection byte - FontAscent int16 - FontDescent int16 - OverallAscent int16 - OverallDescent int16 - OverallWidth int32 - OverallLeft int32 - OverallRight int32 -} - -// Waits and reads reply data from request QueryTextExtents -func (cook QueryTextExtentsCookie) Reply() (*QueryTextExtentsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return queryTextExtentsReply(buf), nil -} - -// Read reply into structure from buffer for QueryTextExtents -func queryTextExtentsReply(buf []byte) *QueryTextExtentsReply { - v := new(QueryTextExtentsReply) - b := 1 // skip reply determinant - - v.DrawDirection = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.FontAscent = int16(Get16(buf[b:])) - b += 2 - - v.FontDescent = int16(Get16(buf[b:])) - b += 2 - - v.OverallAscent = int16(Get16(buf[b:])) - b += 2 - - v.OverallDescent = int16(Get16(buf[b:])) - b += 2 - - v.OverallWidth = int32(Get32(buf[b:])) - b += 4 - - v.OverallLeft = int32(Get32(buf[b:])) - b += 4 - - v.OverallRight = int32(Get32(buf[b:])) - b += 4 - - return v -} - -func (cook QueryTextExtentsCookie) Check() error { - return cook.check() -} - -// Write request to wire for QueryTextExtents -func (c *Conn) queryTextExtentsRequest(Font Fontable, String []Char2b, StringLen uint16) []byte { - size := pad((8 + pad((len(String) * 2)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 48 // request opcode - b += 1 - - buf[b] = byte((int(StringLen) & 1)) - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Font)) - b += 4 - - b += Char2bListBytes(buf[b:], String) - - // skip writing local field: StringLen (2) :: uint16 - - return buf -} - -// Request ListFonts -// size: pad((8 + pad((int(PatternLen) * 1)))) -type ListFontsCookie struct { - *cookie -} - -func (c *Conn) ListFonts(MaxNames uint16, PatternLen uint16, Pattern string) ListFontsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.listFontsRequest(MaxNames, PatternLen, Pattern), cookie) - return ListFontsCookie{cookie} -} - -func (c *Conn) ListFontsUnchecked(MaxNames uint16, PatternLen uint16, Pattern string) ListFontsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.listFontsRequest(MaxNames, PatternLen, Pattern), cookie) - return ListFontsCookie{cookie} -} - -// Request reply for ListFonts -// size: (32 + StrListSize(Names)) -type ListFontsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NamesLen uint16 - // padding: 22 bytes - Names []Str // size: StrListSize(Names) -} - -// Waits and reads reply data from request ListFonts -func (cook ListFontsCookie) Reply() (*ListFontsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return listFontsReply(buf), nil -} - -// Read reply into structure from buffer for ListFonts -func listFontsReply(buf []byte) *ListFontsReply { - v := new(ListFontsReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.NamesLen = Get16(buf[b:]) - b += 2 - - b += 22 // padding - - v.Names = make([]Str, v.NamesLen) - b += ReadStrList(buf[b:], v.Names) - - return v -} - -func (cook ListFontsCookie) Check() error { - return cook.check() -} - -// Write request to wire for ListFonts -func (c *Conn) listFontsRequest(MaxNames uint16, PatternLen uint16, Pattern string) []byte { - size := pad((8 + pad((int(PatternLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 49 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], MaxNames) - b += 2 - - Put16(buf[b:], PatternLen) - b += 2 - - copy(buf[b:], Pattern[:PatternLen]) - b += pad(int(PatternLen)) - - return buf -} - -// Request ListFontsWithInfo -// size: pad((8 + pad((int(PatternLen) * 1)))) -type ListFontsWithInfoCookie struct { - *cookie -} - -func (c *Conn) ListFontsWithInfo(MaxNames uint16, PatternLen uint16, Pattern string) ListFontsWithInfoCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.listFontsWithInfoRequest(MaxNames, PatternLen, Pattern), cookie) - return ListFontsWithInfoCookie{cookie} -} - -func (c *Conn) ListFontsWithInfoUnchecked(MaxNames uint16, PatternLen uint16, Pattern string) ListFontsWithInfoCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.listFontsWithInfoRequest(MaxNames, PatternLen, Pattern), cookie) - return ListFontsWithInfoCookie{cookie} -} - -// Request reply for ListFontsWithInfo -// size: ((60 + pad((int(PropertiesLen) * 8))) + pad((int(NameLen) * 1))) -type ListFontsWithInfoReply struct { - Sequence uint16 - Length uint32 - NameLen byte - MinBounds Charinfo - // padding: 4 bytes - MaxBounds Charinfo - // padding: 4 bytes - MinCharOrByte2 uint16 - MaxCharOrByte2 uint16 - DefaultChar uint16 - PropertiesLen uint16 - DrawDirection byte - MinByte1 byte - MaxByte1 byte - AllCharsExist bool - FontAscent int16 - FontDescent int16 - RepliesHint uint32 - Properties []Fontprop // size: pad((int(PropertiesLen) * 8)) - Name string // size: pad((int(NameLen) * 1)) -} - -// Waits and reads reply data from request ListFontsWithInfo -func (cook ListFontsWithInfoCookie) Reply() (*ListFontsWithInfoReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return listFontsWithInfoReply(buf), nil -} - -// Read reply into structure from buffer for ListFontsWithInfo -func listFontsWithInfoReply(buf []byte) *ListFontsWithInfoReply { - v := new(ListFontsWithInfoReply) - b := 1 // skip reply determinant - - v.NameLen = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.MinBounds = Charinfo{} - b += ReadCharinfo(buf[b:], &v.MinBounds) - - b += 4 // padding - - v.MaxBounds = Charinfo{} - b += ReadCharinfo(buf[b:], &v.MaxBounds) - - b += 4 // padding - - v.MinCharOrByte2 = Get16(buf[b:]) - b += 2 - - v.MaxCharOrByte2 = Get16(buf[b:]) - b += 2 - - v.DefaultChar = Get16(buf[b:]) - b += 2 - - v.PropertiesLen = Get16(buf[b:]) - b += 2 - - v.DrawDirection = buf[b] - b += 1 - - v.MinByte1 = buf[b] - b += 1 - - v.MaxByte1 = buf[b] - b += 1 - - if buf[b] == 1 { - v.AllCharsExist = true - } else { - v.AllCharsExist = false - } - b += 1 - - v.FontAscent = int16(Get16(buf[b:])) - b += 2 - - v.FontDescent = int16(Get16(buf[b:])) - b += 2 - - v.RepliesHint = Get32(buf[b:]) - b += 4 - - v.Properties = make([]Fontprop, v.PropertiesLen) - b += ReadFontpropList(buf[b:], v.Properties) - - { - byteString := make([]byte, v.NameLen) - copy(byteString[:v.NameLen], buf[b:]) - v.Name = string(byteString) - b += pad(int(v.NameLen)) - } - - return v -} - -func (cook ListFontsWithInfoCookie) Check() error { - return cook.check() -} - -// Write request to wire for ListFontsWithInfo -func (c *Conn) listFontsWithInfoRequest(MaxNames uint16, PatternLen uint16, Pattern string) []byte { - size := pad((8 + pad((int(PatternLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 50 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], MaxNames) - b += 2 - - Put16(buf[b:], PatternLen) - b += 2 - - copy(buf[b:], Pattern[:PatternLen]) - b += pad(int(PatternLen)) - - return buf -} - -// Request SetFontPath -// size: pad((8 + StrListSize(Font))) -type SetFontPathCookie struct { - *cookie -} - -// Write request to wire for SetFontPath -func (c *Conn) SetFontPath(FontQty uint16, Font []Str) SetFontPathCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.setFontPathRequest(FontQty, Font), cookie) - return SetFontPathCookie{cookie} -} - -func (c *Conn) SetFontPathChecked(FontQty uint16, Font []Str) SetFontPathCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.setFontPathRequest(FontQty, Font), cookie) - return SetFontPathCookie{cookie} -} - -func (cook SetFontPathCookie) Check() error { - return cook.check() -} - -// Write request to wire for SetFontPath -func (c *Conn) setFontPathRequest(FontQty uint16, Font []Str) []byte { - size := pad((8 + StrListSize(Font))) - b := 0 - buf := make([]byte, size) - - buf[b] = 51 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], FontQty) - b += 2 - - b += 2 // padding - - b += StrListBytes(buf[b:], Font) - - return buf -} - -// Request GetFontPath -// size: 4 -type GetFontPathCookie struct { - *cookie -} - -func (c *Conn) GetFontPath() GetFontPathCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.getFontPathRequest(), cookie) - return GetFontPathCookie{cookie} -} - -func (c *Conn) GetFontPathUnchecked() GetFontPathCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.getFontPathRequest(), cookie) - return GetFontPathCookie{cookie} -} - -// Request reply for GetFontPath -// size: (32 + StrListSize(Path)) -type GetFontPathReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - PathLen uint16 - // padding: 22 bytes - Path []Str // size: StrListSize(Path) -} - -// Waits and reads reply data from request GetFontPath -func (cook GetFontPathCookie) Reply() (*GetFontPathReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getFontPathReply(buf), nil -} - -// Read reply into structure from buffer for GetFontPath -func getFontPathReply(buf []byte) *GetFontPathReply { - v := new(GetFontPathReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.PathLen = Get16(buf[b:]) - b += 2 - - b += 22 // padding - - v.Path = make([]Str, v.PathLen) - b += ReadStrList(buf[b:], v.Path) - - return v -} - -func (cook GetFontPathCookie) Check() error { - return cook.check() -} - -// Write request to wire for GetFontPath -func (c *Conn) getFontPathRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 52 // request opcode - b += 1 - - b += 1 // padding - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request CreatePixmap -// size: 16 -type CreatePixmapCookie struct { - *cookie -} - -// Write request to wire for CreatePixmap -func (c *Conn) CreatePixmap(Depth byte, Pid Pixmap, Drawable Drawable, Width uint16, Height uint16) CreatePixmapCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.createPixmapRequest(Depth, Pid, Drawable, Width, Height), cookie) - return CreatePixmapCookie{cookie} -} - -func (c *Conn) CreatePixmapChecked(Depth byte, Pid Pixmap, Drawable Drawable, Width uint16, Height uint16) CreatePixmapCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.createPixmapRequest(Depth, Pid, Drawable, Width, Height), cookie) - return CreatePixmapCookie{cookie} -} - -func (cook CreatePixmapCookie) Check() error { - return cook.check() -} - -// Write request to wire for CreatePixmap -func (c *Conn) createPixmapRequest(Depth byte, Pid Pixmap, Drawable Drawable, Width uint16, Height uint16) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = 53 // request opcode - b += 1 - - buf[b] = Depth - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Pid)) - b += 4 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put16(buf[b:], Width) - b += 2 - - Put16(buf[b:], Height) - b += 2 - - return buf -} - -// Request FreePixmap -// size: 8 -type FreePixmapCookie struct { - *cookie -} - -// Write request to wire for FreePixmap -func (c *Conn) FreePixmap(Pixmap Pixmap) FreePixmapCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.freePixmapRequest(Pixmap), cookie) - return FreePixmapCookie{cookie} -} - -func (c *Conn) FreePixmapChecked(Pixmap Pixmap) FreePixmapCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.freePixmapRequest(Pixmap), cookie) - return FreePixmapCookie{cookie} -} - -func (cook FreePixmapCookie) Check() error { - return cook.check() -} - -// Write request to wire for FreePixmap -func (c *Conn) freePixmapRequest(Pixmap Pixmap) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 54 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Pixmap)) - b += 4 - - return buf -} - -// Request CreateGC -// size: pad((12 + (4 + pad((4 * popCount(int(ValueMask))))))) -type CreateGCCookie struct { - *cookie -} - -// Write request to wire for CreateGC -func (c *Conn) CreateGC(Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) CreateGCCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.createGCRequest(Cid, Drawable, ValueMask, ValueList), cookie) - return CreateGCCookie{cookie} -} - -func (c *Conn) CreateGCChecked(Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) CreateGCCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.createGCRequest(Cid, Drawable, ValueMask, ValueList), cookie) - return CreateGCCookie{cookie} -} - -func (cook CreateGCCookie) Check() error { - return cook.check() -} - -// Write request to wire for CreateGC -func (c *Conn) createGCRequest(Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) []byte { - size := pad((12 + (4 + pad((4 * popCount(int(ValueMask))))))) - b := 0 - buf := make([]byte, size) - - buf[b] = 55 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cid)) - b += 4 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], ValueMask) - b += 4 - for i := 0; i < popCount(int(ValueMask)); i++ { - Put32(buf[b:], ValueList[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Request ChangeGC -// size: pad((8 + (4 + pad((4 * popCount(int(ValueMask))))))) -type ChangeGCCookie struct { - *cookie -} - -// Write request to wire for ChangeGC -func (c *Conn) ChangeGC(Gc Gcontext, ValueMask uint32, ValueList []uint32) ChangeGCCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.changeGCRequest(Gc, ValueMask, ValueList), cookie) - return ChangeGCCookie{cookie} -} - -func (c *Conn) ChangeGCChecked(Gc Gcontext, ValueMask uint32, ValueList []uint32) ChangeGCCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.changeGCRequest(Gc, ValueMask, ValueList), cookie) - return ChangeGCCookie{cookie} -} - -func (cook ChangeGCCookie) Check() error { - return cook.check() -} - -// Write request to wire for ChangeGC -func (c *Conn) changeGCRequest(Gc Gcontext, ValueMask uint32, ValueList []uint32) []byte { - size := pad((8 + (4 + pad((4 * popCount(int(ValueMask))))))) - b := 0 - buf := make([]byte, size) - - buf[b] = 56 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - Put32(buf[b:], ValueMask) - b += 4 - for i := 0; i < popCount(int(ValueMask)); i++ { - Put32(buf[b:], ValueList[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Request CopyGC -// size: 16 -type CopyGCCookie struct { - *cookie -} - -// Write request to wire for CopyGC -func (c *Conn) CopyGC(SrcGc Gcontext, DstGc Gcontext, ValueMask uint32) CopyGCCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.copyGCRequest(SrcGc, DstGc, ValueMask), cookie) - return CopyGCCookie{cookie} -} - -func (c *Conn) CopyGCChecked(SrcGc Gcontext, DstGc Gcontext, ValueMask uint32) CopyGCCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.copyGCRequest(SrcGc, DstGc, ValueMask), cookie) - return CopyGCCookie{cookie} -} - -func (cook CopyGCCookie) Check() error { - return cook.check() -} - -// Write request to wire for CopyGC -func (c *Conn) copyGCRequest(SrcGc Gcontext, DstGc Gcontext, ValueMask uint32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = 57 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(SrcGc)) - b += 4 - - Put32(buf[b:], uint32(DstGc)) - b += 4 - - Put32(buf[b:], ValueMask) - b += 4 - - return buf -} - -// Request SetDashes -// size: pad((12 + pad((int(DashesLen) * 1)))) -type SetDashesCookie struct { - *cookie -} - -// Write request to wire for SetDashes -func (c *Conn) SetDashes(Gc Gcontext, DashOffset uint16, DashesLen uint16, Dashes []byte) SetDashesCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.setDashesRequest(Gc, DashOffset, DashesLen, Dashes), cookie) - return SetDashesCookie{cookie} -} - -func (c *Conn) SetDashesChecked(Gc Gcontext, DashOffset uint16, DashesLen uint16, Dashes []byte) SetDashesCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.setDashesRequest(Gc, DashOffset, DashesLen, Dashes), cookie) - return SetDashesCookie{cookie} -} - -func (cook SetDashesCookie) Check() error { - return cook.check() -} - -// Write request to wire for SetDashes -func (c *Conn) setDashesRequest(Gc Gcontext, DashOffset uint16, DashesLen uint16, Dashes []byte) []byte { - size := pad((12 + pad((int(DashesLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 58 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - Put16(buf[b:], DashOffset) - b += 2 - - Put16(buf[b:], DashesLen) - b += 2 - - copy(buf[b:], Dashes[:DashesLen]) - b += pad(int(DashesLen)) - - return buf -} - -// Request SetClipRectangles -// size: pad((12 + pad((len(Rectangles) * 8)))) -type SetClipRectanglesCookie struct { - *cookie -} - -// Write request to wire for SetClipRectangles -func (c *Conn) SetClipRectangles(Ordering byte, Gc Gcontext, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) SetClipRectanglesCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.setClipRectanglesRequest(Ordering, Gc, ClipXOrigin, ClipYOrigin, Rectangles), cookie) - return SetClipRectanglesCookie{cookie} -} - -func (c *Conn) SetClipRectanglesChecked(Ordering byte, Gc Gcontext, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) SetClipRectanglesCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.setClipRectanglesRequest(Ordering, Gc, ClipXOrigin, ClipYOrigin, Rectangles), cookie) - return SetClipRectanglesCookie{cookie} -} - -func (cook SetClipRectanglesCookie) Check() error { - return cook.check() -} - -// Write request to wire for SetClipRectangles -func (c *Conn) setClipRectanglesRequest(Ordering byte, Gc Gcontext, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) []byte { - size := pad((12 + pad((len(Rectangles) * 8)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 59 // request opcode - b += 1 - - buf[b] = Ordering - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - Put16(buf[b:], uint16(ClipXOrigin)) - b += 2 - - Put16(buf[b:], uint16(ClipYOrigin)) - b += 2 - - b += RectangleListBytes(buf[b:], Rectangles) - - return buf -} - -// Request FreeGC -// size: 8 -type FreeGCCookie struct { - *cookie -} - -// Write request to wire for FreeGC -func (c *Conn) FreeGC(Gc Gcontext) FreeGCCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.freeGCRequest(Gc), cookie) - return FreeGCCookie{cookie} -} - -func (c *Conn) FreeGCChecked(Gc Gcontext) FreeGCCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.freeGCRequest(Gc), cookie) - return FreeGCCookie{cookie} -} - -func (cook FreeGCCookie) Check() error { - return cook.check() -} - -// Write request to wire for FreeGC -func (c *Conn) freeGCRequest(Gc Gcontext) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 60 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - return buf -} - -// Request ClearArea -// size: 16 -type ClearAreaCookie struct { - *cookie -} - -// Write request to wire for ClearArea -func (c *Conn) ClearArea(Exposures bool, Window Window, X int16, Y int16, Width uint16, Height uint16) ClearAreaCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.clearAreaRequest(Exposures, Window, X, Y, Width, Height), cookie) - return ClearAreaCookie{cookie} -} - -func (c *Conn) ClearAreaChecked(Exposures bool, Window Window, X int16, Y int16, Width uint16, Height uint16) ClearAreaCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.clearAreaRequest(Exposures, Window, X, Y, Width, Height), cookie) - return ClearAreaCookie{cookie} -} - -func (cook ClearAreaCookie) Check() error { - return cook.check() -} - -// Write request to wire for ClearArea -func (c *Conn) clearAreaRequest(Exposures bool, Window Window, X int16, Y int16, Width uint16, Height uint16) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = 61 // request opcode - b += 1 - - if Exposures { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - Put16(buf[b:], uint16(X)) - b += 2 - - Put16(buf[b:], uint16(Y)) - b += 2 - - Put16(buf[b:], Width) - b += 2 - - Put16(buf[b:], Height) - b += 2 - - return buf -} - -// Request CopyArea -// size: 28 -type CopyAreaCookie struct { - *cookie -} - -// Write request to wire for CopyArea -func (c *Conn) CopyArea(SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16) CopyAreaCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.copyAreaRequest(SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height), cookie) - return CopyAreaCookie{cookie} -} - -func (c *Conn) CopyAreaChecked(SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16) CopyAreaCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.copyAreaRequest(SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height), cookie) - return CopyAreaCookie{cookie} -} - -func (cook CopyAreaCookie) Check() error { - return cook.check() -} - -// Write request to wire for CopyArea -func (c *Conn) copyAreaRequest(SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16) []byte { - size := 28 - b := 0 - buf := make([]byte, size) - - buf[b] = 62 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(SrcDrawable)) - b += 4 - - Put32(buf[b:], uint32(DstDrawable)) - b += 4 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - Put16(buf[b:], uint16(SrcX)) - b += 2 - - Put16(buf[b:], uint16(SrcY)) - b += 2 - - Put16(buf[b:], uint16(DstX)) - b += 2 - - Put16(buf[b:], uint16(DstY)) - b += 2 - - Put16(buf[b:], Width) - b += 2 - - Put16(buf[b:], Height) - b += 2 - - return buf -} - -// Request CopyPlane -// size: 32 -type CopyPlaneCookie struct { - *cookie -} - -// Write request to wire for CopyPlane -func (c *Conn) CopyPlane(SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16, BitPlane uint32) CopyPlaneCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.copyPlaneRequest(SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height, BitPlane), cookie) - return CopyPlaneCookie{cookie} -} - -func (c *Conn) CopyPlaneChecked(SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16, BitPlane uint32) CopyPlaneCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.copyPlaneRequest(SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height, BitPlane), cookie) - return CopyPlaneCookie{cookie} -} - -func (cook CopyPlaneCookie) Check() error { - return cook.check() -} - -// Write request to wire for CopyPlane -func (c *Conn) copyPlaneRequest(SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16, BitPlane uint32) []byte { - size := 32 - b := 0 - buf := make([]byte, size) - - buf[b] = 63 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(SrcDrawable)) - b += 4 - - Put32(buf[b:], uint32(DstDrawable)) - b += 4 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - Put16(buf[b:], uint16(SrcX)) - b += 2 - - Put16(buf[b:], uint16(SrcY)) - b += 2 - - Put16(buf[b:], uint16(DstX)) - b += 2 - - Put16(buf[b:], uint16(DstY)) - b += 2 - - Put16(buf[b:], Width) - b += 2 - - Put16(buf[b:], Height) - b += 2 - - Put32(buf[b:], BitPlane) - b += 4 - - return buf -} - -// Request PolyPoint -// size: pad((12 + pad((len(Points) * 4)))) -type PolyPointCookie struct { - *cookie -} - -// Write request to wire for PolyPoint -func (c *Conn) PolyPoint(CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyPointCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.polyPointRequest(CoordinateMode, Drawable, Gc, Points), cookie) - return PolyPointCookie{cookie} -} - -func (c *Conn) PolyPointChecked(CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyPointCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.polyPointRequest(CoordinateMode, Drawable, Gc, Points), cookie) - return PolyPointCookie{cookie} -} - -func (cook PolyPointCookie) Check() error { - return cook.check() -} - -// Write request to wire for PolyPoint -func (c *Conn) polyPointRequest(CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) []byte { - size := pad((12 + pad((len(Points) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 64 // request opcode - b += 1 - - buf[b] = CoordinateMode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - b += PointListBytes(buf[b:], Points) - - return buf -} - -// Request PolyLine -// size: pad((12 + pad((len(Points) * 4)))) -type PolyLineCookie struct { - *cookie -} - -// Write request to wire for PolyLine -func (c *Conn) PolyLine(CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyLineCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.polyLineRequest(CoordinateMode, Drawable, Gc, Points), cookie) - return PolyLineCookie{cookie} -} - -func (c *Conn) PolyLineChecked(CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyLineCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.polyLineRequest(CoordinateMode, Drawable, Gc, Points), cookie) - return PolyLineCookie{cookie} -} - -func (cook PolyLineCookie) Check() error { - return cook.check() -} - -// Write request to wire for PolyLine -func (c *Conn) polyLineRequest(CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) []byte { - size := pad((12 + pad((len(Points) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 65 // request opcode - b += 1 - - buf[b] = CoordinateMode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - b += PointListBytes(buf[b:], Points) - - return buf -} - -// Request PolySegment -// size: pad((12 + pad((len(Segments) * 8)))) -type PolySegmentCookie struct { - *cookie -} - -// Write request to wire for PolySegment -func (c *Conn) PolySegment(Drawable Drawable, Gc Gcontext, Segments []Segment) PolySegmentCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.polySegmentRequest(Drawable, Gc, Segments), cookie) - return PolySegmentCookie{cookie} -} - -func (c *Conn) PolySegmentChecked(Drawable Drawable, Gc Gcontext, Segments []Segment) PolySegmentCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.polySegmentRequest(Drawable, Gc, Segments), cookie) - return PolySegmentCookie{cookie} -} - -func (cook PolySegmentCookie) Check() error { - return cook.check() -} - -// Write request to wire for PolySegment -func (c *Conn) polySegmentRequest(Drawable Drawable, Gc Gcontext, Segments []Segment) []byte { - size := pad((12 + pad((len(Segments) * 8)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 66 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - b += SegmentListBytes(buf[b:], Segments) - - return buf -} - -// Request PolyRectangle -// size: pad((12 + pad((len(Rectangles) * 8)))) -type PolyRectangleCookie struct { - *cookie -} - -// Write request to wire for PolyRectangle -func (c *Conn) PolyRectangle(Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyRectangleCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.polyRectangleRequest(Drawable, Gc, Rectangles), cookie) - return PolyRectangleCookie{cookie} -} - -func (c *Conn) PolyRectangleChecked(Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyRectangleCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.polyRectangleRequest(Drawable, Gc, Rectangles), cookie) - return PolyRectangleCookie{cookie} -} - -func (cook PolyRectangleCookie) Check() error { - return cook.check() -} - -// Write request to wire for PolyRectangle -func (c *Conn) polyRectangleRequest(Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) []byte { - size := pad((12 + pad((len(Rectangles) * 8)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 67 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - b += RectangleListBytes(buf[b:], Rectangles) - - return buf -} - -// Request PolyArc -// size: pad((12 + pad((len(Arcs) * 12)))) -type PolyArcCookie struct { - *cookie -} - -// Write request to wire for PolyArc -func (c *Conn) PolyArc(Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyArcCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.polyArcRequest(Drawable, Gc, Arcs), cookie) - return PolyArcCookie{cookie} -} - -func (c *Conn) PolyArcChecked(Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyArcCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.polyArcRequest(Drawable, Gc, Arcs), cookie) - return PolyArcCookie{cookie} -} - -func (cook PolyArcCookie) Check() error { - return cook.check() -} - -// Write request to wire for PolyArc -func (c *Conn) polyArcRequest(Drawable Drawable, Gc Gcontext, Arcs []Arc) []byte { - size := pad((12 + pad((len(Arcs) * 12)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 68 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - b += ArcListBytes(buf[b:], Arcs) - - return buf -} - -// Request FillPoly -// size: pad((16 + pad((len(Points) * 4)))) -type FillPolyCookie struct { - *cookie -} - -// Write request to wire for FillPoly -func (c *Conn) FillPoly(Drawable Drawable, Gc Gcontext, Shape byte, CoordinateMode byte, Points []Point) FillPolyCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.fillPolyRequest(Drawable, Gc, Shape, CoordinateMode, Points), cookie) - return FillPolyCookie{cookie} -} - -func (c *Conn) FillPolyChecked(Drawable Drawable, Gc Gcontext, Shape byte, CoordinateMode byte, Points []Point) FillPolyCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.fillPolyRequest(Drawable, Gc, Shape, CoordinateMode, Points), cookie) - return FillPolyCookie{cookie} -} - -func (cook FillPolyCookie) Check() error { - return cook.check() -} - -// Write request to wire for FillPoly -func (c *Conn) fillPolyRequest(Drawable Drawable, Gc Gcontext, Shape byte, CoordinateMode byte, Points []Point) []byte { - size := pad((16 + pad((len(Points) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 69 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - buf[b] = Shape - b += 1 - - buf[b] = CoordinateMode - b += 1 - - b += 2 // padding - - b += PointListBytes(buf[b:], Points) - - return buf -} - -// Request PolyFillRectangle -// size: pad((12 + pad((len(Rectangles) * 8)))) -type PolyFillRectangleCookie struct { - *cookie -} - -// Write request to wire for PolyFillRectangle -func (c *Conn) PolyFillRectangle(Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyFillRectangleCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.polyFillRectangleRequest(Drawable, Gc, Rectangles), cookie) - return PolyFillRectangleCookie{cookie} -} - -func (c *Conn) PolyFillRectangleChecked(Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyFillRectangleCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.polyFillRectangleRequest(Drawable, Gc, Rectangles), cookie) - return PolyFillRectangleCookie{cookie} -} - -func (cook PolyFillRectangleCookie) Check() error { - return cook.check() -} - -// Write request to wire for PolyFillRectangle -func (c *Conn) polyFillRectangleRequest(Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) []byte { - size := pad((12 + pad((len(Rectangles) * 8)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 70 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - b += RectangleListBytes(buf[b:], Rectangles) - - return buf -} - -// Request PolyFillArc -// size: pad((12 + pad((len(Arcs) * 12)))) -type PolyFillArcCookie struct { - *cookie -} - -// Write request to wire for PolyFillArc -func (c *Conn) PolyFillArc(Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyFillArcCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.polyFillArcRequest(Drawable, Gc, Arcs), cookie) - return PolyFillArcCookie{cookie} -} - -func (c *Conn) PolyFillArcChecked(Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyFillArcCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.polyFillArcRequest(Drawable, Gc, Arcs), cookie) - return PolyFillArcCookie{cookie} -} - -func (cook PolyFillArcCookie) Check() error { - return cook.check() -} - -// Write request to wire for PolyFillArc -func (c *Conn) polyFillArcRequest(Drawable Drawable, Gc Gcontext, Arcs []Arc) []byte { - size := pad((12 + pad((len(Arcs) * 12)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 71 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - b += ArcListBytes(buf[b:], Arcs) - - return buf -} - -// Request PutImage -// size: pad((24 + pad((len(Data) * 1)))) -type PutImageCookie struct { - *cookie -} - -// Write request to wire for PutImage -func (c *Conn) PutImage(Format byte, Drawable Drawable, Gc Gcontext, Width uint16, Height uint16, DstX int16, DstY int16, LeftPad byte, Depth byte, Data []byte) PutImageCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.putImageRequest(Format, Drawable, Gc, Width, Height, DstX, DstY, LeftPad, Depth, Data), cookie) - return PutImageCookie{cookie} -} - -func (c *Conn) PutImageChecked(Format byte, Drawable Drawable, Gc Gcontext, Width uint16, Height uint16, DstX int16, DstY int16, LeftPad byte, Depth byte, Data []byte) PutImageCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.putImageRequest(Format, Drawable, Gc, Width, Height, DstX, DstY, LeftPad, Depth, Data), cookie) - return PutImageCookie{cookie} -} - -func (cook PutImageCookie) Check() error { - return cook.check() -} - -// Write request to wire for PutImage -func (c *Conn) putImageRequest(Format byte, Drawable Drawable, Gc Gcontext, Width uint16, Height uint16, DstX int16, DstY int16, LeftPad byte, Depth byte, Data []byte) []byte { - size := pad((24 + pad((len(Data) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 72 // request opcode - b += 1 - - buf[b] = Format - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - Put16(buf[b:], Width) - b += 2 - - Put16(buf[b:], Height) - b += 2 - - Put16(buf[b:], uint16(DstX)) - b += 2 - - Put16(buf[b:], uint16(DstY)) - b += 2 - - buf[b] = LeftPad - b += 1 - - buf[b] = Depth - b += 1 - - b += 2 // padding - - copy(buf[b:], Data[:len(Data)]) - b += pad(int(len(Data))) - - return buf -} - -// Request GetImage -// size: 20 -type GetImageCookie struct { - *cookie -} - -func (c *Conn) GetImage(Format byte, Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32) GetImageCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.getImageRequest(Format, Drawable, X, Y, Width, Height, PlaneMask), cookie) - return GetImageCookie{cookie} -} - -func (c *Conn) GetImageUnchecked(Format byte, Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32) GetImageCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.getImageRequest(Format, Drawable, X, Y, Width, Height, PlaneMask), cookie) - return GetImageCookie{cookie} -} - -// Request reply for GetImage -// size: (32 + pad(((int(Length) * 4) * 1))) -type GetImageReply struct { - Sequence uint16 - Length uint32 - Depth byte - Visual Visualid - // padding: 20 bytes - Data []byte // size: pad(((int(Length) * 4) * 1)) -} - -// Waits and reads reply data from request GetImage -func (cook GetImageCookie) Reply() (*GetImageReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getImageReply(buf), nil -} - -// Read reply into structure from buffer for GetImage -func getImageReply(buf []byte) *GetImageReply { - v := new(GetImageReply) - b := 1 // skip reply determinant - - v.Depth = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Visual = Visualid(Get32(buf[b:])) - b += 4 - - b += 20 // padding - - v.Data = make([]byte, (int(v.Length) * 4)) - copy(v.Data[:(int(v.Length)*4)], buf[b:]) - b += pad(int((int(v.Length) * 4))) - - return v -} - -func (cook GetImageCookie) Check() error { - return cook.check() -} - -// Write request to wire for GetImage -func (c *Conn) getImageRequest(Format byte, Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32) []byte { - size := 20 - b := 0 - buf := make([]byte, size) - - buf[b] = 73 // request opcode - b += 1 - - buf[b] = Format - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put16(buf[b:], uint16(X)) - b += 2 - - Put16(buf[b:], uint16(Y)) - b += 2 - - Put16(buf[b:], Width) - b += 2 - - Put16(buf[b:], Height) - b += 2 - - Put32(buf[b:], PlaneMask) - b += 4 - - return buf -} - -// Request PolyText8 -// size: pad((16 + pad((len(Items) * 1)))) -type PolyText8Cookie struct { - *cookie -} - -// Write request to wire for PolyText8 -func (c *Conn) PolyText8(Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText8Cookie { - cookie := c.newCookie(false, false) - c.newRequest(c.polyText8Request(Drawable, Gc, X, Y, Items), cookie) - return PolyText8Cookie{cookie} -} - -func (c *Conn) PolyText8Checked(Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText8Cookie { - cookie := c.newCookie(true, false) - c.newRequest(c.polyText8Request(Drawable, Gc, X, Y, Items), cookie) - return PolyText8Cookie{cookie} -} - -func (cook PolyText8Cookie) Check() error { - return cook.check() -} - -// Write request to wire for PolyText8 -func (c *Conn) polyText8Request(Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) []byte { - size := pad((16 + pad((len(Items) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 74 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - Put16(buf[b:], uint16(X)) - b += 2 - - Put16(buf[b:], uint16(Y)) - b += 2 - - copy(buf[b:], Items[:len(Items)]) - b += pad(int(len(Items))) - - return buf -} - -// Request PolyText16 -// size: pad((16 + pad((len(Items) * 1)))) -type PolyText16Cookie struct { - *cookie -} - -// Write request to wire for PolyText16 -func (c *Conn) PolyText16(Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText16Cookie { - cookie := c.newCookie(false, false) - c.newRequest(c.polyText16Request(Drawable, Gc, X, Y, Items), cookie) - return PolyText16Cookie{cookie} -} - -func (c *Conn) PolyText16Checked(Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText16Cookie { - cookie := c.newCookie(true, false) - c.newRequest(c.polyText16Request(Drawable, Gc, X, Y, Items), cookie) - return PolyText16Cookie{cookie} -} - -func (cook PolyText16Cookie) Check() error { - return cook.check() -} - -// Write request to wire for PolyText16 -func (c *Conn) polyText16Request(Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) []byte { - size := pad((16 + pad((len(Items) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 75 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - Put16(buf[b:], uint16(X)) - b += 2 - - Put16(buf[b:], uint16(Y)) - b += 2 - - copy(buf[b:], Items[:len(Items)]) - b += pad(int(len(Items))) - - return buf -} - -// Request ImageText8 -// size: pad((16 + pad((int(StringLen) * 1)))) -type ImageText8Cookie struct { - *cookie -} - -// Write request to wire for ImageText8 -func (c *Conn) ImageText8(StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String string) ImageText8Cookie { - cookie := c.newCookie(false, false) - c.newRequest(c.imageText8Request(StringLen, Drawable, Gc, X, Y, String), cookie) - return ImageText8Cookie{cookie} -} - -func (c *Conn) ImageText8Checked(StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String string) ImageText8Cookie { - cookie := c.newCookie(true, false) - c.newRequest(c.imageText8Request(StringLen, Drawable, Gc, X, Y, String), cookie) - return ImageText8Cookie{cookie} -} - -func (cook ImageText8Cookie) Check() error { - return cook.check() -} - -// Write request to wire for ImageText8 -func (c *Conn) imageText8Request(StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String string) []byte { - size := pad((16 + pad((int(StringLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 76 // request opcode - b += 1 - - buf[b] = StringLen - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - Put16(buf[b:], uint16(X)) - b += 2 - - Put16(buf[b:], uint16(Y)) - b += 2 - - copy(buf[b:], String[:StringLen]) - b += pad(int(StringLen)) - - return buf -} - -// Request ImageText16 -// size: pad((16 + pad((int(StringLen) * 2)))) -type ImageText16Cookie struct { - *cookie -} - -// Write request to wire for ImageText16 -func (c *Conn) ImageText16(StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String []Char2b) ImageText16Cookie { - cookie := c.newCookie(false, false) - c.newRequest(c.imageText16Request(StringLen, Drawable, Gc, X, Y, String), cookie) - return ImageText16Cookie{cookie} -} - -func (c *Conn) ImageText16Checked(StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String []Char2b) ImageText16Cookie { - cookie := c.newCookie(true, false) - c.newRequest(c.imageText16Request(StringLen, Drawable, Gc, X, Y, String), cookie) - return ImageText16Cookie{cookie} -} - -func (cook ImageText16Cookie) Check() error { - return cook.check() -} - -// Write request to wire for ImageText16 -func (c *Conn) imageText16Request(StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String []Char2b) []byte { - size := pad((16 + pad((int(StringLen) * 2)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 77 // request opcode - b += 1 - - buf[b] = StringLen - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - Put16(buf[b:], uint16(X)) - b += 2 - - Put16(buf[b:], uint16(Y)) - b += 2 - - b += Char2bListBytes(buf[b:], String) - - return buf -} - -// Request CreateColormap -// size: 16 -type CreateColormapCookie struct { - *cookie -} - -// Write request to wire for CreateColormap -func (c *Conn) CreateColormap(Alloc byte, Mid Colormap, Window Window, Visual Visualid) CreateColormapCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.createColormapRequest(Alloc, Mid, Window, Visual), cookie) - return CreateColormapCookie{cookie} -} - -func (c *Conn) CreateColormapChecked(Alloc byte, Mid Colormap, Window Window, Visual Visualid) CreateColormapCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.createColormapRequest(Alloc, Mid, Window, Visual), cookie) - return CreateColormapCookie{cookie} -} - -func (cook CreateColormapCookie) Check() error { - return cook.check() -} - -// Write request to wire for CreateColormap -func (c *Conn) createColormapRequest(Alloc byte, Mid Colormap, Window Window, Visual Visualid) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = 78 // request opcode - b += 1 - - buf[b] = Alloc - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Mid)) - b += 4 - - Put32(buf[b:], uint32(Window)) - b += 4 - - Put32(buf[b:], uint32(Visual)) - b += 4 - - return buf -} - -// Request FreeColormap -// size: 8 -type FreeColormapCookie struct { - *cookie -} - -// Write request to wire for FreeColormap -func (c *Conn) FreeColormap(Cmap Colormap) FreeColormapCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.freeColormapRequest(Cmap), cookie) - return FreeColormapCookie{cookie} -} - -func (c *Conn) FreeColormapChecked(Cmap Colormap) FreeColormapCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.freeColormapRequest(Cmap), cookie) - return FreeColormapCookie{cookie} -} - -func (cook FreeColormapCookie) Check() error { - return cook.check() -} - -// Write request to wire for FreeColormap -func (c *Conn) freeColormapRequest(Cmap Colormap) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 79 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cmap)) - b += 4 - - return buf -} - -// Request CopyColormapAndFree -// size: 12 -type CopyColormapAndFreeCookie struct { - *cookie -} - -// Write request to wire for CopyColormapAndFree -func (c *Conn) CopyColormapAndFree(Mid Colormap, SrcCmap Colormap) CopyColormapAndFreeCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.copyColormapAndFreeRequest(Mid, SrcCmap), cookie) - return CopyColormapAndFreeCookie{cookie} -} - -func (c *Conn) CopyColormapAndFreeChecked(Mid Colormap, SrcCmap Colormap) CopyColormapAndFreeCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.copyColormapAndFreeRequest(Mid, SrcCmap), cookie) - return CopyColormapAndFreeCookie{cookie} -} - -func (cook CopyColormapAndFreeCookie) Check() error { - return cook.check() -} - -// Write request to wire for CopyColormapAndFree -func (c *Conn) copyColormapAndFreeRequest(Mid Colormap, SrcCmap Colormap) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = 80 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Mid)) - b += 4 - - Put32(buf[b:], uint32(SrcCmap)) - b += 4 - - return buf -} - -// Request InstallColormap -// size: 8 -type InstallColormapCookie struct { - *cookie -} - -// Write request to wire for InstallColormap -func (c *Conn) InstallColormap(Cmap Colormap) InstallColormapCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.installColormapRequest(Cmap), cookie) - return InstallColormapCookie{cookie} -} - -func (c *Conn) InstallColormapChecked(Cmap Colormap) InstallColormapCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.installColormapRequest(Cmap), cookie) - return InstallColormapCookie{cookie} -} - -func (cook InstallColormapCookie) Check() error { - return cook.check() -} - -// Write request to wire for InstallColormap -func (c *Conn) installColormapRequest(Cmap Colormap) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 81 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cmap)) - b += 4 - - return buf -} - -// Request UninstallColormap -// size: 8 -type UninstallColormapCookie struct { - *cookie -} - -// Write request to wire for UninstallColormap -func (c *Conn) UninstallColormap(Cmap Colormap) UninstallColormapCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.uninstallColormapRequest(Cmap), cookie) - return UninstallColormapCookie{cookie} -} - -func (c *Conn) UninstallColormapChecked(Cmap Colormap) UninstallColormapCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.uninstallColormapRequest(Cmap), cookie) - return UninstallColormapCookie{cookie} -} - -func (cook UninstallColormapCookie) Check() error { - return cook.check() -} - -// Write request to wire for UninstallColormap -func (c *Conn) uninstallColormapRequest(Cmap Colormap) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 82 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cmap)) - b += 4 - - return buf -} - -// Request ListInstalledColormaps -// size: 8 -type ListInstalledColormapsCookie struct { - *cookie -} - -func (c *Conn) ListInstalledColormaps(Window Window) ListInstalledColormapsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.listInstalledColormapsRequest(Window), cookie) - return ListInstalledColormapsCookie{cookie} -} - -func (c *Conn) ListInstalledColormapsUnchecked(Window Window) ListInstalledColormapsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.listInstalledColormapsRequest(Window), cookie) - return ListInstalledColormapsCookie{cookie} -} - -// Request reply for ListInstalledColormaps -// size: (32 + pad((int(CmapsLen) * 4))) -type ListInstalledColormapsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - CmapsLen uint16 - // padding: 22 bytes - Cmaps []Colormap // size: pad((int(CmapsLen) * 4)) -} - -// Waits and reads reply data from request ListInstalledColormaps -func (cook ListInstalledColormapsCookie) Reply() (*ListInstalledColormapsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return listInstalledColormapsReply(buf), nil -} - -// Read reply into structure from buffer for ListInstalledColormaps -func listInstalledColormapsReply(buf []byte) *ListInstalledColormapsReply { - v := new(ListInstalledColormapsReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.CmapsLen = Get16(buf[b:]) - b += 2 - - b += 22 // padding - - v.Cmaps = make([]Colormap, v.CmapsLen) - for i := 0; i < int(v.CmapsLen); i++ { - v.Cmaps[i] = Colormap(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook ListInstalledColormapsCookie) Check() error { - return cook.check() -} - -// Write request to wire for ListInstalledColormaps -func (c *Conn) listInstalledColormapsRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 83 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - return buf -} - -// Request AllocColor -// size: 16 -type AllocColorCookie struct { - *cookie -} - -func (c *Conn) AllocColor(Cmap Colormap, Red uint16, Green uint16, Blue uint16) AllocColorCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.allocColorRequest(Cmap, Red, Green, Blue), cookie) - return AllocColorCookie{cookie} -} - -func (c *Conn) AllocColorUnchecked(Cmap Colormap, Red uint16, Green uint16, Blue uint16) AllocColorCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.allocColorRequest(Cmap, Red, Green, Blue), cookie) - return AllocColorCookie{cookie} -} - -// Request reply for AllocColor -// size: 20 -type AllocColorReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Red uint16 - Green uint16 - Blue uint16 - // padding: 2 bytes - Pixel uint32 -} - -// Waits and reads reply data from request AllocColor -func (cook AllocColorCookie) Reply() (*AllocColorReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return allocColorReply(buf), nil -} - -// Read reply into structure from buffer for AllocColor -func allocColorReply(buf []byte) *AllocColorReply { - v := new(AllocColorReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Red = Get16(buf[b:]) - b += 2 - - v.Green = Get16(buf[b:]) - b += 2 - - v.Blue = Get16(buf[b:]) - b += 2 - - b += 2 // padding - - v.Pixel = Get32(buf[b:]) - b += 4 - - return v -} - -func (cook AllocColorCookie) Check() error { - return cook.check() -} - -// Write request to wire for AllocColor -func (c *Conn) allocColorRequest(Cmap Colormap, Red uint16, Green uint16, Blue uint16) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = 84 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cmap)) - b += 4 - - Put16(buf[b:], Red) - b += 2 - - Put16(buf[b:], Green) - b += 2 - - Put16(buf[b:], Blue) - b += 2 - - b += 2 // padding - - return buf -} - -// Request AllocNamedColor -// size: pad((12 + pad((int(NameLen) * 1)))) -type AllocNamedColorCookie struct { - *cookie -} - -func (c *Conn) AllocNamedColor(Cmap Colormap, NameLen uint16, Name string) AllocNamedColorCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.allocNamedColorRequest(Cmap, NameLen, Name), cookie) - return AllocNamedColorCookie{cookie} -} - -func (c *Conn) AllocNamedColorUnchecked(Cmap Colormap, NameLen uint16, Name string) AllocNamedColorCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.allocNamedColorRequest(Cmap, NameLen, Name), cookie) - return AllocNamedColorCookie{cookie} -} - -// Request reply for AllocNamedColor -// size: 24 -type AllocNamedColorReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Pixel uint32 - ExactRed uint16 - ExactGreen uint16 - ExactBlue uint16 - VisualRed uint16 - VisualGreen uint16 - VisualBlue uint16 -} - -// Waits and reads reply data from request AllocNamedColor -func (cook AllocNamedColorCookie) Reply() (*AllocNamedColorReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return allocNamedColorReply(buf), nil -} - -// Read reply into structure from buffer for AllocNamedColor -func allocNamedColorReply(buf []byte) *AllocNamedColorReply { - v := new(AllocNamedColorReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Pixel = Get32(buf[b:]) - b += 4 - - v.ExactRed = Get16(buf[b:]) - b += 2 - - v.ExactGreen = Get16(buf[b:]) - b += 2 - - v.ExactBlue = Get16(buf[b:]) - b += 2 - - v.VisualRed = Get16(buf[b:]) - b += 2 - - v.VisualGreen = Get16(buf[b:]) - b += 2 - - v.VisualBlue = Get16(buf[b:]) - b += 2 - - return v -} - -func (cook AllocNamedColorCookie) Check() error { - return cook.check() -} - -// Write request to wire for AllocNamedColor -func (c *Conn) allocNamedColorRequest(Cmap Colormap, NameLen uint16, Name string) []byte { - size := pad((12 + pad((int(NameLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 85 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cmap)) - b += 4 - - Put16(buf[b:], NameLen) - b += 2 - - b += 2 // padding - - copy(buf[b:], Name[:NameLen]) - b += pad(int(NameLen)) - - return buf -} - -// Request AllocColorCells -// size: 12 -type AllocColorCellsCookie struct { - *cookie -} - -func (c *Conn) AllocColorCells(Contiguous bool, Cmap Colormap, Colors uint16, Planes uint16) AllocColorCellsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.allocColorCellsRequest(Contiguous, Cmap, Colors, Planes), cookie) - return AllocColorCellsCookie{cookie} -} - -func (c *Conn) AllocColorCellsUnchecked(Contiguous bool, Cmap Colormap, Colors uint16, Planes uint16) AllocColorCellsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.allocColorCellsRequest(Contiguous, Cmap, Colors, Planes), cookie) - return AllocColorCellsCookie{cookie} -} - -// Request reply for AllocColorCells -// size: ((32 + pad((int(PixelsLen) * 4))) + pad((int(MasksLen) * 4))) -type AllocColorCellsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - PixelsLen uint16 - MasksLen uint16 - // padding: 20 bytes - Pixels []uint32 // size: pad((int(PixelsLen) * 4)) - Masks []uint32 // size: pad((int(MasksLen) * 4)) -} - -// Waits and reads reply data from request AllocColorCells -func (cook AllocColorCellsCookie) Reply() (*AllocColorCellsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return allocColorCellsReply(buf), nil -} - -// Read reply into structure from buffer for AllocColorCells -func allocColorCellsReply(buf []byte) *AllocColorCellsReply { - v := new(AllocColorCellsReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.PixelsLen = Get16(buf[b:]) - b += 2 - - v.MasksLen = Get16(buf[b:]) - b += 2 - - b += 20 // padding - - v.Pixels = make([]uint32, v.PixelsLen) - for i := 0; i < int(v.PixelsLen); i++ { - v.Pixels[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - v.Masks = make([]uint32, v.MasksLen) - for i := 0; i < int(v.MasksLen); i++ { - v.Masks[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook AllocColorCellsCookie) Check() error { - return cook.check() -} - -// Write request to wire for AllocColorCells -func (c *Conn) allocColorCellsRequest(Contiguous bool, Cmap Colormap, Colors uint16, Planes uint16) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = 86 // request opcode - b += 1 - - if Contiguous { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cmap)) - b += 4 - - Put16(buf[b:], Colors) - b += 2 - - Put16(buf[b:], Planes) - b += 2 - - return buf -} - -// Request AllocColorPlanes -// size: 16 -type AllocColorPlanesCookie struct { - *cookie -} - -func (c *Conn) AllocColorPlanes(Contiguous bool, Cmap Colormap, Colors uint16, Reds uint16, Greens uint16, Blues uint16) AllocColorPlanesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.allocColorPlanesRequest(Contiguous, Cmap, Colors, Reds, Greens, Blues), cookie) - return AllocColorPlanesCookie{cookie} -} - -func (c *Conn) AllocColorPlanesUnchecked(Contiguous bool, Cmap Colormap, Colors uint16, Reds uint16, Greens uint16, Blues uint16) AllocColorPlanesCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.allocColorPlanesRequest(Contiguous, Cmap, Colors, Reds, Greens, Blues), cookie) - return AllocColorPlanesCookie{cookie} -} - -// Request reply for AllocColorPlanes -// size: (32 + pad((int(PixelsLen) * 4))) -type AllocColorPlanesReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - PixelsLen uint16 - // padding: 2 bytes - RedMask uint32 - GreenMask uint32 - BlueMask uint32 - // padding: 8 bytes - Pixels []uint32 // size: pad((int(PixelsLen) * 4)) -} - -// Waits and reads reply data from request AllocColorPlanes -func (cook AllocColorPlanesCookie) Reply() (*AllocColorPlanesReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return allocColorPlanesReply(buf), nil -} - -// Read reply into structure from buffer for AllocColorPlanes -func allocColorPlanesReply(buf []byte) *AllocColorPlanesReply { - v := new(AllocColorPlanesReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.PixelsLen = Get16(buf[b:]) - b += 2 - - b += 2 // padding - - v.RedMask = Get32(buf[b:]) - b += 4 - - v.GreenMask = Get32(buf[b:]) - b += 4 - - v.BlueMask = Get32(buf[b:]) - b += 4 - - b += 8 // padding - - v.Pixels = make([]uint32, v.PixelsLen) - for i := 0; i < int(v.PixelsLen); i++ { - v.Pixels[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook AllocColorPlanesCookie) Check() error { - return cook.check() -} - -// Write request to wire for AllocColorPlanes -func (c *Conn) allocColorPlanesRequest(Contiguous bool, Cmap Colormap, Colors uint16, Reds uint16, Greens uint16, Blues uint16) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = 87 // request opcode - b += 1 - - if Contiguous { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cmap)) - b += 4 - - Put16(buf[b:], Colors) - b += 2 - - Put16(buf[b:], Reds) - b += 2 - - Put16(buf[b:], Greens) - b += 2 - - Put16(buf[b:], Blues) - b += 2 - - return buf -} - -// Request FreeColors -// size: pad((12 + pad((len(Pixels) * 4)))) -type FreeColorsCookie struct { - *cookie -} - -// Write request to wire for FreeColors -func (c *Conn) FreeColors(Cmap Colormap, PlaneMask uint32, Pixels []uint32) FreeColorsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.freeColorsRequest(Cmap, PlaneMask, Pixels), cookie) - return FreeColorsCookie{cookie} -} - -func (c *Conn) FreeColorsChecked(Cmap Colormap, PlaneMask uint32, Pixels []uint32) FreeColorsCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.freeColorsRequest(Cmap, PlaneMask, Pixels), cookie) - return FreeColorsCookie{cookie} -} - -func (cook FreeColorsCookie) Check() error { - return cook.check() -} - -// Write request to wire for FreeColors -func (c *Conn) freeColorsRequest(Cmap Colormap, PlaneMask uint32, Pixels []uint32) []byte { - size := pad((12 + pad((len(Pixels) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 88 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cmap)) - b += 4 - - Put32(buf[b:], PlaneMask) - b += 4 - - for i := 0; i < int(len(Pixels)); i++ { - Put32(buf[b:], Pixels[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Request StoreColors -// size: pad((8 + pad((len(Items) * 12)))) -type StoreColorsCookie struct { - *cookie -} - -// Write request to wire for StoreColors -func (c *Conn) StoreColors(Cmap Colormap, Items []Coloritem) StoreColorsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.storeColorsRequest(Cmap, Items), cookie) - return StoreColorsCookie{cookie} -} - -func (c *Conn) StoreColorsChecked(Cmap Colormap, Items []Coloritem) StoreColorsCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.storeColorsRequest(Cmap, Items), cookie) - return StoreColorsCookie{cookie} -} - -func (cook StoreColorsCookie) Check() error { - return cook.check() -} - -// Write request to wire for StoreColors -func (c *Conn) storeColorsRequest(Cmap Colormap, Items []Coloritem) []byte { - size := pad((8 + pad((len(Items) * 12)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 89 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cmap)) - b += 4 - - b += ColoritemListBytes(buf[b:], Items) - - return buf -} - -// Request StoreNamedColor -// size: pad((16 + pad((int(NameLen) * 1)))) -type StoreNamedColorCookie struct { - *cookie -} - -// Write request to wire for StoreNamedColor -func (c *Conn) StoreNamedColor(Flags byte, Cmap Colormap, Pixel uint32, NameLen uint16, Name string) StoreNamedColorCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.storeNamedColorRequest(Flags, Cmap, Pixel, NameLen, Name), cookie) - return StoreNamedColorCookie{cookie} -} - -func (c *Conn) StoreNamedColorChecked(Flags byte, Cmap Colormap, Pixel uint32, NameLen uint16, Name string) StoreNamedColorCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.storeNamedColorRequest(Flags, Cmap, Pixel, NameLen, Name), cookie) - return StoreNamedColorCookie{cookie} -} - -func (cook StoreNamedColorCookie) Check() error { - return cook.check() -} - -// Write request to wire for StoreNamedColor -func (c *Conn) storeNamedColorRequest(Flags byte, Cmap Colormap, Pixel uint32, NameLen uint16, Name string) []byte { - size := pad((16 + pad((int(NameLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 90 // request opcode - b += 1 - - buf[b] = Flags - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cmap)) - b += 4 - - Put32(buf[b:], Pixel) - b += 4 - - Put16(buf[b:], NameLen) - b += 2 - - b += 2 // padding - - copy(buf[b:], Name[:NameLen]) - b += pad(int(NameLen)) - - return buf -} - -// Request QueryColors -// size: pad((8 + pad((len(Pixels) * 4)))) -type QueryColorsCookie struct { - *cookie -} - -func (c *Conn) QueryColors(Cmap Colormap, Pixels []uint32) QueryColorsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.queryColorsRequest(Cmap, Pixels), cookie) - return QueryColorsCookie{cookie} -} - -func (c *Conn) QueryColorsUnchecked(Cmap Colormap, Pixels []uint32) QueryColorsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.queryColorsRequest(Cmap, Pixels), cookie) - return QueryColorsCookie{cookie} -} - -// Request reply for QueryColors -// size: (32 + pad((int(ColorsLen) * 8))) -type QueryColorsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ColorsLen uint16 - // padding: 22 bytes - Colors []Rgb // size: pad((int(ColorsLen) * 8)) -} - -// Waits and reads reply data from request QueryColors -func (cook QueryColorsCookie) Reply() (*QueryColorsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return queryColorsReply(buf), nil -} - -// Read reply into structure from buffer for QueryColors -func queryColorsReply(buf []byte) *QueryColorsReply { - v := new(QueryColorsReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.ColorsLen = Get16(buf[b:]) - b += 2 - - b += 22 // padding - - v.Colors = make([]Rgb, v.ColorsLen) - b += ReadRgbList(buf[b:], v.Colors) - - return v -} - -func (cook QueryColorsCookie) Check() error { - return cook.check() -} - -// Write request to wire for QueryColors -func (c *Conn) queryColorsRequest(Cmap Colormap, Pixels []uint32) []byte { - size := pad((8 + pad((len(Pixels) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 91 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cmap)) - b += 4 - - for i := 0; i < int(len(Pixels)); i++ { - Put32(buf[b:], Pixels[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Request LookupColor -// size: pad((12 + pad((int(NameLen) * 1)))) -type LookupColorCookie struct { - *cookie -} - -func (c *Conn) LookupColor(Cmap Colormap, NameLen uint16, Name string) LookupColorCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.lookupColorRequest(Cmap, NameLen, Name), cookie) - return LookupColorCookie{cookie} -} - -func (c *Conn) LookupColorUnchecked(Cmap Colormap, NameLen uint16, Name string) LookupColorCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.lookupColorRequest(Cmap, NameLen, Name), cookie) - return LookupColorCookie{cookie} -} - -// Request reply for LookupColor -// size: 20 -type LookupColorReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ExactRed uint16 - ExactGreen uint16 - ExactBlue uint16 - VisualRed uint16 - VisualGreen uint16 - VisualBlue uint16 -} - -// Waits and reads reply data from request LookupColor -func (cook LookupColorCookie) Reply() (*LookupColorReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return lookupColorReply(buf), nil -} - -// Read reply into structure from buffer for LookupColor -func lookupColorReply(buf []byte) *LookupColorReply { - v := new(LookupColorReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.ExactRed = Get16(buf[b:]) - b += 2 - - v.ExactGreen = Get16(buf[b:]) - b += 2 - - v.ExactBlue = Get16(buf[b:]) - b += 2 - - v.VisualRed = Get16(buf[b:]) - b += 2 - - v.VisualGreen = Get16(buf[b:]) - b += 2 - - v.VisualBlue = Get16(buf[b:]) - b += 2 - - return v -} - -func (cook LookupColorCookie) Check() error { - return cook.check() -} - -// Write request to wire for LookupColor -func (c *Conn) lookupColorRequest(Cmap Colormap, NameLen uint16, Name string) []byte { - size := pad((12 + pad((int(NameLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 92 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cmap)) - b += 4 - - Put16(buf[b:], NameLen) - b += 2 - - b += 2 // padding - - copy(buf[b:], Name[:NameLen]) - b += pad(int(NameLen)) - - return buf -} - -// Request CreateCursor -// size: 32 -type CreateCursorCookie struct { - *cookie -} - -// Write request to wire for CreateCursor -func (c *Conn) CreateCursor(Cid Cursor, Source Pixmap, Mask Pixmap, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16, X uint16, Y uint16) CreateCursorCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.createCursorRequest(Cid, Source, Mask, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue, X, Y), cookie) - return CreateCursorCookie{cookie} -} - -func (c *Conn) CreateCursorChecked(Cid Cursor, Source Pixmap, Mask Pixmap, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16, X uint16, Y uint16) CreateCursorCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.createCursorRequest(Cid, Source, Mask, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue, X, Y), cookie) - return CreateCursorCookie{cookie} -} - -func (cook CreateCursorCookie) Check() error { - return cook.check() -} - -// Write request to wire for CreateCursor -func (c *Conn) createCursorRequest(Cid Cursor, Source Pixmap, Mask Pixmap, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16, X uint16, Y uint16) []byte { - size := 32 - b := 0 - buf := make([]byte, size) - - buf[b] = 93 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cid)) - b += 4 - - Put32(buf[b:], uint32(Source)) - b += 4 - - Put32(buf[b:], uint32(Mask)) - b += 4 - - Put16(buf[b:], ForeRed) - b += 2 - - Put16(buf[b:], ForeGreen) - b += 2 - - Put16(buf[b:], ForeBlue) - b += 2 - - Put16(buf[b:], BackRed) - b += 2 - - Put16(buf[b:], BackGreen) - b += 2 - - Put16(buf[b:], BackBlue) - b += 2 - - Put16(buf[b:], X) - b += 2 - - Put16(buf[b:], Y) - b += 2 - - return buf -} - -// Request CreateGlyphCursor -// size: 32 -type CreateGlyphCursorCookie struct { - *cookie -} - -// Write request to wire for CreateGlyphCursor -func (c *Conn) CreateGlyphCursor(Cid Cursor, SourceFont Font, MaskFont Font, SourceChar uint16, MaskChar uint16, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) CreateGlyphCursorCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.createGlyphCursorRequest(Cid, SourceFont, MaskFont, SourceChar, MaskChar, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) - return CreateGlyphCursorCookie{cookie} -} - -func (c *Conn) CreateGlyphCursorChecked(Cid Cursor, SourceFont Font, MaskFont Font, SourceChar uint16, MaskChar uint16, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) CreateGlyphCursorCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.createGlyphCursorRequest(Cid, SourceFont, MaskFont, SourceChar, MaskChar, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) - return CreateGlyphCursorCookie{cookie} -} - -func (cook CreateGlyphCursorCookie) Check() error { - return cook.check() -} - -// Write request to wire for CreateGlyphCursor -func (c *Conn) createGlyphCursorRequest(Cid Cursor, SourceFont Font, MaskFont Font, SourceChar uint16, MaskChar uint16, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) []byte { - size := 32 - b := 0 - buf := make([]byte, size) - - buf[b] = 94 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cid)) - b += 4 - - Put32(buf[b:], uint32(SourceFont)) - b += 4 - - Put32(buf[b:], uint32(MaskFont)) - b += 4 - - Put16(buf[b:], SourceChar) - b += 2 - - Put16(buf[b:], MaskChar) - b += 2 - - Put16(buf[b:], ForeRed) - b += 2 - - Put16(buf[b:], ForeGreen) - b += 2 - - Put16(buf[b:], ForeBlue) - b += 2 - - Put16(buf[b:], BackRed) - b += 2 - - Put16(buf[b:], BackGreen) - b += 2 - - Put16(buf[b:], BackBlue) - b += 2 - - return buf -} - -// Request FreeCursor -// size: 8 -type FreeCursorCookie struct { - *cookie -} - -// Write request to wire for FreeCursor -func (c *Conn) FreeCursor(Cursor Cursor) FreeCursorCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.freeCursorRequest(Cursor), cookie) - return FreeCursorCookie{cookie} -} - -func (c *Conn) FreeCursorChecked(Cursor Cursor) FreeCursorCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.freeCursorRequest(Cursor), cookie) - return FreeCursorCookie{cookie} -} - -func (cook FreeCursorCookie) Check() error { - return cook.check() -} - -// Write request to wire for FreeCursor -func (c *Conn) freeCursorRequest(Cursor Cursor) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 95 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cursor)) - b += 4 - - return buf -} - -// Request RecolorCursor -// size: 20 -type RecolorCursorCookie struct { - *cookie -} - -// Write request to wire for RecolorCursor -func (c *Conn) RecolorCursor(Cursor Cursor, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) RecolorCursorCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.recolorCursorRequest(Cursor, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) - return RecolorCursorCookie{cookie} -} - -func (c *Conn) RecolorCursorChecked(Cursor Cursor, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) RecolorCursorCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.recolorCursorRequest(Cursor, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) - return RecolorCursorCookie{cookie} -} - -func (cook RecolorCursorCookie) Check() error { - return cook.check() -} - -// Write request to wire for RecolorCursor -func (c *Conn) recolorCursorRequest(Cursor Cursor, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) []byte { - size := 20 - b := 0 - buf := make([]byte, size) - - buf[b] = 96 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Cursor)) - b += 4 - - Put16(buf[b:], ForeRed) - b += 2 - - Put16(buf[b:], ForeGreen) - b += 2 - - Put16(buf[b:], ForeBlue) - b += 2 - - Put16(buf[b:], BackRed) - b += 2 - - Put16(buf[b:], BackGreen) - b += 2 - - Put16(buf[b:], BackBlue) - b += 2 - - return buf -} - -// Request QueryBestSize -// size: 12 -type QueryBestSizeCookie struct { - *cookie -} - -func (c *Conn) QueryBestSize(Class byte, Drawable Drawable, Width uint16, Height uint16) QueryBestSizeCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.queryBestSizeRequest(Class, Drawable, Width, Height), cookie) - return QueryBestSizeCookie{cookie} -} - -func (c *Conn) QueryBestSizeUnchecked(Class byte, Drawable Drawable, Width uint16, Height uint16) QueryBestSizeCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.queryBestSizeRequest(Class, Drawable, Width, Height), cookie) - return QueryBestSizeCookie{cookie} -} - -// Request reply for QueryBestSize -// size: 12 -type QueryBestSizeReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Width uint16 - Height uint16 -} - -// Waits and reads reply data from request QueryBestSize -func (cook QueryBestSizeCookie) Reply() (*QueryBestSizeReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return queryBestSizeReply(buf), nil -} - -// Read reply into structure from buffer for QueryBestSize -func queryBestSizeReply(buf []byte) *QueryBestSizeReply { - v := new(QueryBestSizeReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - return v -} - -func (cook QueryBestSizeCookie) Check() error { - return cook.check() -} - -// Write request to wire for QueryBestSize -func (c *Conn) queryBestSizeRequest(Class byte, Drawable Drawable, Width uint16, Height uint16) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = 97 // request opcode - b += 1 - - buf[b] = Class - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put16(buf[b:], Width) - b += 2 - - Put16(buf[b:], Height) - b += 2 - - return buf -} - -// Request QueryExtension -// size: pad((8 + pad((int(NameLen) * 1)))) -type QueryExtensionCookie struct { - *cookie -} - -func (c *Conn) QueryExtension(NameLen uint16, Name string) QueryExtensionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.queryExtensionRequest(NameLen, Name), cookie) - return QueryExtensionCookie{cookie} -} - -func (c *Conn) QueryExtensionUnchecked(NameLen uint16, Name string) QueryExtensionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.queryExtensionRequest(NameLen, Name), cookie) - return QueryExtensionCookie{cookie} -} - -// Request reply for QueryExtension -// size: 12 -type QueryExtensionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Present bool - MajorOpcode byte - FirstEvent byte - FirstError byte -} - -// Waits and reads reply data from request QueryExtension -func (cook QueryExtensionCookie) Reply() (*QueryExtensionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return queryExtensionReply(buf), nil -} - -// Read reply into structure from buffer for QueryExtension -func queryExtensionReply(buf []byte) *QueryExtensionReply { - v := new(QueryExtensionReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - if buf[b] == 1 { - v.Present = true - } else { - v.Present = false - } - b += 1 - - v.MajorOpcode = buf[b] - b += 1 - - v.FirstEvent = buf[b] - b += 1 - - v.FirstError = buf[b] - b += 1 - - return v -} - -func (cook QueryExtensionCookie) Check() error { - return cook.check() -} - -// Write request to wire for QueryExtension -func (c *Conn) queryExtensionRequest(NameLen uint16, Name string) []byte { - size := pad((8 + pad((int(NameLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 98 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], NameLen) - b += 2 - - b += 2 // padding - - copy(buf[b:], Name[:NameLen]) - b += pad(int(NameLen)) - - return buf -} - -// Request ListExtensions -// size: 4 -type ListExtensionsCookie struct { - *cookie -} - -func (c *Conn) ListExtensions() ListExtensionsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.listExtensionsRequest(), cookie) - return ListExtensionsCookie{cookie} -} - -func (c *Conn) ListExtensionsUnchecked() ListExtensionsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.listExtensionsRequest(), cookie) - return ListExtensionsCookie{cookie} -} - -// Request reply for ListExtensions -// size: (32 + StrListSize(Names)) -type ListExtensionsReply struct { - Sequence uint16 - Length uint32 - NamesLen byte - // padding: 24 bytes - Names []Str // size: StrListSize(Names) -} - -// Waits and reads reply data from request ListExtensions -func (cook ListExtensionsCookie) Reply() (*ListExtensionsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return listExtensionsReply(buf), nil -} - -// Read reply into structure from buffer for ListExtensions -func listExtensionsReply(buf []byte) *ListExtensionsReply { - v := new(ListExtensionsReply) - b := 1 // skip reply determinant - - v.NamesLen = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 24 // padding - - v.Names = make([]Str, v.NamesLen) - b += ReadStrList(buf[b:], v.Names) - - return v -} - -func (cook ListExtensionsCookie) Check() error { - return cook.check() -} - -// Write request to wire for ListExtensions -func (c *Conn) listExtensionsRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 99 // request opcode - b += 1 - - b += 1 // padding - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request ChangeKeyboardMapping -// size: pad((8 + pad(((int(KeycodeCount) * int(KeysymsPerKeycode)) * 4)))) -type ChangeKeyboardMappingCookie struct { - *cookie -} - -// Write request to wire for ChangeKeyboardMapping -func (c *Conn) ChangeKeyboardMapping(KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) ChangeKeyboardMappingCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.changeKeyboardMappingRequest(KeycodeCount, FirstKeycode, KeysymsPerKeycode, Keysyms), cookie) - return ChangeKeyboardMappingCookie{cookie} -} - -func (c *Conn) ChangeKeyboardMappingChecked(KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) ChangeKeyboardMappingCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.changeKeyboardMappingRequest(KeycodeCount, FirstKeycode, KeysymsPerKeycode, Keysyms), cookie) - return ChangeKeyboardMappingCookie{cookie} -} - -func (cook ChangeKeyboardMappingCookie) Check() error { - return cook.check() -} - -// Write request to wire for ChangeKeyboardMapping -func (c *Conn) changeKeyboardMappingRequest(KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) []byte { - size := pad((8 + pad(((int(KeycodeCount) * int(KeysymsPerKeycode)) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 100 // request opcode - b += 1 - - buf[b] = KeycodeCount - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = byte(FirstKeycode) - b += 1 - - buf[b] = KeysymsPerKeycode - b += 1 - - b += 2 // padding - - for i := 0; i < int((int(KeycodeCount) * int(KeysymsPerKeycode))); i++ { - Put32(buf[b:], uint32(Keysyms[i])) - b += 4 - } - b = pad(b) - - return buf -} - -// Request GetKeyboardMapping -// size: 8 -type GetKeyboardMappingCookie struct { - *cookie -} - -func (c *Conn) GetKeyboardMapping(FirstKeycode Keycode, Count byte) GetKeyboardMappingCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.getKeyboardMappingRequest(FirstKeycode, Count), cookie) - return GetKeyboardMappingCookie{cookie} -} - -func (c *Conn) GetKeyboardMappingUnchecked(FirstKeycode Keycode, Count byte) GetKeyboardMappingCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.getKeyboardMappingRequest(FirstKeycode, Count), cookie) - return GetKeyboardMappingCookie{cookie} -} - -// Request reply for GetKeyboardMapping -// size: (32 + pad((int(Length) * 4))) -type GetKeyboardMappingReply struct { - Sequence uint16 - Length uint32 - KeysymsPerKeycode byte - // padding: 24 bytes - Keysyms []Keysym // size: pad((int(Length) * 4)) -} - -// Waits and reads reply data from request GetKeyboardMapping -func (cook GetKeyboardMappingCookie) Reply() (*GetKeyboardMappingReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getKeyboardMappingReply(buf), nil -} - -// Read reply into structure from buffer for GetKeyboardMapping -func getKeyboardMappingReply(buf []byte) *GetKeyboardMappingReply { - v := new(GetKeyboardMappingReply) - b := 1 // skip reply determinant - - v.KeysymsPerKeycode = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 24 // padding - - v.Keysyms = make([]Keysym, v.Length) - for i := 0; i < int(v.Length); i++ { - v.Keysyms[i] = Keysym(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - return v -} - -func (cook GetKeyboardMappingCookie) Check() error { - return cook.check() -} - -// Write request to wire for GetKeyboardMapping -func (c *Conn) getKeyboardMappingRequest(FirstKeycode Keycode, Count byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 101 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = byte(FirstKeycode) - b += 1 - - buf[b] = Count - b += 1 - - return buf -} - -// Request ChangeKeyboardControl -// size: pad((4 + (4 + pad((4 * popCount(int(ValueMask))))))) -type ChangeKeyboardControlCookie struct { - *cookie -} - -// Write request to wire for ChangeKeyboardControl -func (c *Conn) ChangeKeyboardControl(ValueMask uint32, ValueList []uint32) ChangeKeyboardControlCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.changeKeyboardControlRequest(ValueMask, ValueList), cookie) - return ChangeKeyboardControlCookie{cookie} -} - -func (c *Conn) ChangeKeyboardControlChecked(ValueMask uint32, ValueList []uint32) ChangeKeyboardControlCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.changeKeyboardControlRequest(ValueMask, ValueList), cookie) - return ChangeKeyboardControlCookie{cookie} -} - -func (cook ChangeKeyboardControlCookie) Check() error { - return cook.check() -} - -// Write request to wire for ChangeKeyboardControl -func (c *Conn) changeKeyboardControlRequest(ValueMask uint32, ValueList []uint32) []byte { - size := pad((4 + (4 + pad((4 * popCount(int(ValueMask))))))) - b := 0 - buf := make([]byte, size) - - buf[b] = 102 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], ValueMask) - b += 4 - for i := 0; i < popCount(int(ValueMask)); i++ { - Put32(buf[b:], ValueList[i]) - b += 4 - } - b = pad(b) - - return buf -} - -// Request GetKeyboardControl -// size: 4 -type GetKeyboardControlCookie struct { - *cookie -} - -func (c *Conn) GetKeyboardControl() GetKeyboardControlCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.getKeyboardControlRequest(), cookie) - return GetKeyboardControlCookie{cookie} -} - -func (c *Conn) GetKeyboardControlUnchecked() GetKeyboardControlCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.getKeyboardControlRequest(), cookie) - return GetKeyboardControlCookie{cookie} -} - -// Request reply for GetKeyboardControl -// size: 52 -type GetKeyboardControlReply struct { - Sequence uint16 - Length uint32 - GlobalAutoRepeat byte - LedMask uint32 - KeyClickPercent byte - BellPercent byte - BellPitch uint16 - BellDuration uint16 - // padding: 2 bytes - AutoRepeats []byte // size: 32 -} - -// Waits and reads reply data from request GetKeyboardControl -func (cook GetKeyboardControlCookie) Reply() (*GetKeyboardControlReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getKeyboardControlReply(buf), nil -} - -// Read reply into structure from buffer for GetKeyboardControl -func getKeyboardControlReply(buf []byte) *GetKeyboardControlReply { - v := new(GetKeyboardControlReply) - b := 1 // skip reply determinant - - v.GlobalAutoRepeat = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.LedMask = Get32(buf[b:]) - b += 4 - - v.KeyClickPercent = buf[b] - b += 1 - - v.BellPercent = buf[b] - b += 1 - - v.BellPitch = Get16(buf[b:]) - b += 2 - - v.BellDuration = Get16(buf[b:]) - b += 2 - - b += 2 // padding - - v.AutoRepeats = make([]byte, 32) - copy(v.AutoRepeats[:32], buf[b:]) - b += pad(int(32)) - - return v -} - -func (cook GetKeyboardControlCookie) Check() error { - return cook.check() -} - -// Write request to wire for GetKeyboardControl -func (c *Conn) getKeyboardControlRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 103 // request opcode - b += 1 - - b += 1 // padding - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request Bell -// size: 4 -type BellCookie struct { - *cookie -} - -// Write request to wire for Bell -func (c *Conn) Bell(Percent int8) BellCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.bellRequest(Percent), cookie) - return BellCookie{cookie} -} - -func (c *Conn) BellChecked(Percent int8) BellCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.bellRequest(Percent), cookie) - return BellCookie{cookie} -} - -func (cook BellCookie) Check() error { - return cook.check() -} - -// Write request to wire for Bell -func (c *Conn) bellRequest(Percent int8) []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 104 // request opcode - b += 1 - - buf[b] = byte(Percent) - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request ChangePointerControl -// size: 12 -type ChangePointerControlCookie struct { - *cookie -} - -// Write request to wire for ChangePointerControl -func (c *Conn) ChangePointerControl(AccelerationNumerator int16, AccelerationDenominator int16, Threshold int16, DoAcceleration bool, DoThreshold bool) ChangePointerControlCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.changePointerControlRequest(AccelerationNumerator, AccelerationDenominator, Threshold, DoAcceleration, DoThreshold), cookie) - return ChangePointerControlCookie{cookie} -} - -func (c *Conn) ChangePointerControlChecked(AccelerationNumerator int16, AccelerationDenominator int16, Threshold int16, DoAcceleration bool, DoThreshold bool) ChangePointerControlCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.changePointerControlRequest(AccelerationNumerator, AccelerationDenominator, Threshold, DoAcceleration, DoThreshold), cookie) - return ChangePointerControlCookie{cookie} -} - -func (cook ChangePointerControlCookie) Check() error { - return cook.check() -} - -// Write request to wire for ChangePointerControl -func (c *Conn) changePointerControlRequest(AccelerationNumerator int16, AccelerationDenominator int16, Threshold int16, DoAcceleration bool, DoThreshold bool) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = 105 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], uint16(AccelerationNumerator)) - b += 2 - - Put16(buf[b:], uint16(AccelerationDenominator)) - b += 2 - - Put16(buf[b:], uint16(Threshold)) - b += 2 - - if DoAcceleration { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - if DoThreshold { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - return buf -} - -// Request GetPointerControl -// size: 4 -type GetPointerControlCookie struct { - *cookie -} - -func (c *Conn) GetPointerControl() GetPointerControlCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.getPointerControlRequest(), cookie) - return GetPointerControlCookie{cookie} -} - -func (c *Conn) GetPointerControlUnchecked() GetPointerControlCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.getPointerControlRequest(), cookie) - return GetPointerControlCookie{cookie} -} - -// Request reply for GetPointerControl -// size: 32 -type GetPointerControlReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - AccelerationNumerator uint16 - AccelerationDenominator uint16 - Threshold uint16 - // padding: 18 bytes -} - -// Waits and reads reply data from request GetPointerControl -func (cook GetPointerControlCookie) Reply() (*GetPointerControlReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getPointerControlReply(buf), nil -} - -// Read reply into structure from buffer for GetPointerControl -func getPointerControlReply(buf []byte) *GetPointerControlReply { - v := new(GetPointerControlReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.AccelerationNumerator = Get16(buf[b:]) - b += 2 - - v.AccelerationDenominator = Get16(buf[b:]) - b += 2 - - v.Threshold = Get16(buf[b:]) - b += 2 - - b += 18 // padding - - return v -} - -func (cook GetPointerControlCookie) Check() error { - return cook.check() -} - -// Write request to wire for GetPointerControl -func (c *Conn) getPointerControlRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 106 // request opcode - b += 1 - - b += 1 // padding - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request SetScreenSaver -// size: 12 -type SetScreenSaverCookie struct { - *cookie -} - -// Write request to wire for SetScreenSaver -func (c *Conn) SetScreenSaver(Timeout int16, Interval int16, PreferBlanking byte, AllowExposures byte) SetScreenSaverCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.setScreenSaverRequest(Timeout, Interval, PreferBlanking, AllowExposures), cookie) - return SetScreenSaverCookie{cookie} -} - -func (c *Conn) SetScreenSaverChecked(Timeout int16, Interval int16, PreferBlanking byte, AllowExposures byte) SetScreenSaverCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.setScreenSaverRequest(Timeout, Interval, PreferBlanking, AllowExposures), cookie) - return SetScreenSaverCookie{cookie} -} - -func (cook SetScreenSaverCookie) Check() error { - return cook.check() -} - -// Write request to wire for SetScreenSaver -func (c *Conn) setScreenSaverRequest(Timeout int16, Interval int16, PreferBlanking byte, AllowExposures byte) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = 107 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put16(buf[b:], uint16(Timeout)) - b += 2 - - Put16(buf[b:], uint16(Interval)) - b += 2 - - buf[b] = PreferBlanking - b += 1 - - buf[b] = AllowExposures - b += 1 - - return buf -} - -// Request GetScreenSaver -// size: 4 -type GetScreenSaverCookie struct { - *cookie -} - -func (c *Conn) GetScreenSaver() GetScreenSaverCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.getScreenSaverRequest(), cookie) - return GetScreenSaverCookie{cookie} -} - -func (c *Conn) GetScreenSaverUnchecked() GetScreenSaverCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.getScreenSaverRequest(), cookie) - return GetScreenSaverCookie{cookie} -} - -// Request reply for GetScreenSaver -// size: 32 -type GetScreenSaverReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Timeout uint16 - Interval uint16 - PreferBlanking byte - AllowExposures byte - // padding: 18 bytes -} - -// Waits and reads reply data from request GetScreenSaver -func (cook GetScreenSaverCookie) Reply() (*GetScreenSaverReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getScreenSaverReply(buf), nil -} - -// Read reply into structure from buffer for GetScreenSaver -func getScreenSaverReply(buf []byte) *GetScreenSaverReply { - v := new(GetScreenSaverReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Timeout = Get16(buf[b:]) - b += 2 - - v.Interval = Get16(buf[b:]) - b += 2 - - v.PreferBlanking = buf[b] - b += 1 - - v.AllowExposures = buf[b] - b += 1 - - b += 18 // padding - - return v -} - -func (cook GetScreenSaverCookie) Check() error { - return cook.check() -} - -// Write request to wire for GetScreenSaver -func (c *Conn) getScreenSaverRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 108 // request opcode - b += 1 - - b += 1 // padding - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request ChangeHosts -// size: pad((8 + pad((int(AddressLen) * 1)))) -type ChangeHostsCookie struct { - *cookie -} - -// Write request to wire for ChangeHosts -func (c *Conn) ChangeHosts(Mode byte, Family byte, AddressLen uint16, Address []byte) ChangeHostsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.changeHostsRequest(Mode, Family, AddressLen, Address), cookie) - return ChangeHostsCookie{cookie} -} - -func (c *Conn) ChangeHostsChecked(Mode byte, Family byte, AddressLen uint16, Address []byte) ChangeHostsCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.changeHostsRequest(Mode, Family, AddressLen, Address), cookie) - return ChangeHostsCookie{cookie} -} - -func (cook ChangeHostsCookie) Check() error { - return cook.check() -} - -// Write request to wire for ChangeHosts -func (c *Conn) changeHostsRequest(Mode byte, Family byte, AddressLen uint16, Address []byte) []byte { - size := pad((8 + pad((int(AddressLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 109 // request opcode - b += 1 - - buf[b] = Mode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = Family - b += 1 - - b += 1 // padding - - Put16(buf[b:], AddressLen) - b += 2 - - copy(buf[b:], Address[:AddressLen]) - b += pad(int(AddressLen)) - - return buf -} - -// Request ListHosts -// size: 4 -type ListHostsCookie struct { - *cookie -} - -func (c *Conn) ListHosts() ListHostsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.listHostsRequest(), cookie) - return ListHostsCookie{cookie} -} - -func (c *Conn) ListHostsUnchecked() ListHostsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.listHostsRequest(), cookie) - return ListHostsCookie{cookie} -} - -// Request reply for ListHosts -// size: (32 + HostListSize(Hosts)) -type ListHostsReply struct { - Sequence uint16 - Length uint32 - Mode byte - HostsLen uint16 - // padding: 22 bytes - Hosts []Host // size: HostListSize(Hosts) -} - -// Waits and reads reply data from request ListHosts -func (cook ListHostsCookie) Reply() (*ListHostsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return listHostsReply(buf), nil -} - -// Read reply into structure from buffer for ListHosts -func listHostsReply(buf []byte) *ListHostsReply { - v := new(ListHostsReply) - b := 1 // skip reply determinant - - v.Mode = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.HostsLen = Get16(buf[b:]) - b += 2 - - b += 22 // padding - - v.Hosts = make([]Host, v.HostsLen) - b += ReadHostList(buf[b:], v.Hosts) - - return v -} - -func (cook ListHostsCookie) Check() error { - return cook.check() -} - -// Write request to wire for ListHosts -func (c *Conn) listHostsRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 110 // request opcode - b += 1 - - b += 1 // padding - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request SetAccessControl -// size: 4 -type SetAccessControlCookie struct { - *cookie -} - -// Write request to wire for SetAccessControl -func (c *Conn) SetAccessControl(Mode byte) SetAccessControlCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.setAccessControlRequest(Mode), cookie) - return SetAccessControlCookie{cookie} -} - -func (c *Conn) SetAccessControlChecked(Mode byte) SetAccessControlCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.setAccessControlRequest(Mode), cookie) - return SetAccessControlCookie{cookie} -} - -func (cook SetAccessControlCookie) Check() error { - return cook.check() -} - -// Write request to wire for SetAccessControl -func (c *Conn) setAccessControlRequest(Mode byte) []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 111 // request opcode - b += 1 - - buf[b] = Mode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request SetCloseDownMode -// size: 4 -type SetCloseDownModeCookie struct { - *cookie -} - -// Write request to wire for SetCloseDownMode -func (c *Conn) SetCloseDownMode(Mode byte) SetCloseDownModeCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.setCloseDownModeRequest(Mode), cookie) - return SetCloseDownModeCookie{cookie} -} - -func (c *Conn) SetCloseDownModeChecked(Mode byte) SetCloseDownModeCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.setCloseDownModeRequest(Mode), cookie) - return SetCloseDownModeCookie{cookie} -} - -func (cook SetCloseDownModeCookie) Check() error { - return cook.check() -} - -// Write request to wire for SetCloseDownMode -func (c *Conn) setCloseDownModeRequest(Mode byte) []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 112 // request opcode - b += 1 - - buf[b] = Mode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request KillClient -// size: 8 -type KillClientCookie struct { - *cookie -} - -// Write request to wire for KillClient -func (c *Conn) KillClient(Resource uint32) KillClientCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.killClientRequest(Resource), cookie) - return KillClientCookie{cookie} -} - -func (c *Conn) KillClientChecked(Resource uint32) KillClientCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.killClientRequest(Resource), cookie) - return KillClientCookie{cookie} -} - -func (cook KillClientCookie) Check() error { - return cook.check() -} - -// Write request to wire for KillClient -func (c *Conn) killClientRequest(Resource uint32) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = 113 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Resource) - b += 4 - - return buf -} - -// Request RotateProperties -// size: pad((12 + pad((int(AtomsLen) * 4)))) -type RotatePropertiesCookie struct { - *cookie -} - -// Write request to wire for RotateProperties -func (c *Conn) RotateProperties(Window Window, AtomsLen uint16, Delta int16, Atoms []Atom) RotatePropertiesCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.rotatePropertiesRequest(Window, AtomsLen, Delta, Atoms), cookie) - return RotatePropertiesCookie{cookie} -} - -func (c *Conn) RotatePropertiesChecked(Window Window, AtomsLen uint16, Delta int16, Atoms []Atom) RotatePropertiesCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.rotatePropertiesRequest(Window, AtomsLen, Delta, Atoms), cookie) - return RotatePropertiesCookie{cookie} -} - -func (cook RotatePropertiesCookie) Check() error { - return cook.check() -} - -// Write request to wire for RotateProperties -func (c *Conn) rotatePropertiesRequest(Window Window, AtomsLen uint16, Delta int16, Atoms []Atom) []byte { - size := pad((12 + pad((int(AtomsLen) * 4)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 114 // request opcode - b += 1 - - b += 1 // padding - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - Put16(buf[b:], AtomsLen) - b += 2 - - Put16(buf[b:], uint16(Delta)) - b += 2 - - for i := 0; i < int(AtomsLen); i++ { - Put32(buf[b:], uint32(Atoms[i])) - b += 4 - } - b = pad(b) - - return buf -} - -// Request ForceScreenSaver -// size: 4 -type ForceScreenSaverCookie struct { - *cookie -} - -// Write request to wire for ForceScreenSaver -func (c *Conn) ForceScreenSaver(Mode byte) ForceScreenSaverCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.forceScreenSaverRequest(Mode), cookie) - return ForceScreenSaverCookie{cookie} -} - -func (c *Conn) ForceScreenSaverChecked(Mode byte) ForceScreenSaverCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.forceScreenSaverRequest(Mode), cookie) - return ForceScreenSaverCookie{cookie} -} - -func (cook ForceScreenSaverCookie) Check() error { - return cook.check() -} - -// Write request to wire for ForceScreenSaver -func (c *Conn) forceScreenSaverRequest(Mode byte) []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 115 // request opcode - b += 1 - - buf[b] = Mode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request SetPointerMapping -// size: pad((4 + pad((int(MapLen) * 1)))) -type SetPointerMappingCookie struct { - *cookie -} - -func (c *Conn) SetPointerMapping(MapLen byte, Map []byte) SetPointerMappingCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.setPointerMappingRequest(MapLen, Map), cookie) - return SetPointerMappingCookie{cookie} -} - -func (c *Conn) SetPointerMappingUnchecked(MapLen byte, Map []byte) SetPointerMappingCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.setPointerMappingRequest(MapLen, Map), cookie) - return SetPointerMappingCookie{cookie} -} - -// Request reply for SetPointerMapping -// size: 8 -type SetPointerMappingReply struct { - Sequence uint16 - Length uint32 - Status byte -} - -// Waits and reads reply data from request SetPointerMapping -func (cook SetPointerMappingCookie) Reply() (*SetPointerMappingReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return setPointerMappingReply(buf), nil -} - -// Read reply into structure from buffer for SetPointerMapping -func setPointerMappingReply(buf []byte) *SetPointerMappingReply { - v := new(SetPointerMappingReply) - b := 1 // skip reply determinant - - v.Status = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - return v -} - -func (cook SetPointerMappingCookie) Check() error { - return cook.check() -} - -// Write request to wire for SetPointerMapping -func (c *Conn) setPointerMappingRequest(MapLen byte, Map []byte) []byte { - size := pad((4 + pad((int(MapLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 116 // request opcode - b += 1 - - buf[b] = MapLen - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - copy(buf[b:], Map[:MapLen]) - b += pad(int(MapLen)) - - return buf -} - -// Request GetPointerMapping -// size: 4 -type GetPointerMappingCookie struct { - *cookie -} - -func (c *Conn) GetPointerMapping() GetPointerMappingCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.getPointerMappingRequest(), cookie) - return GetPointerMappingCookie{cookie} -} - -func (c *Conn) GetPointerMappingUnchecked() GetPointerMappingCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.getPointerMappingRequest(), cookie) - return GetPointerMappingCookie{cookie} -} - -// Request reply for GetPointerMapping -// size: (32 + pad((int(MapLen) * 1))) -type GetPointerMappingReply struct { - Sequence uint16 - Length uint32 - MapLen byte - // padding: 24 bytes - Map []byte // size: pad((int(MapLen) * 1)) -} - -// Waits and reads reply data from request GetPointerMapping -func (cook GetPointerMappingCookie) Reply() (*GetPointerMappingReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getPointerMappingReply(buf), nil -} - -// Read reply into structure from buffer for GetPointerMapping -func getPointerMappingReply(buf []byte) *GetPointerMappingReply { - v := new(GetPointerMappingReply) - b := 1 // skip reply determinant - - v.MapLen = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 24 // padding - - v.Map = make([]byte, v.MapLen) - copy(v.Map[:v.MapLen], buf[b:]) - b += pad(int(v.MapLen)) - - return v -} - -func (cook GetPointerMappingCookie) Check() error { - return cook.check() -} - -// Write request to wire for GetPointerMapping -func (c *Conn) getPointerMappingRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 117 // request opcode - b += 1 - - b += 1 // padding - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request SetModifierMapping -// size: pad((4 + pad(((int(KeycodesPerModifier) * 8) * 1)))) -type SetModifierMappingCookie struct { - *cookie -} - -func (c *Conn) SetModifierMapping(KeycodesPerModifier byte, Keycodes []Keycode) SetModifierMappingCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.setModifierMappingRequest(KeycodesPerModifier, Keycodes), cookie) - return SetModifierMappingCookie{cookie} -} - -func (c *Conn) SetModifierMappingUnchecked(KeycodesPerModifier byte, Keycodes []Keycode) SetModifierMappingCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.setModifierMappingRequest(KeycodesPerModifier, Keycodes), cookie) - return SetModifierMappingCookie{cookie} -} - -// Request reply for SetModifierMapping -// size: 8 -type SetModifierMappingReply struct { - Sequence uint16 - Length uint32 - Status byte -} - -// Waits and reads reply data from request SetModifierMapping -func (cook SetModifierMappingCookie) Reply() (*SetModifierMappingReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return setModifierMappingReply(buf), nil -} - -// Read reply into structure from buffer for SetModifierMapping -func setModifierMappingReply(buf []byte) *SetModifierMappingReply { - v := new(SetModifierMappingReply) - b := 1 // skip reply determinant - - v.Status = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - return v -} - -func (cook SetModifierMappingCookie) Check() error { - return cook.check() -} - -// Write request to wire for SetModifierMapping -func (c *Conn) setModifierMappingRequest(KeycodesPerModifier byte, Keycodes []Keycode) []byte { - size := pad((4 + pad(((int(KeycodesPerModifier) * 8) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = 118 // request opcode - b += 1 - - buf[b] = KeycodesPerModifier - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - for i := 0; i < int((int(KeycodesPerModifier) * 8)); i++ { - buf[b] = byte(Keycodes[i]) - b += 1 - } - b = pad(b) - - return buf -} - -// Request GetModifierMapping -// size: 4 -type GetModifierMappingCookie struct { - *cookie -} - -func (c *Conn) GetModifierMapping() GetModifierMappingCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.getModifierMappingRequest(), cookie) - return GetModifierMappingCookie{cookie} -} - -func (c *Conn) GetModifierMappingUnchecked() GetModifierMappingCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.getModifierMappingRequest(), cookie) - return GetModifierMappingCookie{cookie} -} - -// Request reply for GetModifierMapping -// size: (32 + pad(((int(KeycodesPerModifier) * 8) * 1))) -type GetModifierMappingReply struct { - Sequence uint16 - Length uint32 - KeycodesPerModifier byte - // padding: 24 bytes - Keycodes []Keycode // size: pad(((int(KeycodesPerModifier) * 8) * 1)) -} - -// Waits and reads reply data from request GetModifierMapping -func (cook GetModifierMappingCookie) Reply() (*GetModifierMappingReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getModifierMappingReply(buf), nil -} - -// Read reply into structure from buffer for GetModifierMapping -func getModifierMappingReply(buf []byte) *GetModifierMappingReply { - v := new(GetModifierMappingReply) - b := 1 // skip reply determinant - - v.KeycodesPerModifier = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 24 // padding - - v.Keycodes = make([]Keycode, (int(v.KeycodesPerModifier) * 8)) - for i := 0; i < int((int(v.KeycodesPerModifier) * 8)); i++ { - v.Keycodes[i] = Keycode(buf[b]) - b += 1 - } - b = pad(b) - - return v -} - -func (cook GetModifierMappingCookie) Check() error { - return cook.check() -} - -// Write request to wire for GetModifierMapping -func (c *Conn) getModifierMappingRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 119 // request opcode - b += 1 - - b += 1 // padding - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request NoOperation -// size: 4 -type NoOperationCookie struct { - *cookie -} - -// Write request to wire for NoOperation -func (c *Conn) NoOperation() NoOperationCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.noOperationRequest(), cookie) - return NoOperationCookie{cookie} -} - -func (c *Conn) NoOperationChecked() NoOperationCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.noOperationRequest(), cookie) - return NoOperationCookie{cookie} -} - -func (cook NoOperationCookie) Check() error { - return cook.check() -} - -// Write request to wire for NoOperation -func (c *Conn) noOperationRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = 127 // request opcode - b += 1 - - b += 1 // padding - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} diff --git a/nexgb/auto_xselinux.go b/nexgb/auto_xselinux.go deleted file mode 100644 index 4e7ee81..0000000 --- a/nexgb/auto_xselinux.go +++ /dev/null @@ -1,1965 +0,0 @@ -package xgb - -/* - This file was generated by xselinux.xml on May 10 2012 12:39:34pm EDT. - This file is automatically generated. Edit at your peril! -*/ - -// Imports are not necessary for XGB because everything is -// in one package. They are still listed here for reference. -// import "xproto" - -// XselinuxInit must be called before using the SELinux extension. -func (c *Conn) XselinuxInit() error { - reply, err := c.QueryExtension(7, "SELinux").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named SELinux could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["SELinux"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["SELinux"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["SELinux"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["SELinux"] = make(map[int]newEventFun) - newExtErrorFuncs["SELinux"] = make(map[int]newErrorFun) -} - -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - -// Skipping definition for base type 'Int8' - -// Skipping definition for base type 'Card16' - -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - -// Skipping definition for base type 'Float' - -// 'XselinuxListItem' struct definition -// Size: ((12 + pad((int(ObjectContextLen) * 1))) + pad((int(DataContextLen) * 1))) -type XselinuxListItem struct { - Name Atom - ObjectContextLen uint32 - DataContextLen uint32 - ObjectContext string // size: pad((int(ObjectContextLen) * 1)) - DataContext string // size: pad((int(DataContextLen) * 1)) -} - -// Struct read XselinuxListItem -func ReadXselinuxListItem(buf []byte, v *XselinuxListItem) int { - b := 0 - - v.Name = Atom(Get32(buf[b:])) - b += 4 - - v.ObjectContextLen = Get32(buf[b:]) - b += 4 - - v.DataContextLen = Get32(buf[b:]) - b += 4 - - { - byteString := make([]byte, v.ObjectContextLen) - copy(byteString[:v.ObjectContextLen], buf[b:]) - v.ObjectContext = string(byteString) - b += pad(int(v.ObjectContextLen)) - } - - { - byteString := make([]byte, v.DataContextLen) - copy(byteString[:v.DataContextLen], buf[b:]) - v.DataContext = string(byteString) - b += pad(int(v.DataContextLen)) - } - - return b -} - -// Struct list read XselinuxListItem -func ReadXselinuxListItemList(buf []byte, dest []XselinuxListItem) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XselinuxListItem{} - b += ReadXselinuxListItem(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XselinuxListItem -func (v XselinuxListItem) Bytes() []byte { - buf := make([]byte, ((12 + pad((int(v.ObjectContextLen) * 1))) + pad((int(v.DataContextLen) * 1)))) - b := 0 - - Put32(buf[b:], uint32(v.Name)) - b += 4 - - Put32(buf[b:], v.ObjectContextLen) - b += 4 - - Put32(buf[b:], v.DataContextLen) - b += 4 - - copy(buf[b:], v.ObjectContext[:v.ObjectContextLen]) - b += pad(int(v.ObjectContextLen)) - - copy(buf[b:], v.DataContext[:v.DataContextLen]) - b += pad(int(v.DataContextLen)) - - return buf -} - -// Write struct list XselinuxListItem -func XselinuxListItemListBytes(buf []byte, list []XselinuxListItem) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size XselinuxListItem -func XselinuxListItemListSize(list []XselinuxListItem) int { - size := 0 - for _, item := range list { - size += ((12 + pad((int(item.ObjectContextLen) * 1))) + pad((int(item.DataContextLen) * 1))) - } - return size -} - -// Request XselinuxQueryVersion -// size: 8 -type XselinuxQueryVersionCookie struct { - *cookie -} - -func (c *Conn) XselinuxQueryVersion(ClientMajor byte, ClientMinor byte) XselinuxQueryVersionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xselinuxQueryVersionRequest(ClientMajor, ClientMinor), cookie) - return XselinuxQueryVersionCookie{cookie} -} - -func (c *Conn) XselinuxQueryVersionUnchecked(ClientMajor byte, ClientMinor byte) XselinuxQueryVersionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xselinuxQueryVersionRequest(ClientMajor, ClientMinor), cookie) - return XselinuxQueryVersionCookie{cookie} -} - -// Request reply for XselinuxQueryVersion -// size: 12 -type XselinuxQueryVersionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ServerMajor uint16 - ServerMinor uint16 -} - -// Waits and reads reply data from request XselinuxQueryVersion -func (cook XselinuxQueryVersionCookie) Reply() (*XselinuxQueryVersionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xselinuxQueryVersionReply(buf), nil -} - -// Read reply into structure from buffer for XselinuxQueryVersion -func xselinuxQueryVersionReply(buf []byte) *XselinuxQueryVersionReply { - v := new(XselinuxQueryVersionReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.ServerMajor = Get16(buf[b:]) - b += 2 - - v.ServerMinor = Get16(buf[b:]) - b += 2 - - return v -} - -func (cook XselinuxQueryVersionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxQueryVersion -func (c *Conn) xselinuxQueryVersionRequest(ClientMajor byte, ClientMinor byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - b += 1 - - buf[b] = 0 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = ClientMajor - b += 1 - - buf[b] = ClientMinor - b += 1 - - return buf -} - -// Request XselinuxSetDeviceCreateContext -// size: pad((8 + pad((int(ContextLen) * 1)))) -type XselinuxSetDeviceCreateContextCookie struct { - *cookie -} - -// Write request to wire for XselinuxSetDeviceCreateContext -func (c *Conn) XselinuxSetDeviceCreateContext(ContextLen uint32, Context string) XselinuxSetDeviceCreateContextCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xselinuxSetDeviceCreateContextRequest(ContextLen, Context), cookie) - return XselinuxSetDeviceCreateContextCookie{cookie} -} - -func (c *Conn) XselinuxSetDeviceCreateContextChecked(ContextLen uint32, Context string) XselinuxSetDeviceCreateContextCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xselinuxSetDeviceCreateContextRequest(ContextLen, Context), cookie) - return XselinuxSetDeviceCreateContextCookie{cookie} -} - -func (cook XselinuxSetDeviceCreateContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxSetDeviceCreateContext -func (c *Conn) xselinuxSetDeviceCreateContextRequest(ContextLen uint32, Context string) []byte { - size := pad((8 + pad((int(ContextLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - b += 1 - - buf[b] = 1 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], ContextLen) - b += 4 - - copy(buf[b:], Context[:ContextLen]) - b += pad(int(ContextLen)) - - return buf -} - -// Request XselinuxGetDeviceCreateContext -// size: 4 -type XselinuxGetDeviceCreateContextCookie struct { - *cookie -} - -func (c *Conn) XselinuxGetDeviceCreateContext() XselinuxGetDeviceCreateContextCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xselinuxGetDeviceCreateContextRequest(), cookie) - return XselinuxGetDeviceCreateContextCookie{cookie} -} - -func (c *Conn) XselinuxGetDeviceCreateContextUnchecked() XselinuxGetDeviceCreateContextCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xselinuxGetDeviceCreateContextRequest(), cookie) - return XselinuxGetDeviceCreateContextCookie{cookie} -} - -// Request reply for XselinuxGetDeviceCreateContext -// size: (32 + pad((int(ContextLen) * 1))) -type XselinuxGetDeviceCreateContextReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ContextLen uint32 - // padding: 20 bytes - Context string // size: pad((int(ContextLen) * 1)) -} - -// Waits and reads reply data from request XselinuxGetDeviceCreateContext -func (cook XselinuxGetDeviceCreateContextCookie) Reply() (*XselinuxGetDeviceCreateContextReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xselinuxGetDeviceCreateContextReply(buf), nil -} - -// Read reply into structure from buffer for XselinuxGetDeviceCreateContext -func xselinuxGetDeviceCreateContextReply(buf []byte) *XselinuxGetDeviceCreateContextReply { - v := new(XselinuxGetDeviceCreateContextReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.ContextLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - { - byteString := make([]byte, v.ContextLen) - copy(byteString[:v.ContextLen], buf[b:]) - v.Context = string(byteString) - b += pad(int(v.ContextLen)) - } - - return v -} - -func (cook XselinuxGetDeviceCreateContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxGetDeviceCreateContext -func (c *Conn) xselinuxGetDeviceCreateContextRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - b += 1 - - buf[b] = 2 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request XselinuxSetDeviceContext -// size: pad((12 + pad((int(ContextLen) * 1)))) -type XselinuxSetDeviceContextCookie struct { - *cookie -} - -// Write request to wire for XselinuxSetDeviceContext -func (c *Conn) XselinuxSetDeviceContext(Device uint32, ContextLen uint32, Context string) XselinuxSetDeviceContextCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xselinuxSetDeviceContextRequest(Device, ContextLen, Context), cookie) - return XselinuxSetDeviceContextCookie{cookie} -} - -func (c *Conn) XselinuxSetDeviceContextChecked(Device uint32, ContextLen uint32, Context string) XselinuxSetDeviceContextCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xselinuxSetDeviceContextRequest(Device, ContextLen, Context), cookie) - return XselinuxSetDeviceContextCookie{cookie} -} - -func (cook XselinuxSetDeviceContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxSetDeviceContext -func (c *Conn) xselinuxSetDeviceContextRequest(Device uint32, ContextLen uint32, Context string) []byte { - size := pad((12 + pad((int(ContextLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - b += 1 - - buf[b] = 3 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Device) - b += 4 - - Put32(buf[b:], ContextLen) - b += 4 - - copy(buf[b:], Context[:ContextLen]) - b += pad(int(ContextLen)) - - return buf -} - -// Request XselinuxGetDeviceContext -// size: 8 -type XselinuxGetDeviceContextCookie struct { - *cookie -} - -func (c *Conn) XselinuxGetDeviceContext(Device uint32) XselinuxGetDeviceContextCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xselinuxGetDeviceContextRequest(Device), cookie) - return XselinuxGetDeviceContextCookie{cookie} -} - -func (c *Conn) XselinuxGetDeviceContextUnchecked(Device uint32) XselinuxGetDeviceContextCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xselinuxGetDeviceContextRequest(Device), cookie) - return XselinuxGetDeviceContextCookie{cookie} -} - -// Request reply for XselinuxGetDeviceContext -// size: (32 + pad((int(ContextLen) * 1))) -type XselinuxGetDeviceContextReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ContextLen uint32 - // padding: 20 bytes - Context string // size: pad((int(ContextLen) * 1)) -} - -// Waits and reads reply data from request XselinuxGetDeviceContext -func (cook XselinuxGetDeviceContextCookie) Reply() (*XselinuxGetDeviceContextReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xselinuxGetDeviceContextReply(buf), nil -} - -// Read reply into structure from buffer for XselinuxGetDeviceContext -func xselinuxGetDeviceContextReply(buf []byte) *XselinuxGetDeviceContextReply { - v := new(XselinuxGetDeviceContextReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.ContextLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - { - byteString := make([]byte, v.ContextLen) - copy(byteString[:v.ContextLen], buf[b:]) - v.Context = string(byteString) - b += pad(int(v.ContextLen)) - } - - return v -} - -func (cook XselinuxGetDeviceContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxGetDeviceContext -func (c *Conn) xselinuxGetDeviceContextRequest(Device uint32) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - b += 1 - - buf[b] = 4 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Device) - b += 4 - - return buf -} - -// Request XselinuxSetWindowCreateContext -// size: pad((8 + pad((int(ContextLen) * 1)))) -type XselinuxSetWindowCreateContextCookie struct { - *cookie -} - -// Write request to wire for XselinuxSetWindowCreateContext -func (c *Conn) XselinuxSetWindowCreateContext(ContextLen uint32, Context string) XselinuxSetWindowCreateContextCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xselinuxSetWindowCreateContextRequest(ContextLen, Context), cookie) - return XselinuxSetWindowCreateContextCookie{cookie} -} - -func (c *Conn) XselinuxSetWindowCreateContextChecked(ContextLen uint32, Context string) XselinuxSetWindowCreateContextCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xselinuxSetWindowCreateContextRequest(ContextLen, Context), cookie) - return XselinuxSetWindowCreateContextCookie{cookie} -} - -func (cook XselinuxSetWindowCreateContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxSetWindowCreateContext -func (c *Conn) xselinuxSetWindowCreateContextRequest(ContextLen uint32, Context string) []byte { - size := pad((8 + pad((int(ContextLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - b += 1 - - buf[b] = 5 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], ContextLen) - b += 4 - - copy(buf[b:], Context[:ContextLen]) - b += pad(int(ContextLen)) - - return buf -} - -// Request XselinuxGetWindowCreateContext -// size: 4 -type XselinuxGetWindowCreateContextCookie struct { - *cookie -} - -func (c *Conn) XselinuxGetWindowCreateContext() XselinuxGetWindowCreateContextCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xselinuxGetWindowCreateContextRequest(), cookie) - return XselinuxGetWindowCreateContextCookie{cookie} -} - -func (c *Conn) XselinuxGetWindowCreateContextUnchecked() XselinuxGetWindowCreateContextCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xselinuxGetWindowCreateContextRequest(), cookie) - return XselinuxGetWindowCreateContextCookie{cookie} -} - -// Request reply for XselinuxGetWindowCreateContext -// size: (32 + pad((int(ContextLen) * 1))) -type XselinuxGetWindowCreateContextReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ContextLen uint32 - // padding: 20 bytes - Context string // size: pad((int(ContextLen) * 1)) -} - -// Waits and reads reply data from request XselinuxGetWindowCreateContext -func (cook XselinuxGetWindowCreateContextCookie) Reply() (*XselinuxGetWindowCreateContextReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xselinuxGetWindowCreateContextReply(buf), nil -} - -// Read reply into structure from buffer for XselinuxGetWindowCreateContext -func xselinuxGetWindowCreateContextReply(buf []byte) *XselinuxGetWindowCreateContextReply { - v := new(XselinuxGetWindowCreateContextReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.ContextLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - { - byteString := make([]byte, v.ContextLen) - copy(byteString[:v.ContextLen], buf[b:]) - v.Context = string(byteString) - b += pad(int(v.ContextLen)) - } - - return v -} - -func (cook XselinuxGetWindowCreateContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxGetWindowCreateContext -func (c *Conn) xselinuxGetWindowCreateContextRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - b += 1 - - buf[b] = 6 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request XselinuxGetWindowContext -// size: 8 -type XselinuxGetWindowContextCookie struct { - *cookie -} - -func (c *Conn) XselinuxGetWindowContext(Window Window) XselinuxGetWindowContextCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xselinuxGetWindowContextRequest(Window), cookie) - return XselinuxGetWindowContextCookie{cookie} -} - -func (c *Conn) XselinuxGetWindowContextUnchecked(Window Window) XselinuxGetWindowContextCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xselinuxGetWindowContextRequest(Window), cookie) - return XselinuxGetWindowContextCookie{cookie} -} - -// Request reply for XselinuxGetWindowContext -// size: (32 + pad((int(ContextLen) * 1))) -type XselinuxGetWindowContextReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ContextLen uint32 - // padding: 20 bytes - Context string // size: pad((int(ContextLen) * 1)) -} - -// Waits and reads reply data from request XselinuxGetWindowContext -func (cook XselinuxGetWindowContextCookie) Reply() (*XselinuxGetWindowContextReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xselinuxGetWindowContextReply(buf), nil -} - -// Read reply into structure from buffer for XselinuxGetWindowContext -func xselinuxGetWindowContextReply(buf []byte) *XselinuxGetWindowContextReply { - v := new(XselinuxGetWindowContextReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.ContextLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - { - byteString := make([]byte, v.ContextLen) - copy(byteString[:v.ContextLen], buf[b:]) - v.Context = string(byteString) - b += pad(int(v.ContextLen)) - } - - return v -} - -func (cook XselinuxGetWindowContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxGetWindowContext -func (c *Conn) xselinuxGetWindowContextRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - b += 1 - - buf[b] = 7 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - return buf -} - -// Request XselinuxSetPropertyCreateContext -// size: pad((8 + pad((int(ContextLen) * 1)))) -type XselinuxSetPropertyCreateContextCookie struct { - *cookie -} - -// Write request to wire for XselinuxSetPropertyCreateContext -func (c *Conn) XselinuxSetPropertyCreateContext(ContextLen uint32, Context string) XselinuxSetPropertyCreateContextCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xselinuxSetPropertyCreateContextRequest(ContextLen, Context), cookie) - return XselinuxSetPropertyCreateContextCookie{cookie} -} - -func (c *Conn) XselinuxSetPropertyCreateContextChecked(ContextLen uint32, Context string) XselinuxSetPropertyCreateContextCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xselinuxSetPropertyCreateContextRequest(ContextLen, Context), cookie) - return XselinuxSetPropertyCreateContextCookie{cookie} -} - -func (cook XselinuxSetPropertyCreateContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxSetPropertyCreateContext -func (c *Conn) xselinuxSetPropertyCreateContextRequest(ContextLen uint32, Context string) []byte { - size := pad((8 + pad((int(ContextLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - b += 1 - - buf[b] = 8 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], ContextLen) - b += 4 - - copy(buf[b:], Context[:ContextLen]) - b += pad(int(ContextLen)) - - return buf -} - -// Request XselinuxGetPropertyCreateContext -// size: 4 -type XselinuxGetPropertyCreateContextCookie struct { - *cookie -} - -func (c *Conn) XselinuxGetPropertyCreateContext() XselinuxGetPropertyCreateContextCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xselinuxGetPropertyCreateContextRequest(), cookie) - return XselinuxGetPropertyCreateContextCookie{cookie} -} - -func (c *Conn) XselinuxGetPropertyCreateContextUnchecked() XselinuxGetPropertyCreateContextCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xselinuxGetPropertyCreateContextRequest(), cookie) - return XselinuxGetPropertyCreateContextCookie{cookie} -} - -// Request reply for XselinuxGetPropertyCreateContext -// size: (32 + pad((int(ContextLen) * 1))) -type XselinuxGetPropertyCreateContextReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ContextLen uint32 - // padding: 20 bytes - Context string // size: pad((int(ContextLen) * 1)) -} - -// Waits and reads reply data from request XselinuxGetPropertyCreateContext -func (cook XselinuxGetPropertyCreateContextCookie) Reply() (*XselinuxGetPropertyCreateContextReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xselinuxGetPropertyCreateContextReply(buf), nil -} - -// Read reply into structure from buffer for XselinuxGetPropertyCreateContext -func xselinuxGetPropertyCreateContextReply(buf []byte) *XselinuxGetPropertyCreateContextReply { - v := new(XselinuxGetPropertyCreateContextReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.ContextLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - { - byteString := make([]byte, v.ContextLen) - copy(byteString[:v.ContextLen], buf[b:]) - v.Context = string(byteString) - b += pad(int(v.ContextLen)) - } - - return v -} - -func (cook XselinuxGetPropertyCreateContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxGetPropertyCreateContext -func (c *Conn) xselinuxGetPropertyCreateContextRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - b += 1 - - buf[b] = 9 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request XselinuxSetPropertyUseContext -// size: pad((8 + pad((int(ContextLen) * 1)))) -type XselinuxSetPropertyUseContextCookie struct { - *cookie -} - -// Write request to wire for XselinuxSetPropertyUseContext -func (c *Conn) XselinuxSetPropertyUseContext(ContextLen uint32, Context string) XselinuxSetPropertyUseContextCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xselinuxSetPropertyUseContextRequest(ContextLen, Context), cookie) - return XselinuxSetPropertyUseContextCookie{cookie} -} - -func (c *Conn) XselinuxSetPropertyUseContextChecked(ContextLen uint32, Context string) XselinuxSetPropertyUseContextCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xselinuxSetPropertyUseContextRequest(ContextLen, Context), cookie) - return XselinuxSetPropertyUseContextCookie{cookie} -} - -func (cook XselinuxSetPropertyUseContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxSetPropertyUseContext -func (c *Conn) xselinuxSetPropertyUseContextRequest(ContextLen uint32, Context string) []byte { - size := pad((8 + pad((int(ContextLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - b += 1 - - buf[b] = 10 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], ContextLen) - b += 4 - - copy(buf[b:], Context[:ContextLen]) - b += pad(int(ContextLen)) - - return buf -} - -// Request XselinuxGetPropertyUseContext -// size: 4 -type XselinuxGetPropertyUseContextCookie struct { - *cookie -} - -func (c *Conn) XselinuxGetPropertyUseContext() XselinuxGetPropertyUseContextCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xselinuxGetPropertyUseContextRequest(), cookie) - return XselinuxGetPropertyUseContextCookie{cookie} -} - -func (c *Conn) XselinuxGetPropertyUseContextUnchecked() XselinuxGetPropertyUseContextCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xselinuxGetPropertyUseContextRequest(), cookie) - return XselinuxGetPropertyUseContextCookie{cookie} -} - -// Request reply for XselinuxGetPropertyUseContext -// size: (32 + pad((int(ContextLen) * 1))) -type XselinuxGetPropertyUseContextReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ContextLen uint32 - // padding: 20 bytes - Context string // size: pad((int(ContextLen) * 1)) -} - -// Waits and reads reply data from request XselinuxGetPropertyUseContext -func (cook XselinuxGetPropertyUseContextCookie) Reply() (*XselinuxGetPropertyUseContextReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xselinuxGetPropertyUseContextReply(buf), nil -} - -// Read reply into structure from buffer for XselinuxGetPropertyUseContext -func xselinuxGetPropertyUseContextReply(buf []byte) *XselinuxGetPropertyUseContextReply { - v := new(XselinuxGetPropertyUseContextReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.ContextLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - { - byteString := make([]byte, v.ContextLen) - copy(byteString[:v.ContextLen], buf[b:]) - v.Context = string(byteString) - b += pad(int(v.ContextLen)) - } - - return v -} - -func (cook XselinuxGetPropertyUseContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxGetPropertyUseContext -func (c *Conn) xselinuxGetPropertyUseContextRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - b += 1 - - buf[b] = 11 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request XselinuxGetPropertyContext -// size: 12 -type XselinuxGetPropertyContextCookie struct { - *cookie -} - -func (c *Conn) XselinuxGetPropertyContext(Window Window, Property Atom) XselinuxGetPropertyContextCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xselinuxGetPropertyContextRequest(Window, Property), cookie) - return XselinuxGetPropertyContextCookie{cookie} -} - -func (c *Conn) XselinuxGetPropertyContextUnchecked(Window Window, Property Atom) XselinuxGetPropertyContextCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xselinuxGetPropertyContextRequest(Window, Property), cookie) - return XselinuxGetPropertyContextCookie{cookie} -} - -// Request reply for XselinuxGetPropertyContext -// size: (32 + pad((int(ContextLen) * 1))) -type XselinuxGetPropertyContextReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ContextLen uint32 - // padding: 20 bytes - Context string // size: pad((int(ContextLen) * 1)) -} - -// Waits and reads reply data from request XselinuxGetPropertyContext -func (cook XselinuxGetPropertyContextCookie) Reply() (*XselinuxGetPropertyContextReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xselinuxGetPropertyContextReply(buf), nil -} - -// Read reply into structure from buffer for XselinuxGetPropertyContext -func xselinuxGetPropertyContextReply(buf []byte) *XselinuxGetPropertyContextReply { - v := new(XselinuxGetPropertyContextReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.ContextLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - { - byteString := make([]byte, v.ContextLen) - copy(byteString[:v.ContextLen], buf[b:]) - v.Context = string(byteString) - b += pad(int(v.ContextLen)) - } - - return v -} - -func (cook XselinuxGetPropertyContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxGetPropertyContext -func (c *Conn) xselinuxGetPropertyContextRequest(Window Window, Property Atom) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - b += 1 - - buf[b] = 12 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - Put32(buf[b:], uint32(Property)) - b += 4 - - return buf -} - -// Request XselinuxGetPropertyDataContext -// size: 12 -type XselinuxGetPropertyDataContextCookie struct { - *cookie -} - -func (c *Conn) XselinuxGetPropertyDataContext(Window Window, Property Atom) XselinuxGetPropertyDataContextCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xselinuxGetPropertyDataContextRequest(Window, Property), cookie) - return XselinuxGetPropertyDataContextCookie{cookie} -} - -func (c *Conn) XselinuxGetPropertyDataContextUnchecked(Window Window, Property Atom) XselinuxGetPropertyDataContextCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xselinuxGetPropertyDataContextRequest(Window, Property), cookie) - return XselinuxGetPropertyDataContextCookie{cookie} -} - -// Request reply for XselinuxGetPropertyDataContext -// size: (32 + pad((int(ContextLen) * 1))) -type XselinuxGetPropertyDataContextReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ContextLen uint32 - // padding: 20 bytes - Context string // size: pad((int(ContextLen) * 1)) -} - -// Waits and reads reply data from request XselinuxGetPropertyDataContext -func (cook XselinuxGetPropertyDataContextCookie) Reply() (*XselinuxGetPropertyDataContextReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xselinuxGetPropertyDataContextReply(buf), nil -} - -// Read reply into structure from buffer for XselinuxGetPropertyDataContext -func xselinuxGetPropertyDataContextReply(buf []byte) *XselinuxGetPropertyDataContextReply { - v := new(XselinuxGetPropertyDataContextReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.ContextLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - { - byteString := make([]byte, v.ContextLen) - copy(byteString[:v.ContextLen], buf[b:]) - v.Context = string(byteString) - b += pad(int(v.ContextLen)) - } - - return v -} - -func (cook XselinuxGetPropertyDataContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxGetPropertyDataContext -func (c *Conn) xselinuxGetPropertyDataContextRequest(Window Window, Property Atom) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - b += 1 - - buf[b] = 13 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - Put32(buf[b:], uint32(Property)) - b += 4 - - return buf -} - -// Request XselinuxListProperties -// size: 8 -type XselinuxListPropertiesCookie struct { - *cookie -} - -func (c *Conn) XselinuxListProperties(Window Window) XselinuxListPropertiesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xselinuxListPropertiesRequest(Window), cookie) - return XselinuxListPropertiesCookie{cookie} -} - -func (c *Conn) XselinuxListPropertiesUnchecked(Window Window) XselinuxListPropertiesCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xselinuxListPropertiesRequest(Window), cookie) - return XselinuxListPropertiesCookie{cookie} -} - -// Request reply for XselinuxListProperties -// size: (32 + XselinuxListItemListSize(Properties)) -type XselinuxListPropertiesReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - PropertiesLen uint32 - // padding: 20 bytes - Properties []XselinuxListItem // size: XselinuxListItemListSize(Properties) -} - -// Waits and reads reply data from request XselinuxListProperties -func (cook XselinuxListPropertiesCookie) Reply() (*XselinuxListPropertiesReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xselinuxListPropertiesReply(buf), nil -} - -// Read reply into structure from buffer for XselinuxListProperties -func xselinuxListPropertiesReply(buf []byte) *XselinuxListPropertiesReply { - v := new(XselinuxListPropertiesReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.PropertiesLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Properties = make([]XselinuxListItem, v.PropertiesLen) - b += ReadXselinuxListItemList(buf[b:], v.Properties) - - return v -} - -func (cook XselinuxListPropertiesCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxListProperties -func (c *Conn) xselinuxListPropertiesRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - b += 1 - - buf[b] = 14 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - return buf -} - -// Request XselinuxSetSelectionCreateContext -// size: pad((8 + pad((int(ContextLen) * 1)))) -type XselinuxSetSelectionCreateContextCookie struct { - *cookie -} - -// Write request to wire for XselinuxSetSelectionCreateContext -func (c *Conn) XselinuxSetSelectionCreateContext(ContextLen uint32, Context string) XselinuxSetSelectionCreateContextCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xselinuxSetSelectionCreateContextRequest(ContextLen, Context), cookie) - return XselinuxSetSelectionCreateContextCookie{cookie} -} - -func (c *Conn) XselinuxSetSelectionCreateContextChecked(ContextLen uint32, Context string) XselinuxSetSelectionCreateContextCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xselinuxSetSelectionCreateContextRequest(ContextLen, Context), cookie) - return XselinuxSetSelectionCreateContextCookie{cookie} -} - -func (cook XselinuxSetSelectionCreateContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxSetSelectionCreateContext -func (c *Conn) xselinuxSetSelectionCreateContextRequest(ContextLen uint32, Context string) []byte { - size := pad((8 + pad((int(ContextLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - b += 1 - - buf[b] = 15 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], ContextLen) - b += 4 - - copy(buf[b:], Context[:ContextLen]) - b += pad(int(ContextLen)) - - return buf -} - -// Request XselinuxGetSelectionCreateContext -// size: 4 -type XselinuxGetSelectionCreateContextCookie struct { - *cookie -} - -func (c *Conn) XselinuxGetSelectionCreateContext() XselinuxGetSelectionCreateContextCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xselinuxGetSelectionCreateContextRequest(), cookie) - return XselinuxGetSelectionCreateContextCookie{cookie} -} - -func (c *Conn) XselinuxGetSelectionCreateContextUnchecked() XselinuxGetSelectionCreateContextCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xselinuxGetSelectionCreateContextRequest(), cookie) - return XselinuxGetSelectionCreateContextCookie{cookie} -} - -// Request reply for XselinuxGetSelectionCreateContext -// size: (32 + pad((int(ContextLen) * 1))) -type XselinuxGetSelectionCreateContextReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ContextLen uint32 - // padding: 20 bytes - Context string // size: pad((int(ContextLen) * 1)) -} - -// Waits and reads reply data from request XselinuxGetSelectionCreateContext -func (cook XselinuxGetSelectionCreateContextCookie) Reply() (*XselinuxGetSelectionCreateContextReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xselinuxGetSelectionCreateContextReply(buf), nil -} - -// Read reply into structure from buffer for XselinuxGetSelectionCreateContext -func xselinuxGetSelectionCreateContextReply(buf []byte) *XselinuxGetSelectionCreateContextReply { - v := new(XselinuxGetSelectionCreateContextReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.ContextLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - { - byteString := make([]byte, v.ContextLen) - copy(byteString[:v.ContextLen], buf[b:]) - v.Context = string(byteString) - b += pad(int(v.ContextLen)) - } - - return v -} - -func (cook XselinuxGetSelectionCreateContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxGetSelectionCreateContext -func (c *Conn) xselinuxGetSelectionCreateContextRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - b += 1 - - buf[b] = 16 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request XselinuxSetSelectionUseContext -// size: pad((8 + pad((int(ContextLen) * 1)))) -type XselinuxSetSelectionUseContextCookie struct { - *cookie -} - -// Write request to wire for XselinuxSetSelectionUseContext -func (c *Conn) XselinuxSetSelectionUseContext(ContextLen uint32, Context string) XselinuxSetSelectionUseContextCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xselinuxSetSelectionUseContextRequest(ContextLen, Context), cookie) - return XselinuxSetSelectionUseContextCookie{cookie} -} - -func (c *Conn) XselinuxSetSelectionUseContextChecked(ContextLen uint32, Context string) XselinuxSetSelectionUseContextCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xselinuxSetSelectionUseContextRequest(ContextLen, Context), cookie) - return XselinuxSetSelectionUseContextCookie{cookie} -} - -func (cook XselinuxSetSelectionUseContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxSetSelectionUseContext -func (c *Conn) xselinuxSetSelectionUseContextRequest(ContextLen uint32, Context string) []byte { - size := pad((8 + pad((int(ContextLen) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - b += 1 - - buf[b] = 17 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], ContextLen) - b += 4 - - copy(buf[b:], Context[:ContextLen]) - b += pad(int(ContextLen)) - - return buf -} - -// Request XselinuxGetSelectionUseContext -// size: 4 -type XselinuxGetSelectionUseContextCookie struct { - *cookie -} - -func (c *Conn) XselinuxGetSelectionUseContext() XselinuxGetSelectionUseContextCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xselinuxGetSelectionUseContextRequest(), cookie) - return XselinuxGetSelectionUseContextCookie{cookie} -} - -func (c *Conn) XselinuxGetSelectionUseContextUnchecked() XselinuxGetSelectionUseContextCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xselinuxGetSelectionUseContextRequest(), cookie) - return XselinuxGetSelectionUseContextCookie{cookie} -} - -// Request reply for XselinuxGetSelectionUseContext -// size: (32 + pad((int(ContextLen) * 1))) -type XselinuxGetSelectionUseContextReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ContextLen uint32 - // padding: 20 bytes - Context string // size: pad((int(ContextLen) * 1)) -} - -// Waits and reads reply data from request XselinuxGetSelectionUseContext -func (cook XselinuxGetSelectionUseContextCookie) Reply() (*XselinuxGetSelectionUseContextReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xselinuxGetSelectionUseContextReply(buf), nil -} - -// Read reply into structure from buffer for XselinuxGetSelectionUseContext -func xselinuxGetSelectionUseContextReply(buf []byte) *XselinuxGetSelectionUseContextReply { - v := new(XselinuxGetSelectionUseContextReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.ContextLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - { - byteString := make([]byte, v.ContextLen) - copy(byteString[:v.ContextLen], buf[b:]) - v.Context = string(byteString) - b += pad(int(v.ContextLen)) - } - - return v -} - -func (cook XselinuxGetSelectionUseContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxGetSelectionUseContext -func (c *Conn) xselinuxGetSelectionUseContextRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - b += 1 - - buf[b] = 18 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request XselinuxGetSelectionContext -// size: 8 -type XselinuxGetSelectionContextCookie struct { - *cookie -} - -func (c *Conn) XselinuxGetSelectionContext(Selection Atom) XselinuxGetSelectionContextCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xselinuxGetSelectionContextRequest(Selection), cookie) - return XselinuxGetSelectionContextCookie{cookie} -} - -func (c *Conn) XselinuxGetSelectionContextUnchecked(Selection Atom) XselinuxGetSelectionContextCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xselinuxGetSelectionContextRequest(Selection), cookie) - return XselinuxGetSelectionContextCookie{cookie} -} - -// Request reply for XselinuxGetSelectionContext -// size: (32 + pad((int(ContextLen) * 1))) -type XselinuxGetSelectionContextReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ContextLen uint32 - // padding: 20 bytes - Context string // size: pad((int(ContextLen) * 1)) -} - -// Waits and reads reply data from request XselinuxGetSelectionContext -func (cook XselinuxGetSelectionContextCookie) Reply() (*XselinuxGetSelectionContextReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xselinuxGetSelectionContextReply(buf), nil -} - -// Read reply into structure from buffer for XselinuxGetSelectionContext -func xselinuxGetSelectionContextReply(buf []byte) *XselinuxGetSelectionContextReply { - v := new(XselinuxGetSelectionContextReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.ContextLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - { - byteString := make([]byte, v.ContextLen) - copy(byteString[:v.ContextLen], buf[b:]) - v.Context = string(byteString) - b += pad(int(v.ContextLen)) - } - - return v -} - -func (cook XselinuxGetSelectionContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxGetSelectionContext -func (c *Conn) xselinuxGetSelectionContextRequest(Selection Atom) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - b += 1 - - buf[b] = 19 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Selection)) - b += 4 - - return buf -} - -// Request XselinuxGetSelectionDataContext -// size: 8 -type XselinuxGetSelectionDataContextCookie struct { - *cookie -} - -func (c *Conn) XselinuxGetSelectionDataContext(Selection Atom) XselinuxGetSelectionDataContextCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xselinuxGetSelectionDataContextRequest(Selection), cookie) - return XselinuxGetSelectionDataContextCookie{cookie} -} - -func (c *Conn) XselinuxGetSelectionDataContextUnchecked(Selection Atom) XselinuxGetSelectionDataContextCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xselinuxGetSelectionDataContextRequest(Selection), cookie) - return XselinuxGetSelectionDataContextCookie{cookie} -} - -// Request reply for XselinuxGetSelectionDataContext -// size: (32 + pad((int(ContextLen) * 1))) -type XselinuxGetSelectionDataContextReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ContextLen uint32 - // padding: 20 bytes - Context string // size: pad((int(ContextLen) * 1)) -} - -// Waits and reads reply data from request XselinuxGetSelectionDataContext -func (cook XselinuxGetSelectionDataContextCookie) Reply() (*XselinuxGetSelectionDataContextReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xselinuxGetSelectionDataContextReply(buf), nil -} - -// Read reply into structure from buffer for XselinuxGetSelectionDataContext -func xselinuxGetSelectionDataContextReply(buf []byte) *XselinuxGetSelectionDataContextReply { - v := new(XselinuxGetSelectionDataContextReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.ContextLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - { - byteString := make([]byte, v.ContextLen) - copy(byteString[:v.ContextLen], buf[b:]) - v.Context = string(byteString) - b += pad(int(v.ContextLen)) - } - - return v -} - -func (cook XselinuxGetSelectionDataContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxGetSelectionDataContext -func (c *Conn) xselinuxGetSelectionDataContextRequest(Selection Atom) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - b += 1 - - buf[b] = 20 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Selection)) - b += 4 - - return buf -} - -// Request XselinuxListSelections -// size: 4 -type XselinuxListSelectionsCookie struct { - *cookie -} - -func (c *Conn) XselinuxListSelections() XselinuxListSelectionsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xselinuxListSelectionsRequest(), cookie) - return XselinuxListSelectionsCookie{cookie} -} - -func (c *Conn) XselinuxListSelectionsUnchecked() XselinuxListSelectionsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xselinuxListSelectionsRequest(), cookie) - return XselinuxListSelectionsCookie{cookie} -} - -// Request reply for XselinuxListSelections -// size: (32 + XselinuxListItemListSize(Selections)) -type XselinuxListSelectionsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - SelectionsLen uint32 - // padding: 20 bytes - Selections []XselinuxListItem // size: XselinuxListItemListSize(Selections) -} - -// Waits and reads reply data from request XselinuxListSelections -func (cook XselinuxListSelectionsCookie) Reply() (*XselinuxListSelectionsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xselinuxListSelectionsReply(buf), nil -} - -// Read reply into structure from buffer for XselinuxListSelections -func xselinuxListSelectionsReply(buf []byte) *XselinuxListSelectionsReply { - v := new(XselinuxListSelectionsReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.SelectionsLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Selections = make([]XselinuxListItem, v.SelectionsLen) - b += ReadXselinuxListItemList(buf[b:], v.Selections) - - return v -} - -func (cook XselinuxListSelectionsCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxListSelections -func (c *Conn) xselinuxListSelectionsRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - b += 1 - - buf[b] = 21 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request XselinuxGetClientContext -// size: 8 -type XselinuxGetClientContextCookie struct { - *cookie -} - -func (c *Conn) XselinuxGetClientContext(Resource uint32) XselinuxGetClientContextCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xselinuxGetClientContextRequest(Resource), cookie) - return XselinuxGetClientContextCookie{cookie} -} - -func (c *Conn) XselinuxGetClientContextUnchecked(Resource uint32) XselinuxGetClientContextCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xselinuxGetClientContextRequest(Resource), cookie) - return XselinuxGetClientContextCookie{cookie} -} - -// Request reply for XselinuxGetClientContext -// size: (32 + pad((int(ContextLen) * 1))) -type XselinuxGetClientContextReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ContextLen uint32 - // padding: 20 bytes - Context string // size: pad((int(ContextLen) * 1)) -} - -// Waits and reads reply data from request XselinuxGetClientContext -func (cook XselinuxGetClientContextCookie) Reply() (*XselinuxGetClientContextReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xselinuxGetClientContextReply(buf), nil -} - -// Read reply into structure from buffer for XselinuxGetClientContext -func xselinuxGetClientContextReply(buf []byte) *XselinuxGetClientContextReply { - v := new(XselinuxGetClientContextReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.ContextLen = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - { - byteString := make([]byte, v.ContextLen) - copy(byteString[:v.ContextLen], buf[b:]) - v.Context = string(byteString) - b += pad(int(v.ContextLen)) - } - - return v -} - -func (cook XselinuxGetClientContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XselinuxGetClientContext -func (c *Conn) xselinuxGetClientContextRequest(Resource uint32) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["SELINUX"] - b += 1 - - buf[b] = 22 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], Resource) - b += 4 - - return buf -} diff --git a/nexgb/auto_xtest.go b/nexgb/auto_xtest.go deleted file mode 100644 index f3b92a2..0000000 --- a/nexgb/auto_xtest.go +++ /dev/null @@ -1,361 +0,0 @@ -package xgb - -/* - This file was generated by xtest.xml on May 10 2012 12:39:34pm EDT. - This file is automatically generated. Edit at your peril! -*/ - -// Imports are not necessary for XGB because everything is -// in one package. They are still listed here for reference. -// import "xproto" - -// XtestInit must be called before using the XTEST extension. -func (c *Conn) XtestInit() error { - reply, err := c.QueryExtension(5, "XTEST").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named XTEST could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["XTEST"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["XTEST"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["XTEST"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["XTEST"] = make(map[int]newEventFun) - newExtErrorFuncs["XTEST"] = make(map[int]newErrorFun) -} - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - -// Skipping definition for base type 'Int8' - -// Skipping definition for base type 'Card16' - -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - -// Skipping definition for base type 'Float' - -// Skipping definition for base type 'Card8' - -const ( - XtestCursorNone = 0 - XtestCursorCurrent = 1 -) - -// Request XtestGetVersion -// size: 8 -type XtestGetVersionCookie struct { - *cookie -} - -func (c *Conn) XtestGetVersion(MajorVersion byte, MinorVersion uint16) XtestGetVersionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xtestGetVersionRequest(MajorVersion, MinorVersion), cookie) - return XtestGetVersionCookie{cookie} -} - -func (c *Conn) XtestGetVersionUnchecked(MajorVersion byte, MinorVersion uint16) XtestGetVersionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xtestGetVersionRequest(MajorVersion, MinorVersion), cookie) - return XtestGetVersionCookie{cookie} -} - -// Request reply for XtestGetVersion -// size: 10 -type XtestGetVersionReply struct { - Sequence uint16 - Length uint32 - MajorVersion byte - MinorVersion uint16 -} - -// Waits and reads reply data from request XtestGetVersion -func (cook XtestGetVersionCookie) Reply() (*XtestGetVersionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xtestGetVersionReply(buf), nil -} - -// Read reply into structure from buffer for XtestGetVersion -func xtestGetVersionReply(buf []byte) *XtestGetVersionReply { - v := new(XtestGetVersionReply) - b := 1 // skip reply determinant - - v.MajorVersion = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.MinorVersion = Get16(buf[b:]) - b += 2 - - return v -} - -func (cook XtestGetVersionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XtestGetVersion -func (c *Conn) xtestGetVersionRequest(MajorVersion byte, MinorVersion uint16) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XTEST"] - b += 1 - - buf[b] = 0 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = MajorVersion - b += 1 - - b += 1 // padding - - Put16(buf[b:], MinorVersion) - b += 2 - - return buf -} - -// Request XtestCompareCursor -// size: 12 -type XtestCompareCursorCookie struct { - *cookie -} - -func (c *Conn) XtestCompareCursor(Window Window, Cursor Cursor) XtestCompareCursorCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xtestCompareCursorRequest(Window, Cursor), cookie) - return XtestCompareCursorCookie{cookie} -} - -func (c *Conn) XtestCompareCursorUnchecked(Window Window, Cursor Cursor) XtestCompareCursorCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xtestCompareCursorRequest(Window, Cursor), cookie) - return XtestCompareCursorCookie{cookie} -} - -// Request reply for XtestCompareCursor -// size: 8 -type XtestCompareCursorReply struct { - Sequence uint16 - Length uint32 - Same bool -} - -// Waits and reads reply data from request XtestCompareCursor -func (cook XtestCompareCursorCookie) Reply() (*XtestCompareCursorReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xtestCompareCursorReply(buf), nil -} - -// Read reply into structure from buffer for XtestCompareCursor -func xtestCompareCursorReply(buf []byte) *XtestCompareCursorReply { - v := new(XtestCompareCursorReply) - b := 1 // skip reply determinant - - if buf[b] == 1 { - v.Same = true - } else { - v.Same = false - } - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - return v -} - -func (cook XtestCompareCursorCookie) Check() error { - return cook.check() -} - -// Write request to wire for XtestCompareCursor -func (c *Conn) xtestCompareCursorRequest(Window Window, Cursor Cursor) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XTEST"] - b += 1 - - buf[b] = 1 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - Put32(buf[b:], uint32(Cursor)) - b += 4 - - return buf -} - -// Request XtestFakeInput -// size: 36 -type XtestFakeInputCookie struct { - *cookie -} - -// Write request to wire for XtestFakeInput -func (c *Conn) XtestFakeInput(Type byte, Detail byte, Time uint32, Root Window, RootX int16, RootY int16, Deviceid byte) XtestFakeInputCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xtestFakeInputRequest(Type, Detail, Time, Root, RootX, RootY, Deviceid), cookie) - return XtestFakeInputCookie{cookie} -} - -func (c *Conn) XtestFakeInputChecked(Type byte, Detail byte, Time uint32, Root Window, RootX int16, RootY int16, Deviceid byte) XtestFakeInputCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xtestFakeInputRequest(Type, Detail, Time, Root, RootX, RootY, Deviceid), cookie) - return XtestFakeInputCookie{cookie} -} - -func (cook XtestFakeInputCookie) Check() error { - return cook.check() -} - -// Write request to wire for XtestFakeInput -func (c *Conn) xtestFakeInputRequest(Type byte, Detail byte, Time uint32, Root Window, RootX int16, RootY int16, Deviceid byte) []byte { - size := 36 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XTEST"] - b += 1 - - buf[b] = 2 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = Type - b += 1 - - buf[b] = Detail - b += 1 - - b += 2 // padding - - Put32(buf[b:], Time) - b += 4 - - Put32(buf[b:], uint32(Root)) - b += 4 - - b += 8 // padding - - Put16(buf[b:], uint16(RootX)) - b += 2 - - Put16(buf[b:], uint16(RootY)) - b += 2 - - b += 7 // padding - - buf[b] = Deviceid - b += 1 - - return buf -} - -// Request XtestGrabControl -// size: 8 -type XtestGrabControlCookie struct { - *cookie -} - -// Write request to wire for XtestGrabControl -func (c *Conn) XtestGrabControl(Impervious bool) XtestGrabControlCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xtestGrabControlRequest(Impervious), cookie) - return XtestGrabControlCookie{cookie} -} - -func (c *Conn) XtestGrabControlChecked(Impervious bool) XtestGrabControlCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xtestGrabControlRequest(Impervious), cookie) - return XtestGrabControlCookie{cookie} -} - -func (cook XtestGrabControlCookie) Check() error { - return cook.check() -} - -// Write request to wire for XtestGrabControl -func (c *Conn) xtestGrabControlRequest(Impervious bool) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XTEST"] - b += 1 - - buf[b] = 3 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - if Impervious { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 3 // padding - - return buf -} diff --git a/nexgb/auto_xv.go b/nexgb/auto_xv.go deleted file mode 100644 index 25f0491..0000000 --- a/nexgb/auto_xv.go +++ /dev/null @@ -1,2780 +0,0 @@ -package xgb - -/* - This file was generated by xv.xml on May 10 2012 12:39:35pm EDT. - This file is automatically generated. Edit at your peril! -*/ - -// Imports are not necessary for XGB because everything is -// in one package. They are still listed here for reference. -// import "xproto" -// import "shm" - -// XvInit must be called before using the XVideo extension. -func (c *Conn) XvInit() error { - reply, err := c.QueryExtension(6, "XVideo").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named XVideo could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["XVideo"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["XVideo"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["XVideo"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["XVideo"] = make(map[int]newEventFun) - newExtErrorFuncs["XVideo"] = make(map[int]newErrorFun) -} - -// Skipping definition for base type 'Float' - -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - -// Skipping definition for base type 'Int8' - -// Skipping definition for base type 'Card16' - -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - -const ( - XvTypeInputMask = 1 - XvTypeOutputMask = 2 - XvTypeVideoMask = 4 - XvTypeStillMask = 8 - XvTypeImageMask = 16 -) - -const ( - XvImageFormatInfoTypeRgb = 0 - XvImageFormatInfoTypeYuv = 1 -) - -const ( - XvImageFormatInfoFormatPacked = 0 - XvImageFormatInfoFormatPlanar = 1 -) - -const ( - XvAttributeFlagGettable = 1 - XvAttributeFlagSettable = 2 -) - -const ( - XvVideoNotifyReasonStarted = 0 - XvVideoNotifyReasonStopped = 1 - XvVideoNotifyReasonBusy = 2 - XvVideoNotifyReasonPreempted = 3 - XvVideoNotifyReasonHardError = 4 -) - -const ( - XvScanlineOrderTopToBottom = 0 - XvScanlineOrderBottomToTop = 1 -) - -const ( - XvGrabPortStatusSuccess = 0 - XvGrabPortStatusBadExtension = 1 - XvGrabPortStatusAlreadyGrabbed = 2 - XvGrabPortStatusInvalidTime = 3 - XvGrabPortStatusBadReply = 4 - XvGrabPortStatusBadAlloc = 5 -) - -type XvPort uint32 - -func (c *Conn) NewXvPortId() (XvPort, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return XvPort(id), nil -} - -type XvEncoding uint32 - -func (c *Conn) NewXvEncodingId() (XvEncoding, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return XvEncoding(id), nil -} - -// 'XvRational' struct definition -// Size: 8 -type XvRational struct { - Numerator int32 - Denominator int32 -} - -// Struct read XvRational -func ReadXvRational(buf []byte, v *XvRational) int { - b := 0 - - v.Numerator = int32(Get32(buf[b:])) - b += 4 - - v.Denominator = int32(Get32(buf[b:])) - b += 4 - - return b -} - -// Struct list read XvRational -func ReadXvRationalList(buf []byte, dest []XvRational) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XvRational{} - b += ReadXvRational(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XvRational -func (v XvRational) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put32(buf[b:], uint32(v.Numerator)) - b += 4 - - Put32(buf[b:], uint32(v.Denominator)) - b += 4 - - return buf -} - -// Write struct list XvRational -func XvRationalListBytes(buf []byte, list []XvRational) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XvFormat' struct definition -// Size: 8 -type XvFormat struct { - Visual Visualid - Depth byte - // padding: 3 bytes -} - -// Struct read XvFormat -func ReadXvFormat(buf []byte, v *XvFormat) int { - b := 0 - - v.Visual = Visualid(Get32(buf[b:])) - b += 4 - - v.Depth = buf[b] - b += 1 - - b += 3 // padding - - return b -} - -// Struct list read XvFormat -func ReadXvFormatList(buf []byte, dest []XvFormat) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XvFormat{} - b += ReadXvFormat(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XvFormat -func (v XvFormat) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - Put32(buf[b:], uint32(v.Visual)) - b += 4 - - buf[b] = v.Depth - b += 1 - - b += 3 // padding - - return buf -} - -// Write struct list XvFormat -func XvFormatListBytes(buf []byte, list []XvFormat) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// 'XvAdaptorInfo' struct definition -// Size: ((12 + pad((int(NameSize) * 1))) + pad((int(NumFormats) * 8))) -type XvAdaptorInfo struct { - BaseId XvPort - NameSize uint16 - NumPorts uint16 - NumFormats uint16 - Type byte - // padding: 1 bytes - Name string // size: pad((int(NameSize) * 1)) - Formats []XvFormat // size: pad((int(NumFormats) * 8)) -} - -// Struct read XvAdaptorInfo -func ReadXvAdaptorInfo(buf []byte, v *XvAdaptorInfo) int { - b := 0 - - v.BaseId = XvPort(Get32(buf[b:])) - b += 4 - - v.NameSize = Get16(buf[b:]) - b += 2 - - v.NumPorts = Get16(buf[b:]) - b += 2 - - v.NumFormats = Get16(buf[b:]) - b += 2 - - v.Type = buf[b] - b += 1 - - b += 1 // padding - - { - byteString := make([]byte, v.NameSize) - copy(byteString[:v.NameSize], buf[b:]) - v.Name = string(byteString) - b += pad(int(v.NameSize)) - } - - v.Formats = make([]XvFormat, v.NumFormats) - b += ReadXvFormatList(buf[b:], v.Formats) - - return b -} - -// Struct list read XvAdaptorInfo -func ReadXvAdaptorInfoList(buf []byte, dest []XvAdaptorInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XvAdaptorInfo{} - b += ReadXvAdaptorInfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XvAdaptorInfo -func (v XvAdaptorInfo) Bytes() []byte { - buf := make([]byte, ((12 + pad((int(v.NameSize) * 1))) + pad((int(v.NumFormats) * 8)))) - b := 0 - - Put32(buf[b:], uint32(v.BaseId)) - b += 4 - - Put16(buf[b:], v.NameSize) - b += 2 - - Put16(buf[b:], v.NumPorts) - b += 2 - - Put16(buf[b:], v.NumFormats) - b += 2 - - buf[b] = v.Type - b += 1 - - b += 1 // padding - - copy(buf[b:], v.Name[:v.NameSize]) - b += pad(int(v.NameSize)) - - b += XvFormatListBytes(buf[b:], v.Formats) - - return buf -} - -// Write struct list XvAdaptorInfo -func XvAdaptorInfoListBytes(buf []byte, list []XvAdaptorInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size XvAdaptorInfo -func XvAdaptorInfoListSize(list []XvAdaptorInfo) int { - size := 0 - for _, item := range list { - size += ((12 + pad((int(item.NameSize) * 1))) + pad((int(item.NumFormats) * 8))) - } - return size -} - -// 'XvEncodingInfo' struct definition -// Size: (20 + pad((int(NameSize) * 1))) -type XvEncodingInfo struct { - Encoding XvEncoding - NameSize uint16 - Width uint16 - Height uint16 - // padding: 2 bytes - Rate XvRational - Name string // size: pad((int(NameSize) * 1)) -} - -// Struct read XvEncodingInfo -func ReadXvEncodingInfo(buf []byte, v *XvEncodingInfo) int { - b := 0 - - v.Encoding = XvEncoding(Get32(buf[b:])) - b += 4 - - v.NameSize = Get16(buf[b:]) - b += 2 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - b += 2 // padding - - v.Rate = XvRational{} - b += ReadXvRational(buf[b:], &v.Rate) - - { - byteString := make([]byte, v.NameSize) - copy(byteString[:v.NameSize], buf[b:]) - v.Name = string(byteString) - b += pad(int(v.NameSize)) - } - - return b -} - -// Struct list read XvEncodingInfo -func ReadXvEncodingInfoList(buf []byte, dest []XvEncodingInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XvEncodingInfo{} - b += ReadXvEncodingInfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XvEncodingInfo -func (v XvEncodingInfo) Bytes() []byte { - buf := make([]byte, (20 + pad((int(v.NameSize) * 1)))) - b := 0 - - Put32(buf[b:], uint32(v.Encoding)) - b += 4 - - Put16(buf[b:], v.NameSize) - b += 2 - - Put16(buf[b:], v.Width) - b += 2 - - Put16(buf[b:], v.Height) - b += 2 - - b += 2 // padding - - { - structBytes := v.Rate.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - - copy(buf[b:], v.Name[:v.NameSize]) - b += pad(int(v.NameSize)) - - return buf -} - -// Write struct list XvEncodingInfo -func XvEncodingInfoListBytes(buf []byte, list []XvEncodingInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size XvEncodingInfo -func XvEncodingInfoListSize(list []XvEncodingInfo) int { - size := 0 - for _, item := range list { - size += (20 + pad((int(item.NameSize) * 1))) - } - return size -} - -// 'XvImage' struct definition -// Size: (((16 + pad((int(NumPlanes) * 4))) + pad((int(NumPlanes) * 4))) + pad((int(DataSize) * 1))) -type XvImage struct { - Id uint32 - Width uint16 - Height uint16 - DataSize uint32 - NumPlanes uint32 - Pitches []uint32 // size: pad((int(NumPlanes) * 4)) - Offsets []uint32 // size: pad((int(NumPlanes) * 4)) - Data []byte // size: pad((int(DataSize) * 1)) -} - -// Struct read XvImage -func ReadXvImage(buf []byte, v *XvImage) int { - b := 0 - - v.Id = Get32(buf[b:]) - b += 4 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - v.DataSize = Get32(buf[b:]) - b += 4 - - v.NumPlanes = Get32(buf[b:]) - b += 4 - - v.Pitches = make([]uint32, v.NumPlanes) - for i := 0; i < int(v.NumPlanes); i++ { - v.Pitches[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - v.Offsets = make([]uint32, v.NumPlanes) - for i := 0; i < int(v.NumPlanes); i++ { - v.Offsets[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - v.Data = make([]byte, v.DataSize) - copy(v.Data[:v.DataSize], buf[b:]) - b += pad(int(v.DataSize)) - - return b -} - -// Struct list read XvImage -func ReadXvImageList(buf []byte, dest []XvImage) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XvImage{} - b += ReadXvImage(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XvImage -func (v XvImage) Bytes() []byte { - buf := make([]byte, (((16 + pad((int(v.NumPlanes) * 4))) + pad((int(v.NumPlanes) * 4))) + pad((int(v.DataSize) * 1)))) - b := 0 - - Put32(buf[b:], v.Id) - b += 4 - - Put16(buf[b:], v.Width) - b += 2 - - Put16(buf[b:], v.Height) - b += 2 - - Put32(buf[b:], v.DataSize) - b += 4 - - Put32(buf[b:], v.NumPlanes) - b += 4 - - for i := 0; i < int(v.NumPlanes); i++ { - Put32(buf[b:], v.Pitches[i]) - b += 4 - } - b = pad(b) - - for i := 0; i < int(v.NumPlanes); i++ { - Put32(buf[b:], v.Offsets[i]) - b += 4 - } - b = pad(b) - - copy(buf[b:], v.Data[:v.DataSize]) - b += pad(int(v.DataSize)) - - return buf -} - -// Write struct list XvImage -func XvImageListBytes(buf []byte, list []XvImage) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size XvImage -func XvImageListSize(list []XvImage) int { - size := 0 - for _, item := range list { - size += (((16 + pad((int(item.NumPlanes) * 4))) + pad((int(item.NumPlanes) * 4))) + pad((int(item.DataSize) * 1))) - } - return size -} - -// 'XvAttributeInfo' struct definition -// Size: (16 + pad((int(Size) * 1))) -type XvAttributeInfo struct { - Flags uint32 - Min int32 - Max int32 - Size uint32 - Name string // size: pad((int(Size) * 1)) -} - -// Struct read XvAttributeInfo -func ReadXvAttributeInfo(buf []byte, v *XvAttributeInfo) int { - b := 0 - - v.Flags = Get32(buf[b:]) - b += 4 - - v.Min = int32(Get32(buf[b:])) - b += 4 - - v.Max = int32(Get32(buf[b:])) - b += 4 - - v.Size = Get32(buf[b:]) - b += 4 - - { - byteString := make([]byte, v.Size) - copy(byteString[:v.Size], buf[b:]) - v.Name = string(byteString) - b += pad(int(v.Size)) - } - - return b -} - -// Struct list read XvAttributeInfo -func ReadXvAttributeInfoList(buf []byte, dest []XvAttributeInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XvAttributeInfo{} - b += ReadXvAttributeInfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XvAttributeInfo -func (v XvAttributeInfo) Bytes() []byte { - buf := make([]byte, (16 + pad((int(v.Size) * 1)))) - b := 0 - - Put32(buf[b:], v.Flags) - b += 4 - - Put32(buf[b:], uint32(v.Min)) - b += 4 - - Put32(buf[b:], uint32(v.Max)) - b += 4 - - Put32(buf[b:], v.Size) - b += 4 - - copy(buf[b:], v.Name[:v.Size]) - b += pad(int(v.Size)) - - return buf -} - -// Write struct list XvAttributeInfo -func XvAttributeInfoListBytes(buf []byte, list []XvAttributeInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size XvAttributeInfo -func XvAttributeInfoListSize(list []XvAttributeInfo) int { - size := 0 - for _, item := range list { - size += (16 + pad((int(item.Size) * 1))) - } - return size -} - -// 'XvImageFormatInfo' struct definition -// Size: 128 -type XvImageFormatInfo struct { - Id uint32 - Type byte - ByteOrder byte - // padding: 2 bytes - Guid []byte // size: 16 - Bpp byte - NumPlanes byte - // padding: 2 bytes - Depth byte - // padding: 3 bytes - RedMask uint32 - GreenMask uint32 - BlueMask uint32 - Format byte - // padding: 3 bytes - YSampleBits uint32 - USampleBits uint32 - VSampleBits uint32 - VhorzYPeriod uint32 - VhorzUPeriod uint32 - VhorzVPeriod uint32 - VvertYPeriod uint32 - VvertUPeriod uint32 - VvertVPeriod uint32 - VcompOrder []byte // size: 32 - VscanlineOrder byte - // padding: 11 bytes -} - -// Struct read XvImageFormatInfo -func ReadXvImageFormatInfo(buf []byte, v *XvImageFormatInfo) int { - b := 0 - - v.Id = Get32(buf[b:]) - b += 4 - - v.Type = buf[b] - b += 1 - - v.ByteOrder = buf[b] - b += 1 - - b += 2 // padding - - v.Guid = make([]byte, 16) - copy(v.Guid[:16], buf[b:]) - b += pad(int(16)) - - v.Bpp = buf[b] - b += 1 - - v.NumPlanes = buf[b] - b += 1 - - b += 2 // padding - - v.Depth = buf[b] - b += 1 - - b += 3 // padding - - v.RedMask = Get32(buf[b:]) - b += 4 - - v.GreenMask = Get32(buf[b:]) - b += 4 - - v.BlueMask = Get32(buf[b:]) - b += 4 - - v.Format = buf[b] - b += 1 - - b += 3 // padding - - v.YSampleBits = Get32(buf[b:]) - b += 4 - - v.USampleBits = Get32(buf[b:]) - b += 4 - - v.VSampleBits = Get32(buf[b:]) - b += 4 - - v.VhorzYPeriod = Get32(buf[b:]) - b += 4 - - v.VhorzUPeriod = Get32(buf[b:]) - b += 4 - - v.VhorzVPeriod = Get32(buf[b:]) - b += 4 - - v.VvertYPeriod = Get32(buf[b:]) - b += 4 - - v.VvertUPeriod = Get32(buf[b:]) - b += 4 - - v.VvertVPeriod = Get32(buf[b:]) - b += 4 - - v.VcompOrder = make([]byte, 32) - copy(v.VcompOrder[:32], buf[b:]) - b += pad(int(32)) - - v.VscanlineOrder = buf[b] - b += 1 - - b += 11 // padding - - return b -} - -// Struct list read XvImageFormatInfo -func ReadXvImageFormatInfoList(buf []byte, dest []XvImageFormatInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XvImageFormatInfo{} - b += ReadXvImageFormatInfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XvImageFormatInfo -func (v XvImageFormatInfo) Bytes() []byte { - buf := make([]byte, 128) - b := 0 - - Put32(buf[b:], v.Id) - b += 4 - - buf[b] = v.Type - b += 1 - - buf[b] = v.ByteOrder - b += 1 - - b += 2 // padding - - copy(buf[b:], v.Guid[:16]) - b += pad(int(16)) - - buf[b] = v.Bpp - b += 1 - - buf[b] = v.NumPlanes - b += 1 - - b += 2 // padding - - buf[b] = v.Depth - b += 1 - - b += 3 // padding - - Put32(buf[b:], v.RedMask) - b += 4 - - Put32(buf[b:], v.GreenMask) - b += 4 - - Put32(buf[b:], v.BlueMask) - b += 4 - - buf[b] = v.Format - b += 1 - - b += 3 // padding - - Put32(buf[b:], v.YSampleBits) - b += 4 - - Put32(buf[b:], v.USampleBits) - b += 4 - - Put32(buf[b:], v.VSampleBits) - b += 4 - - Put32(buf[b:], v.VhorzYPeriod) - b += 4 - - Put32(buf[b:], v.VhorzUPeriod) - b += 4 - - Put32(buf[b:], v.VhorzVPeriod) - b += 4 - - Put32(buf[b:], v.VvertYPeriod) - b += 4 - - Put32(buf[b:], v.VvertUPeriod) - b += 4 - - Put32(buf[b:], v.VvertVPeriod) - b += 4 - - copy(buf[b:], v.VcompOrder[:32]) - b += pad(int(32)) - - buf[b] = v.VscanlineOrder - b += 1 - - b += 11 // padding - - return buf -} - -// Write struct list XvImageFormatInfo -func XvImageFormatInfoListBytes(buf []byte, list []XvImageFormatInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Struct list size XvImageFormatInfo -func XvImageFormatInfoListSize(list []XvImageFormatInfo) int { - size := 0 - for _ = range list { - size += 128 - } - return size -} - -// Event definition XvVideoNotify (0) -// Size: 32 - -const XvVideoNotify = 0 - -type XvVideoNotifyEvent struct { - Sequence uint16 - Reason byte - Time Timestamp - Drawable Drawable - Port XvPort -} - -// Event read XvVideoNotify -func NewXvVideoNotifyEvent(buf []byte) Event { - v := XvVideoNotifyEvent{} - b := 1 // don't read event number - - v.Reason = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Time = Timestamp(Get32(buf[b:])) - b += 4 - - v.Drawable = Drawable(Get32(buf[b:])) - b += 4 - - v.Port = XvPort(Get32(buf[b:])) - b += 4 - - return v -} - -// Event write XvVideoNotify -func (v XvVideoNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 0 - b += 1 - - buf[b] = v.Reason - b += 1 - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Time)) - b += 4 - - Put32(buf[b:], uint32(v.Drawable)) - b += 4 - - Put32(buf[b:], uint32(v.Port)) - b += 4 - - return buf -} - -func (v XvVideoNotifyEvent) ImplementsEvent() {} - -func (v XvVideoNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XvVideoNotifyEvent) String() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Reason: %d", v.Reason)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Drawable: %d", v.Drawable)) - fieldVals = append(fieldVals, sprintf("Port: %d", v.Port)) - return "XvVideoNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XVideo"][0] = NewXvVideoNotifyEvent -} - -// Event definition XvPortNotify (1) -// Size: 32 - -const XvPortNotify = 1 - -type XvPortNotifyEvent struct { - Sequence uint16 - // padding: 1 bytes - Time Timestamp - Port XvPort - Attribute Atom - Value int32 -} - -// Event read XvPortNotify -func NewXvPortNotifyEvent(buf []byte) Event { - v := XvPortNotifyEvent{} - b := 1 // don't read event number - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Time = Timestamp(Get32(buf[b:])) - b += 4 - - v.Port = XvPort(Get32(buf[b:])) - b += 4 - - v.Attribute = Atom(Get32(buf[b:])) - b += 4 - - v.Value = int32(Get32(buf[b:])) - b += 4 - - return v -} - -// Event write XvPortNotify -func (v XvPortNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 1 - b += 1 - - b += 1 // padding - - b += 2 // skip sequence number - - Put32(buf[b:], uint32(v.Time)) - b += 4 - - Put32(buf[b:], uint32(v.Port)) - b += 4 - - Put32(buf[b:], uint32(v.Attribute)) - b += 4 - - Put32(buf[b:], uint32(v.Value)) - b += 4 - - return buf -} - -func (v XvPortNotifyEvent) ImplementsEvent() {} - -func (v XvPortNotifyEvent) SequenceId() uint16 { - return v.Sequence -} - -func (v XvPortNotifyEvent) String() string { - fieldVals := make([]string, 0, 5) - fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, sprintf("Port: %d", v.Port)) - fieldVals = append(fieldVals, sprintf("Attribute: %d", v.Attribute)) - fieldVals = append(fieldVals, sprintf("Value: %d", v.Value)) - return "XvPortNotify {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtEventFuncs["XVideo"][1] = NewXvPortNotifyEvent -} - -// Error definition XvBadPort (0) -// Size: 32 - -const BadXvBadPort = 0 - -type XvBadPortError struct { - Sequence uint16 - NiceName string -} - -// Error read XvBadPort -func NewXvBadPortError(buf []byte) Error { - v := XvBadPortError{} - v.NiceName = "XvBadPort" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err XvBadPortError) ImplementsError() {} - -func (err XvBadPortError) SequenceId() uint16 { - return err.Sequence -} - -func (err XvBadPortError) BadId() uint32 { - return 0 -} - -func (err XvBadPortError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadXvBadPort {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["XVideo"][0] = NewXvBadPortError -} - -// Error definition XvBadEncoding (1) -// Size: 32 - -const BadXvBadEncoding = 1 - -type XvBadEncodingError struct { - Sequence uint16 - NiceName string -} - -// Error read XvBadEncoding -func NewXvBadEncodingError(buf []byte) Error { - v := XvBadEncodingError{} - v.NiceName = "XvBadEncoding" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err XvBadEncodingError) ImplementsError() {} - -func (err XvBadEncodingError) SequenceId() uint16 { - return err.Sequence -} - -func (err XvBadEncodingError) BadId() uint32 { - return 0 -} - -func (err XvBadEncodingError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadXvBadEncoding {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["XVideo"][1] = NewXvBadEncodingError -} - -// Error definition XvBadControl (2) -// Size: 32 - -const BadXvBadControl = 2 - -type XvBadControlError struct { - Sequence uint16 - NiceName string -} - -// Error read XvBadControl -func NewXvBadControlError(buf []byte) Error { - v := XvBadControlError{} - v.NiceName = "XvBadControl" - - b := 1 // skip error determinant - b += 1 // don't read error number - - v.Sequence = Get16(buf[b:]) - b += 2 - - return v -} - -func (err XvBadControlError) ImplementsError() {} - -func (err XvBadControlError) SequenceId() uint16 { - return err.Sequence -} - -func (err XvBadControlError) BadId() uint32 { - return 0 -} - -func (err XvBadControlError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) - return "BadXvBadControl {" + stringsJoin(fieldVals, ", ") + "}" -} - -func init() { - newExtErrorFuncs["XVideo"][2] = NewXvBadControlError -} - -// Request XvQueryExtension -// size: 4 -type XvQueryExtensionCookie struct { - *cookie -} - -func (c *Conn) XvQueryExtension() XvQueryExtensionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xvQueryExtensionRequest(), cookie) - return XvQueryExtensionCookie{cookie} -} - -func (c *Conn) XvQueryExtensionUnchecked() XvQueryExtensionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xvQueryExtensionRequest(), cookie) - return XvQueryExtensionCookie{cookie} -} - -// Request reply for XvQueryExtension -// size: 12 -type XvQueryExtensionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Major uint16 - Minor uint16 -} - -// Waits and reads reply data from request XvQueryExtension -func (cook XvQueryExtensionCookie) Reply() (*XvQueryExtensionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xvQueryExtensionReply(buf), nil -} - -// Read reply into structure from buffer for XvQueryExtension -func xvQueryExtensionReply(buf []byte) *XvQueryExtensionReply { - v := new(XvQueryExtensionReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Major = Get16(buf[b:]) - b += 2 - - v.Minor = Get16(buf[b:]) - b += 2 - - return v -} - -func (cook XvQueryExtensionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvQueryExtension -func (c *Conn) xvQueryExtensionRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - b += 1 - - buf[b] = 0 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request XvQueryAdaptors -// size: 8 -type XvQueryAdaptorsCookie struct { - *cookie -} - -func (c *Conn) XvQueryAdaptors(Window Window) XvQueryAdaptorsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xvQueryAdaptorsRequest(Window), cookie) - return XvQueryAdaptorsCookie{cookie} -} - -func (c *Conn) XvQueryAdaptorsUnchecked(Window Window) XvQueryAdaptorsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xvQueryAdaptorsRequest(Window), cookie) - return XvQueryAdaptorsCookie{cookie} -} - -// Request reply for XvQueryAdaptors -// size: (32 + XvAdaptorInfoListSize(Info)) -type XvQueryAdaptorsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumAdaptors uint16 - // padding: 22 bytes - Info []XvAdaptorInfo // size: XvAdaptorInfoListSize(Info) -} - -// Waits and reads reply data from request XvQueryAdaptors -func (cook XvQueryAdaptorsCookie) Reply() (*XvQueryAdaptorsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xvQueryAdaptorsReply(buf), nil -} - -// Read reply into structure from buffer for XvQueryAdaptors -func xvQueryAdaptorsReply(buf []byte) *XvQueryAdaptorsReply { - v := new(XvQueryAdaptorsReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.NumAdaptors = Get16(buf[b:]) - b += 2 - - b += 22 // padding - - v.Info = make([]XvAdaptorInfo, v.NumAdaptors) - b += ReadXvAdaptorInfoList(buf[b:], v.Info) - - return v -} - -func (cook XvQueryAdaptorsCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvQueryAdaptors -func (c *Conn) xvQueryAdaptorsRequest(Window Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - b += 1 - - buf[b] = 1 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Window)) - b += 4 - - return buf -} - -// Request XvQueryEncodings -// size: 8 -type XvQueryEncodingsCookie struct { - *cookie -} - -func (c *Conn) XvQueryEncodings(Port XvPort) XvQueryEncodingsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xvQueryEncodingsRequest(Port), cookie) - return XvQueryEncodingsCookie{cookie} -} - -func (c *Conn) XvQueryEncodingsUnchecked(Port XvPort) XvQueryEncodingsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xvQueryEncodingsRequest(Port), cookie) - return XvQueryEncodingsCookie{cookie} -} - -// Request reply for XvQueryEncodings -// size: (32 + XvEncodingInfoListSize(Info)) -type XvQueryEncodingsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumEncodings uint16 - // padding: 22 bytes - Info []XvEncodingInfo // size: XvEncodingInfoListSize(Info) -} - -// Waits and reads reply data from request XvQueryEncodings -func (cook XvQueryEncodingsCookie) Reply() (*XvQueryEncodingsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xvQueryEncodingsReply(buf), nil -} - -// Read reply into structure from buffer for XvQueryEncodings -func xvQueryEncodingsReply(buf []byte) *XvQueryEncodingsReply { - v := new(XvQueryEncodingsReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.NumEncodings = Get16(buf[b:]) - b += 2 - - b += 22 // padding - - v.Info = make([]XvEncodingInfo, v.NumEncodings) - b += ReadXvEncodingInfoList(buf[b:], v.Info) - - return v -} - -func (cook XvQueryEncodingsCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvQueryEncodings -func (c *Conn) xvQueryEncodingsRequest(Port XvPort) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - b += 1 - - buf[b] = 2 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Port)) - b += 4 - - return buf -} - -// Request XvGrabPort -// size: 12 -type XvGrabPortCookie struct { - *cookie -} - -func (c *Conn) XvGrabPort(Port XvPort, Time Timestamp) XvGrabPortCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xvGrabPortRequest(Port, Time), cookie) - return XvGrabPortCookie{cookie} -} - -func (c *Conn) XvGrabPortUnchecked(Port XvPort, Time Timestamp) XvGrabPortCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xvGrabPortRequest(Port, Time), cookie) - return XvGrabPortCookie{cookie} -} - -// Request reply for XvGrabPort -// size: 8 -type XvGrabPortReply struct { - Sequence uint16 - Length uint32 - Result byte -} - -// Waits and reads reply data from request XvGrabPort -func (cook XvGrabPortCookie) Reply() (*XvGrabPortReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xvGrabPortReply(buf), nil -} - -// Read reply into structure from buffer for XvGrabPort -func xvGrabPortReply(buf []byte) *XvGrabPortReply { - v := new(XvGrabPortReply) - b := 1 // skip reply determinant - - v.Result = buf[b] - b += 1 - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - return v -} - -func (cook XvGrabPortCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvGrabPort -func (c *Conn) xvGrabPortRequest(Port XvPort, Time Timestamp) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - b += 1 - - buf[b] = 3 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Port)) - b += 4 - - Put32(buf[b:], uint32(Time)) - b += 4 - - return buf -} - -// Request XvUngrabPort -// size: 12 -type XvUngrabPortCookie struct { - *cookie -} - -// Write request to wire for XvUngrabPort -func (c *Conn) XvUngrabPort(Port XvPort, Time Timestamp) XvUngrabPortCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xvUngrabPortRequest(Port, Time), cookie) - return XvUngrabPortCookie{cookie} -} - -func (c *Conn) XvUngrabPortChecked(Port XvPort, Time Timestamp) XvUngrabPortCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xvUngrabPortRequest(Port, Time), cookie) - return XvUngrabPortCookie{cookie} -} - -func (cook XvUngrabPortCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvUngrabPort -func (c *Conn) xvUngrabPortRequest(Port XvPort, Time Timestamp) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - b += 1 - - buf[b] = 4 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Port)) - b += 4 - - Put32(buf[b:], uint32(Time)) - b += 4 - - return buf -} - -// Request XvPutVideo -// size: 32 -type XvPutVideoCookie struct { - *cookie -} - -// Write request to wire for XvPutVideo -func (c *Conn) XvPutVideo(Port XvPort, Drawable Drawable, Gc Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) XvPutVideoCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xvPutVideoRequest(Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) - return XvPutVideoCookie{cookie} -} - -func (c *Conn) XvPutVideoChecked(Port XvPort, Drawable Drawable, Gc Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) XvPutVideoCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xvPutVideoRequest(Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) - return XvPutVideoCookie{cookie} -} - -func (cook XvPutVideoCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvPutVideo -func (c *Conn) xvPutVideoRequest(Port XvPort, Drawable Drawable, Gc Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { - size := 32 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - b += 1 - - buf[b] = 5 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Port)) - b += 4 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - Put16(buf[b:], uint16(VidX)) - b += 2 - - Put16(buf[b:], uint16(VidY)) - b += 2 - - Put16(buf[b:], VidW) - b += 2 - - Put16(buf[b:], VidH) - b += 2 - - Put16(buf[b:], uint16(DrwX)) - b += 2 - - Put16(buf[b:], uint16(DrwY)) - b += 2 - - Put16(buf[b:], DrwW) - b += 2 - - Put16(buf[b:], DrwH) - b += 2 - - return buf -} - -// Request XvPutStill -// size: 32 -type XvPutStillCookie struct { - *cookie -} - -// Write request to wire for XvPutStill -func (c *Conn) XvPutStill(Port XvPort, Drawable Drawable, Gc Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) XvPutStillCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xvPutStillRequest(Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) - return XvPutStillCookie{cookie} -} - -func (c *Conn) XvPutStillChecked(Port XvPort, Drawable Drawable, Gc Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) XvPutStillCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xvPutStillRequest(Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) - return XvPutStillCookie{cookie} -} - -func (cook XvPutStillCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvPutStill -func (c *Conn) xvPutStillRequest(Port XvPort, Drawable Drawable, Gc Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { - size := 32 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - b += 1 - - buf[b] = 6 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Port)) - b += 4 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - Put16(buf[b:], uint16(VidX)) - b += 2 - - Put16(buf[b:], uint16(VidY)) - b += 2 - - Put16(buf[b:], VidW) - b += 2 - - Put16(buf[b:], VidH) - b += 2 - - Put16(buf[b:], uint16(DrwX)) - b += 2 - - Put16(buf[b:], uint16(DrwY)) - b += 2 - - Put16(buf[b:], DrwW) - b += 2 - - Put16(buf[b:], DrwH) - b += 2 - - return buf -} - -// Request XvGetVideo -// size: 32 -type XvGetVideoCookie struct { - *cookie -} - -// Write request to wire for XvGetVideo -func (c *Conn) XvGetVideo(Port XvPort, Drawable Drawable, Gc Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) XvGetVideoCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xvGetVideoRequest(Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) - return XvGetVideoCookie{cookie} -} - -func (c *Conn) XvGetVideoChecked(Port XvPort, Drawable Drawable, Gc Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) XvGetVideoCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xvGetVideoRequest(Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) - return XvGetVideoCookie{cookie} -} - -func (cook XvGetVideoCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvGetVideo -func (c *Conn) xvGetVideoRequest(Port XvPort, Drawable Drawable, Gc Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { - size := 32 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - b += 1 - - buf[b] = 7 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Port)) - b += 4 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - Put16(buf[b:], uint16(VidX)) - b += 2 - - Put16(buf[b:], uint16(VidY)) - b += 2 - - Put16(buf[b:], VidW) - b += 2 - - Put16(buf[b:], VidH) - b += 2 - - Put16(buf[b:], uint16(DrwX)) - b += 2 - - Put16(buf[b:], uint16(DrwY)) - b += 2 - - Put16(buf[b:], DrwW) - b += 2 - - Put16(buf[b:], DrwH) - b += 2 - - return buf -} - -// Request XvGetStill -// size: 32 -type XvGetStillCookie struct { - *cookie -} - -// Write request to wire for XvGetStill -func (c *Conn) XvGetStill(Port XvPort, Drawable Drawable, Gc Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) XvGetStillCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xvGetStillRequest(Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) - return XvGetStillCookie{cookie} -} - -func (c *Conn) XvGetStillChecked(Port XvPort, Drawable Drawable, Gc Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) XvGetStillCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xvGetStillRequest(Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) - return XvGetStillCookie{cookie} -} - -func (cook XvGetStillCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvGetStill -func (c *Conn) xvGetStillRequest(Port XvPort, Drawable Drawable, Gc Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { - size := 32 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - b += 1 - - buf[b] = 8 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Port)) - b += 4 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - Put16(buf[b:], uint16(VidX)) - b += 2 - - Put16(buf[b:], uint16(VidY)) - b += 2 - - Put16(buf[b:], VidW) - b += 2 - - Put16(buf[b:], VidH) - b += 2 - - Put16(buf[b:], uint16(DrwX)) - b += 2 - - Put16(buf[b:], uint16(DrwY)) - b += 2 - - Put16(buf[b:], DrwW) - b += 2 - - Put16(buf[b:], DrwH) - b += 2 - - return buf -} - -// Request XvStopVideo -// size: 12 -type XvStopVideoCookie struct { - *cookie -} - -// Write request to wire for XvStopVideo -func (c *Conn) XvStopVideo(Port XvPort, Drawable Drawable) XvStopVideoCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xvStopVideoRequest(Port, Drawable), cookie) - return XvStopVideoCookie{cookie} -} - -func (c *Conn) XvStopVideoChecked(Port XvPort, Drawable Drawable) XvStopVideoCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xvStopVideoRequest(Port, Drawable), cookie) - return XvStopVideoCookie{cookie} -} - -func (cook XvStopVideoCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvStopVideo -func (c *Conn) xvStopVideoRequest(Port XvPort, Drawable Drawable) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - b += 1 - - buf[b] = 9 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Port)) - b += 4 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - return buf -} - -// Request XvSelectVideoNotify -// size: 12 -type XvSelectVideoNotifyCookie struct { - *cookie -} - -// Write request to wire for XvSelectVideoNotify -func (c *Conn) XvSelectVideoNotify(Drawable Drawable, Onoff bool) XvSelectVideoNotifyCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xvSelectVideoNotifyRequest(Drawable, Onoff), cookie) - return XvSelectVideoNotifyCookie{cookie} -} - -func (c *Conn) XvSelectVideoNotifyChecked(Drawable Drawable, Onoff bool) XvSelectVideoNotifyCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xvSelectVideoNotifyRequest(Drawable, Onoff), cookie) - return XvSelectVideoNotifyCookie{cookie} -} - -func (cook XvSelectVideoNotifyCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvSelectVideoNotify -func (c *Conn) xvSelectVideoNotifyRequest(Drawable Drawable, Onoff bool) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - b += 1 - - buf[b] = 10 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - if Onoff { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 3 // padding - - return buf -} - -// Request XvSelectPortNotify -// size: 12 -type XvSelectPortNotifyCookie struct { - *cookie -} - -// Write request to wire for XvSelectPortNotify -func (c *Conn) XvSelectPortNotify(Port XvPort, Onoff bool) XvSelectPortNotifyCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xvSelectPortNotifyRequest(Port, Onoff), cookie) - return XvSelectPortNotifyCookie{cookie} -} - -func (c *Conn) XvSelectPortNotifyChecked(Port XvPort, Onoff bool) XvSelectPortNotifyCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xvSelectPortNotifyRequest(Port, Onoff), cookie) - return XvSelectPortNotifyCookie{cookie} -} - -func (cook XvSelectPortNotifyCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvSelectPortNotify -func (c *Conn) xvSelectPortNotifyRequest(Port XvPort, Onoff bool) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - b += 1 - - buf[b] = 11 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Port)) - b += 4 - - if Onoff { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 3 // padding - - return buf -} - -// Request XvQueryBestSize -// size: 20 -type XvQueryBestSizeCookie struct { - *cookie -} - -func (c *Conn) XvQueryBestSize(Port XvPort, VidW uint16, VidH uint16, DrwW uint16, DrwH uint16, Motion bool) XvQueryBestSizeCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xvQueryBestSizeRequest(Port, VidW, VidH, DrwW, DrwH, Motion), cookie) - return XvQueryBestSizeCookie{cookie} -} - -func (c *Conn) XvQueryBestSizeUnchecked(Port XvPort, VidW uint16, VidH uint16, DrwW uint16, DrwH uint16, Motion bool) XvQueryBestSizeCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xvQueryBestSizeRequest(Port, VidW, VidH, DrwW, DrwH, Motion), cookie) - return XvQueryBestSizeCookie{cookie} -} - -// Request reply for XvQueryBestSize -// size: 12 -type XvQueryBestSizeReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - ActualWidth uint16 - ActualHeight uint16 -} - -// Waits and reads reply data from request XvQueryBestSize -func (cook XvQueryBestSizeCookie) Reply() (*XvQueryBestSizeReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xvQueryBestSizeReply(buf), nil -} - -// Read reply into structure from buffer for XvQueryBestSize -func xvQueryBestSizeReply(buf []byte) *XvQueryBestSizeReply { - v := new(XvQueryBestSizeReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.ActualWidth = Get16(buf[b:]) - b += 2 - - v.ActualHeight = Get16(buf[b:]) - b += 2 - - return v -} - -func (cook XvQueryBestSizeCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvQueryBestSize -func (c *Conn) xvQueryBestSizeRequest(Port XvPort, VidW uint16, VidH uint16, DrwW uint16, DrwH uint16, Motion bool) []byte { - size := 20 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - b += 1 - - buf[b] = 12 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Port)) - b += 4 - - Put16(buf[b:], VidW) - b += 2 - - Put16(buf[b:], VidH) - b += 2 - - Put16(buf[b:], DrwW) - b += 2 - - Put16(buf[b:], DrwH) - b += 2 - - if Motion { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 3 // padding - - return buf -} - -// Request XvSetPortAttribute -// size: 16 -type XvSetPortAttributeCookie struct { - *cookie -} - -// Write request to wire for XvSetPortAttribute -func (c *Conn) XvSetPortAttribute(Port XvPort, Attribute Atom, Value int32) XvSetPortAttributeCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xvSetPortAttributeRequest(Port, Attribute, Value), cookie) - return XvSetPortAttributeCookie{cookie} -} - -func (c *Conn) XvSetPortAttributeChecked(Port XvPort, Attribute Atom, Value int32) XvSetPortAttributeCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xvSetPortAttributeRequest(Port, Attribute, Value), cookie) - return XvSetPortAttributeCookie{cookie} -} - -func (cook XvSetPortAttributeCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvSetPortAttribute -func (c *Conn) xvSetPortAttributeRequest(Port XvPort, Attribute Atom, Value int32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - b += 1 - - buf[b] = 13 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Port)) - b += 4 - - Put32(buf[b:], uint32(Attribute)) - b += 4 - - Put32(buf[b:], uint32(Value)) - b += 4 - - return buf -} - -// Request XvGetPortAttribute -// size: 12 -type XvGetPortAttributeCookie struct { - *cookie -} - -func (c *Conn) XvGetPortAttribute(Port XvPort, Attribute Atom) XvGetPortAttributeCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xvGetPortAttributeRequest(Port, Attribute), cookie) - return XvGetPortAttributeCookie{cookie} -} - -func (c *Conn) XvGetPortAttributeUnchecked(Port XvPort, Attribute Atom) XvGetPortAttributeCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xvGetPortAttributeRequest(Port, Attribute), cookie) - return XvGetPortAttributeCookie{cookie} -} - -// Request reply for XvGetPortAttribute -// size: 12 -type XvGetPortAttributeReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Value int32 -} - -// Waits and reads reply data from request XvGetPortAttribute -func (cook XvGetPortAttributeCookie) Reply() (*XvGetPortAttributeReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xvGetPortAttributeReply(buf), nil -} - -// Read reply into structure from buffer for XvGetPortAttribute -func xvGetPortAttributeReply(buf []byte) *XvGetPortAttributeReply { - v := new(XvGetPortAttributeReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Value = int32(Get32(buf[b:])) - b += 4 - - return v -} - -func (cook XvGetPortAttributeCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvGetPortAttribute -func (c *Conn) xvGetPortAttributeRequest(Port XvPort, Attribute Atom) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - b += 1 - - buf[b] = 14 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Port)) - b += 4 - - Put32(buf[b:], uint32(Attribute)) - b += 4 - - return buf -} - -// Request XvQueryPortAttributes -// size: 8 -type XvQueryPortAttributesCookie struct { - *cookie -} - -func (c *Conn) XvQueryPortAttributes(Port XvPort) XvQueryPortAttributesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xvQueryPortAttributesRequest(Port), cookie) - return XvQueryPortAttributesCookie{cookie} -} - -func (c *Conn) XvQueryPortAttributesUnchecked(Port XvPort) XvQueryPortAttributesCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xvQueryPortAttributesRequest(Port), cookie) - return XvQueryPortAttributesCookie{cookie} -} - -// Request reply for XvQueryPortAttributes -// size: (32 + XvAttributeInfoListSize(Attributes)) -type XvQueryPortAttributesReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumAttributes uint32 - TextSize uint32 - // padding: 16 bytes - Attributes []XvAttributeInfo // size: XvAttributeInfoListSize(Attributes) -} - -// Waits and reads reply data from request XvQueryPortAttributes -func (cook XvQueryPortAttributesCookie) Reply() (*XvQueryPortAttributesReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xvQueryPortAttributesReply(buf), nil -} - -// Read reply into structure from buffer for XvQueryPortAttributes -func xvQueryPortAttributesReply(buf []byte) *XvQueryPortAttributesReply { - v := new(XvQueryPortAttributesReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.NumAttributes = Get32(buf[b:]) - b += 4 - - v.TextSize = Get32(buf[b:]) - b += 4 - - b += 16 // padding - - v.Attributes = make([]XvAttributeInfo, v.NumAttributes) - b += ReadXvAttributeInfoList(buf[b:], v.Attributes) - - return v -} - -func (cook XvQueryPortAttributesCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvQueryPortAttributes -func (c *Conn) xvQueryPortAttributesRequest(Port XvPort) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - b += 1 - - buf[b] = 15 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Port)) - b += 4 - - return buf -} - -// Request XvListImageFormats -// size: 8 -type XvListImageFormatsCookie struct { - *cookie -} - -func (c *Conn) XvListImageFormats(Port XvPort) XvListImageFormatsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xvListImageFormatsRequest(Port), cookie) - return XvListImageFormatsCookie{cookie} -} - -func (c *Conn) XvListImageFormatsUnchecked(Port XvPort) XvListImageFormatsCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xvListImageFormatsRequest(Port), cookie) - return XvListImageFormatsCookie{cookie} -} - -// Request reply for XvListImageFormats -// size: (32 + XvImageFormatInfoListSize(Format)) -type XvListImageFormatsReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumFormats uint32 - // padding: 20 bytes - Format []XvImageFormatInfo // size: XvImageFormatInfoListSize(Format) -} - -// Waits and reads reply data from request XvListImageFormats -func (cook XvListImageFormatsCookie) Reply() (*XvListImageFormatsReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xvListImageFormatsReply(buf), nil -} - -// Read reply into structure from buffer for XvListImageFormats -func xvListImageFormatsReply(buf []byte) *XvListImageFormatsReply { - v := new(XvListImageFormatsReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.NumFormats = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Format = make([]XvImageFormatInfo, v.NumFormats) - b += ReadXvImageFormatInfoList(buf[b:], v.Format) - - return v -} - -func (cook XvListImageFormatsCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvListImageFormats -func (c *Conn) xvListImageFormatsRequest(Port XvPort) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - b += 1 - - buf[b] = 16 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Port)) - b += 4 - - return buf -} - -// Request XvQueryImageAttributes -// size: 16 -type XvQueryImageAttributesCookie struct { - *cookie -} - -func (c *Conn) XvQueryImageAttributes(Port XvPort, Id uint32, Width uint16, Height uint16) XvQueryImageAttributesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xvQueryImageAttributesRequest(Port, Id, Width, Height), cookie) - return XvQueryImageAttributesCookie{cookie} -} - -func (c *Conn) XvQueryImageAttributesUnchecked(Port XvPort, Id uint32, Width uint16, Height uint16) XvQueryImageAttributesCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xvQueryImageAttributesRequest(Port, Id, Width, Height), cookie) - return XvQueryImageAttributesCookie{cookie} -} - -// Request reply for XvQueryImageAttributes -// size: ((32 + pad((int(NumPlanes) * 4))) + pad((int(NumPlanes) * 4))) -type XvQueryImageAttributesReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - NumPlanes uint32 - DataSize uint32 - Width uint16 - Height uint16 - // padding: 12 bytes - Pitches []uint32 // size: pad((int(NumPlanes) * 4)) - Offsets []uint32 // size: pad((int(NumPlanes) * 4)) -} - -// Waits and reads reply data from request XvQueryImageAttributes -func (cook XvQueryImageAttributesCookie) Reply() (*XvQueryImageAttributesReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xvQueryImageAttributesReply(buf), nil -} - -// Read reply into structure from buffer for XvQueryImageAttributes -func xvQueryImageAttributesReply(buf []byte) *XvQueryImageAttributesReply { - v := new(XvQueryImageAttributesReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.NumPlanes = Get32(buf[b:]) - b += 4 - - v.DataSize = Get32(buf[b:]) - b += 4 - - v.Width = Get16(buf[b:]) - b += 2 - - v.Height = Get16(buf[b:]) - b += 2 - - b += 12 // padding - - v.Pitches = make([]uint32, v.NumPlanes) - for i := 0; i < int(v.NumPlanes); i++ { - v.Pitches[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - v.Offsets = make([]uint32, v.NumPlanes) - for i := 0; i < int(v.NumPlanes); i++ { - v.Offsets[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook XvQueryImageAttributesCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvQueryImageAttributes -func (c *Conn) xvQueryImageAttributesRequest(Port XvPort, Id uint32, Width uint16, Height uint16) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - b += 1 - - buf[b] = 17 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Port)) - b += 4 - - Put32(buf[b:], Id) - b += 4 - - Put16(buf[b:], Width) - b += 2 - - Put16(buf[b:], Height) - b += 2 - - return buf -} - -// Request XvPutImage -// size: pad((40 + pad((len(Data) * 1)))) -type XvPutImageCookie struct { - *cookie -} - -// Write request to wire for XvPutImage -func (c *Conn) XvPutImage(Port XvPort, Drawable Drawable, Gc Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) XvPutImageCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xvPutImageRequest(Port, Drawable, Gc, Id, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, Data), cookie) - return XvPutImageCookie{cookie} -} - -func (c *Conn) XvPutImageChecked(Port XvPort, Drawable Drawable, Gc Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) XvPutImageCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xvPutImageRequest(Port, Drawable, Gc, Id, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, Data), cookie) - return XvPutImageCookie{cookie} -} - -func (cook XvPutImageCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvPutImage -func (c *Conn) xvPutImageRequest(Port XvPort, Drawable Drawable, Gc Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) []byte { - size := pad((40 + pad((len(Data) * 1)))) - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - b += 1 - - buf[b] = 18 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Port)) - b += 4 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - Put32(buf[b:], Id) - b += 4 - - Put16(buf[b:], uint16(SrcX)) - b += 2 - - Put16(buf[b:], uint16(SrcY)) - b += 2 - - Put16(buf[b:], SrcW) - b += 2 - - Put16(buf[b:], SrcH) - b += 2 - - Put16(buf[b:], uint16(DrwX)) - b += 2 - - Put16(buf[b:], uint16(DrwY)) - b += 2 - - Put16(buf[b:], DrwW) - b += 2 - - Put16(buf[b:], DrwH) - b += 2 - - Put16(buf[b:], Width) - b += 2 - - Put16(buf[b:], Height) - b += 2 - - copy(buf[b:], Data[:len(Data)]) - b += pad(int(len(Data))) - - return buf -} - -// Request XvShmPutImage -// size: 52 -type XvShmPutImageCookie struct { - *cookie -} - -// Write request to wire for XvShmPutImage -func (c *Conn) XvShmPutImage(Port XvPort, Drawable Drawable, Gc Gcontext, Shmseg ShmSeg, Id uint32, Offset uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, SendEvent byte) XvShmPutImageCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xvShmPutImageRequest(Port, Drawable, Gc, Shmseg, Id, Offset, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, SendEvent), cookie) - return XvShmPutImageCookie{cookie} -} - -func (c *Conn) XvShmPutImageChecked(Port XvPort, Drawable Drawable, Gc Gcontext, Shmseg ShmSeg, Id uint32, Offset uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, SendEvent byte) XvShmPutImageCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xvShmPutImageRequest(Port, Drawable, Gc, Shmseg, Id, Offset, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, SendEvent), cookie) - return XvShmPutImageCookie{cookie} -} - -func (cook XvShmPutImageCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvShmPutImage -func (c *Conn) xvShmPutImageRequest(Port XvPort, Drawable Drawable, Gc Gcontext, Shmseg ShmSeg, Id uint32, Offset uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, SendEvent byte) []byte { - size := 52 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO"] - b += 1 - - buf[b] = 19 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(Port)) - b += 4 - - Put32(buf[b:], uint32(Drawable)) - b += 4 - - Put32(buf[b:], uint32(Gc)) - b += 4 - - Put32(buf[b:], uint32(Shmseg)) - b += 4 - - Put32(buf[b:], Id) - b += 4 - - Put32(buf[b:], Offset) - b += 4 - - Put16(buf[b:], uint16(SrcX)) - b += 2 - - Put16(buf[b:], uint16(SrcY)) - b += 2 - - Put16(buf[b:], SrcW) - b += 2 - - Put16(buf[b:], SrcH) - b += 2 - - Put16(buf[b:], uint16(DrwX)) - b += 2 - - Put16(buf[b:], uint16(DrwY)) - b += 2 - - Put16(buf[b:], DrwW) - b += 2 - - Put16(buf[b:], DrwH) - b += 2 - - Put16(buf[b:], Width) - b += 2 - - Put16(buf[b:], Height) - b += 2 - - buf[b] = SendEvent - b += 1 - - b += 3 // padding - - return buf -} diff --git a/nexgb/auto_xvmc.go b/nexgb/auto_xvmc.go deleted file mode 100644 index ba4bd44..0000000 --- a/nexgb/auto_xvmc.go +++ /dev/null @@ -1,929 +0,0 @@ -package xgb - -/* - This file was generated by xvmc.xml on May 10 2012 12:39:35pm EDT. - This file is automatically generated. Edit at your peril! -*/ - -// Imports are not necessary for XGB because everything is -// in one package. They are still listed here for reference. -// import "xv" - -// XvmcInit must be called before using the XVideo-MotionCompensation extension. -func (c *Conn) XvmcInit() error { - reply, err := c.QueryExtension(25, "XVideo-MotionCompensation").Reply() - switch { - case err != nil: - return err - case !reply.Present: - return errorf("No extension named XVideo-MotionCompensation could be found on on the server.") - } - - c.extLock.Lock() - c.extensions["XVideo-MotionCompensation"] = reply.MajorOpcode - for evNum, fun := range newExtEventFuncs["XVideo-MotionCompensation"] { - newEventFuncs[int(reply.FirstEvent)+evNum] = fun - } - for errNum, fun := range newExtErrorFuncs["XVideo-MotionCompensation"] { - newErrorFuncs[int(reply.FirstError)+errNum] = fun - } - c.extLock.Unlock() - - return nil -} - -func init() { - newExtEventFuncs["XVideo-MotionCompensation"] = make(map[int]newEventFun) - newExtErrorFuncs["XVideo-MotionCompensation"] = make(map[int]newErrorFun) -} - -// Skipping definition for base type 'Int8' - -// Skipping definition for base type 'Card16' - -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - -// Skipping definition for base type 'Float' - -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - -type XvmcContext uint32 - -func (c *Conn) NewXvmcContextId() (XvmcContext, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return XvmcContext(id), nil -} - -type XvmcSurface uint32 - -func (c *Conn) NewXvmcSurfaceId() (XvmcSurface, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return XvmcSurface(id), nil -} - -type XvmcSubpicture uint32 - -func (c *Conn) NewXvmcSubpictureId() (XvmcSubpicture, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return XvmcSubpicture(id), nil -} - -// 'XvmcSurfaceInfo' struct definition -// Size: 24 -type XvmcSurfaceInfo struct { - Id XvmcSurface - ChromaFormat uint16 - Pad0 uint16 - MaxWidth uint16 - MaxHeight uint16 - SubpictureMaxWidth uint16 - SubpictureMaxHeight uint16 - McType uint32 - Flags uint32 -} - -// Struct read XvmcSurfaceInfo -func ReadXvmcSurfaceInfo(buf []byte, v *XvmcSurfaceInfo) int { - b := 0 - - v.Id = XvmcSurface(Get32(buf[b:])) - b += 4 - - v.ChromaFormat = Get16(buf[b:]) - b += 2 - - v.Pad0 = Get16(buf[b:]) - b += 2 - - v.MaxWidth = Get16(buf[b:]) - b += 2 - - v.MaxHeight = Get16(buf[b:]) - b += 2 - - v.SubpictureMaxWidth = Get16(buf[b:]) - b += 2 - - v.SubpictureMaxHeight = Get16(buf[b:]) - b += 2 - - v.McType = Get32(buf[b:]) - b += 4 - - v.Flags = Get32(buf[b:]) - b += 4 - - return b -} - -// Struct list read XvmcSurfaceInfo -func ReadXvmcSurfaceInfoList(buf []byte, dest []XvmcSurfaceInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = XvmcSurfaceInfo{} - b += ReadXvmcSurfaceInfo(buf[b:], &dest[i]) - } - return pad(b) -} - -// Struct write XvmcSurfaceInfo -func (v XvmcSurfaceInfo) Bytes() []byte { - buf := make([]byte, 24) - b := 0 - - Put32(buf[b:], uint32(v.Id)) - b += 4 - - Put16(buf[b:], v.ChromaFormat) - b += 2 - - Put16(buf[b:], v.Pad0) - b += 2 - - Put16(buf[b:], v.MaxWidth) - b += 2 - - Put16(buf[b:], v.MaxHeight) - b += 2 - - Put16(buf[b:], v.SubpictureMaxWidth) - b += 2 - - Put16(buf[b:], v.SubpictureMaxHeight) - b += 2 - - Put32(buf[b:], v.McType) - b += 4 - - Put32(buf[b:], v.Flags) - b += 4 - - return buf -} - -// Write struct list XvmcSurfaceInfo -func XvmcSurfaceInfoListBytes(buf []byte, list []XvmcSurfaceInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += pad(len(structBytes)) - } - return b -} - -// Request XvmcQueryVersion -// size: 4 -type XvmcQueryVersionCookie struct { - *cookie -} - -func (c *Conn) XvmcQueryVersion() XvmcQueryVersionCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xvmcQueryVersionRequest(), cookie) - return XvmcQueryVersionCookie{cookie} -} - -func (c *Conn) XvmcQueryVersionUnchecked() XvmcQueryVersionCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xvmcQueryVersionRequest(), cookie) - return XvmcQueryVersionCookie{cookie} -} - -// Request reply for XvmcQueryVersion -// size: 16 -type XvmcQueryVersionReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Major uint32 - Minor uint32 -} - -// Waits and reads reply data from request XvmcQueryVersion -func (cook XvmcQueryVersionCookie) Reply() (*XvmcQueryVersionReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xvmcQueryVersionReply(buf), nil -} - -// Read reply into structure from buffer for XvmcQueryVersion -func xvmcQueryVersionReply(buf []byte) *XvmcQueryVersionReply { - v := new(XvmcQueryVersionReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Major = Get32(buf[b:]) - b += 4 - - v.Minor = Get32(buf[b:]) - b += 4 - - return v -} - -func (cook XvmcQueryVersionCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvmcQueryVersion -func (c *Conn) xvmcQueryVersionRequest() []byte { - size := 4 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO-MOTIONCOMPENSATION"] - b += 1 - - buf[b] = 0 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request XvmcListSurfaceTypes -// size: 8 -type XvmcListSurfaceTypesCookie struct { - *cookie -} - -func (c *Conn) XvmcListSurfaceTypes(PortId XvPort) XvmcListSurfaceTypesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xvmcListSurfaceTypesRequest(PortId), cookie) - return XvmcListSurfaceTypesCookie{cookie} -} - -func (c *Conn) XvmcListSurfaceTypesUnchecked(PortId XvPort) XvmcListSurfaceTypesCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xvmcListSurfaceTypesRequest(PortId), cookie) - return XvmcListSurfaceTypesCookie{cookie} -} - -// Request reply for XvmcListSurfaceTypes -// size: (32 + pad((int(Num) * 24))) -type XvmcListSurfaceTypesReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Num uint32 - // padding: 20 bytes - Surfaces []XvmcSurfaceInfo // size: pad((int(Num) * 24)) -} - -// Waits and reads reply data from request XvmcListSurfaceTypes -func (cook XvmcListSurfaceTypesCookie) Reply() (*XvmcListSurfaceTypesReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xvmcListSurfaceTypesReply(buf), nil -} - -// Read reply into structure from buffer for XvmcListSurfaceTypes -func xvmcListSurfaceTypesReply(buf []byte) *XvmcListSurfaceTypesReply { - v := new(XvmcListSurfaceTypesReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Num = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Surfaces = make([]XvmcSurfaceInfo, v.Num) - b += ReadXvmcSurfaceInfoList(buf[b:], v.Surfaces) - - return v -} - -func (cook XvmcListSurfaceTypesCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvmcListSurfaceTypes -func (c *Conn) xvmcListSurfaceTypesRequest(PortId XvPort) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO-MOTIONCOMPENSATION"] - b += 1 - - buf[b] = 1 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(PortId)) - b += 4 - - return buf -} - -// Request XvmcCreateContext -// size: 24 -type XvmcCreateContextCookie struct { - *cookie -} - -func (c *Conn) XvmcCreateContext(ContextId XvmcContext, PortId XvPort, SurfaceId XvmcSurface, Width uint16, Height uint16, Flags uint32) XvmcCreateContextCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xvmcCreateContextRequest(ContextId, PortId, SurfaceId, Width, Height, Flags), cookie) - return XvmcCreateContextCookie{cookie} -} - -func (c *Conn) XvmcCreateContextUnchecked(ContextId XvmcContext, PortId XvPort, SurfaceId XvmcSurface, Width uint16, Height uint16, Flags uint32) XvmcCreateContextCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xvmcCreateContextRequest(ContextId, PortId, SurfaceId, Width, Height, Flags), cookie) - return XvmcCreateContextCookie{cookie} -} - -// Request reply for XvmcCreateContext -// size: (36 + pad((int(Length) * 4))) -type XvmcCreateContextReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - WidthActual uint16 - HeightActual uint16 - FlagsReturn uint32 - // padding: 20 bytes - PrivData []uint32 // size: pad((int(Length) * 4)) -} - -// Waits and reads reply data from request XvmcCreateContext -func (cook XvmcCreateContextCookie) Reply() (*XvmcCreateContextReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xvmcCreateContextReply(buf), nil -} - -// Read reply into structure from buffer for XvmcCreateContext -func xvmcCreateContextReply(buf []byte) *XvmcCreateContextReply { - v := new(XvmcCreateContextReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.WidthActual = Get16(buf[b:]) - b += 2 - - v.HeightActual = Get16(buf[b:]) - b += 2 - - v.FlagsReturn = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.PrivData = make([]uint32, v.Length) - for i := 0; i < int(v.Length); i++ { - v.PrivData[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook XvmcCreateContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvmcCreateContext -func (c *Conn) xvmcCreateContextRequest(ContextId XvmcContext, PortId XvPort, SurfaceId XvmcSurface, Width uint16, Height uint16, Flags uint32) []byte { - size := 24 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO-MOTIONCOMPENSATION"] - b += 1 - - buf[b] = 2 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextId)) - b += 4 - - Put32(buf[b:], uint32(PortId)) - b += 4 - - Put32(buf[b:], uint32(SurfaceId)) - b += 4 - - Put16(buf[b:], Width) - b += 2 - - Put16(buf[b:], Height) - b += 2 - - Put32(buf[b:], Flags) - b += 4 - - return buf -} - -// Request XvmcDestroyContext -// size: 8 -type XvmcDestroyContextCookie struct { - *cookie -} - -// Write request to wire for XvmcDestroyContext -func (c *Conn) XvmcDestroyContext(ContextId XvmcContext) XvmcDestroyContextCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xvmcDestroyContextRequest(ContextId), cookie) - return XvmcDestroyContextCookie{cookie} -} - -func (c *Conn) XvmcDestroyContextChecked(ContextId XvmcContext) XvmcDestroyContextCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xvmcDestroyContextRequest(ContextId), cookie) - return XvmcDestroyContextCookie{cookie} -} - -func (cook XvmcDestroyContextCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvmcDestroyContext -func (c *Conn) xvmcDestroyContextRequest(ContextId XvmcContext) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO-MOTIONCOMPENSATION"] - b += 1 - - buf[b] = 3 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(ContextId)) - b += 4 - - return buf -} - -// Request XvmcCreateSurface -// size: 12 -type XvmcCreateSurfaceCookie struct { - *cookie -} - -func (c *Conn) XvmcCreateSurface(SurfaceId XvmcSurface, ContextId XvmcContext) XvmcCreateSurfaceCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xvmcCreateSurfaceRequest(SurfaceId, ContextId), cookie) - return XvmcCreateSurfaceCookie{cookie} -} - -func (c *Conn) XvmcCreateSurfaceUnchecked(SurfaceId XvmcSurface, ContextId XvmcContext) XvmcCreateSurfaceCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xvmcCreateSurfaceRequest(SurfaceId, ContextId), cookie) - return XvmcCreateSurfaceCookie{cookie} -} - -// Request reply for XvmcCreateSurface -// size: (32 + pad((int(Length) * 4))) -type XvmcCreateSurfaceReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - // padding: 24 bytes - PrivData []uint32 // size: pad((int(Length) * 4)) -} - -// Waits and reads reply data from request XvmcCreateSurface -func (cook XvmcCreateSurfaceCookie) Reply() (*XvmcCreateSurfaceReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xvmcCreateSurfaceReply(buf), nil -} - -// Read reply into structure from buffer for XvmcCreateSurface -func xvmcCreateSurfaceReply(buf []byte) *XvmcCreateSurfaceReply { - v := new(XvmcCreateSurfaceReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - b += 24 // padding - - v.PrivData = make([]uint32, v.Length) - for i := 0; i < int(v.Length); i++ { - v.PrivData[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook XvmcCreateSurfaceCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvmcCreateSurface -func (c *Conn) xvmcCreateSurfaceRequest(SurfaceId XvmcSurface, ContextId XvmcContext) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO-MOTIONCOMPENSATION"] - b += 1 - - buf[b] = 4 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(SurfaceId)) - b += 4 - - Put32(buf[b:], uint32(ContextId)) - b += 4 - - return buf -} - -// Request XvmcDestroySurface -// size: 8 -type XvmcDestroySurfaceCookie struct { - *cookie -} - -// Write request to wire for XvmcDestroySurface -func (c *Conn) XvmcDestroySurface(SurfaceId XvmcSurface) XvmcDestroySurfaceCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xvmcDestroySurfaceRequest(SurfaceId), cookie) - return XvmcDestroySurfaceCookie{cookie} -} - -func (c *Conn) XvmcDestroySurfaceChecked(SurfaceId XvmcSurface) XvmcDestroySurfaceCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xvmcDestroySurfaceRequest(SurfaceId), cookie) - return XvmcDestroySurfaceCookie{cookie} -} - -func (cook XvmcDestroySurfaceCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvmcDestroySurface -func (c *Conn) xvmcDestroySurfaceRequest(SurfaceId XvmcSurface) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO-MOTIONCOMPENSATION"] - b += 1 - - buf[b] = 5 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(SurfaceId)) - b += 4 - - return buf -} - -// Request XvmcCreateSubpicture -// size: 20 -type XvmcCreateSubpictureCookie struct { - *cookie -} - -func (c *Conn) XvmcCreateSubpicture(SubpictureId XvmcSubpicture, Context XvmcContext, XvimageId uint32, Width uint16, Height uint16) XvmcCreateSubpictureCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xvmcCreateSubpictureRequest(SubpictureId, Context, XvimageId, Width, Height), cookie) - return XvmcCreateSubpictureCookie{cookie} -} - -func (c *Conn) XvmcCreateSubpictureUnchecked(SubpictureId XvmcSubpicture, Context XvmcContext, XvimageId uint32, Width uint16, Height uint16) XvmcCreateSubpictureCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xvmcCreateSubpictureRequest(SubpictureId, Context, XvimageId, Width, Height), cookie) - return XvmcCreateSubpictureCookie{cookie} -} - -// Request reply for XvmcCreateSubpicture -// size: (32 + pad((int(Length) * 4))) -type XvmcCreateSubpictureReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - WidthActual uint16 - HeightActual uint16 - NumPaletteEntries uint16 - EntryBytes uint16 - ComponentOrder []byte // size: 4 - // padding: 12 bytes - PrivData []uint32 // size: pad((int(Length) * 4)) -} - -// Waits and reads reply data from request XvmcCreateSubpicture -func (cook XvmcCreateSubpictureCookie) Reply() (*XvmcCreateSubpictureReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xvmcCreateSubpictureReply(buf), nil -} - -// Read reply into structure from buffer for XvmcCreateSubpicture -func xvmcCreateSubpictureReply(buf []byte) *XvmcCreateSubpictureReply { - v := new(XvmcCreateSubpictureReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.WidthActual = Get16(buf[b:]) - b += 2 - - v.HeightActual = Get16(buf[b:]) - b += 2 - - v.NumPaletteEntries = Get16(buf[b:]) - b += 2 - - v.EntryBytes = Get16(buf[b:]) - b += 2 - - v.ComponentOrder = make([]byte, 4) - copy(v.ComponentOrder[:4], buf[b:]) - b += pad(int(4)) - - b += 12 // padding - - v.PrivData = make([]uint32, v.Length) - for i := 0; i < int(v.Length); i++ { - v.PrivData[i] = Get32(buf[b:]) - b += 4 - } - b = pad(b) - - return v -} - -func (cook XvmcCreateSubpictureCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvmcCreateSubpicture -func (c *Conn) xvmcCreateSubpictureRequest(SubpictureId XvmcSubpicture, Context XvmcContext, XvimageId uint32, Width uint16, Height uint16) []byte { - size := 20 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO-MOTIONCOMPENSATION"] - b += 1 - - buf[b] = 6 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(SubpictureId)) - b += 4 - - Put32(buf[b:], uint32(Context)) - b += 4 - - Put32(buf[b:], XvimageId) - b += 4 - - Put16(buf[b:], Width) - b += 2 - - Put16(buf[b:], Height) - b += 2 - - return buf -} - -// Request XvmcDestroySubpicture -// size: 8 -type XvmcDestroySubpictureCookie struct { - *cookie -} - -// Write request to wire for XvmcDestroySubpicture -func (c *Conn) XvmcDestroySubpicture(SubpictureId XvmcSubpicture) XvmcDestroySubpictureCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.xvmcDestroySubpictureRequest(SubpictureId), cookie) - return XvmcDestroySubpictureCookie{cookie} -} - -func (c *Conn) XvmcDestroySubpictureChecked(SubpictureId XvmcSubpicture) XvmcDestroySubpictureCookie { - cookie := c.newCookie(true, false) - c.newRequest(c.xvmcDestroySubpictureRequest(SubpictureId), cookie) - return XvmcDestroySubpictureCookie{cookie} -} - -func (cook XvmcDestroySubpictureCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvmcDestroySubpicture -func (c *Conn) xvmcDestroySubpictureRequest(SubpictureId XvmcSubpicture) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO-MOTIONCOMPENSATION"] - b += 1 - - buf[b] = 7 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(SubpictureId)) - b += 4 - - return buf -} - -// Request XvmcListSubpictureTypes -// size: 12 -type XvmcListSubpictureTypesCookie struct { - *cookie -} - -func (c *Conn) XvmcListSubpictureTypes(PortId XvPort, SurfaceId XvmcSurface) XvmcListSubpictureTypesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xvmcListSubpictureTypesRequest(PortId, SurfaceId), cookie) - return XvmcListSubpictureTypesCookie{cookie} -} - -func (c *Conn) XvmcListSubpictureTypesUnchecked(PortId XvPort, SurfaceId XvmcSurface) XvmcListSubpictureTypesCookie { - cookie := c.newCookie(false, true) - c.newRequest(c.xvmcListSubpictureTypesRequest(PortId, SurfaceId), cookie) - return XvmcListSubpictureTypesCookie{cookie} -} - -// Request reply for XvmcListSubpictureTypes -// size: (32 + XvImageFormatInfoListSize(Types)) -type XvmcListSubpictureTypesReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Num uint32 - // padding: 20 bytes - Types []XvImageFormatInfo // size: XvImageFormatInfoListSize(Types) -} - -// Waits and reads reply data from request XvmcListSubpictureTypes -func (cook XvmcListSubpictureTypesCookie) Reply() (*XvmcListSubpictureTypesReply, error) { - buf, err := cook.reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return xvmcListSubpictureTypesReply(buf), nil -} - -// Read reply into structure from buffer for XvmcListSubpictureTypes -func xvmcListSubpictureTypesReply(buf []byte) *XvmcListSubpictureTypesReply { - v := new(XvmcListSubpictureTypesReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = Get16(buf[b:]) - b += 2 - - v.Length = Get32(buf[b:]) // 4-byte units - b += 4 - - v.Num = Get32(buf[b:]) - b += 4 - - b += 20 // padding - - v.Types = make([]XvImageFormatInfo, v.Num) - b += ReadXvImageFormatInfoList(buf[b:], v.Types) - - return v -} - -func (cook XvmcListSubpictureTypesCookie) Check() error { - return cook.check() -} - -// Write request to wire for XvmcListSubpictureTypes -func (c *Conn) xvmcListSubpictureTypesRequest(PortId XvPort, SurfaceId XvmcSurface) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XVIDEO-MOTIONCOMPENSATION"] - b += 1 - - buf[b] = 8 // request opcode - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - Put32(buf[b:], uint32(PortId)) - b += 4 - - Put32(buf[b:], uint32(SurfaceId)) - b += 4 - - return buf -} diff --git a/nexgb/bigreq/bigreq.go b/nexgb/bigreq/bigreq.go new file mode 100644 index 0000000..8bb05c1 --- /dev/null +++ b/nexgb/bigreq/bigreq.go @@ -0,0 +1,140 @@ +package bigreq + +/* + This file was generated by bigreq.xml on May 10 2012 4:20:27pm EDT. + This file is automatically generated. Edit at your peril! +*/ + +import ( + "github.com/BurntSushi/xgb" + + "github.com/BurntSushi/xgb/xproto" +) + +// Init must be called before using the BIG-REQUESTS extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 12, "BIG-REQUESTS").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named BIG-REQUESTS could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["BIG-REQUESTS"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["BIG-REQUESTS"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["BIG-REQUESTS"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["BIG-REQUESTS"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["BIG-REQUESTS"] = make(map[int]xgb.NewErrorFun) +} + +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Bool' + +// Skipping definition for base type 'Float' + +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + +// Request Enable +// size: 4 +type EnableCookie struct { + *xgb.Cookie +} + +func Enable(c *xgb.Conn) EnableCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(enableRequest(c), cookie) + return EnableCookie{cookie} +} + +func EnableUnchecked(c *xgb.Conn) EnableCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(enableRequest(c), cookie) + return EnableCookie{cookie} +} + +// Request reply for Enable +// size: 12 +type EnableReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + MaximumRequestLength uint32 +} + +// Waits and reads reply data from request Enable +func (cook EnableCookie) Reply() (*EnableReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return enableReply(buf), nil +} + +// Read reply into structure from buffer for Enable +func enableReply(buf []byte) *EnableReply { + v := new(EnableReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.MaximumRequestLength = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for Enable +func enableRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["BIG-REQUESTS"] + b += 1 + + buf[b] = 0 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} diff --git a/nexgb/composite/composite.go b/nexgb/composite/composite.go new file mode 100644 index 0000000..266c087 --- /dev/null +++ b/nexgb/composite/composite.go @@ -0,0 +1,575 @@ +package composite + +/* + This file was generated by composite.xml on May 10 2012 4:20:27pm EDT. + This file is automatically generated. Edit at your peril! +*/ + +import ( + "github.com/BurntSushi/xgb" + + "github.com/BurntSushi/xgb/xfixes" + "github.com/BurntSushi/xgb/xproto" +) + +// Init must be called before using the Composite extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 9, "Composite").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named Composite could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["Composite"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["Composite"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["Composite"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["Composite"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["Composite"] = make(map[int]xgb.NewErrorFun) +} + +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Bool' + +// Skipping definition for base type 'Float' + +const ( + RedirectAutomatic = 0 + RedirectManual = 1 +) + +// Request QueryVersion +// size: 12 +type QueryVersionCookie struct { + *xgb.Cookie +} + +func QueryVersion(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return QueryVersionCookie{cookie} +} + +func QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return QueryVersionCookie{cookie} +} + +// Request reply for QueryVersion +// size: 32 +type QueryVersionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + MajorVersion uint32 + MinorVersion uint32 + // padding: 16 bytes +} + +// Waits and reads reply data from request QueryVersion +func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryVersionReply(buf), nil +} + +// Read reply into structure from buffer for QueryVersion +func queryVersionReply(buf []byte) *QueryVersionReply { + v := new(QueryVersionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.MajorVersion = xgb.Get32(buf[b:]) + b += 4 + + v.MinorVersion = xgb.Get32(buf[b:]) + b += 4 + + b += 16 // padding + + return v +} + +// Write request to wire for QueryVersion +func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["COMPOSITE"] + b += 1 + + buf[b] = 0 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], ClientMajorVersion) + b += 4 + + xgb.Put32(buf[b:], ClientMinorVersion) + b += 4 + + return buf +} + +// Request RedirectWindow +// size: 12 +type RedirectWindowCookie struct { + *xgb.Cookie +} + +// Write request to wire for RedirectWindow +func RedirectWindow(c *xgb.Conn, Window xproto.Window, Update byte) RedirectWindowCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(redirectWindowRequest(c, Window, Update), cookie) + return RedirectWindowCookie{cookie} +} + +func RedirectWindowChecked(c *xgb.Conn, Window xproto.Window, Update byte) RedirectWindowCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(redirectWindowRequest(c, Window, Update), cookie) + return RedirectWindowCookie{cookie} +} + +func (cook RedirectWindowCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for RedirectWindow +func redirectWindowRequest(c *xgb.Conn, Window xproto.Window, Update byte) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["COMPOSITE"] + b += 1 + + buf[b] = 1 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + buf[b] = Update + b += 1 + + b += 3 // padding + + return buf +} + +// Request RedirectSubwindows +// size: 12 +type RedirectSubwindowsCookie struct { + *xgb.Cookie +} + +// Write request to wire for RedirectSubwindows +func RedirectSubwindows(c *xgb.Conn, Window xproto.Window, Update byte) RedirectSubwindowsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(redirectSubwindowsRequest(c, Window, Update), cookie) + return RedirectSubwindowsCookie{cookie} +} + +func RedirectSubwindowsChecked(c *xgb.Conn, Window xproto.Window, Update byte) RedirectSubwindowsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(redirectSubwindowsRequest(c, Window, Update), cookie) + return RedirectSubwindowsCookie{cookie} +} + +func (cook RedirectSubwindowsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for RedirectSubwindows +func redirectSubwindowsRequest(c *xgb.Conn, Window xproto.Window, Update byte) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["COMPOSITE"] + b += 1 + + buf[b] = 2 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + buf[b] = Update + b += 1 + + b += 3 // padding + + return buf +} + +// Request UnredirectWindow +// size: 12 +type UnredirectWindowCookie struct { + *xgb.Cookie +} + +// Write request to wire for UnredirectWindow +func UnredirectWindow(c *xgb.Conn, Window xproto.Window, Update byte) UnredirectWindowCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(unredirectWindowRequest(c, Window, Update), cookie) + return UnredirectWindowCookie{cookie} +} + +func UnredirectWindowChecked(c *xgb.Conn, Window xproto.Window, Update byte) UnredirectWindowCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(unredirectWindowRequest(c, Window, Update), cookie) + return UnredirectWindowCookie{cookie} +} + +func (cook UnredirectWindowCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for UnredirectWindow +func unredirectWindowRequest(c *xgb.Conn, Window xproto.Window, Update byte) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["COMPOSITE"] + b += 1 + + buf[b] = 3 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + buf[b] = Update + b += 1 + + b += 3 // padding + + return buf +} + +// Request UnredirectSubwindows +// size: 12 +type UnredirectSubwindowsCookie struct { + *xgb.Cookie +} + +// Write request to wire for UnredirectSubwindows +func UnredirectSubwindows(c *xgb.Conn, Window xproto.Window, Update byte) UnredirectSubwindowsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(unredirectSubwindowsRequest(c, Window, Update), cookie) + return UnredirectSubwindowsCookie{cookie} +} + +func UnredirectSubwindowsChecked(c *xgb.Conn, Window xproto.Window, Update byte) UnredirectSubwindowsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(unredirectSubwindowsRequest(c, Window, Update), cookie) + return UnredirectSubwindowsCookie{cookie} +} + +func (cook UnredirectSubwindowsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for UnredirectSubwindows +func unredirectSubwindowsRequest(c *xgb.Conn, Window xproto.Window, Update byte) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["COMPOSITE"] + b += 1 + + buf[b] = 4 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + buf[b] = Update + b += 1 + + b += 3 // padding + + return buf +} + +// Request CreateRegionFromBorderClip +// size: 12 +type CreateRegionFromBorderClipCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateRegionFromBorderClip +func CreateRegionFromBorderClip(c *xgb.Conn, Region xfixes.Region, Window xproto.Window) CreateRegionFromBorderClipCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createRegionFromBorderClipRequest(c, Region, Window), cookie) + return CreateRegionFromBorderClipCookie{cookie} +} + +func CreateRegionFromBorderClipChecked(c *xgb.Conn, Region xfixes.Region, Window xproto.Window) CreateRegionFromBorderClipCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createRegionFromBorderClipRequest(c, Region, Window), cookie) + return CreateRegionFromBorderClipCookie{cookie} +} + +func (cook CreateRegionFromBorderClipCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateRegionFromBorderClip +func createRegionFromBorderClipRequest(c *xgb.Conn, Region xfixes.Region, Window xproto.Window) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["COMPOSITE"] + b += 1 + + buf[b] = 5 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Region)) + b += 4 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + +// Request NameWindowPixmap +// size: 12 +type NameWindowPixmapCookie struct { + *xgb.Cookie +} + +// Write request to wire for NameWindowPixmap +func NameWindowPixmap(c *xgb.Conn, Window xproto.Window, Pixmap xproto.Pixmap) NameWindowPixmapCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(nameWindowPixmapRequest(c, Window, Pixmap), cookie) + return NameWindowPixmapCookie{cookie} +} + +func NameWindowPixmapChecked(c *xgb.Conn, Window xproto.Window, Pixmap xproto.Pixmap) NameWindowPixmapCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(nameWindowPixmapRequest(c, Window, Pixmap), cookie) + return NameWindowPixmapCookie{cookie} +} + +func (cook NameWindowPixmapCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for NameWindowPixmap +func nameWindowPixmapRequest(c *xgb.Conn, Window xproto.Window, Pixmap xproto.Pixmap) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["COMPOSITE"] + b += 1 + + buf[b] = 6 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(Pixmap)) + b += 4 + + return buf +} + +// Request GetOverlayWindow +// size: 8 +type GetOverlayWindowCookie struct { + *xgb.Cookie +} + +func GetOverlayWindow(c *xgb.Conn, Window xproto.Window) GetOverlayWindowCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getOverlayWindowRequest(c, Window), cookie) + return GetOverlayWindowCookie{cookie} +} + +func GetOverlayWindowUnchecked(c *xgb.Conn, Window xproto.Window) GetOverlayWindowCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getOverlayWindowRequest(c, Window), cookie) + return GetOverlayWindowCookie{cookie} +} + +// Request reply for GetOverlayWindow +// size: 32 +type GetOverlayWindowReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + OverlayWin xproto.Window + // padding: 20 bytes +} + +// Waits and reads reply data from request GetOverlayWindow +func (cook GetOverlayWindowCookie) Reply() (*GetOverlayWindowReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getOverlayWindowReply(buf), nil +} + +// Read reply into structure from buffer for GetOverlayWindow +func getOverlayWindowReply(buf []byte) *GetOverlayWindowReply { + v := new(GetOverlayWindowReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.OverlayWin = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + b += 20 // padding + + return v +} + +// Write request to wire for GetOverlayWindow +func getOverlayWindowRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["COMPOSITE"] + b += 1 + + buf[b] = 7 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + +// Request ReleaseOverlayWindow +// size: 8 +type ReleaseOverlayWindowCookie struct { + *xgb.Cookie +} + +// Write request to wire for ReleaseOverlayWindow +func ReleaseOverlayWindow(c *xgb.Conn, Window xproto.Window) ReleaseOverlayWindowCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(releaseOverlayWindowRequest(c, Window), cookie) + return ReleaseOverlayWindowCookie{cookie} +} + +func ReleaseOverlayWindowChecked(c *xgb.Conn, Window xproto.Window) ReleaseOverlayWindowCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(releaseOverlayWindowRequest(c, Window), cookie) + return ReleaseOverlayWindowCookie{cookie} +} + +func (cook ReleaseOverlayWindowCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ReleaseOverlayWindow +func releaseOverlayWindowRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["COMPOSITE"] + b += 1 + + buf[b] = 8 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} diff --git a/nexgb/conn.go b/nexgb/conn.go index af78be9..662a059 100644 --- a/nexgb/conn.go +++ b/nexgb/conn.go @@ -38,7 +38,7 @@ func (c *Conn) connect(display string) error { return errors.New("unsupported auth protocol " + authName) } - buf := make([]byte, 12+pad(len(authName))+pad(len(authData))) + buf := make([]byte, 12+Pad(len(authName))+Pad(len(authData))) buf[0] = 0x6c buf[1] = 0 Put16(buf[2:], 11) @@ -47,7 +47,7 @@ func (c *Conn) connect(display string) error { Put16(buf[8:], uint16(len(authData))) Put16(buf[10:], 0) copy(buf[12:], []byte(authName)) - copy(buf[12+pad(len(authName)):], authData) + copy(buf[12+Pad(len(authName)):], authData) if _, err = c.conn.Write(buf); err != nil { return err } @@ -78,11 +78,14 @@ func (c *Conn) connect(display string) error { string(reason)) } - ReadSetupInfo(buf, &c.Setup) + // Unfortunately, it isn't really feasible to read the setup bytes here, + // since the code to do so is in a different package. + // Users must call 'xproto.Setup(X)' to get the setup info. + c.SetupBytes = buf - if c.defaultScreen >= len(c.Setup.Roots) { - c.defaultScreen = 0 - } + // But also read stuff that we *need* to get started. + c.setupResourceIdBase = Get32(buf[12:]) + c.setupResourceIdMask = Get32(buf[16:]) return nil } @@ -137,7 +140,7 @@ func (c *Conn) dial(display string) error { } if len(scr) != 0 { - c.defaultScreen, err = strconv.Atoi(scr) + c.DefaultScreen, err = strconv.Atoi(scr) if err != nil { return errors.New("bad display string: " + display0) } diff --git a/nexgb/cookie.go b/nexgb/cookie.go index 8c0774d..0f32990 100644 --- a/nexgb/cookie.go +++ b/nexgb/cookie.go @@ -4,11 +4,11 @@ import ( "errors" ) -// cookie is the internal representation of a cookie, where one is generated +// Cookie is the internal representation of a cookie, where one is generated // for *every* request sent by XGB. // 'cookie' is most frequently used by embedding it into a more specific // kind of cookie, i.e., 'GetInputFocusCookie'. -type cookie struct { +type Cookie struct { conn *Conn Sequence uint16 replyChan chan []byte @@ -22,8 +22,10 @@ type cookie struct { // function for more info on those.) // Note that a sequence number is not set until just before the request // corresponding to this cookie is sent over the wire. -func (c *Conn) newCookie(checked, reply bool) *cookie { - cookie := &cookie{ +// This function should not be used. It is exported for use in the extension +// sub-packages. +func (c *Conn) NewCookie(checked, reply bool) *Cookie { + cookie := &Cookie{ conn: c, Sequence: 0, // we add the sequence id just before sending a request replyChan: nil, @@ -60,21 +62,23 @@ func (c *Conn) newCookie(checked, reply bool) *cookie { return cookie } -// reply detects whether this is a checked or unchecked cookie, and calls +// Reply detects whether this is a checked or unchecked cookie, and calls // 'replyChecked' or 'replyUnchecked' appropriately. -func (c cookie) reply() ([]byte, error) { +// This should not be used. It is exported for use in extension sub-packages. +func (c Cookie) Reply() ([]byte, error) { // checked if c.errorChan != nil { - return c.replyChecked() + return c.ReplyChecked() } - return c.replyUnchecked() + return c.ReplyUnchecked() } -// replyChecked waits for a response on either the replyChan or errorChan +// ReplyChecked waits for a response on either the replyChan or errorChan // channels. If the former arrives, the bytes are returned with a nil error. // If the latter arrives, no bytes are returned (nil) and the error received // is returned. -func (c cookie) replyChecked() ([]byte, error) { +// This should not be used. It is exported for use in extension sub-packages. +func (c Cookie) ReplyChecked() ([]byte, error) { if c.replyChan == nil { return nil, errors.New("Cannot call 'replyChecked' on a cookie that " + "is not expecting a *reply* or an error.") @@ -93,13 +97,14 @@ func (c cookie) replyChecked() ([]byte, error) { panic("unreachable") } -// replyChecked waits for a response on either the replyChan or pingChan +// ReplyChecked waits for a response on either the replyChan or pingChan // channels. If the former arrives, the bytes are returned with a nil error. // If the latter arrives, no bytes are returned (nil) and a nil error // is returned. (In the latter case, the corresponding error can be retrieved // from (Wait|Poll)ForEvent asynchronously.) // In all honesty, you *probably* don't want to use this method. -func (c cookie) replyUnchecked() ([]byte, error) { +// This should not be used. It is exported for use in extension sub-packages. +func (c Cookie) ReplyUnchecked() ([]byte, error) { if c.replyChan == nil { return nil, errors.New("Cannot call 'replyUnchecked' on a cookie " + "that is not expecting a *reply*.") @@ -114,7 +119,7 @@ func (c cookie) replyUnchecked() ([]byte, error) { panic("unreachable") } -// check is used for checked requests that have no replies. It is a mechanism +// Check is used for checked requests that have no replies. It is a mechanism // by which to report "success" or "error" in a synchronous fashion. (Therefore, // unchecked requests without replies cannot use this method.) // If the request causes an error, it is sent to this cookie's errorChan. @@ -122,7 +127,8 @@ func (c cookie) replyUnchecked() ([]byte, error) { // Thus, pingChan is sent a value when the *next* reply is read. // If no more replies are being processed, we force a round trip request with // GetInputFocus. -func (c cookie) check() error { +// This should not be used. It is exported for use in extension sub-packages. +func (c Cookie) Check() error { if c.replyChan != nil { return errors.New("Cannot call 'Check' on a cookie that is " + "expecting a *reply*. Use 'Reply' instead.") @@ -142,7 +148,7 @@ func (c cookie) check() error { } // Now force a round trip and try again, but block this time. - c.conn.GetInputFocus().Reply() + c.conn.Sync() select { case err := <-c.errorChan: return err diff --git a/nexgb/damage/damage.go b/nexgb/damage/damage.go new file mode 100644 index 0000000..8fe1e38 --- /dev/null +++ b/nexgb/damage/damage.go @@ -0,0 +1,511 @@ +package damage + +/* + This file was generated by damage.xml on May 10 2012 4:20:27pm EDT. + This file is automatically generated. Edit at your peril! +*/ + +import ( + "github.com/BurntSushi/xgb" + + "github.com/BurntSushi/xgb/xfixes" + "github.com/BurntSushi/xgb/xproto" +) + +// Init must be called before using the DAMAGE extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 6, "DAMAGE").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named DAMAGE could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["DAMAGE"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["DAMAGE"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["DAMAGE"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["DAMAGE"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["DAMAGE"] = make(map[int]xgb.NewErrorFun) +} + +// Skipping definition for base type 'Float' + +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Bool' + +const ( + ReportLevelRawRectangles = 0 + ReportLevelDeltaRectangles = 1 + ReportLevelBoundingBox = 2 + ReportLevelNonEmpty = 3 +) + +type Damage uint32 + +func NewDamageId(c *xgb.Conn) (Damage, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Damage(id), nil +} + +// Event definition Notify (0) +// Size: 32 + +const Notify = 0 + +type NotifyEvent struct { + Sequence uint16 + Level byte + Drawable xproto.Drawable + Damage Damage + Timestamp xproto.Timestamp + Area xproto.Rectangle + Geometry xproto.Rectangle +} + +// Event read Notify +func NotifyEventNew(buf []byte) xgb.Event { + v := NotifyEvent{} + b := 1 // don't read event number + + v.Level = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Drawable = xproto.Drawable(xgb.Get32(buf[b:])) + b += 4 + + v.Damage = Damage(xgb.Get32(buf[b:])) + b += 4 + + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Area = xproto.Rectangle{} + b += xproto.RectangleRead(buf[b:], &v.Area) + + v.Geometry = xproto.Rectangle{} + b += xproto.RectangleRead(buf[b:], &v.Geometry) + + return v +} + +// Event write Notify +func (v NotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 0 + b += 1 + + buf[b] = v.Level + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Damage)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Timestamp)) + b += 4 + + { + structBytes := v.Area.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.Geometry.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + return buf +} + +func (v NotifyEvent) ImplementsEvent() {} + +func (v NotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v NotifyEvent) String() string { + fieldVals := make([]string, 0, 6) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Level: %d", v.Level)) + fieldVals = append(fieldVals, xgb.Sprintf("Drawable: %d", v.Drawable)) + fieldVals = append(fieldVals, xgb.Sprintf("Damage: %d", v.Damage)) + fieldVals = append(fieldVals, xgb.Sprintf("Timestamp: %d", v.Timestamp)) + return "Notify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["DAMAGE"][0] = NotifyEventNew +} + +// Error definition BadDamage (0) +// Size: 32 + +const BadBadDamage = 0 + +type BadDamageError struct { + Sequence uint16 + NiceName string +} + +// Error read BadDamage +func BadDamageErrorNew(buf []byte) xgb.Error { + v := BadDamageError{} + v.NiceName = "BadDamage" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err BadDamageError) ImplementsError() {} + +func (err BadDamageError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadDamageError) BadId() uint32 { + return 0 +} + +func (err BadDamageError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadDamage {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["DAMAGE"][0] = BadDamageErrorNew +} + +// Request QueryVersion +// size: 12 +type QueryVersionCookie struct { + *xgb.Cookie +} + +func QueryVersion(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return QueryVersionCookie{cookie} +} + +func QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return QueryVersionCookie{cookie} +} + +// Request reply for QueryVersion +// size: 32 +type QueryVersionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + MajorVersion uint32 + MinorVersion uint32 + // padding: 16 bytes +} + +// Waits and reads reply data from request QueryVersion +func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryVersionReply(buf), nil +} + +// Read reply into structure from buffer for QueryVersion +func queryVersionReply(buf []byte) *QueryVersionReply { + v := new(QueryVersionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.MajorVersion = xgb.Get32(buf[b:]) + b += 4 + + v.MinorVersion = xgb.Get32(buf[b:]) + b += 4 + + b += 16 // padding + + return v +} + +// Write request to wire for QueryVersion +func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DAMAGE"] + b += 1 + + buf[b] = 0 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], ClientMajorVersion) + b += 4 + + xgb.Put32(buf[b:], ClientMinorVersion) + b += 4 + + return buf +} + +// Request Create +// size: 16 +type CreateCookie struct { + *xgb.Cookie +} + +// Write request to wire for Create +func Create(c *xgb.Conn, Damage Damage, Drawable xproto.Drawable, Level byte) CreateCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createRequest(c, Damage, Drawable, Level), cookie) + return CreateCookie{cookie} +} + +func CreateChecked(c *xgb.Conn, Damage Damage, Drawable xproto.Drawable, Level byte) CreateCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createRequest(c, Damage, Drawable, Level), cookie) + return CreateCookie{cookie} +} + +func (cook CreateCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for Create +func createRequest(c *xgb.Conn, Damage Damage, Drawable xproto.Drawable, Level byte) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DAMAGE"] + b += 1 + + buf[b] = 1 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Damage)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + buf[b] = Level + b += 1 + + b += 3 // padding + + return buf +} + +// Request Destroy +// size: 8 +type DestroyCookie struct { + *xgb.Cookie +} + +// Write request to wire for Destroy +func Destroy(c *xgb.Conn, Damage Damage) DestroyCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroyRequest(c, Damage), cookie) + return DestroyCookie{cookie} +} + +func DestroyChecked(c *xgb.Conn, Damage Damage) DestroyCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(destroyRequest(c, Damage), cookie) + return DestroyCookie{cookie} +} + +func (cook DestroyCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for Destroy +func destroyRequest(c *xgb.Conn, Damage Damage) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DAMAGE"] + b += 1 + + buf[b] = 2 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Damage)) + b += 4 + + return buf +} + +// Request Subtract +// size: 16 +type SubtractCookie struct { + *xgb.Cookie +} + +// Write request to wire for Subtract +func Subtract(c *xgb.Conn, Damage Damage, Repair xfixes.Region, Parts xfixes.Region) SubtractCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(subtractRequest(c, Damage, Repair, Parts), cookie) + return SubtractCookie{cookie} +} + +func SubtractChecked(c *xgb.Conn, Damage Damage, Repair xfixes.Region, Parts xfixes.Region) SubtractCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(subtractRequest(c, Damage, Repair, Parts), cookie) + return SubtractCookie{cookie} +} + +func (cook SubtractCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for Subtract +func subtractRequest(c *xgb.Conn, Damage Damage, Repair xfixes.Region, Parts xfixes.Region) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DAMAGE"] + b += 1 + + buf[b] = 3 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Damage)) + b += 4 + + xgb.Put32(buf[b:], uint32(Repair)) + b += 4 + + xgb.Put32(buf[b:], uint32(Parts)) + b += 4 + + return buf +} + +// Request Add +// size: 12 +type AddCookie struct { + *xgb.Cookie +} + +// Write request to wire for Add +func Add(c *xgb.Conn, Drawable xproto.Drawable, Region xfixes.Region) AddCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(addRequest(c, Drawable, Region), cookie) + return AddCookie{cookie} +} + +func AddChecked(c *xgb.Conn, Drawable xproto.Drawable, Region xfixes.Region) AddCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(addRequest(c, Drawable, Region), cookie) + return AddCookie{cookie} +} + +func (cook AddCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for Add +func addRequest(c *xgb.Conn, Drawable xproto.Drawable, Region xfixes.Region) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DAMAGE"] + b += 1 + + buf[b] = 4 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Region)) + b += 4 + + return buf +} diff --git a/nexgb/doc.go b/nexgb/doc.go index b6c956f..91c6406 100644 --- a/nexgb/doc.go +++ b/nexgb/doc.go @@ -24,6 +24,7 @@ accompanying documentation can be found in examples/create-window. import ( "fmt" "github.com/BurntSushi/xgb" + "github.com/BurntSushi/xgb/xproto" ) func main() { @@ -33,18 +34,19 @@ accompanying documentation can be found in examples/create-window. return } - wid, _ := X.NewId() - X.CreateWindow(X.DefaultScreen().RootDepth, wid, X.DefaultScreen().Root, + wid, _ := xproto.NewWindowId(X) + screen := xproto.Setup(X).DefaultScreen(X) + xproto.CreateWindow(X, screen.RootDepth, wid, screen.Root, 0, 0, 500, 500, 0, - xgb.WindowClassInputOutput, X.DefaultScreen().RootVisual, - xgb.CwBackPixel | xgb.CwEventMask, + xproto.WindowClassInputOutput, screen.RootVisual, + xproto.CwBackPixel | xproto.CwEventMask, []uint32{ // values must be in the order defined by the protocol 0xffffffff, - xgb.EventMaskStructureNotify | - xgb.EventMaskKeyPress | - xgb.EventMaskKeyRelease}) + xproto.EventMaskStructureNotify | + xproto.EventMaskKeyPress | + xproto.EventMaskKeyRelease}) - X.MapWindow(wid) + xproto.MapWindow(X, wid) for { ev, xerr := X.WaitForEvent() if ev == nil && xerr == nil { @@ -73,6 +75,7 @@ can be found in examples/xinerama. "fmt" "log" "github.com/BurntSushi/xgb" + "github.com/BurntSushi/xgb/xinerama" ) func main() { @@ -84,12 +87,12 @@ can be found in examples/xinerama. // Initialize the Xinerama extension. // The appropriate 'Init' function must be run for *every* // extension before any of its requests can be used. - err = X.XineramaInit() + err = xinerama.Init(X) if err != nil { log.Fatal(err) } - reply, err := X.XineramaQueryScreens().Reply() + reply, err := xinerama.QueryScreens(X).Reply() if err != nil { log.Fatal(err) } diff --git a/nexgb/dpms/dpms.go b/nexgb/dpms/dpms.go new file mode 100644 index 0000000..01314ac --- /dev/null +++ b/nexgb/dpms/dpms.go @@ -0,0 +1,590 @@ +package dpms + +/* + This file was generated by dpms.xml on May 10 2012 4:20:27pm EDT. + This file is automatically generated. Edit at your peril! +*/ + +import ( + "github.com/BurntSushi/xgb" + + "github.com/BurntSushi/xgb/xproto" +) + +// Init must be called before using the DPMS extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 4, "DPMS").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named DPMS could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["DPMS"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["DPMS"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["DPMS"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["DPMS"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["DPMS"] = make(map[int]xgb.NewErrorFun) +} + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Bool' + +// Skipping definition for base type 'Float' + +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +const ( + DPMSModeOn = 0 + DPMSModeStandby = 1 + DPMSModeSuspend = 2 + DPMSModeOff = 3 +) + +// Request GetVersion +// size: 8 +type GetVersionCookie struct { + *xgb.Cookie +} + +func GetVersion(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) GetVersionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return GetVersionCookie{cookie} +} + +func GetVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) GetVersionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return GetVersionCookie{cookie} +} + +// Request reply for GetVersion +// size: 12 +type GetVersionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ServerMajorVersion uint16 + ServerMinorVersion uint16 +} + +// Waits and reads reply data from request GetVersion +func (cook GetVersionCookie) Reply() (*GetVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getVersionReply(buf), nil +} + +// Read reply into structure from buffer for GetVersion +func getVersionReply(buf []byte) *GetVersionReply { + v := new(GetVersionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ServerMajorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.ServerMinorVersion = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Write request to wire for GetVersion +func getVersionRequest(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DPMS"] + b += 1 + + buf[b] = 0 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], ClientMajorVersion) + b += 2 + + xgb.Put16(buf[b:], ClientMinorVersion) + b += 2 + + return buf +} + +// Request Capable +// size: 4 +type CapableCookie struct { + *xgb.Cookie +} + +func Capable(c *xgb.Conn) CapableCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(capableRequest(c), cookie) + return CapableCookie{cookie} +} + +func CapableUnchecked(c *xgb.Conn) CapableCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(capableRequest(c), cookie) + return CapableCookie{cookie} +} + +// Request reply for Capable +// size: 32 +type CapableReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Capable bool + // padding: 23 bytes +} + +// Waits and reads reply data from request Capable +func (cook CapableCookie) Reply() (*CapableReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return capableReply(buf), nil +} + +// Read reply into structure from buffer for Capable +func capableReply(buf []byte) *CapableReply { + v := new(CapableReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + if buf[b] == 1 { + v.Capable = true + } else { + v.Capable = false + } + b += 1 + + b += 23 // padding + + return v +} + +// Write request to wire for Capable +func capableRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DPMS"] + b += 1 + + buf[b] = 1 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request GetTimeouts +// size: 4 +type GetTimeoutsCookie struct { + *xgb.Cookie +} + +func GetTimeouts(c *xgb.Conn) GetTimeoutsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getTimeoutsRequest(c), cookie) + return GetTimeoutsCookie{cookie} +} + +func GetTimeoutsUnchecked(c *xgb.Conn) GetTimeoutsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getTimeoutsRequest(c), cookie) + return GetTimeoutsCookie{cookie} +} + +// Request reply for GetTimeouts +// size: 32 +type GetTimeoutsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + StandbyTimeout uint16 + SuspendTimeout uint16 + OffTimeout uint16 + // padding: 18 bytes +} + +// Waits and reads reply data from request GetTimeouts +func (cook GetTimeoutsCookie) Reply() (*GetTimeoutsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getTimeoutsReply(buf), nil +} + +// Read reply into structure from buffer for GetTimeouts +func getTimeoutsReply(buf []byte) *GetTimeoutsReply { + v := new(GetTimeoutsReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.StandbyTimeout = xgb.Get16(buf[b:]) + b += 2 + + v.SuspendTimeout = xgb.Get16(buf[b:]) + b += 2 + + v.OffTimeout = xgb.Get16(buf[b:]) + b += 2 + + b += 18 // padding + + return v +} + +// Write request to wire for GetTimeouts +func getTimeoutsRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DPMS"] + b += 1 + + buf[b] = 2 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request SetTimeouts +// size: 12 +type SetTimeoutsCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetTimeouts +func SetTimeouts(c *xgb.Conn, StandbyTimeout uint16, SuspendTimeout uint16, OffTimeout uint16) SetTimeoutsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setTimeoutsRequest(c, StandbyTimeout, SuspendTimeout, OffTimeout), cookie) + return SetTimeoutsCookie{cookie} +} + +func SetTimeoutsChecked(c *xgb.Conn, StandbyTimeout uint16, SuspendTimeout uint16, OffTimeout uint16) SetTimeoutsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setTimeoutsRequest(c, StandbyTimeout, SuspendTimeout, OffTimeout), cookie) + return SetTimeoutsCookie{cookie} +} + +func (cook SetTimeoutsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetTimeouts +func setTimeoutsRequest(c *xgb.Conn, StandbyTimeout uint16, SuspendTimeout uint16, OffTimeout uint16) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DPMS"] + b += 1 + + buf[b] = 3 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], StandbyTimeout) + b += 2 + + xgb.Put16(buf[b:], SuspendTimeout) + b += 2 + + xgb.Put16(buf[b:], OffTimeout) + b += 2 + + return buf +} + +// Request Enable +// size: 4 +type EnableCookie struct { + *xgb.Cookie +} + +// Write request to wire for Enable +func Enable(c *xgb.Conn) EnableCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(enableRequest(c), cookie) + return EnableCookie{cookie} +} + +func EnableChecked(c *xgb.Conn) EnableCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(enableRequest(c), cookie) + return EnableCookie{cookie} +} + +func (cook EnableCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for Enable +func enableRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DPMS"] + b += 1 + + buf[b] = 4 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request Disable +// size: 4 +type DisableCookie struct { + *xgb.Cookie +} + +// Write request to wire for Disable +func Disable(c *xgb.Conn) DisableCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(disableRequest(c), cookie) + return DisableCookie{cookie} +} + +func DisableChecked(c *xgb.Conn) DisableCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(disableRequest(c), cookie) + return DisableCookie{cookie} +} + +func (cook DisableCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for Disable +func disableRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DPMS"] + b += 1 + + buf[b] = 5 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request ForceLevel +// size: 8 +type ForceLevelCookie struct { + *xgb.Cookie +} + +// Write request to wire for ForceLevel +func ForceLevel(c *xgb.Conn, PowerLevel uint16) ForceLevelCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(forceLevelRequest(c, PowerLevel), cookie) + return ForceLevelCookie{cookie} +} + +func ForceLevelChecked(c *xgb.Conn, PowerLevel uint16) ForceLevelCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(forceLevelRequest(c, PowerLevel), cookie) + return ForceLevelCookie{cookie} +} + +func (cook ForceLevelCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ForceLevel +func forceLevelRequest(c *xgb.Conn, PowerLevel uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DPMS"] + b += 1 + + buf[b] = 6 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], PowerLevel) + b += 2 + + return buf +} + +// Request Info +// size: 4 +type InfoCookie struct { + *xgb.Cookie +} + +func Info(c *xgb.Conn) InfoCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(infoRequest(c), cookie) + return InfoCookie{cookie} +} + +func InfoUnchecked(c *xgb.Conn) InfoCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(infoRequest(c), cookie) + return InfoCookie{cookie} +} + +// Request reply for Info +// size: 32 +type InfoReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + PowerLevel uint16 + State bool + // padding: 21 bytes +} + +// Waits and reads reply data from request Info +func (cook InfoCookie) Reply() (*InfoReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return infoReply(buf), nil +} + +// Read reply into structure from buffer for Info +func infoReply(buf []byte) *InfoReply { + v := new(InfoReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.PowerLevel = xgb.Get16(buf[b:]) + b += 2 + + if buf[b] == 1 { + v.State = true + } else { + v.State = false + } + b += 1 + + b += 21 // padding + + return v +} + +// Write request to wire for Info +func infoRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DPMS"] + b += 1 + + buf[b] = 7 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} diff --git a/nexgb/dri2/dri2.go b/nexgb/dri2/dri2.go new file mode 100644 index 0000000..cffe20e --- /dev/null +++ b/nexgb/dri2/dri2.go @@ -0,0 +1,1522 @@ +package dri2 + +/* + This file was generated by dri2.xml on May 10 2012 4:20:27pm EDT. + This file is automatically generated. Edit at your peril! +*/ + +import ( + "github.com/BurntSushi/xgb" + + "github.com/BurntSushi/xgb/xproto" +) + +// Init must be called before using the DRI2 extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 4, "DRI2").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named DRI2 could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["DRI2"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["DRI2"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["DRI2"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["DRI2"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["DRI2"] = make(map[int]xgb.NewErrorFun) +} + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Bool' + +// Skipping definition for base type 'Float' + +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +const ( + AttachmentBufferFrontLeft = 0 + AttachmentBufferBackLeft = 1 + AttachmentBufferFrontRight = 2 + AttachmentBufferBackRight = 3 + AttachmentBufferDepth = 4 + AttachmentBufferStencil = 5 + AttachmentBufferAccum = 6 + AttachmentBufferFakeFrontLeft = 7 + AttachmentBufferFakeFrontRight = 8 + AttachmentBufferDepthStencil = 9 + AttachmentBufferHiz = 10 +) + +const ( + DriverTypeDri = 0 + DriverTypeVdpau = 1 +) + +const ( + EventTypeExchangeComplete = 1 + EventTypeBlitComplete = 2 + EventTypeFlipComplete = 3 +) + +// 'DRI2Buffer' struct definition +// Size: 20 +type DRI2Buffer struct { + Attachment uint32 + Name uint32 + Pitch uint32 + Cpp uint32 + Flags uint32 +} + +// Struct read DRI2Buffer +func DRI2BufferRead(buf []byte, v *DRI2Buffer) int { + b := 0 + + v.Attachment = xgb.Get32(buf[b:]) + b += 4 + + v.Name = xgb.Get32(buf[b:]) + b += 4 + + v.Pitch = xgb.Get32(buf[b:]) + b += 4 + + v.Cpp = xgb.Get32(buf[b:]) + b += 4 + + v.Flags = xgb.Get32(buf[b:]) + b += 4 + + return b +} + +// Struct list read DRI2Buffer +func DRI2BufferReadList(buf []byte, dest []DRI2Buffer) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DRI2Buffer{} + b += DRI2BufferRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write DRI2Buffer +func (v DRI2Buffer) Bytes() []byte { + buf := make([]byte, 20) + b := 0 + + xgb.Put32(buf[b:], v.Attachment) + b += 4 + + xgb.Put32(buf[b:], v.Name) + b += 4 + + xgb.Put32(buf[b:], v.Pitch) + b += 4 + + xgb.Put32(buf[b:], v.Cpp) + b += 4 + + xgb.Put32(buf[b:], v.Flags) + b += 4 + + return buf +} + +// Write struct list DRI2Buffer +func DRI2BufferListBytes(buf []byte, list []DRI2Buffer) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'AttachFormat' struct definition +// Size: 8 +type AttachFormat struct { + Attachment uint32 + Format uint32 +} + +// Struct read AttachFormat +func AttachFormatRead(buf []byte, v *AttachFormat) int { + b := 0 + + v.Attachment = xgb.Get32(buf[b:]) + b += 4 + + v.Format = xgb.Get32(buf[b:]) + b += 4 + + return b +} + +// Struct list read AttachFormat +func AttachFormatReadList(buf []byte, dest []AttachFormat) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = AttachFormat{} + b += AttachFormatRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write AttachFormat +func (v AttachFormat) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put32(buf[b:], v.Attachment) + b += 4 + + xgb.Put32(buf[b:], v.Format) + b += 4 + + return buf +} + +// Write struct list AttachFormat +func AttachFormatListBytes(buf []byte, list []AttachFormat) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Event definition BufferSwapComplete (0) +// Size: 32 + +const BufferSwapComplete = 0 + +type BufferSwapCompleteEvent struct { + Sequence uint16 + // padding: 1 bytes + EventType uint16 + // padding: 2 bytes + Drawable xproto.Drawable + UstHi uint32 + UstLo uint32 + MscHi uint32 + MscLo uint32 + Sbc uint32 +} + +// Event read BufferSwapComplete +func BufferSwapCompleteEventNew(buf []byte) xgb.Event { + v := BufferSwapCompleteEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.EventType = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + v.Drawable = xproto.Drawable(xgb.Get32(buf[b:])) + b += 4 + + v.UstHi = xgb.Get32(buf[b:]) + b += 4 + + v.UstLo = xgb.Get32(buf[b:]) + b += 4 + + v.MscHi = xgb.Get32(buf[b:]) + b += 4 + + v.MscLo = xgb.Get32(buf[b:]) + b += 4 + + v.Sbc = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Event write BufferSwapComplete +func (v BufferSwapCompleteEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 0 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put16(buf[b:], v.EventType) + b += 2 + + b += 2 // padding + + xgb.Put32(buf[b:], uint32(v.Drawable)) + b += 4 + + xgb.Put32(buf[b:], v.UstHi) + b += 4 + + xgb.Put32(buf[b:], v.UstLo) + b += 4 + + xgb.Put32(buf[b:], v.MscHi) + b += 4 + + xgb.Put32(buf[b:], v.MscLo) + b += 4 + + xgb.Put32(buf[b:], v.Sbc) + b += 4 + + return buf +} + +func (v BufferSwapCompleteEvent) ImplementsEvent() {} + +func (v BufferSwapCompleteEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v BufferSwapCompleteEvent) String() string { + fieldVals := make([]string, 0, 9) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("EventType: %d", v.EventType)) + fieldVals = append(fieldVals, xgb.Sprintf("Drawable: %d", v.Drawable)) + fieldVals = append(fieldVals, xgb.Sprintf("UstHi: %d", v.UstHi)) + fieldVals = append(fieldVals, xgb.Sprintf("UstLo: %d", v.UstLo)) + fieldVals = append(fieldVals, xgb.Sprintf("MscHi: %d", v.MscHi)) + fieldVals = append(fieldVals, xgb.Sprintf("MscLo: %d", v.MscLo)) + fieldVals = append(fieldVals, xgb.Sprintf("Sbc: %d", v.Sbc)) + return "BufferSwapComplete {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["DRI2"][0] = BufferSwapCompleteEventNew +} + +// Event definition InvalidateBuffers (1) +// Size: 32 + +const InvalidateBuffers = 1 + +type InvalidateBuffersEvent struct { + Sequence uint16 + // padding: 1 bytes + Drawable xproto.Drawable +} + +// Event read InvalidateBuffers +func InvalidateBuffersEventNew(buf []byte) xgb.Event { + v := InvalidateBuffersEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Drawable = xproto.Drawable(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Event write InvalidateBuffers +func (v InvalidateBuffersEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 1 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Drawable)) + b += 4 + + return buf +} + +func (v InvalidateBuffersEvent) ImplementsEvent() {} + +func (v InvalidateBuffersEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v InvalidateBuffersEvent) String() string { + fieldVals := make([]string, 0, 2) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Drawable: %d", v.Drawable)) + return "InvalidateBuffers {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["DRI2"][1] = InvalidateBuffersEventNew +} + +// Request QueryVersion +// size: 12 +type QueryVersionCookie struct { + *xgb.Cookie +} + +func QueryVersion(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) + return QueryVersionCookie{cookie} +} + +func QueryVersionUnchecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) + return QueryVersionCookie{cookie} +} + +// Request reply for QueryVersion +// size: 16 +type QueryVersionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + MajorVersion uint32 + MinorVersion uint32 +} + +// Waits and reads reply data from request QueryVersion +func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryVersionReply(buf), nil +} + +// Read reply into structure from buffer for QueryVersion +func queryVersionReply(buf []byte) *QueryVersionReply { + v := new(QueryVersionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.MajorVersion = xgb.Get32(buf[b:]) + b += 4 + + v.MinorVersion = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for QueryVersion +func queryVersionRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DRI2"] + b += 1 + + buf[b] = 0 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], MajorVersion) + b += 4 + + xgb.Put32(buf[b:], MinorVersion) + b += 4 + + return buf +} + +// Request Connect +// size: 12 +type ConnectCookie struct { + *xgb.Cookie +} + +func Connect(c *xgb.Conn, Window xproto.Window, DriverType uint32) ConnectCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(connectRequest(c, Window, DriverType), cookie) + return ConnectCookie{cookie} +} + +func ConnectUnchecked(c *xgb.Conn, Window xproto.Window, DriverType uint32) ConnectCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(connectRequest(c, Window, DriverType), cookie) + return ConnectCookie{cookie} +} + +// Request reply for Connect +// size: (((32 + xgb.Pad((int(DriverNameLength) * 1))) + xgb.Pad(((((int(DriverNameLength) + 3) & -4) - int(DriverNameLength)) * 1))) + xgb.Pad((int(DeviceNameLength) * 1))) +type ConnectReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + DriverNameLength uint32 + DeviceNameLength uint32 + // padding: 16 bytes + DriverName string // size: xgb.Pad((int(DriverNameLength) * 1)) + AlignmentPad []byte // size: xgb.Pad(((((int(DriverNameLength) + 3) & -4) - int(DriverNameLength)) * 1)) + DeviceName string // size: xgb.Pad((int(DeviceNameLength) * 1)) +} + +// Waits and reads reply data from request Connect +func (cook ConnectCookie) Reply() (*ConnectReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return connectReply(buf), nil +} + +// Read reply into structure from buffer for Connect +func connectReply(buf []byte) *ConnectReply { + v := new(ConnectReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.DriverNameLength = xgb.Get32(buf[b:]) + b += 4 + + v.DeviceNameLength = xgb.Get32(buf[b:]) + b += 4 + + b += 16 // padding + + { + byteString := make([]byte, v.DriverNameLength) + copy(byteString[:v.DriverNameLength], buf[b:]) + v.DriverName = string(byteString) + b += xgb.Pad(int(v.DriverNameLength)) + } + + v.AlignmentPad = make([]byte, (((int(v.DriverNameLength) + 3) & -4) - int(v.DriverNameLength))) + copy(v.AlignmentPad[:(((int(v.DriverNameLength)+3)&-4)-int(v.DriverNameLength))], buf[b:]) + b += xgb.Pad(int((((int(v.DriverNameLength) + 3) & -4) - int(v.DriverNameLength)))) + + { + byteString := make([]byte, v.DeviceNameLength) + copy(byteString[:v.DeviceNameLength], buf[b:]) + v.DeviceName = string(byteString) + b += xgb.Pad(int(v.DeviceNameLength)) + } + + return v +} + +// Write request to wire for Connect +func connectRequest(c *xgb.Conn, Window xproto.Window, DriverType uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DRI2"] + b += 1 + + buf[b] = 1 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put32(buf[b:], DriverType) + b += 4 + + return buf +} + +// Request Authenticate +// size: 12 +type AuthenticateCookie struct { + *xgb.Cookie +} + +func Authenticate(c *xgb.Conn, Window xproto.Window, Magic uint32) AuthenticateCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(authenticateRequest(c, Window, Magic), cookie) + return AuthenticateCookie{cookie} +} + +func AuthenticateUnchecked(c *xgb.Conn, Window xproto.Window, Magic uint32) AuthenticateCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(authenticateRequest(c, Window, Magic), cookie) + return AuthenticateCookie{cookie} +} + +// Request reply for Authenticate +// size: 12 +type AuthenticateReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Authenticated uint32 +} + +// Waits and reads reply data from request Authenticate +func (cook AuthenticateCookie) Reply() (*AuthenticateReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return authenticateReply(buf), nil +} + +// Read reply into structure from buffer for Authenticate +func authenticateReply(buf []byte) *AuthenticateReply { + v := new(AuthenticateReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Authenticated = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for Authenticate +func authenticateRequest(c *xgb.Conn, Window xproto.Window, Magic uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DRI2"] + b += 1 + + buf[b] = 2 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put32(buf[b:], Magic) + b += 4 + + return buf +} + +// Request CreateDrawable +// size: 8 +type CreateDrawableCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateDrawable +func CreateDrawable(c *xgb.Conn, Drawable xproto.Drawable) CreateDrawableCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createDrawableRequest(c, Drawable), cookie) + return CreateDrawableCookie{cookie} +} + +func CreateDrawableChecked(c *xgb.Conn, Drawable xproto.Drawable) CreateDrawableCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createDrawableRequest(c, Drawable), cookie) + return CreateDrawableCookie{cookie} +} + +func (cook CreateDrawableCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateDrawable +func createDrawableRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DRI2"] + b += 1 + + buf[b] = 3 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + return buf +} + +// Request DestroyDrawable +// size: 8 +type DestroyDrawableCookie struct { + *xgb.Cookie +} + +// Write request to wire for DestroyDrawable +func DestroyDrawable(c *xgb.Conn, Drawable xproto.Drawable) DestroyDrawableCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroyDrawableRequest(c, Drawable), cookie) + return DestroyDrawableCookie{cookie} +} + +func DestroyDrawableChecked(c *xgb.Conn, Drawable xproto.Drawable) DestroyDrawableCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(destroyDrawableRequest(c, Drawable), cookie) + return DestroyDrawableCookie{cookie} +} + +func (cook DestroyDrawableCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DestroyDrawable +func destroyDrawableRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DRI2"] + b += 1 + + buf[b] = 4 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + return buf +} + +// Request GetBuffers +// size: xgb.Pad((12 + xgb.Pad((len(Attachments) * 4)))) +type GetBuffersCookie struct { + *xgb.Cookie +} + +func GetBuffers(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Attachments []uint32) GetBuffersCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getBuffersRequest(c, Drawable, Count, Attachments), cookie) + return GetBuffersCookie{cookie} +} + +func GetBuffersUnchecked(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Attachments []uint32) GetBuffersCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getBuffersRequest(c, Drawable, Count, Attachments), cookie) + return GetBuffersCookie{cookie} +} + +// Request reply for GetBuffers +// size: (32 + xgb.Pad((int(Count) * 20))) +type GetBuffersReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Width uint32 + Height uint32 + Count uint32 + // padding: 12 bytes + Buffers []DRI2Buffer // size: xgb.Pad((int(Count) * 20)) +} + +// Waits and reads reply data from request GetBuffers +func (cook GetBuffersCookie) Reply() (*GetBuffersReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getBuffersReply(buf), nil +} + +// Read reply into structure from buffer for GetBuffers +func getBuffersReply(buf []byte) *GetBuffersReply { + v := new(GetBuffersReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Width = xgb.Get32(buf[b:]) + b += 4 + + v.Height = xgb.Get32(buf[b:]) + b += 4 + + v.Count = xgb.Get32(buf[b:]) + b += 4 + + b += 12 // padding + + v.Buffers = make([]DRI2Buffer, v.Count) + b += DRI2BufferReadList(buf[b:], v.Buffers) + + return v +} + +// Write request to wire for GetBuffers +func getBuffersRequest(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Attachments []uint32) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Attachments) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DRI2"] + b += 1 + + buf[b] = 5 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], Count) + b += 4 + + for i := 0; i < int(len(Attachments)); i++ { + xgb.Put32(buf[b:], Attachments[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request CopyRegion +// size: 20 +type CopyRegionCookie struct { + *xgb.Cookie +} + +func CopyRegion(c *xgb.Conn, Drawable xproto.Drawable, Region uint32, Dest uint32, Src uint32) CopyRegionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(copyRegionRequest(c, Drawable, Region, Dest, Src), cookie) + return CopyRegionCookie{cookie} +} + +func CopyRegionUnchecked(c *xgb.Conn, Drawable xproto.Drawable, Region uint32, Dest uint32, Src uint32) CopyRegionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(copyRegionRequest(c, Drawable, Region, Dest, Src), cookie) + return CopyRegionCookie{cookie} +} + +// Request reply for CopyRegion +// size: 8 +type CopyRegionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes +} + +// Waits and reads reply data from request CopyRegion +func (cook CopyRegionCookie) Reply() (*CopyRegionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return copyRegionReply(buf), nil +} + +// Read reply into structure from buffer for CopyRegion +func copyRegionReply(buf []byte) *CopyRegionReply { + v := new(CopyRegionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + return v +} + +// Write request to wire for CopyRegion +func copyRegionRequest(c *xgb.Conn, Drawable xproto.Drawable, Region uint32, Dest uint32, Src uint32) []byte { + size := 20 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DRI2"] + b += 1 + + buf[b] = 6 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], Region) + b += 4 + + xgb.Put32(buf[b:], Dest) + b += 4 + + xgb.Put32(buf[b:], Src) + b += 4 + + return buf +} + +// Request GetBuffersWithFormat +// size: xgb.Pad((12 + xgb.Pad((len(Attachments) * 8)))) +type GetBuffersWithFormatCookie struct { + *xgb.Cookie +} + +func GetBuffersWithFormat(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Attachments []AttachFormat) GetBuffersWithFormatCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getBuffersWithFormatRequest(c, Drawable, Count, Attachments), cookie) + return GetBuffersWithFormatCookie{cookie} +} + +func GetBuffersWithFormatUnchecked(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Attachments []AttachFormat) GetBuffersWithFormatCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getBuffersWithFormatRequest(c, Drawable, Count, Attachments), cookie) + return GetBuffersWithFormatCookie{cookie} +} + +// Request reply for GetBuffersWithFormat +// size: (32 + xgb.Pad((int(Count) * 20))) +type GetBuffersWithFormatReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Width uint32 + Height uint32 + Count uint32 + // padding: 12 bytes + Buffers []DRI2Buffer // size: xgb.Pad((int(Count) * 20)) +} + +// Waits and reads reply data from request GetBuffersWithFormat +func (cook GetBuffersWithFormatCookie) Reply() (*GetBuffersWithFormatReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getBuffersWithFormatReply(buf), nil +} + +// Read reply into structure from buffer for GetBuffersWithFormat +func getBuffersWithFormatReply(buf []byte) *GetBuffersWithFormatReply { + v := new(GetBuffersWithFormatReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Width = xgb.Get32(buf[b:]) + b += 4 + + v.Height = xgb.Get32(buf[b:]) + b += 4 + + v.Count = xgb.Get32(buf[b:]) + b += 4 + + b += 12 // padding + + v.Buffers = make([]DRI2Buffer, v.Count) + b += DRI2BufferReadList(buf[b:], v.Buffers) + + return v +} + +// Write request to wire for GetBuffersWithFormat +func getBuffersWithFormatRequest(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Attachments []AttachFormat) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Attachments) * 8)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DRI2"] + b += 1 + + buf[b] = 7 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], Count) + b += 4 + + b += AttachFormatListBytes(buf[b:], Attachments) + + return buf +} + +// Request SwapBuffers +// size: 32 +type SwapBuffersCookie struct { + *xgb.Cookie +} + +func SwapBuffers(c *xgb.Conn, Drawable xproto.Drawable, TargetMscHi uint32, TargetMscLo uint32, DivisorHi uint32, DivisorLo uint32, RemainderHi uint32, RemainderLo uint32) SwapBuffersCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(swapBuffersRequest(c, Drawable, TargetMscHi, TargetMscLo, DivisorHi, DivisorLo, RemainderHi, RemainderLo), cookie) + return SwapBuffersCookie{cookie} +} + +func SwapBuffersUnchecked(c *xgb.Conn, Drawable xproto.Drawable, TargetMscHi uint32, TargetMscLo uint32, DivisorHi uint32, DivisorLo uint32, RemainderHi uint32, RemainderLo uint32) SwapBuffersCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(swapBuffersRequest(c, Drawable, TargetMscHi, TargetMscLo, DivisorHi, DivisorLo, RemainderHi, RemainderLo), cookie) + return SwapBuffersCookie{cookie} +} + +// Request reply for SwapBuffers +// size: 16 +type SwapBuffersReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + SwapHi uint32 + SwapLo uint32 +} + +// Waits and reads reply data from request SwapBuffers +func (cook SwapBuffersCookie) Reply() (*SwapBuffersReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return swapBuffersReply(buf), nil +} + +// Read reply into structure from buffer for SwapBuffers +func swapBuffersReply(buf []byte) *SwapBuffersReply { + v := new(SwapBuffersReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.SwapHi = xgb.Get32(buf[b:]) + b += 4 + + v.SwapLo = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for SwapBuffers +func swapBuffersRequest(c *xgb.Conn, Drawable xproto.Drawable, TargetMscHi uint32, TargetMscLo uint32, DivisorHi uint32, DivisorLo uint32, RemainderHi uint32, RemainderLo uint32) []byte { + size := 32 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DRI2"] + b += 1 + + buf[b] = 8 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], TargetMscHi) + b += 4 + + xgb.Put32(buf[b:], TargetMscLo) + b += 4 + + xgb.Put32(buf[b:], DivisorHi) + b += 4 + + xgb.Put32(buf[b:], DivisorLo) + b += 4 + + xgb.Put32(buf[b:], RemainderHi) + b += 4 + + xgb.Put32(buf[b:], RemainderLo) + b += 4 + + return buf +} + +// Request GetMSC +// size: 8 +type GetMSCCookie struct { + *xgb.Cookie +} + +func GetMSC(c *xgb.Conn, Drawable xproto.Drawable) GetMSCCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getMSCRequest(c, Drawable), cookie) + return GetMSCCookie{cookie} +} + +func GetMSCUnchecked(c *xgb.Conn, Drawable xproto.Drawable) GetMSCCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getMSCRequest(c, Drawable), cookie) + return GetMSCCookie{cookie} +} + +// Request reply for GetMSC +// size: 32 +type GetMSCReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + UstHi uint32 + UstLo uint32 + MscHi uint32 + MscLo uint32 + SbcHi uint32 + SbcLo uint32 +} + +// Waits and reads reply data from request GetMSC +func (cook GetMSCCookie) Reply() (*GetMSCReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getMSCReply(buf), nil +} + +// Read reply into structure from buffer for GetMSC +func getMSCReply(buf []byte) *GetMSCReply { + v := new(GetMSCReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.UstHi = xgb.Get32(buf[b:]) + b += 4 + + v.UstLo = xgb.Get32(buf[b:]) + b += 4 + + v.MscHi = xgb.Get32(buf[b:]) + b += 4 + + v.MscLo = xgb.Get32(buf[b:]) + b += 4 + + v.SbcHi = xgb.Get32(buf[b:]) + b += 4 + + v.SbcLo = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for GetMSC +func getMSCRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DRI2"] + b += 1 + + buf[b] = 9 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + return buf +} + +// Request WaitMSC +// size: 32 +type WaitMSCCookie struct { + *xgb.Cookie +} + +func WaitMSC(c *xgb.Conn, Drawable xproto.Drawable, TargetMscHi uint32, TargetMscLo uint32, DivisorHi uint32, DivisorLo uint32, RemainderHi uint32, RemainderLo uint32) WaitMSCCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(waitMSCRequest(c, Drawable, TargetMscHi, TargetMscLo, DivisorHi, DivisorLo, RemainderHi, RemainderLo), cookie) + return WaitMSCCookie{cookie} +} + +func WaitMSCUnchecked(c *xgb.Conn, Drawable xproto.Drawable, TargetMscHi uint32, TargetMscLo uint32, DivisorHi uint32, DivisorLo uint32, RemainderHi uint32, RemainderLo uint32) WaitMSCCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(waitMSCRequest(c, Drawable, TargetMscHi, TargetMscLo, DivisorHi, DivisorLo, RemainderHi, RemainderLo), cookie) + return WaitMSCCookie{cookie} +} + +// Request reply for WaitMSC +// size: 32 +type WaitMSCReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + UstHi uint32 + UstLo uint32 + MscHi uint32 + MscLo uint32 + SbcHi uint32 + SbcLo uint32 +} + +// Waits and reads reply data from request WaitMSC +func (cook WaitMSCCookie) Reply() (*WaitMSCReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return waitMSCReply(buf), nil +} + +// Read reply into structure from buffer for WaitMSC +func waitMSCReply(buf []byte) *WaitMSCReply { + v := new(WaitMSCReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.UstHi = xgb.Get32(buf[b:]) + b += 4 + + v.UstLo = xgb.Get32(buf[b:]) + b += 4 + + v.MscHi = xgb.Get32(buf[b:]) + b += 4 + + v.MscLo = xgb.Get32(buf[b:]) + b += 4 + + v.SbcHi = xgb.Get32(buf[b:]) + b += 4 + + v.SbcLo = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for WaitMSC +func waitMSCRequest(c *xgb.Conn, Drawable xproto.Drawable, TargetMscHi uint32, TargetMscLo uint32, DivisorHi uint32, DivisorLo uint32, RemainderHi uint32, RemainderLo uint32) []byte { + size := 32 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DRI2"] + b += 1 + + buf[b] = 10 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], TargetMscHi) + b += 4 + + xgb.Put32(buf[b:], TargetMscLo) + b += 4 + + xgb.Put32(buf[b:], DivisorHi) + b += 4 + + xgb.Put32(buf[b:], DivisorLo) + b += 4 + + xgb.Put32(buf[b:], RemainderHi) + b += 4 + + xgb.Put32(buf[b:], RemainderLo) + b += 4 + + return buf +} + +// Request WaitSBC +// size: 16 +type WaitSBCCookie struct { + *xgb.Cookie +} + +func WaitSBC(c *xgb.Conn, Drawable xproto.Drawable, TargetSbcHi uint32, TargetSbcLo uint32) WaitSBCCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(waitSBCRequest(c, Drawable, TargetSbcHi, TargetSbcLo), cookie) + return WaitSBCCookie{cookie} +} + +func WaitSBCUnchecked(c *xgb.Conn, Drawable xproto.Drawable, TargetSbcHi uint32, TargetSbcLo uint32) WaitSBCCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(waitSBCRequest(c, Drawable, TargetSbcHi, TargetSbcLo), cookie) + return WaitSBCCookie{cookie} +} + +// Request reply for WaitSBC +// size: 32 +type WaitSBCReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + UstHi uint32 + UstLo uint32 + MscHi uint32 + MscLo uint32 + SbcHi uint32 + SbcLo uint32 +} + +// Waits and reads reply data from request WaitSBC +func (cook WaitSBCCookie) Reply() (*WaitSBCReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return waitSBCReply(buf), nil +} + +// Read reply into structure from buffer for WaitSBC +func waitSBCReply(buf []byte) *WaitSBCReply { + v := new(WaitSBCReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.UstHi = xgb.Get32(buf[b:]) + b += 4 + + v.UstLo = xgb.Get32(buf[b:]) + b += 4 + + v.MscHi = xgb.Get32(buf[b:]) + b += 4 + + v.MscLo = xgb.Get32(buf[b:]) + b += 4 + + v.SbcHi = xgb.Get32(buf[b:]) + b += 4 + + v.SbcLo = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for WaitSBC +func waitSBCRequest(c *xgb.Conn, Drawable xproto.Drawable, TargetSbcHi uint32, TargetSbcLo uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DRI2"] + b += 1 + + buf[b] = 11 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], TargetSbcHi) + b += 4 + + xgb.Put32(buf[b:], TargetSbcLo) + b += 4 + + return buf +} + +// Request SwapInterval +// size: 12 +type SwapIntervalCookie struct { + *xgb.Cookie +} + +// Write request to wire for SwapInterval +func SwapInterval(c *xgb.Conn, Drawable xproto.Drawable, Interval uint32) SwapIntervalCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(swapIntervalRequest(c, Drawable, Interval), cookie) + return SwapIntervalCookie{cookie} +} + +func SwapIntervalChecked(c *xgb.Conn, Drawable xproto.Drawable, Interval uint32) SwapIntervalCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(swapIntervalRequest(c, Drawable, Interval), cookie) + return SwapIntervalCookie{cookie} +} + +func (cook SwapIntervalCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SwapInterval +func swapIntervalRequest(c *xgb.Conn, Drawable xproto.Drawable, Interval uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DRI2"] + b += 1 + + buf[b] = 12 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], Interval) + b += 4 + + return buf +} diff --git a/nexgb/examples/create-window/main.go b/nexgb/examples/create-window/main.go index 6996f37..73a0099 100644 --- a/nexgb/examples/create-window/main.go +++ b/nexgb/examples/create-window/main.go @@ -8,6 +8,7 @@ import ( "fmt" "github.com/BurntSushi/xgb" + "github.com/BurntSushi/xgb/xproto" ) func main() { @@ -17,15 +18,23 @@ func main() { return } + // xproto.Setup retrieves the Setup information from the setup bytes + // gathered during connection. + setup := xproto.Setup(X) + + // This is the default screen with all its associated info. + screen := setup.DefaultScreen(X) + // Any time a new resource (i.e., a window, pixmap, graphics context, etc.) - // is created, we need to generate a resource identifier with NewId. - wid, _ := X.NewId() + // is created, we need to generate a resource identifier. + // If the resource is a window, then use xproto.NewWindowId. If it's for + // a pixmap, then use xproto.NewPixmapId. And so on... + wid, _ := xproto.NewWindowId(X) // CreateWindow takes a boatload of parameters. - X.CreateWindow(X.DefaultScreen().RootDepth, wid, X.DefaultScreen().Root, + xproto.CreateWindow(X, screen.RootDepth, wid, screen.Root, 0, 0, 500, 500, 0, - xgb.WindowClassInputOutput, X.DefaultScreen().RootVisual, - 0, []uint32{}) + xproto.WindowClassInputOutput, screen.RootVisual, 0, []uint32{}) // This call to ChangeWindowAttributes could be factored out and // included with the above CreateWindow call, but it is left here for @@ -34,13 +43,13 @@ func main() { // etc.) and when a key press or a key release has been made when the // window has focus. // We also set the 'BackPixel' to white so that the window isn't butt ugly. - X.ChangeWindowAttributes(wid, - xgb.CwBackPixel|xgb.CwEventMask, + xproto.ChangeWindowAttributes(X, wid, + xproto.CwBackPixel|xproto.CwEventMask, []uint32{ // values must be in the order defined by the protocol 0xffffffff, - xgb.EventMaskStructureNotify | - xgb.EventMaskKeyPress | - xgb.EventMaskKeyRelease}) + xproto.EventMaskStructureNotify | + xproto.EventMaskKeyPress | + xproto.EventMaskKeyRelease}) // MapWindow makes the window we've created appear on the screen. // We demonstrated the use of a 'checked' request here. @@ -58,7 +67,7 @@ func main() { // // Note that requests without replies are by default unchecked while // requests *with* replies are checked by default. - err = X.MapWindowChecked(wid).Check() + err = xproto.MapWindowChecked(X, wid).Check() if err != nil { fmt.Printf("Checked Error for mapping window %d: %s\n", wid, err) } else { @@ -67,7 +76,7 @@ func main() { // This is an example of an invalid MapWindow request and what an error // looks like. - err = X.MapWindowChecked(0).Check() + err = xproto.MapWindowChecked(X, 0).Check() if err != nil { fmt.Printf("Checked Error for mapping window 0x1: %s\n", err) } else { // neva diff --git a/nexgb/examples/get-active-window/main.go b/nexgb/examples/get-active-window/main.go index e90563c..48e020c 100644 --- a/nexgb/examples/get-active-window/main.go +++ b/nexgb/examples/get-active-window/main.go @@ -7,6 +7,7 @@ import ( "log" "github.com/BurntSushi/xgb" + "github.com/BurntSushi/xgb/xproto" ) func main() { @@ -16,18 +17,21 @@ func main() { } // Get the window id of the root window. - root := X.DefaultScreen().Root + setup := xproto.Setup(X) + root := setup.DefaultScreen(X).Root // Get the atom id (i.e., intern an atom) of "_NET_ACTIVE_WINDOW". aname := "_NET_ACTIVE_WINDOW" - activeAtom, err := X.InternAtom(true, uint16(len(aname)), aname).Reply() + activeAtom, err := xproto.InternAtom(X, true, uint16(len(aname)), + aname).Reply() if err != nil { log.Fatal(err) } // Get the atom id (i.e., intern an atom) of "_NET_WM_NAME". aname = "_NET_WM_NAME" - nameAtom, err := X.InternAtom(true, uint16(len(aname)), aname).Reply() + nameAtom, err := xproto.InternAtom(X, true, uint16(len(aname)), + aname).Reply() if err != nil { log.Fatal(err) } @@ -37,19 +41,19 @@ func main() { // XGB helper function, 'Get32', to pull an unsigned 32-bit integer out // of the byte slice. We then convert it to an X resource id so it can // be used to get the name of the window in the next GetProperty request. - reply, err := X.GetProperty(false, root, activeAtom.Atom, - xgb.GetPropertyTypeAny, 0, (1<<32)-1).Reply() + reply, err := xproto.GetProperty(X, false, root, activeAtom.Atom, + xproto.GetPropertyTypeAny, 0, (1<<32)-1).Reply() if err != nil { log.Fatal(err) } - windowId := xgb.Id(xgb.Get32(reply.Value)) + windowId := xproto.Window(xgb.Get32(reply.Value)) fmt.Printf("Active window id: %X\n", windowId) // Now get the value of _NET_WM_NAME for the active window. // Note that this time, we simply convert the resulting byte slice, // reply.Value, to a string. - reply, err = X.GetProperty(false, windowId, nameAtom.Atom, - xgb.GetPropertyTypeAny, 0, (1<<32)-1).Reply() + reply, err = xproto.GetProperty(X, false, windowId, nameAtom.Atom, + xproto.GetPropertyTypeAny, 0, (1<<32)-1).Reply() if err != nil { log.Fatal(err) } diff --git a/nexgb/examples/randr/main.go b/nexgb/examples/randr/main.go index 5c56609..ad575ee 100644 --- a/nexgb/examples/randr/main.go +++ b/nexgb/examples/randr/main.go @@ -15,27 +15,32 @@ import ( "log" "github.com/BurntSushi/xgb" + "github.com/BurntSushi/xgb/randr" + "github.com/BurntSushi/xgb/xproto" ) func main() { X, _ := xgb.NewConn() // Every extension must be initialized before it can be used. - err := X.RandrInit() + err := randr.Init(X) if err != nil { log.Fatal(err) } + // Get the root window on the default screen. + root := xproto.Setup(X).DefaultScreen(X).Root + // Gets the current screen resources. Screen resources contains a list // of names, crtcs, outputs and modes, among other things. - resources, err := X.RandrGetScreenResources(X.DefaultScreen().Root).Reply() + resources, err := randr.GetScreenResources(X, root).Reply() if err != nil { log.Fatal(err) } // Iterate through all of the outputs and show some of their info. for _, output := range resources.Outputs { - info, err := X.RandrGetOutputInfo(output, 0).Reply() + info, err := randr.GetOutputInfo(X, output, 0).Reply() if err != nil { log.Fatal(err) } @@ -52,7 +57,7 @@ func main() { // Iterate through all of the crtcs and show some of their info. for _, crtc := range resources.Crtcs { - info, err := X.RandrGetCrtcInfo(crtc, 0).Reply() + info, err := randr.GetCrtcInfo(X, crtc, 0).Reply() if err != nil { log.Fatal(err) } @@ -61,11 +66,11 @@ func main() { } // Tell RandR to send us events. (I think these are all of them, as of 1.3.) - err = X.RandrSelectInputChecked(X.DefaultScreen().Root, - xgb.RandrNotifyMaskScreenChange| - xgb.RandrNotifyMaskCrtcChange| - xgb.RandrNotifyMaskOutputChange| - xgb.RandrNotifyMaskOutputProperty).Check() + err = randr.SelectInputChecked(X, root, + randr.NotifyMaskScreenChange| + randr.NotifyMaskCrtcChange| + randr.NotifyMaskOutputChange| + randr.NotifyMaskOutputProperty).Check() if err != nil { log.Fatal(err) } diff --git a/nexgb/examples/xinerama/main.go b/nexgb/examples/xinerama/main.go index ec7f46a..896bb63 100644 --- a/nexgb/examples/xinerama/main.go +++ b/nexgb/examples/xinerama/main.go @@ -6,6 +6,7 @@ import ( "log" "github.com/BurntSushi/xgb" + "github.com/BurntSushi/xgb/xinerama" ) func main() { @@ -17,13 +18,13 @@ func main() { // Initialize the Xinerama extension. // The appropriate 'Init' function must be run for *every* // extension before any of its requests can be used. - err = X.XineramaInit() + err = xinerama.Init(X) if err != nil { log.Fatal(err) } // Issue a request to get the screen information. - reply, err := X.XineramaQueryScreens().Reply() + reply, err := xinerama.QueryScreens(X).Reply() if err != nil { log.Fatal(err) } diff --git a/nexgb/ge/ge.go b/nexgb/ge/ge.go new file mode 100644 index 0000000..7753e28 --- /dev/null +++ b/nexgb/ge/ge.go @@ -0,0 +1,153 @@ +package ge + +/* + This file was generated by ge.xml on May 10 2012 4:20:27pm EDT. + This file is automatically generated. Edit at your peril! +*/ + +import ( + "github.com/BurntSushi/xgb" + + "github.com/BurntSushi/xgb/xproto" +) + +// Init must be called before using the Generic Event Extension extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 23, "Generic Event Extension").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named Generic Event Extension could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["Generic Event Extension"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["Generic Event Extension"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["Generic Event Extension"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["Generic Event Extension"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["Generic Event Extension"] = make(map[int]xgb.NewErrorFun) +} + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Bool' + +// Skipping definition for base type 'Float' + +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + +// Skipping definition for base type 'Int8' + +// Request QueryVersion +// size: 8 +type QueryVersionCookie struct { + *xgb.Cookie +} + +func QueryVersion(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) QueryVersionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return QueryVersionCookie{cookie} +} + +func QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) QueryVersionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return QueryVersionCookie{cookie} +} + +// Request reply for QueryVersion +// size: 32 +type QueryVersionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + MajorVersion uint16 + MinorVersion uint16 + // padding: 20 bytes +} + +// Waits and reads reply data from request QueryVersion +func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryVersionReply(buf), nil +} + +// Read reply into structure from buffer for QueryVersion +func queryVersionReply(buf []byte) *QueryVersionReply { + v := new(QueryVersionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.MajorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.MinorVersion = xgb.Get16(buf[b:]) + b += 2 + + b += 20 // padding + + return v +} + +// Write request to wire for QueryVersion +func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GENERIC EVENT EXTENSION"] + b += 1 + + buf[b] = 0 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], ClientMajorVersion) + b += 2 + + xgb.Put16(buf[b:], ClientMinorVersion) + b += 2 + + return buf +} diff --git a/nexgb/glx/glx.go b/nexgb/glx/glx.go new file mode 100644 index 0000000..0aa2e55 --- /dev/null +++ b/nexgb/glx/glx.go @@ -0,0 +1,9168 @@ +package glx + +/* + This file was generated by glx.xml on May 10 2012 4:20:27pm EDT. + This file is automatically generated. Edit at your peril! +*/ + +import ( + "github.com/BurntSushi/xgb" + + "github.com/BurntSushi/xgb/xproto" +) + +// Init must be called before using the GLX extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 3, "GLX").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named GLX could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["GLX"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["GLX"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["GLX"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["GLX"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["GLX"] = make(map[int]xgb.NewErrorFun) +} + +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Bool' + +// Skipping definition for base type 'Float' + +const ( + PbcetDamaged = 32791 + PbcetSaved = 32792 +) + +const ( + PbcdtWindow = 32793 + PbcdtPbuffer = 32794 +) + +const ( + GcGlCurrentBit = 1 + GcGlPointBit = 2 + GcGlLineBit = 4 + GcGlPolygonBit = 8 + GcGlPolygonStippleBit = 16 + GcGlPixelModeBit = 32 + GcGlLightingBit = 64 + GcGlFogBit = 128 + GcGlDepthBufferBit = 256 + GcGlAccumBufferBit = 512 + GcGlStencilBufferBit = 1024 + GcGlViewportBit = 2048 + GcGlTransformBit = 4096 + GcGlEnableBit = 8192 + GcGlColorBufferBit = 16384 + GcGlHintBit = 32768 + GcGlEvalBit = 65536 + GcGlListBit = 131072 + GcGlTextureBit = 262144 + GcGlScissorBit = 524288 + GcGlAllAttribBits = 16777215 +) + +const ( + RmGlRender = 7168 + RmGlFeedback = 7169 + RmGlSelect = 7170 +) + +type Pixmap uint32 + +func NewPixmapId(c *xgb.Conn) (Pixmap, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Pixmap(id), nil +} + +type Context uint32 + +func NewContextId(c *xgb.Conn) (Context, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Context(id), nil +} + +type Pbuffer uint32 + +func NewPbufferId(c *xgb.Conn) (Pbuffer, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Pbuffer(id), nil +} + +type Window uint32 + +func NewWindowId(c *xgb.Conn) (Window, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Window(id), nil +} + +type Fbconfig uint32 + +func NewFbconfigId(c *xgb.Conn) (Fbconfig, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Fbconfig(id), nil +} + +type Drawable uint32 + +func NewDrawableId(c *xgb.Conn) (Drawable, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Drawable(id), nil +} + +type Float32 float64 + +type Float64 float64 + +type Bool32 uint32 + +type ContextTag uint32 + +// Event definition PbufferClobber (0) +// Size: 32 + +const PbufferClobber = 0 + +type PbufferClobberEvent struct { + Sequence uint16 + // padding: 1 bytes + EventType uint16 + DrawType uint16 + Drawable Drawable + BMask uint32 + AuxBuffer uint16 + X uint16 + Y uint16 + Width uint16 + Height uint16 + Count uint16 + // padding: 4 bytes +} + +// Event read PbufferClobber +func PbufferClobberEventNew(buf []byte) xgb.Event { + v := PbufferClobberEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.EventType = xgb.Get16(buf[b:]) + b += 2 + + v.DrawType = xgb.Get16(buf[b:]) + b += 2 + + v.Drawable = Drawable(xgb.Get32(buf[b:])) + b += 4 + + v.BMask = xgb.Get32(buf[b:]) + b += 4 + + v.AuxBuffer = xgb.Get16(buf[b:]) + b += 2 + + v.X = xgb.Get16(buf[b:]) + b += 2 + + v.Y = xgb.Get16(buf[b:]) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.Count = xgb.Get16(buf[b:]) + b += 2 + + b += 4 // padding + + return v +} + +// Event write PbufferClobber +func (v PbufferClobberEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 0 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put16(buf[b:], v.EventType) + b += 2 + + xgb.Put16(buf[b:], v.DrawType) + b += 2 + + xgb.Put32(buf[b:], uint32(v.Drawable)) + b += 4 + + xgb.Put32(buf[b:], v.BMask) + b += 4 + + xgb.Put16(buf[b:], v.AuxBuffer) + b += 2 + + xgb.Put16(buf[b:], v.X) + b += 2 + + xgb.Put16(buf[b:], v.Y) + b += 2 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + xgb.Put16(buf[b:], v.Count) + b += 2 + + b += 4 // padding + + return buf +} + +func (v PbufferClobberEvent) ImplementsEvent() {} + +func (v PbufferClobberEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v PbufferClobberEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("EventType: %d", v.EventType)) + fieldVals = append(fieldVals, xgb.Sprintf("DrawType: %d", v.DrawType)) + fieldVals = append(fieldVals, xgb.Sprintf("Drawable: %d", v.Drawable)) + fieldVals = append(fieldVals, xgb.Sprintf("BMask: %d", v.BMask)) + fieldVals = append(fieldVals, xgb.Sprintf("AuxBuffer: %d", v.AuxBuffer)) + fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) + fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) + fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) + fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) + fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) + return "PbufferClobber {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["GLX"][0] = PbufferClobberEventNew +} + +// Error definition Generic (-1) +// Size: 32 + +const BadGeneric = -1 + +type GenericError struct { + Sequence uint16 + NiceName string + BadValue uint32 + MinorOpcode uint16 + MajorOpcode byte + // padding: 21 bytes +} + +// Error read Generic +func GenericErrorNew(buf []byte) xgb.Error { + v := GenericError{} + v.NiceName = "Generic" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.BadValue = xgb.Get32(buf[b:]) + b += 4 + + v.MinorOpcode = xgb.Get16(buf[b:]) + b += 2 + + v.MajorOpcode = buf[b] + b += 1 + + b += 21 // padding + + return v +} + +func (err GenericError) ImplementsError() {} + +func (err GenericError) SequenceId() uint16 { + return err.Sequence +} + +func (err GenericError) BadId() uint32 { + return 0 +} + +func (err GenericError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadGeneric {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][-1] = GenericErrorNew +} + +// ErrorCopy definition BadContext (0) + +const BadBadContext = 0 + +type BadContextError GenericError + +func BadContextErrorNew(buf []byte) xgb.Error { + v := BadContextError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "BadContext" + return v +} + +func (err BadContextError) ImplementsError() {} + +func (err BadContextError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadContextError) BadId() uint32 { + return 0 +} + +func (err BadContextError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadBadContext {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][0] = BadContextErrorNew +} + +// ErrorCopy definition BadContextState (1) + +const BadBadContextState = 1 + +type BadContextStateError GenericError + +func BadContextStateErrorNew(buf []byte) xgb.Error { + v := BadContextStateError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "BadContextState" + return v +} + +func (err BadContextStateError) ImplementsError() {} + +func (err BadContextStateError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadContextStateError) BadId() uint32 { + return 0 +} + +func (err BadContextStateError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadBadContextState {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][1] = BadContextStateErrorNew +} + +// ErrorCopy definition BadDrawable (2) + +const BadBadDrawable = 2 + +type BadDrawableError GenericError + +func BadDrawableErrorNew(buf []byte) xgb.Error { + v := BadDrawableError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "BadDrawable" + return v +} + +func (err BadDrawableError) ImplementsError() {} + +func (err BadDrawableError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadDrawableError) BadId() uint32 { + return 0 +} + +func (err BadDrawableError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadBadDrawable {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][2] = BadDrawableErrorNew +} + +// ErrorCopy definition BadPixmap (3) + +const BadBadPixmap = 3 + +type BadPixmapError GenericError + +func BadPixmapErrorNew(buf []byte) xgb.Error { + v := BadPixmapError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "BadPixmap" + return v +} + +func (err BadPixmapError) ImplementsError() {} + +func (err BadPixmapError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadPixmapError) BadId() uint32 { + return 0 +} + +func (err BadPixmapError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadBadPixmap {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][3] = BadPixmapErrorNew +} + +// ErrorCopy definition BadContextTag (4) + +const BadBadContextTag = 4 + +type BadContextTagError GenericError + +func BadContextTagErrorNew(buf []byte) xgb.Error { + v := BadContextTagError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "BadContextTag" + return v +} + +func (err BadContextTagError) ImplementsError() {} + +func (err BadContextTagError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadContextTagError) BadId() uint32 { + return 0 +} + +func (err BadContextTagError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadBadContextTag {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][4] = BadContextTagErrorNew +} + +// ErrorCopy definition BadCurrentWindow (5) + +const BadBadCurrentWindow = 5 + +type BadCurrentWindowError GenericError + +func BadCurrentWindowErrorNew(buf []byte) xgb.Error { + v := BadCurrentWindowError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "BadCurrentWindow" + return v +} + +func (err BadCurrentWindowError) ImplementsError() {} + +func (err BadCurrentWindowError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadCurrentWindowError) BadId() uint32 { + return 0 +} + +func (err BadCurrentWindowError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadBadCurrentWindow {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][5] = BadCurrentWindowErrorNew +} + +// ErrorCopy definition BadRenderRequest (6) + +const BadBadRenderRequest = 6 + +type BadRenderRequestError GenericError + +func BadRenderRequestErrorNew(buf []byte) xgb.Error { + v := BadRenderRequestError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "BadRenderRequest" + return v +} + +func (err BadRenderRequestError) ImplementsError() {} + +func (err BadRenderRequestError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadRenderRequestError) BadId() uint32 { + return 0 +} + +func (err BadRenderRequestError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadBadRenderRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][6] = BadRenderRequestErrorNew +} + +// ErrorCopy definition BadLargeRequest (7) + +const BadBadLargeRequest = 7 + +type BadLargeRequestError GenericError + +func BadLargeRequestErrorNew(buf []byte) xgb.Error { + v := BadLargeRequestError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "BadLargeRequest" + return v +} + +func (err BadLargeRequestError) ImplementsError() {} + +func (err BadLargeRequestError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadLargeRequestError) BadId() uint32 { + return 0 +} + +func (err BadLargeRequestError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadBadLargeRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][7] = BadLargeRequestErrorNew +} + +// ErrorCopy definition UnsupportedPrivateRequest (8) + +const BadUnsupportedPrivateRequest = 8 + +type UnsupportedPrivateRequestError GenericError + +func UnsupportedPrivateRequestErrorNew(buf []byte) xgb.Error { + v := UnsupportedPrivateRequestError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "UnsupportedPrivateRequest" + return v +} + +func (err UnsupportedPrivateRequestError) ImplementsError() {} + +func (err UnsupportedPrivateRequestError) SequenceId() uint16 { + return err.Sequence +} + +func (err UnsupportedPrivateRequestError) BadId() uint32 { + return 0 +} + +func (err UnsupportedPrivateRequestError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadUnsupportedPrivateRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][8] = UnsupportedPrivateRequestErrorNew +} + +// ErrorCopy definition BadFBConfig (9) + +const BadBadFBConfig = 9 + +type BadFBConfigError GenericError + +func BadFBConfigErrorNew(buf []byte) xgb.Error { + v := BadFBConfigError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "BadFBConfig" + return v +} + +func (err BadFBConfigError) ImplementsError() {} + +func (err BadFBConfigError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadFBConfigError) BadId() uint32 { + return 0 +} + +func (err BadFBConfigError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadBadFBConfig {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][9] = BadFBConfigErrorNew +} + +// ErrorCopy definition BadPbuffer (10) + +const BadBadPbuffer = 10 + +type BadPbufferError GenericError + +func BadPbufferErrorNew(buf []byte) xgb.Error { + v := BadPbufferError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "BadPbuffer" + return v +} + +func (err BadPbufferError) ImplementsError() {} + +func (err BadPbufferError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadPbufferError) BadId() uint32 { + return 0 +} + +func (err BadPbufferError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadBadPbuffer {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][10] = BadPbufferErrorNew +} + +// ErrorCopy definition BadCurrentDrawable (11) + +const BadBadCurrentDrawable = 11 + +type BadCurrentDrawableError GenericError + +func BadCurrentDrawableErrorNew(buf []byte) xgb.Error { + v := BadCurrentDrawableError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "BadCurrentDrawable" + return v +} + +func (err BadCurrentDrawableError) ImplementsError() {} + +func (err BadCurrentDrawableError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadCurrentDrawableError) BadId() uint32 { + return 0 +} + +func (err BadCurrentDrawableError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadBadCurrentDrawable {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][11] = BadCurrentDrawableErrorNew +} + +// ErrorCopy definition BadWindow (12) + +const BadBadWindow = 12 + +type BadWindowError GenericError + +func BadWindowErrorNew(buf []byte) xgb.Error { + v := BadWindowError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "BadWindow" + return v +} + +func (err BadWindowError) ImplementsError() {} + +func (err BadWindowError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadWindowError) BadId() uint32 { + return 0 +} + +func (err BadWindowError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadBadWindow {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][12] = BadWindowErrorNew +} + +// ErrorCopy definition GLXBadProfileARB (13) + +const BadGLXBadProfileARB = 13 + +type GLXBadProfileARBError GenericError + +func GLXBadProfileARBErrorNew(buf []byte) xgb.Error { + v := GLXBadProfileARBError(GenericErrorNew(buf).(GenericError)) + v.NiceName = "GLXBadProfileARB" + return v +} + +func (err GLXBadProfileARBError) ImplementsError() {} + +func (err GLXBadProfileARBError) SequenceId() uint16 { + return err.Sequence +} + +func (err GLXBadProfileARBError) BadId() uint32 { + return 0 +} + +func (err GLXBadProfileARBError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadGLXBadProfileARB {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["GLX"][13] = GLXBadProfileARBErrorNew +} + +// Request Render +// size: xgb.Pad((8 + xgb.Pad((len(Data) * 1)))) +type RenderCookie struct { + *xgb.Cookie +} + +// Write request to wire for Render +func Render(c *xgb.Conn, ContextTag ContextTag, Data []byte) RenderCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(renderRequest(c, ContextTag, Data), cookie) + return RenderCookie{cookie} +} + +func RenderChecked(c *xgb.Conn, ContextTag ContextTag, Data []byte) RenderCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(renderRequest(c, ContextTag, Data), cookie) + return RenderCookie{cookie} +} + +func (cook RenderCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for Render +func renderRequest(c *xgb.Conn, ContextTag ContextTag, Data []byte) []byte { + size := xgb.Pad((8 + xgb.Pad((len(Data) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 1 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + copy(buf[b:], Data[:len(Data)]) + b += xgb.Pad(int(len(Data))) + + return buf +} + +// Request RenderLarge +// size: xgb.Pad((16 + xgb.Pad((int(DataLen) * 1)))) +type RenderLargeCookie struct { + *xgb.Cookie +} + +// Write request to wire for RenderLarge +func RenderLarge(c *xgb.Conn, ContextTag ContextTag, RequestNum uint16, RequestTotal uint16, DataLen uint32, Data []byte) RenderLargeCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(renderLargeRequest(c, ContextTag, RequestNum, RequestTotal, DataLen, Data), cookie) + return RenderLargeCookie{cookie} +} + +func RenderLargeChecked(c *xgb.Conn, ContextTag ContextTag, RequestNum uint16, RequestTotal uint16, DataLen uint32, Data []byte) RenderLargeCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(renderLargeRequest(c, ContextTag, RequestNum, RequestTotal, DataLen, Data), cookie) + return RenderLargeCookie{cookie} +} + +func (cook RenderLargeCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for RenderLarge +func renderLargeRequest(c *xgb.Conn, ContextTag ContextTag, RequestNum uint16, RequestTotal uint16, DataLen uint32, Data []byte) []byte { + size := xgb.Pad((16 + xgb.Pad((int(DataLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 2 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put16(buf[b:], RequestNum) + b += 2 + + xgb.Put16(buf[b:], RequestTotal) + b += 2 + + xgb.Put32(buf[b:], DataLen) + b += 4 + + copy(buf[b:], Data[:DataLen]) + b += xgb.Pad(int(DataLen)) + + return buf +} + +// Request CreateContext +// size: 24 +type CreateContextCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateContext +func CreateContext(c *xgb.Conn, Context Context, Visual xproto.Visualid, Screen uint32, ShareList Context, IsDirect bool) CreateContextCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createContextRequest(c, Context, Visual, Screen, ShareList, IsDirect), cookie) + return CreateContextCookie{cookie} +} + +func CreateContextChecked(c *xgb.Conn, Context Context, Visual xproto.Visualid, Screen uint32, ShareList Context, IsDirect bool) CreateContextCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createContextRequest(c, Context, Visual, Screen, ShareList, IsDirect), cookie) + return CreateContextCookie{cookie} +} + +func (cook CreateContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateContext +func createContextRequest(c *xgb.Conn, Context Context, Visual xproto.Visualid, Screen uint32, ShareList Context, IsDirect bool) []byte { + size := 24 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 3 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + xgb.Put32(buf[b:], uint32(Visual)) + b += 4 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], uint32(ShareList)) + b += 4 + + if IsDirect { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding + + return buf +} + +// Request DestroyContext +// size: 8 +type DestroyContextCookie struct { + *xgb.Cookie +} + +// Write request to wire for DestroyContext +func DestroyContext(c *xgb.Conn, Context Context) DestroyContextCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroyContextRequest(c, Context), cookie) + return DestroyContextCookie{cookie} +} + +func DestroyContextChecked(c *xgb.Conn, Context Context) DestroyContextCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(destroyContextRequest(c, Context), cookie) + return DestroyContextCookie{cookie} +} + +func (cook DestroyContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DestroyContext +func destroyContextRequest(c *xgb.Conn, Context Context) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 4 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + return buf +} + +// Request MakeCurrent +// size: 16 +type MakeCurrentCookie struct { + *xgb.Cookie +} + +func MakeCurrent(c *xgb.Conn, Drawable Drawable, Context Context, OldContextTag ContextTag) MakeCurrentCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(makeCurrentRequest(c, Drawable, Context, OldContextTag), cookie) + return MakeCurrentCookie{cookie} +} + +func MakeCurrentUnchecked(c *xgb.Conn, Drawable Drawable, Context Context, OldContextTag ContextTag) MakeCurrentCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(makeCurrentRequest(c, Drawable, Context, OldContextTag), cookie) + return MakeCurrentCookie{cookie} +} + +// Request reply for MakeCurrent +// size: 32 +type MakeCurrentReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ContextTag ContextTag + // padding: 20 bytes +} + +// Waits and reads reply data from request MakeCurrent +func (cook MakeCurrentCookie) Reply() (*MakeCurrentReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return makeCurrentReply(buf), nil +} + +// Read reply into structure from buffer for MakeCurrent +func makeCurrentReply(buf []byte) *MakeCurrentReply { + v := new(MakeCurrentReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ContextTag = ContextTag(xgb.Get32(buf[b:])) + b += 4 + + b += 20 // padding + + return v +} + +// Write request to wire for MakeCurrent +func makeCurrentRequest(c *xgb.Conn, Drawable Drawable, Context Context, OldContextTag ContextTag) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 5 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + xgb.Put32(buf[b:], uint32(OldContextTag)) + b += 4 + + return buf +} + +// Request IsDirect +// size: 8 +type IsDirectCookie struct { + *xgb.Cookie +} + +func IsDirect(c *xgb.Conn, Context Context) IsDirectCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(isDirectRequest(c, Context), cookie) + return IsDirectCookie{cookie} +} + +func IsDirectUnchecked(c *xgb.Conn, Context Context) IsDirectCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(isDirectRequest(c, Context), cookie) + return IsDirectCookie{cookie} +} + +// Request reply for IsDirect +// size: 32 +type IsDirectReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + IsDirect bool + // padding: 23 bytes +} + +// Waits and reads reply data from request IsDirect +func (cook IsDirectCookie) Reply() (*IsDirectReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return isDirectReply(buf), nil +} + +// Read reply into structure from buffer for IsDirect +func isDirectReply(buf []byte) *IsDirectReply { + v := new(IsDirectReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + if buf[b] == 1 { + v.IsDirect = true + } else { + v.IsDirect = false + } + b += 1 + + b += 23 // padding + + return v +} + +// Write request to wire for IsDirect +func isDirectRequest(c *xgb.Conn, Context Context) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 6 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + return buf +} + +// Request QueryVersion +// size: 12 +type QueryVersionCookie struct { + *xgb.Cookie +} + +func QueryVersion(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) + return QueryVersionCookie{cookie} +} + +func QueryVersionUnchecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) + return QueryVersionCookie{cookie} +} + +// Request reply for QueryVersion +// size: 32 +type QueryVersionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + MajorVersion uint32 + MinorVersion uint32 + // padding: 16 bytes +} + +// Waits and reads reply data from request QueryVersion +func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryVersionReply(buf), nil +} + +// Read reply into structure from buffer for QueryVersion +func queryVersionReply(buf []byte) *QueryVersionReply { + v := new(QueryVersionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.MajorVersion = xgb.Get32(buf[b:]) + b += 4 + + v.MinorVersion = xgb.Get32(buf[b:]) + b += 4 + + b += 16 // padding + + return v +} + +// Write request to wire for QueryVersion +func queryVersionRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 7 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], MajorVersion) + b += 4 + + xgb.Put32(buf[b:], MinorVersion) + b += 4 + + return buf +} + +// Request WaitGL +// size: 8 +type WaitGLCookie struct { + *xgb.Cookie +} + +// Write request to wire for WaitGL +func WaitGL(c *xgb.Conn, ContextTag ContextTag) WaitGLCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(waitGLRequest(c, ContextTag), cookie) + return WaitGLCookie{cookie} +} + +func WaitGLChecked(c *xgb.Conn, ContextTag ContextTag) WaitGLCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(waitGLRequest(c, ContextTag), cookie) + return WaitGLCookie{cookie} +} + +func (cook WaitGLCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for WaitGL +func waitGLRequest(c *xgb.Conn, ContextTag ContextTag) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 8 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + return buf +} + +// Request WaitX +// size: 8 +type WaitXCookie struct { + *xgb.Cookie +} + +// Write request to wire for WaitX +func WaitX(c *xgb.Conn, ContextTag ContextTag) WaitXCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(waitXRequest(c, ContextTag), cookie) + return WaitXCookie{cookie} +} + +func WaitXChecked(c *xgb.Conn, ContextTag ContextTag) WaitXCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(waitXRequest(c, ContextTag), cookie) + return WaitXCookie{cookie} +} + +func (cook WaitXCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for WaitX +func waitXRequest(c *xgb.Conn, ContextTag ContextTag) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 9 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + return buf +} + +// Request CopyContext +// size: 20 +type CopyContextCookie struct { + *xgb.Cookie +} + +// Write request to wire for CopyContext +func CopyContext(c *xgb.Conn, Src Context, Dest Context, Mask uint32, SrcContextTag ContextTag) CopyContextCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(copyContextRequest(c, Src, Dest, Mask, SrcContextTag), cookie) + return CopyContextCookie{cookie} +} + +func CopyContextChecked(c *xgb.Conn, Src Context, Dest Context, Mask uint32, SrcContextTag ContextTag) CopyContextCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(copyContextRequest(c, Src, Dest, Mask, SrcContextTag), cookie) + return CopyContextCookie{cookie} +} + +func (cook CopyContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CopyContext +func copyContextRequest(c *xgb.Conn, Src Context, Dest Context, Mask uint32, SrcContextTag ContextTag) []byte { + size := 20 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 10 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Src)) + b += 4 + + xgb.Put32(buf[b:], uint32(Dest)) + b += 4 + + xgb.Put32(buf[b:], Mask) + b += 4 + + xgb.Put32(buf[b:], uint32(SrcContextTag)) + b += 4 + + return buf +} + +// Request SwapBuffers +// size: 12 +type SwapBuffersCookie struct { + *xgb.Cookie +} + +// Write request to wire for SwapBuffers +func SwapBuffers(c *xgb.Conn, ContextTag ContextTag, Drawable Drawable) SwapBuffersCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(swapBuffersRequest(c, ContextTag, Drawable), cookie) + return SwapBuffersCookie{cookie} +} + +func SwapBuffersChecked(c *xgb.Conn, ContextTag ContextTag, Drawable Drawable) SwapBuffersCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(swapBuffersRequest(c, ContextTag, Drawable), cookie) + return SwapBuffersCookie{cookie} +} + +func (cook SwapBuffersCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SwapBuffers +func swapBuffersRequest(c *xgb.Conn, ContextTag ContextTag, Drawable Drawable) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 11 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + return buf +} + +// Request UseXFont +// size: 24 +type UseXFontCookie struct { + *xgb.Cookie +} + +// Write request to wire for UseXFont +func UseXFont(c *xgb.Conn, ContextTag ContextTag, Font xproto.Font, First uint32, Count uint32, ListBase uint32) UseXFontCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(useXFontRequest(c, ContextTag, Font, First, Count, ListBase), cookie) + return UseXFontCookie{cookie} +} + +func UseXFontChecked(c *xgb.Conn, ContextTag ContextTag, Font xproto.Font, First uint32, Count uint32, ListBase uint32) UseXFontCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(useXFontRequest(c, ContextTag, Font, First, Count, ListBase), cookie) + return UseXFontCookie{cookie} +} + +func (cook UseXFontCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for UseXFont +func useXFontRequest(c *xgb.Conn, ContextTag ContextTag, Font xproto.Font, First uint32, Count uint32, ListBase uint32) []byte { + size := 24 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 12 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], uint32(Font)) + b += 4 + + xgb.Put32(buf[b:], First) + b += 4 + + xgb.Put32(buf[b:], Count) + b += 4 + + xgb.Put32(buf[b:], ListBase) + b += 4 + + return buf +} + +// Request CreateGLXPixmap +// size: 20 +type CreateGLXPixmapCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateGLXPixmap +func CreateGLXPixmap(c *xgb.Conn, Screen uint32, Visual xproto.Visualid, Pixmap xproto.Pixmap, GlxPixmap Pixmap) CreateGLXPixmapCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createGLXPixmapRequest(c, Screen, Visual, Pixmap, GlxPixmap), cookie) + return CreateGLXPixmapCookie{cookie} +} + +func CreateGLXPixmapChecked(c *xgb.Conn, Screen uint32, Visual xproto.Visualid, Pixmap xproto.Pixmap, GlxPixmap Pixmap) CreateGLXPixmapCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createGLXPixmapRequest(c, Screen, Visual, Pixmap, GlxPixmap), cookie) + return CreateGLXPixmapCookie{cookie} +} + +func (cook CreateGLXPixmapCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateGLXPixmap +func createGLXPixmapRequest(c *xgb.Conn, Screen uint32, Visual xproto.Visualid, Pixmap xproto.Pixmap, GlxPixmap Pixmap) []byte { + size := 20 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 13 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], uint32(Visual)) + b += 4 + + xgb.Put32(buf[b:], uint32(Pixmap)) + b += 4 + + xgb.Put32(buf[b:], uint32(GlxPixmap)) + b += 4 + + return buf +} + +// Request GetVisualConfigs +// size: 8 +type GetVisualConfigsCookie struct { + *xgb.Cookie +} + +func GetVisualConfigs(c *xgb.Conn, Screen uint32) GetVisualConfigsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getVisualConfigsRequest(c, Screen), cookie) + return GetVisualConfigsCookie{cookie} +} + +func GetVisualConfigsUnchecked(c *xgb.Conn, Screen uint32) GetVisualConfigsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getVisualConfigsRequest(c, Screen), cookie) + return GetVisualConfigsCookie{cookie} +} + +// Request reply for GetVisualConfigs +// size: (32 + xgb.Pad((int(Length) * 4))) +type GetVisualConfigsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumVisuals uint32 + NumProperties uint32 + // padding: 16 bytes + PropertyList []uint32 // size: xgb.Pad((int(Length) * 4)) +} + +// Waits and reads reply data from request GetVisualConfigs +func (cook GetVisualConfigsCookie) Reply() (*GetVisualConfigsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getVisualConfigsReply(buf), nil +} + +// Read reply into structure from buffer for GetVisualConfigs +func getVisualConfigsReply(buf []byte) *GetVisualConfigsReply { + v := new(GetVisualConfigsReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NumVisuals = xgb.Get32(buf[b:]) + b += 4 + + v.NumProperties = xgb.Get32(buf[b:]) + b += 4 + + b += 16 // padding + + v.PropertyList = make([]uint32, v.Length) + for i := 0; i < int(v.Length); i++ { + v.PropertyList[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetVisualConfigs +func getVisualConfigsRequest(c *xgb.Conn, Screen uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 14 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + return buf +} + +// Request DestroyGLXPixmap +// size: 8 +type DestroyGLXPixmapCookie struct { + *xgb.Cookie +} + +// Write request to wire for DestroyGLXPixmap +func DestroyGLXPixmap(c *xgb.Conn, GlxPixmap Pixmap) DestroyGLXPixmapCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroyGLXPixmapRequest(c, GlxPixmap), cookie) + return DestroyGLXPixmapCookie{cookie} +} + +func DestroyGLXPixmapChecked(c *xgb.Conn, GlxPixmap Pixmap) DestroyGLXPixmapCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(destroyGLXPixmapRequest(c, GlxPixmap), cookie) + return DestroyGLXPixmapCookie{cookie} +} + +func (cook DestroyGLXPixmapCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DestroyGLXPixmap +func destroyGLXPixmapRequest(c *xgb.Conn, GlxPixmap Pixmap) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 15 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(GlxPixmap)) + b += 4 + + return buf +} + +// Request VendorPrivate +// size: xgb.Pad((12 + xgb.Pad((len(Data) * 1)))) +type VendorPrivateCookie struct { + *xgb.Cookie +} + +// Write request to wire for VendorPrivate +func VendorPrivate(c *xgb.Conn, VendorCode uint32, ContextTag ContextTag, Data []byte) VendorPrivateCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(vendorPrivateRequest(c, VendorCode, ContextTag, Data), cookie) + return VendorPrivateCookie{cookie} +} + +func VendorPrivateChecked(c *xgb.Conn, VendorCode uint32, ContextTag ContextTag, Data []byte) VendorPrivateCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(vendorPrivateRequest(c, VendorCode, ContextTag, Data), cookie) + return VendorPrivateCookie{cookie} +} + +func (cook VendorPrivateCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for VendorPrivate +func vendorPrivateRequest(c *xgb.Conn, VendorCode uint32, ContextTag ContextTag, Data []byte) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Data) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 16 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], VendorCode) + b += 4 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + copy(buf[b:], Data[:len(Data)]) + b += xgb.Pad(int(len(Data))) + + return buf +} + +// Request VendorPrivateWithReply +// size: xgb.Pad((12 + xgb.Pad((len(Data) * 1)))) +type VendorPrivateWithReplyCookie struct { + *xgb.Cookie +} + +func VendorPrivateWithReply(c *xgb.Conn, VendorCode uint32, ContextTag ContextTag, Data []byte) VendorPrivateWithReplyCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(vendorPrivateWithReplyRequest(c, VendorCode, ContextTag, Data), cookie) + return VendorPrivateWithReplyCookie{cookie} +} + +func VendorPrivateWithReplyUnchecked(c *xgb.Conn, VendorCode uint32, ContextTag ContextTag, Data []byte) VendorPrivateWithReplyCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(vendorPrivateWithReplyRequest(c, VendorCode, ContextTag, Data), cookie) + return VendorPrivateWithReplyCookie{cookie} +} + +// Request reply for VendorPrivateWithReply +// size: (36 + xgb.Pad(((int(Length) * 4) * 1))) +type VendorPrivateWithReplyReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Retval uint32 + Data1 []byte // size: 24 + Data2 []byte // size: xgb.Pad(((int(Length) * 4) * 1)) +} + +// Waits and reads reply data from request VendorPrivateWithReply +func (cook VendorPrivateWithReplyCookie) Reply() (*VendorPrivateWithReplyReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return vendorPrivateWithReplyReply(buf), nil +} + +// Read reply into structure from buffer for VendorPrivateWithReply +func vendorPrivateWithReplyReply(buf []byte) *VendorPrivateWithReplyReply { + v := new(VendorPrivateWithReplyReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Retval = xgb.Get32(buf[b:]) + b += 4 + + v.Data1 = make([]byte, 24) + copy(v.Data1[:24], buf[b:]) + b += xgb.Pad(int(24)) + + v.Data2 = make([]byte, (int(v.Length) * 4)) + copy(v.Data2[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) + + return v +} + +// Write request to wire for VendorPrivateWithReply +func vendorPrivateWithReplyRequest(c *xgb.Conn, VendorCode uint32, ContextTag ContextTag, Data []byte) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Data) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 17 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], VendorCode) + b += 4 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + copy(buf[b:], Data[:len(Data)]) + b += xgb.Pad(int(len(Data))) + + return buf +} + +// Request QueryExtensionsString +// size: 8 +type QueryExtensionsStringCookie struct { + *xgb.Cookie +} + +func QueryExtensionsString(c *xgb.Conn, Screen uint32) QueryExtensionsStringCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryExtensionsStringRequest(c, Screen), cookie) + return QueryExtensionsStringCookie{cookie} +} + +func QueryExtensionsStringUnchecked(c *xgb.Conn, Screen uint32) QueryExtensionsStringCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryExtensionsStringRequest(c, Screen), cookie) + return QueryExtensionsStringCookie{cookie} +} + +// Request reply for QueryExtensionsString +// size: 32 +type QueryExtensionsStringReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + // padding: 16 bytes +} + +// Waits and reads reply data from request QueryExtensionsString +func (cook QueryExtensionsStringCookie) Reply() (*QueryExtensionsStringReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryExtensionsStringReply(buf), nil +} + +// Read reply into structure from buffer for QueryExtensionsString +func queryExtensionsStringReply(buf []byte) *QueryExtensionsStringReply { + v := new(QueryExtensionsStringReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + b += 16 // padding + + return v +} + +// Write request to wire for QueryExtensionsString +func queryExtensionsStringRequest(c *xgb.Conn, Screen uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 18 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + return buf +} + +// Request QueryServerString +// size: 12 +type QueryServerStringCookie struct { + *xgb.Cookie +} + +func QueryServerString(c *xgb.Conn, Screen uint32, Name uint32) QueryServerStringCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryServerStringRequest(c, Screen, Name), cookie) + return QueryServerStringCookie{cookie} +} + +func QueryServerStringUnchecked(c *xgb.Conn, Screen uint32, Name uint32) QueryServerStringCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryServerStringRequest(c, Screen, Name), cookie) + return QueryServerStringCookie{cookie} +} + +// Request reply for QueryServerString +// size: (32 + xgb.Pad((int(StrLen) * 1))) +type QueryServerStringReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + StrLen uint32 + // padding: 16 bytes + String string // size: xgb.Pad((int(StrLen) * 1)) +} + +// Waits and reads reply data from request QueryServerString +func (cook QueryServerStringCookie) Reply() (*QueryServerStringReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryServerStringReply(buf), nil +} + +// Read reply into structure from buffer for QueryServerString +func queryServerStringReply(buf []byte) *QueryServerStringReply { + v := new(QueryServerStringReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.StrLen = xgb.Get32(buf[b:]) + b += 4 + + b += 16 // padding + + { + byteString := make([]byte, v.StrLen) + copy(byteString[:v.StrLen], buf[b:]) + v.String = string(byteString) + b += xgb.Pad(int(v.StrLen)) + } + + return v +} + +// Write request to wire for QueryServerString +func queryServerStringRequest(c *xgb.Conn, Screen uint32, Name uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 19 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], Name) + b += 4 + + return buf +} + +// Request ClientInfo +// size: xgb.Pad((16 + xgb.Pad((int(StrLen) * 1)))) +type ClientInfoCookie struct { + *xgb.Cookie +} + +// Write request to wire for ClientInfo +func ClientInfo(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, StrLen uint32, String string) ClientInfoCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(clientInfoRequest(c, MajorVersion, MinorVersion, StrLen, String), cookie) + return ClientInfoCookie{cookie} +} + +func ClientInfoChecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, StrLen uint32, String string) ClientInfoCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(clientInfoRequest(c, MajorVersion, MinorVersion, StrLen, String), cookie) + return ClientInfoCookie{cookie} +} + +func (cook ClientInfoCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ClientInfo +func clientInfoRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, StrLen uint32, String string) []byte { + size := xgb.Pad((16 + xgb.Pad((int(StrLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 20 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], MajorVersion) + b += 4 + + xgb.Put32(buf[b:], MinorVersion) + b += 4 + + xgb.Put32(buf[b:], StrLen) + b += 4 + + copy(buf[b:], String[:StrLen]) + b += xgb.Pad(int(StrLen)) + + return buf +} + +// Request GetFBConfigs +// size: 8 +type GetFBConfigsCookie struct { + *xgb.Cookie +} + +func GetFBConfigs(c *xgb.Conn, Screen uint32) GetFBConfigsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getFBConfigsRequest(c, Screen), cookie) + return GetFBConfigsCookie{cookie} +} + +func GetFBConfigsUnchecked(c *xgb.Conn, Screen uint32) GetFBConfigsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getFBConfigsRequest(c, Screen), cookie) + return GetFBConfigsCookie{cookie} +} + +// Request reply for GetFBConfigs +// size: (32 + xgb.Pad((int(Length) * 4))) +type GetFBConfigsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumFbConfigs uint32 + NumProperties uint32 + // padding: 16 bytes + PropertyList []uint32 // size: xgb.Pad((int(Length) * 4)) +} + +// Waits and reads reply data from request GetFBConfigs +func (cook GetFBConfigsCookie) Reply() (*GetFBConfigsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getFBConfigsReply(buf), nil +} + +// Read reply into structure from buffer for GetFBConfigs +func getFBConfigsReply(buf []byte) *GetFBConfigsReply { + v := new(GetFBConfigsReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NumFbConfigs = xgb.Get32(buf[b:]) + b += 4 + + v.NumProperties = xgb.Get32(buf[b:]) + b += 4 + + b += 16 // padding + + v.PropertyList = make([]uint32, v.Length) + for i := 0; i < int(v.Length); i++ { + v.PropertyList[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetFBConfigs +func getFBConfigsRequest(c *xgb.Conn, Screen uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 21 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + return buf +} + +// Request CreatePixmap +// size: xgb.Pad((24 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) +type CreatePixmapCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreatePixmap +func CreatePixmap(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Pixmap xproto.Pixmap, GlxPixmap Pixmap, NumAttribs uint32, Attribs []uint32) CreatePixmapCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createPixmapRequest(c, Screen, Fbconfig, Pixmap, GlxPixmap, NumAttribs, Attribs), cookie) + return CreatePixmapCookie{cookie} +} + +func CreatePixmapChecked(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Pixmap xproto.Pixmap, GlxPixmap Pixmap, NumAttribs uint32, Attribs []uint32) CreatePixmapCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createPixmapRequest(c, Screen, Fbconfig, Pixmap, GlxPixmap, NumAttribs, Attribs), cookie) + return CreatePixmapCookie{cookie} +} + +func (cook CreatePixmapCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreatePixmap +func createPixmapRequest(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Pixmap xproto.Pixmap, GlxPixmap Pixmap, NumAttribs uint32, Attribs []uint32) []byte { + size := xgb.Pad((24 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 22 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], uint32(Fbconfig)) + b += 4 + + xgb.Put32(buf[b:], uint32(Pixmap)) + b += 4 + + xgb.Put32(buf[b:], uint32(GlxPixmap)) + b += 4 + + xgb.Put32(buf[b:], NumAttribs) + b += 4 + + for i := 0; i < int((int(NumAttribs) * 2)); i++ { + xgb.Put32(buf[b:], Attribs[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request DestroyPixmap +// size: 8 +type DestroyPixmapCookie struct { + *xgb.Cookie +} + +// Write request to wire for DestroyPixmap +func DestroyPixmap(c *xgb.Conn, GlxPixmap Pixmap) DestroyPixmapCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroyPixmapRequest(c, GlxPixmap), cookie) + return DestroyPixmapCookie{cookie} +} + +func DestroyPixmapChecked(c *xgb.Conn, GlxPixmap Pixmap) DestroyPixmapCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(destroyPixmapRequest(c, GlxPixmap), cookie) + return DestroyPixmapCookie{cookie} +} + +func (cook DestroyPixmapCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DestroyPixmap +func destroyPixmapRequest(c *xgb.Conn, GlxPixmap Pixmap) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 23 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(GlxPixmap)) + b += 4 + + return buf +} + +// Request CreateNewContext +// size: 28 +type CreateNewContextCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateNewContext +func CreateNewContext(c *xgb.Conn, Context Context, Fbconfig Fbconfig, Screen uint32, RenderType uint32, ShareList Context, IsDirect bool) CreateNewContextCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createNewContextRequest(c, Context, Fbconfig, Screen, RenderType, ShareList, IsDirect), cookie) + return CreateNewContextCookie{cookie} +} + +func CreateNewContextChecked(c *xgb.Conn, Context Context, Fbconfig Fbconfig, Screen uint32, RenderType uint32, ShareList Context, IsDirect bool) CreateNewContextCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createNewContextRequest(c, Context, Fbconfig, Screen, RenderType, ShareList, IsDirect), cookie) + return CreateNewContextCookie{cookie} +} + +func (cook CreateNewContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateNewContext +func createNewContextRequest(c *xgb.Conn, Context Context, Fbconfig Fbconfig, Screen uint32, RenderType uint32, ShareList Context, IsDirect bool) []byte { + size := 28 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 24 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + xgb.Put32(buf[b:], uint32(Fbconfig)) + b += 4 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], RenderType) + b += 4 + + xgb.Put32(buf[b:], uint32(ShareList)) + b += 4 + + if IsDirect { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding + + return buf +} + +// Request QueryContext +// size: 8 +type QueryContextCookie struct { + *xgb.Cookie +} + +func QueryContext(c *xgb.Conn, Context Context) QueryContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryContextRequest(c, Context), cookie) + return QueryContextCookie{cookie} +} + +func QueryContextUnchecked(c *xgb.Conn, Context Context) QueryContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryContextRequest(c, Context), cookie) + return QueryContextCookie{cookie} +} + +// Request reply for QueryContext +// size: (32 + xgb.Pad(((int(NumAttribs) * 2) * 4))) +type QueryContextReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumAttribs uint32 + // padding: 20 bytes + Attribs []uint32 // size: xgb.Pad(((int(NumAttribs) * 2) * 4)) +} + +// Waits and reads reply data from request QueryContext +func (cook QueryContextCookie) Reply() (*QueryContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryContextReply(buf), nil +} + +// Read reply into structure from buffer for QueryContext +func queryContextReply(buf []byte) *QueryContextReply { + v := new(QueryContextReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NumAttribs = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Attribs = make([]uint32, (int(v.NumAttribs) * 2)) + for i := 0; i < int((int(v.NumAttribs) * 2)); i++ { + v.Attribs[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for QueryContext +func queryContextRequest(c *xgb.Conn, Context Context) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 25 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + return buf +} + +// Request MakeContextCurrent +// size: 20 +type MakeContextCurrentCookie struct { + *xgb.Cookie +} + +func MakeContextCurrent(c *xgb.Conn, OldContextTag ContextTag, Drawable Drawable, ReadDrawable Drawable, Context Context) MakeContextCurrentCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(makeContextCurrentRequest(c, OldContextTag, Drawable, ReadDrawable, Context), cookie) + return MakeContextCurrentCookie{cookie} +} + +func MakeContextCurrentUnchecked(c *xgb.Conn, OldContextTag ContextTag, Drawable Drawable, ReadDrawable Drawable, Context Context) MakeContextCurrentCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(makeContextCurrentRequest(c, OldContextTag, Drawable, ReadDrawable, Context), cookie) + return MakeContextCurrentCookie{cookie} +} + +// Request reply for MakeContextCurrent +// size: 32 +type MakeContextCurrentReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ContextTag ContextTag + // padding: 20 bytes +} + +// Waits and reads reply data from request MakeContextCurrent +func (cook MakeContextCurrentCookie) Reply() (*MakeContextCurrentReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return makeContextCurrentReply(buf), nil +} + +// Read reply into structure from buffer for MakeContextCurrent +func makeContextCurrentReply(buf []byte) *MakeContextCurrentReply { + v := new(MakeContextCurrentReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ContextTag = ContextTag(xgb.Get32(buf[b:])) + b += 4 + + b += 20 // padding + + return v +} + +// Write request to wire for MakeContextCurrent +func makeContextCurrentRequest(c *xgb.Conn, OldContextTag ContextTag, Drawable Drawable, ReadDrawable Drawable, Context Context) []byte { + size := 20 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 26 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(OldContextTag)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(ReadDrawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + return buf +} + +// Request CreatePbuffer +// size: xgb.Pad((20 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) +type CreatePbufferCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreatePbuffer +func CreatePbuffer(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Pbuffer Pbuffer, NumAttribs uint32, Attribs []uint32) CreatePbufferCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createPbufferRequest(c, Screen, Fbconfig, Pbuffer, NumAttribs, Attribs), cookie) + return CreatePbufferCookie{cookie} +} + +func CreatePbufferChecked(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Pbuffer Pbuffer, NumAttribs uint32, Attribs []uint32) CreatePbufferCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createPbufferRequest(c, Screen, Fbconfig, Pbuffer, NumAttribs, Attribs), cookie) + return CreatePbufferCookie{cookie} +} + +func (cook CreatePbufferCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreatePbuffer +func createPbufferRequest(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Pbuffer Pbuffer, NumAttribs uint32, Attribs []uint32) []byte { + size := xgb.Pad((20 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 27 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], uint32(Fbconfig)) + b += 4 + + xgb.Put32(buf[b:], uint32(Pbuffer)) + b += 4 + + xgb.Put32(buf[b:], NumAttribs) + b += 4 + + for i := 0; i < int((int(NumAttribs) * 2)); i++ { + xgb.Put32(buf[b:], Attribs[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request DestroyPbuffer +// size: 8 +type DestroyPbufferCookie struct { + *xgb.Cookie +} + +// Write request to wire for DestroyPbuffer +func DestroyPbuffer(c *xgb.Conn, Pbuffer Pbuffer) DestroyPbufferCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroyPbufferRequest(c, Pbuffer), cookie) + return DestroyPbufferCookie{cookie} +} + +func DestroyPbufferChecked(c *xgb.Conn, Pbuffer Pbuffer) DestroyPbufferCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(destroyPbufferRequest(c, Pbuffer), cookie) + return DestroyPbufferCookie{cookie} +} + +func (cook DestroyPbufferCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DestroyPbuffer +func destroyPbufferRequest(c *xgb.Conn, Pbuffer Pbuffer) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 28 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Pbuffer)) + b += 4 + + return buf +} + +// Request GetDrawableAttributes +// size: 8 +type GetDrawableAttributesCookie struct { + *xgb.Cookie +} + +func GetDrawableAttributes(c *xgb.Conn, Drawable Drawable) GetDrawableAttributesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getDrawableAttributesRequest(c, Drawable), cookie) + return GetDrawableAttributesCookie{cookie} +} + +func GetDrawableAttributesUnchecked(c *xgb.Conn, Drawable Drawable) GetDrawableAttributesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getDrawableAttributesRequest(c, Drawable), cookie) + return GetDrawableAttributesCookie{cookie} +} + +// Request reply for GetDrawableAttributes +// size: (32 + xgb.Pad(((int(NumAttribs) * 2) * 4))) +type GetDrawableAttributesReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumAttribs uint32 + // padding: 20 bytes + Attribs []uint32 // size: xgb.Pad(((int(NumAttribs) * 2) * 4)) +} + +// Waits and reads reply data from request GetDrawableAttributes +func (cook GetDrawableAttributesCookie) Reply() (*GetDrawableAttributesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDrawableAttributesReply(buf), nil +} + +// Read reply into structure from buffer for GetDrawableAttributes +func getDrawableAttributesReply(buf []byte) *GetDrawableAttributesReply { + v := new(GetDrawableAttributesReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NumAttribs = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Attribs = make([]uint32, (int(v.NumAttribs) * 2)) + for i := 0; i < int((int(v.NumAttribs) * 2)); i++ { + v.Attribs[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetDrawableAttributes +func getDrawableAttributesRequest(c *xgb.Conn, Drawable Drawable) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 29 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + return buf +} + +// Request ChangeDrawableAttributes +// size: xgb.Pad((12 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) +type ChangeDrawableAttributesCookie struct { + *xgb.Cookie +} + +// Write request to wire for ChangeDrawableAttributes +func ChangeDrawableAttributes(c *xgb.Conn, Drawable Drawable, NumAttribs uint32, Attribs []uint32) ChangeDrawableAttributesCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeDrawableAttributesRequest(c, Drawable, NumAttribs, Attribs), cookie) + return ChangeDrawableAttributesCookie{cookie} +} + +func ChangeDrawableAttributesChecked(c *xgb.Conn, Drawable Drawable, NumAttribs uint32, Attribs []uint32) ChangeDrawableAttributesCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeDrawableAttributesRequest(c, Drawable, NumAttribs, Attribs), cookie) + return ChangeDrawableAttributesCookie{cookie} +} + +func (cook ChangeDrawableAttributesCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangeDrawableAttributes +func changeDrawableAttributesRequest(c *xgb.Conn, Drawable Drawable, NumAttribs uint32, Attribs []uint32) []byte { + size := xgb.Pad((12 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 30 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], NumAttribs) + b += 4 + + for i := 0; i < int((int(NumAttribs) * 2)); i++ { + xgb.Put32(buf[b:], Attribs[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request CreateWindow +// size: xgb.Pad((24 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) +type CreateWindowCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateWindow +func CreateWindow(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Window xproto.Window, GlxWindow Window, NumAttribs uint32, Attribs []uint32) CreateWindowCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createWindowRequest(c, Screen, Fbconfig, Window, GlxWindow, NumAttribs, Attribs), cookie) + return CreateWindowCookie{cookie} +} + +func CreateWindowChecked(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Window xproto.Window, GlxWindow Window, NumAttribs uint32, Attribs []uint32) CreateWindowCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createWindowRequest(c, Screen, Fbconfig, Window, GlxWindow, NumAttribs, Attribs), cookie) + return CreateWindowCookie{cookie} +} + +func (cook CreateWindowCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateWindow +func createWindowRequest(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Window xproto.Window, GlxWindow Window, NumAttribs uint32, Attribs []uint32) []byte { + size := xgb.Pad((24 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 31 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], uint32(Fbconfig)) + b += 4 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(GlxWindow)) + b += 4 + + xgb.Put32(buf[b:], NumAttribs) + b += 4 + + for i := 0; i < int((int(NumAttribs) * 2)); i++ { + xgb.Put32(buf[b:], Attribs[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request DeleteWindow +// size: 8 +type DeleteWindowCookie struct { + *xgb.Cookie +} + +// Write request to wire for DeleteWindow +func DeleteWindow(c *xgb.Conn, Glxwindow Window) DeleteWindowCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(deleteWindowRequest(c, Glxwindow), cookie) + return DeleteWindowCookie{cookie} +} + +func DeleteWindowChecked(c *xgb.Conn, Glxwindow Window) DeleteWindowCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(deleteWindowRequest(c, Glxwindow), cookie) + return DeleteWindowCookie{cookie} +} + +func (cook DeleteWindowCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DeleteWindow +func deleteWindowRequest(c *xgb.Conn, Glxwindow Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 32 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Glxwindow)) + b += 4 + + return buf +} + +// Request SetClientInfoARB +// size: xgb.Pad((((24 + xgb.Pad(((int(NumVersions) * 2) * 4))) + xgb.Pad((int(GlStrLen) * 1))) + xgb.Pad((int(GlxStrLen) * 1)))) +type SetClientInfoARBCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetClientInfoARB +func SetClientInfoARB(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) SetClientInfoARBCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setClientInfoARBRequest(c, MajorVersion, MinorVersion, NumVersions, GlStrLen, GlxStrLen, GlVersions, GlExtensionString, GlxExtensionString), cookie) + return SetClientInfoARBCookie{cookie} +} + +func SetClientInfoARBChecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) SetClientInfoARBCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setClientInfoARBRequest(c, MajorVersion, MinorVersion, NumVersions, GlStrLen, GlxStrLen, GlVersions, GlExtensionString, GlxExtensionString), cookie) + return SetClientInfoARBCookie{cookie} +} + +func (cook SetClientInfoARBCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetClientInfoARB +func setClientInfoARBRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) []byte { + size := xgb.Pad((((24 + xgb.Pad(((int(NumVersions) * 2) * 4))) + xgb.Pad((int(GlStrLen) * 1))) + xgb.Pad((int(GlxStrLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 33 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], MajorVersion) + b += 4 + + xgb.Put32(buf[b:], MinorVersion) + b += 4 + + xgb.Put32(buf[b:], NumVersions) + b += 4 + + xgb.Put32(buf[b:], GlStrLen) + b += 4 + + xgb.Put32(buf[b:], GlxStrLen) + b += 4 + + for i := 0; i < int((int(NumVersions) * 2)); i++ { + xgb.Put32(buf[b:], GlVersions[i]) + b += 4 + } + b = xgb.Pad(b) + + copy(buf[b:], GlExtensionString[:GlStrLen]) + b += xgb.Pad(int(GlStrLen)) + + copy(buf[b:], GlxExtensionString[:GlxStrLen]) + b += xgb.Pad(int(GlxStrLen)) + + return buf +} + +// Request CreateContextAttribsARB +// size: xgb.Pad((28 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) +type CreateContextAttribsARBCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateContextAttribsARB +func CreateContextAttribsARB(c *xgb.Conn, Context Context, Fbconfig Fbconfig, Screen uint32, ShareList Context, IsDirect bool, NumAttribs uint32, Attribs []uint32) CreateContextAttribsARBCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createContextAttribsARBRequest(c, Context, Fbconfig, Screen, ShareList, IsDirect, NumAttribs, Attribs), cookie) + return CreateContextAttribsARBCookie{cookie} +} + +func CreateContextAttribsARBChecked(c *xgb.Conn, Context Context, Fbconfig Fbconfig, Screen uint32, ShareList Context, IsDirect bool, NumAttribs uint32, Attribs []uint32) CreateContextAttribsARBCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createContextAttribsARBRequest(c, Context, Fbconfig, Screen, ShareList, IsDirect, NumAttribs, Attribs), cookie) + return CreateContextAttribsARBCookie{cookie} +} + +func (cook CreateContextAttribsARBCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateContextAttribsARB +func createContextAttribsARBRequest(c *xgb.Conn, Context Context, Fbconfig Fbconfig, Screen uint32, ShareList Context, IsDirect bool, NumAttribs uint32, Attribs []uint32) []byte { + size := xgb.Pad((28 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 34 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + xgb.Put32(buf[b:], uint32(Fbconfig)) + b += 4 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], uint32(ShareList)) + b += 4 + + if IsDirect { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], NumAttribs) + b += 4 + + for i := 0; i < int((int(NumAttribs) * 2)); i++ { + xgb.Put32(buf[b:], Attribs[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request SetClientInfo2ARB +// size: xgb.Pad((((24 + xgb.Pad(((int(NumVersions) * 3) * 4))) + xgb.Pad((int(GlStrLen) * 1))) + xgb.Pad((int(GlxStrLen) * 1)))) +type SetClientInfo2ARBCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetClientInfo2ARB +func SetClientInfo2ARB(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) SetClientInfo2ARBCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setClientInfo2ARBRequest(c, MajorVersion, MinorVersion, NumVersions, GlStrLen, GlxStrLen, GlVersions, GlExtensionString, GlxExtensionString), cookie) + return SetClientInfo2ARBCookie{cookie} +} + +func SetClientInfo2ARBChecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) SetClientInfo2ARBCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setClientInfo2ARBRequest(c, MajorVersion, MinorVersion, NumVersions, GlStrLen, GlxStrLen, GlVersions, GlExtensionString, GlxExtensionString), cookie) + return SetClientInfo2ARBCookie{cookie} +} + +func (cook SetClientInfo2ARBCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetClientInfo2ARB +func setClientInfo2ARBRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) []byte { + size := xgb.Pad((((24 + xgb.Pad(((int(NumVersions) * 3) * 4))) + xgb.Pad((int(GlStrLen) * 1))) + xgb.Pad((int(GlxStrLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 35 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], MajorVersion) + b += 4 + + xgb.Put32(buf[b:], MinorVersion) + b += 4 + + xgb.Put32(buf[b:], NumVersions) + b += 4 + + xgb.Put32(buf[b:], GlStrLen) + b += 4 + + xgb.Put32(buf[b:], GlxStrLen) + b += 4 + + for i := 0; i < int((int(NumVersions) * 3)); i++ { + xgb.Put32(buf[b:], GlVersions[i]) + b += 4 + } + b = xgb.Pad(b) + + copy(buf[b:], GlExtensionString[:GlStrLen]) + b += xgb.Pad(int(GlStrLen)) + + copy(buf[b:], GlxExtensionString[:GlxStrLen]) + b += xgb.Pad(int(GlxStrLen)) + + return buf +} + +// Request NewList +// size: 16 +type NewListCookie struct { + *xgb.Cookie +} + +// Write request to wire for NewList +func NewList(c *xgb.Conn, ContextTag ContextTag, List uint32, Mode uint32) NewListCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(newListRequest(c, ContextTag, List, Mode), cookie) + return NewListCookie{cookie} +} + +func NewListChecked(c *xgb.Conn, ContextTag ContextTag, List uint32, Mode uint32) NewListCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(newListRequest(c, ContextTag, List, Mode), cookie) + return NewListCookie{cookie} +} + +func (cook NewListCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for NewList +func newListRequest(c *xgb.Conn, ContextTag ContextTag, List uint32, Mode uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 101 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], List) + b += 4 + + xgb.Put32(buf[b:], Mode) + b += 4 + + return buf +} + +// Request EndList +// size: 8 +type EndListCookie struct { + *xgb.Cookie +} + +// Write request to wire for EndList +func EndList(c *xgb.Conn, ContextTag ContextTag) EndListCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(endListRequest(c, ContextTag), cookie) + return EndListCookie{cookie} +} + +func EndListChecked(c *xgb.Conn, ContextTag ContextTag) EndListCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(endListRequest(c, ContextTag), cookie) + return EndListCookie{cookie} +} + +func (cook EndListCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for EndList +func endListRequest(c *xgb.Conn, ContextTag ContextTag) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 102 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + return buf +} + +// Request DeleteLists +// size: 16 +type DeleteListsCookie struct { + *xgb.Cookie +} + +// Write request to wire for DeleteLists +func DeleteLists(c *xgb.Conn, ContextTag ContextTag, List uint32, Range int32) DeleteListsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(deleteListsRequest(c, ContextTag, List, Range), cookie) + return DeleteListsCookie{cookie} +} + +func DeleteListsChecked(c *xgb.Conn, ContextTag ContextTag, List uint32, Range int32) DeleteListsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(deleteListsRequest(c, ContextTag, List, Range), cookie) + return DeleteListsCookie{cookie} +} + +func (cook DeleteListsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DeleteLists +func deleteListsRequest(c *xgb.Conn, ContextTag ContextTag, List uint32, Range int32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 103 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], List) + b += 4 + + xgb.Put32(buf[b:], uint32(Range)) + b += 4 + + return buf +} + +// Request GenLists +// size: 12 +type GenListsCookie struct { + *xgb.Cookie +} + +func GenLists(c *xgb.Conn, ContextTag ContextTag, Range int32) GenListsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(genListsRequest(c, ContextTag, Range), cookie) + return GenListsCookie{cookie} +} + +func GenListsUnchecked(c *xgb.Conn, ContextTag ContextTag, Range int32) GenListsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(genListsRequest(c, ContextTag, Range), cookie) + return GenListsCookie{cookie} +} + +// Request reply for GenLists +// size: 12 +type GenListsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + RetVal uint32 +} + +// Waits and reads reply data from request GenLists +func (cook GenListsCookie) Reply() (*GenListsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return genListsReply(buf), nil +} + +// Read reply into structure from buffer for GenLists +func genListsReply(buf []byte) *GenListsReply { + v := new(GenListsReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.RetVal = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for GenLists +func genListsRequest(c *xgb.Conn, ContextTag ContextTag, Range int32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 104 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], uint32(Range)) + b += 4 + + return buf +} + +// Request FeedbackBuffer +// size: 16 +type FeedbackBufferCookie struct { + *xgb.Cookie +} + +// Write request to wire for FeedbackBuffer +func FeedbackBuffer(c *xgb.Conn, ContextTag ContextTag, Size int32, Type int32) FeedbackBufferCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(feedbackBufferRequest(c, ContextTag, Size, Type), cookie) + return FeedbackBufferCookie{cookie} +} + +func FeedbackBufferChecked(c *xgb.Conn, ContextTag ContextTag, Size int32, Type int32) FeedbackBufferCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(feedbackBufferRequest(c, ContextTag, Size, Type), cookie) + return FeedbackBufferCookie{cookie} +} + +func (cook FeedbackBufferCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for FeedbackBuffer +func feedbackBufferRequest(c *xgb.Conn, ContextTag ContextTag, Size int32, Type int32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 105 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], uint32(Size)) + b += 4 + + xgb.Put32(buf[b:], uint32(Type)) + b += 4 + + return buf +} + +// Request SelectBuffer +// size: 12 +type SelectBufferCookie struct { + *xgb.Cookie +} + +// Write request to wire for SelectBuffer +func SelectBuffer(c *xgb.Conn, ContextTag ContextTag, Size int32) SelectBufferCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(selectBufferRequest(c, ContextTag, Size), cookie) + return SelectBufferCookie{cookie} +} + +func SelectBufferChecked(c *xgb.Conn, ContextTag ContextTag, Size int32) SelectBufferCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(selectBufferRequest(c, ContextTag, Size), cookie) + return SelectBufferCookie{cookie} +} + +func (cook SelectBufferCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SelectBuffer +func selectBufferRequest(c *xgb.Conn, ContextTag ContextTag, Size int32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 106 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], uint32(Size)) + b += 4 + + return buf +} + +// Request RenderMode +// size: 12 +type RenderModeCookie struct { + *xgb.Cookie +} + +func RenderMode(c *xgb.Conn, ContextTag ContextTag, Mode uint32) RenderModeCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(renderModeRequest(c, ContextTag, Mode), cookie) + return RenderModeCookie{cookie} +} + +func RenderModeUnchecked(c *xgb.Conn, ContextTag ContextTag, Mode uint32) RenderModeCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(renderModeRequest(c, ContextTag, Mode), cookie) + return RenderModeCookie{cookie} +} + +// Request reply for RenderMode +// size: (32 + xgb.Pad((int(N) * 4))) +type RenderModeReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + RetVal uint32 + N uint32 + NewMode uint32 + // padding: 12 bytes + Data []uint32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request RenderMode +func (cook RenderModeCookie) Reply() (*RenderModeReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return renderModeReply(buf), nil +} + +// Read reply into structure from buffer for RenderMode +func renderModeReply(buf []byte) *RenderModeReply { + v := new(RenderModeReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.RetVal = xgb.Get32(buf[b:]) + b += 4 + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.NewMode = xgb.Get32(buf[b:]) + b += 4 + + b += 12 // padding + + v.Data = make([]uint32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for RenderMode +func renderModeRequest(c *xgb.Conn, ContextTag ContextTag, Mode uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 107 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Mode) + b += 4 + + return buf +} + +// Request Finish +// size: 8 +type FinishCookie struct { + *xgb.Cookie +} + +func Finish(c *xgb.Conn, ContextTag ContextTag) FinishCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(finishRequest(c, ContextTag), cookie) + return FinishCookie{cookie} +} + +func FinishUnchecked(c *xgb.Conn, ContextTag ContextTag) FinishCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(finishRequest(c, ContextTag), cookie) + return FinishCookie{cookie} +} + +// Request reply for Finish +// size: 8 +type FinishReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes +} + +// Waits and reads reply data from request Finish +func (cook FinishCookie) Reply() (*FinishReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return finishReply(buf), nil +} + +// Read reply into structure from buffer for Finish +func finishReply(buf []byte) *FinishReply { + v := new(FinishReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + return v +} + +// Write request to wire for Finish +func finishRequest(c *xgb.Conn, ContextTag ContextTag) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 108 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + return buf +} + +// Request PixelStoref +// size: 16 +type PixelStorefCookie struct { + *xgb.Cookie +} + +// Write request to wire for PixelStoref +func PixelStoref(c *xgb.Conn, ContextTag ContextTag, Pname uint32, Datum Float32) PixelStorefCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(pixelStorefRequest(c, ContextTag, Pname, Datum), cookie) + return PixelStorefCookie{cookie} +} + +func PixelStorefChecked(c *xgb.Conn, ContextTag ContextTag, Pname uint32, Datum Float32) PixelStorefCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(pixelStorefRequest(c, ContextTag, Pname, Datum), cookie) + return PixelStorefCookie{cookie} +} + +func (cook PixelStorefCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PixelStoref +func pixelStorefRequest(c *xgb.Conn, ContextTag ContextTag, Pname uint32, Datum Float32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 109 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + xgb.Put32(buf[b:], uint32(Datum)) + b += 4 + + return buf +} + +// Request PixelStorei +// size: 16 +type PixelStoreiCookie struct { + *xgb.Cookie +} + +// Write request to wire for PixelStorei +func PixelStorei(c *xgb.Conn, ContextTag ContextTag, Pname uint32, Datum int32) PixelStoreiCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(pixelStoreiRequest(c, ContextTag, Pname, Datum), cookie) + return PixelStoreiCookie{cookie} +} + +func PixelStoreiChecked(c *xgb.Conn, ContextTag ContextTag, Pname uint32, Datum int32) PixelStoreiCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(pixelStoreiRequest(c, ContextTag, Pname, Datum), cookie) + return PixelStoreiCookie{cookie} +} + +func (cook PixelStoreiCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PixelStorei +func pixelStoreiRequest(c *xgb.Conn, ContextTag ContextTag, Pname uint32, Datum int32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 110 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + xgb.Put32(buf[b:], uint32(Datum)) + b += 4 + + return buf +} + +// Request ReadPixels +// size: 36 +type ReadPixelsCookie struct { + *xgb.Cookie +} + +func ReadPixels(c *xgb.Conn, ContextTag ContextTag, X int32, Y int32, Width int32, Height int32, Format uint32, Type uint32, SwapBytes bool, LsbFirst bool) ReadPixelsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(readPixelsRequest(c, ContextTag, X, Y, Width, Height, Format, Type, SwapBytes, LsbFirst), cookie) + return ReadPixelsCookie{cookie} +} + +func ReadPixelsUnchecked(c *xgb.Conn, ContextTag ContextTag, X int32, Y int32, Width int32, Height int32, Format uint32, Type uint32, SwapBytes bool, LsbFirst bool) ReadPixelsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(readPixelsRequest(c, ContextTag, X, Y, Width, Height, Format, Type, SwapBytes, LsbFirst), cookie) + return ReadPixelsCookie{cookie} +} + +// Request reply for ReadPixels +// size: (32 + xgb.Pad(((int(Length) * 4) * 1))) +type ReadPixelsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 24 bytes + Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) +} + +// Waits and reads reply data from request ReadPixels +func (cook ReadPixelsCookie) Reply() (*ReadPixelsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return readPixelsReply(buf), nil +} + +// Read reply into structure from buffer for ReadPixels +func readPixelsReply(buf []byte) *ReadPixelsReply { + v := new(ReadPixelsReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 24 // padding + + v.Data = make([]byte, (int(v.Length) * 4)) + copy(v.Data[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) + + return v +} + +// Write request to wire for ReadPixels +func readPixelsRequest(c *xgb.Conn, ContextTag ContextTag, X int32, Y int32, Width int32, Height int32, Format uint32, Type uint32, SwapBytes bool, LsbFirst bool) []byte { + size := 36 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 111 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], uint32(X)) + b += 4 + + xgb.Put32(buf[b:], uint32(Y)) + b += 4 + + xgb.Put32(buf[b:], uint32(Width)) + b += 4 + + xgb.Put32(buf[b:], uint32(Height)) + b += 4 + + xgb.Put32(buf[b:], Format) + b += 4 + + xgb.Put32(buf[b:], Type) + b += 4 + + if SwapBytes { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + if LsbFirst { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + return buf +} + +// Request GetBooleanv +// size: 12 +type GetBooleanvCookie struct { + *xgb.Cookie +} + +func GetBooleanv(c *xgb.Conn, ContextTag ContextTag, Pname int32) GetBooleanvCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getBooleanvRequest(c, ContextTag, Pname), cookie) + return GetBooleanvCookie{cookie} +} + +func GetBooleanvUnchecked(c *xgb.Conn, ContextTag ContextTag, Pname int32) GetBooleanvCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getBooleanvRequest(c, ContextTag, Pname), cookie) + return GetBooleanvCookie{cookie} +} + +// Request reply for GetBooleanv +// size: (32 + xgb.Pad((int(N) * 1))) +type GetBooleanvReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum bool + // padding: 15 bytes + Data []bool // size: xgb.Pad((int(N) * 1)) +} + +// Waits and reads reply data from request GetBooleanv +func (cook GetBooleanvCookie) Reply() (*GetBooleanvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getBooleanvReply(buf), nil +} + +// Read reply into structure from buffer for GetBooleanv +func getBooleanvReply(buf []byte) *GetBooleanvReply { + v := new(GetBooleanvReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + if buf[b] == 1 { + v.Datum = true + } else { + v.Datum = false + } + b += 1 + + b += 15 // padding + + v.Data = make([]bool, v.N) + for i := 0; i < int(v.N); i++ { + if buf[b] == 1 { + v.Data[i] = true + } else { + v.Data[i] = false + } + b += 1 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetBooleanv +func getBooleanvRequest(c *xgb.Conn, ContextTag ContextTag, Pname int32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 112 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], uint32(Pname)) + b += 4 + + return buf +} + +// Request GetClipPlane +// size: 12 +type GetClipPlaneCookie struct { + *xgb.Cookie +} + +func GetClipPlane(c *xgb.Conn, ContextTag ContextTag, Plane int32) GetClipPlaneCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getClipPlaneRequest(c, ContextTag, Plane), cookie) + return GetClipPlaneCookie{cookie} +} + +func GetClipPlaneUnchecked(c *xgb.Conn, ContextTag ContextTag, Plane int32) GetClipPlaneCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getClipPlaneRequest(c, ContextTag, Plane), cookie) + return GetClipPlaneCookie{cookie} +} + +// Request reply for GetClipPlane +// size: (32 + xgb.Pad(((int(Length) / 2) * 8))) +type GetClipPlaneReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 24 bytes + Data []Float64 // size: xgb.Pad(((int(Length) / 2) * 8)) +} + +// Waits and reads reply data from request GetClipPlane +func (cook GetClipPlaneCookie) Reply() (*GetClipPlaneReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getClipPlaneReply(buf), nil +} + +// Read reply into structure from buffer for GetClipPlane +func getClipPlaneReply(buf []byte) *GetClipPlaneReply { + v := new(GetClipPlaneReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 24 // padding + + v.Data = make([]Float64, (int(v.Length) / 2)) + for i := 0; i < int((int(v.Length) / 2)); i++ { + v.Data[i] = Float64(xgb.Get64(buf[b:])) + b += 8 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetClipPlane +func getClipPlaneRequest(c *xgb.Conn, ContextTag ContextTag, Plane int32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 113 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], uint32(Plane)) + b += 4 + + return buf +} + +// Request GetDoublev +// size: 12 +type GetDoublevCookie struct { + *xgb.Cookie +} + +func GetDoublev(c *xgb.Conn, ContextTag ContextTag, Pname uint32) GetDoublevCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getDoublevRequest(c, ContextTag, Pname), cookie) + return GetDoublevCookie{cookie} +} + +func GetDoublevUnchecked(c *xgb.Conn, ContextTag ContextTag, Pname uint32) GetDoublevCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getDoublevRequest(c, ContextTag, Pname), cookie) + return GetDoublevCookie{cookie} +} + +// Request reply for GetDoublev +// size: (32 + xgb.Pad((int(N) * 8))) +type GetDoublevReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum Float64 + // padding: 8 bytes + Data []Float64 // size: xgb.Pad((int(N) * 8)) +} + +// Waits and reads reply data from request GetDoublev +func (cook GetDoublevCookie) Reply() (*GetDoublevReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDoublevReply(buf), nil +} + +// Read reply into structure from buffer for GetDoublev +func getDoublevReply(buf []byte) *GetDoublevReply { + v := new(GetDoublevReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = Float64(xgb.Get64(buf[b:])) + b += 8 + + b += 8 // padding + + v.Data = make([]Float64, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = Float64(xgb.Get64(buf[b:])) + b += 8 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetDoublev +func getDoublevRequest(c *xgb.Conn, ContextTag ContextTag, Pname uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 114 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetError +// size: 8 +type GetErrorCookie struct { + *xgb.Cookie +} + +func GetError(c *xgb.Conn, ContextTag ContextTag) GetErrorCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getErrorRequest(c, ContextTag), cookie) + return GetErrorCookie{cookie} +} + +func GetErrorUnchecked(c *xgb.Conn, ContextTag ContextTag) GetErrorCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getErrorRequest(c, ContextTag), cookie) + return GetErrorCookie{cookie} +} + +// Request reply for GetError +// size: 12 +type GetErrorReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Error int32 +} + +// Waits and reads reply data from request GetError +func (cook GetErrorCookie) Reply() (*GetErrorReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getErrorReply(buf), nil +} + +// Read reply into structure from buffer for GetError +func getErrorReply(buf []byte) *GetErrorReply { + v := new(GetErrorReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Error = int32(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Write request to wire for GetError +func getErrorRequest(c *xgb.Conn, ContextTag ContextTag) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 115 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + return buf +} + +// Request GetFloatv +// size: 12 +type GetFloatvCookie struct { + *xgb.Cookie +} + +func GetFloatv(c *xgb.Conn, ContextTag ContextTag, Pname uint32) GetFloatvCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getFloatvRequest(c, ContextTag, Pname), cookie) + return GetFloatvCookie{cookie} +} + +func GetFloatvUnchecked(c *xgb.Conn, ContextTag ContextTag, Pname uint32) GetFloatvCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getFloatvRequest(c, ContextTag, Pname), cookie) + return GetFloatvCookie{cookie} +} + +// Request reply for GetFloatv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetFloatvReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum Float32 + // padding: 12 bytes + Data []Float32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetFloatv +func (cook GetFloatvCookie) Reply() (*GetFloatvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getFloatvReply(buf), nil +} + +// Read reply into structure from buffer for GetFloatv +func getFloatvReply(buf []byte) *GetFloatvReply { + v := new(GetFloatvReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = Float32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]Float32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = Float32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetFloatv +func getFloatvRequest(c *xgb.Conn, ContextTag ContextTag, Pname uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 116 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetIntegerv +// size: 12 +type GetIntegervCookie struct { + *xgb.Cookie +} + +func GetIntegerv(c *xgb.Conn, ContextTag ContextTag, Pname uint32) GetIntegervCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getIntegervRequest(c, ContextTag, Pname), cookie) + return GetIntegervCookie{cookie} +} + +func GetIntegervUnchecked(c *xgb.Conn, ContextTag ContextTag, Pname uint32) GetIntegervCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getIntegervRequest(c, ContextTag, Pname), cookie) + return GetIntegervCookie{cookie} +} + +// Request reply for GetIntegerv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetIntegervReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetIntegerv +func (cook GetIntegervCookie) Reply() (*GetIntegervReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getIntegervReply(buf), nil +} + +// Read reply into structure from buffer for GetIntegerv +func getIntegervReply(buf []byte) *GetIntegervReply { + v := new(GetIntegervReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]int32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetIntegerv +func getIntegervRequest(c *xgb.Conn, ContextTag ContextTag, Pname uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 117 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetLightfv +// size: 16 +type GetLightfvCookie struct { + *xgb.Cookie +} + +func GetLightfv(c *xgb.Conn, ContextTag ContextTag, Light uint32, Pname uint32) GetLightfvCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getLightfvRequest(c, ContextTag, Light, Pname), cookie) + return GetLightfvCookie{cookie} +} + +func GetLightfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Light uint32, Pname uint32) GetLightfvCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getLightfvRequest(c, ContextTag, Light, Pname), cookie) + return GetLightfvCookie{cookie} +} + +// Request reply for GetLightfv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetLightfvReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum Float32 + // padding: 12 bytes + Data []Float32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetLightfv +func (cook GetLightfvCookie) Reply() (*GetLightfvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getLightfvReply(buf), nil +} + +// Read reply into structure from buffer for GetLightfv +func getLightfvReply(buf []byte) *GetLightfvReply { + v := new(GetLightfvReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = Float32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]Float32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = Float32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetLightfv +func getLightfvRequest(c *xgb.Conn, ContextTag ContextTag, Light uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 118 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Light) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetLightiv +// size: 16 +type GetLightivCookie struct { + *xgb.Cookie +} + +func GetLightiv(c *xgb.Conn, ContextTag ContextTag, Light uint32, Pname uint32) GetLightivCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getLightivRequest(c, ContextTag, Light, Pname), cookie) + return GetLightivCookie{cookie} +} + +func GetLightivUnchecked(c *xgb.Conn, ContextTag ContextTag, Light uint32, Pname uint32) GetLightivCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getLightivRequest(c, ContextTag, Light, Pname), cookie) + return GetLightivCookie{cookie} +} + +// Request reply for GetLightiv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetLightivReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetLightiv +func (cook GetLightivCookie) Reply() (*GetLightivReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getLightivReply(buf), nil +} + +// Read reply into structure from buffer for GetLightiv +func getLightivReply(buf []byte) *GetLightivReply { + v := new(GetLightivReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]int32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetLightiv +func getLightivRequest(c *xgb.Conn, ContextTag ContextTag, Light uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 119 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Light) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetMapdv +// size: 16 +type GetMapdvCookie struct { + *xgb.Cookie +} + +func GetMapdv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) GetMapdvCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getMapdvRequest(c, ContextTag, Target, Query), cookie) + return GetMapdvCookie{cookie} +} + +func GetMapdvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) GetMapdvCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getMapdvRequest(c, ContextTag, Target, Query), cookie) + return GetMapdvCookie{cookie} +} + +// Request reply for GetMapdv +// size: (32 + xgb.Pad((int(N) * 8))) +type GetMapdvReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum Float64 + // padding: 8 bytes + Data []Float64 // size: xgb.Pad((int(N) * 8)) +} + +// Waits and reads reply data from request GetMapdv +func (cook GetMapdvCookie) Reply() (*GetMapdvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getMapdvReply(buf), nil +} + +// Read reply into structure from buffer for GetMapdv +func getMapdvReply(buf []byte) *GetMapdvReply { + v := new(GetMapdvReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = Float64(xgb.Get64(buf[b:])) + b += 8 + + b += 8 // padding + + v.Data = make([]Float64, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = Float64(xgb.Get64(buf[b:])) + b += 8 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetMapdv +func getMapdvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 120 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Query) + b += 4 + + return buf +} + +// Request GetMapfv +// size: 16 +type GetMapfvCookie struct { + *xgb.Cookie +} + +func GetMapfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) GetMapfvCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getMapfvRequest(c, ContextTag, Target, Query), cookie) + return GetMapfvCookie{cookie} +} + +func GetMapfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) GetMapfvCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getMapfvRequest(c, ContextTag, Target, Query), cookie) + return GetMapfvCookie{cookie} +} + +// Request reply for GetMapfv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetMapfvReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum Float32 + // padding: 12 bytes + Data []Float32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetMapfv +func (cook GetMapfvCookie) Reply() (*GetMapfvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getMapfvReply(buf), nil +} + +// Read reply into structure from buffer for GetMapfv +func getMapfvReply(buf []byte) *GetMapfvReply { + v := new(GetMapfvReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = Float32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]Float32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = Float32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetMapfv +func getMapfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 121 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Query) + b += 4 + + return buf +} + +// Request GetMapiv +// size: 16 +type GetMapivCookie struct { + *xgb.Cookie +} + +func GetMapiv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) GetMapivCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getMapivRequest(c, ContextTag, Target, Query), cookie) + return GetMapivCookie{cookie} +} + +func GetMapivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) GetMapivCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getMapivRequest(c, ContextTag, Target, Query), cookie) + return GetMapivCookie{cookie} +} + +// Request reply for GetMapiv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetMapivReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetMapiv +func (cook GetMapivCookie) Reply() (*GetMapivReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getMapivReply(buf), nil +} + +// Read reply into structure from buffer for GetMapiv +func getMapivReply(buf []byte) *GetMapivReply { + v := new(GetMapivReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]int32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetMapiv +func getMapivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 122 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Query) + b += 4 + + return buf +} + +// Request GetMaterialfv +// size: 16 +type GetMaterialfvCookie struct { + *xgb.Cookie +} + +func GetMaterialfv(c *xgb.Conn, ContextTag ContextTag, Face uint32, Pname uint32) GetMaterialfvCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getMaterialfvRequest(c, ContextTag, Face, Pname), cookie) + return GetMaterialfvCookie{cookie} +} + +func GetMaterialfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Face uint32, Pname uint32) GetMaterialfvCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getMaterialfvRequest(c, ContextTag, Face, Pname), cookie) + return GetMaterialfvCookie{cookie} +} + +// Request reply for GetMaterialfv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetMaterialfvReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum Float32 + // padding: 12 bytes + Data []Float32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetMaterialfv +func (cook GetMaterialfvCookie) Reply() (*GetMaterialfvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getMaterialfvReply(buf), nil +} + +// Read reply into structure from buffer for GetMaterialfv +func getMaterialfvReply(buf []byte) *GetMaterialfvReply { + v := new(GetMaterialfvReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = Float32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]Float32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = Float32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetMaterialfv +func getMaterialfvRequest(c *xgb.Conn, ContextTag ContextTag, Face uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 123 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Face) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetMaterialiv +// size: 16 +type GetMaterialivCookie struct { + *xgb.Cookie +} + +func GetMaterialiv(c *xgb.Conn, ContextTag ContextTag, Face uint32, Pname uint32) GetMaterialivCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getMaterialivRequest(c, ContextTag, Face, Pname), cookie) + return GetMaterialivCookie{cookie} +} + +func GetMaterialivUnchecked(c *xgb.Conn, ContextTag ContextTag, Face uint32, Pname uint32) GetMaterialivCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getMaterialivRequest(c, ContextTag, Face, Pname), cookie) + return GetMaterialivCookie{cookie} +} + +// Request reply for GetMaterialiv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetMaterialivReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetMaterialiv +func (cook GetMaterialivCookie) Reply() (*GetMaterialivReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getMaterialivReply(buf), nil +} + +// Read reply into structure from buffer for GetMaterialiv +func getMaterialivReply(buf []byte) *GetMaterialivReply { + v := new(GetMaterialivReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]int32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetMaterialiv +func getMaterialivRequest(c *xgb.Conn, ContextTag ContextTag, Face uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 124 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Face) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetPixelMapfv +// size: 12 +type GetPixelMapfvCookie struct { + *xgb.Cookie +} + +func GetPixelMapfv(c *xgb.Conn, ContextTag ContextTag, Map uint32) GetPixelMapfvCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getPixelMapfvRequest(c, ContextTag, Map), cookie) + return GetPixelMapfvCookie{cookie} +} + +func GetPixelMapfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Map uint32) GetPixelMapfvCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getPixelMapfvRequest(c, ContextTag, Map), cookie) + return GetPixelMapfvCookie{cookie} +} + +// Request reply for GetPixelMapfv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetPixelMapfvReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum Float32 + // padding: 12 bytes + Data []Float32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetPixelMapfv +func (cook GetPixelMapfvCookie) Reply() (*GetPixelMapfvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPixelMapfvReply(buf), nil +} + +// Read reply into structure from buffer for GetPixelMapfv +func getPixelMapfvReply(buf []byte) *GetPixelMapfvReply { + v := new(GetPixelMapfvReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = Float32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]Float32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = Float32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetPixelMapfv +func getPixelMapfvRequest(c *xgb.Conn, ContextTag ContextTag, Map uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 125 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Map) + b += 4 + + return buf +} + +// Request GetPixelMapuiv +// size: 12 +type GetPixelMapuivCookie struct { + *xgb.Cookie +} + +func GetPixelMapuiv(c *xgb.Conn, ContextTag ContextTag, Map uint32) GetPixelMapuivCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getPixelMapuivRequest(c, ContextTag, Map), cookie) + return GetPixelMapuivCookie{cookie} +} + +func GetPixelMapuivUnchecked(c *xgb.Conn, ContextTag ContextTag, Map uint32) GetPixelMapuivCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getPixelMapuivRequest(c, ContextTag, Map), cookie) + return GetPixelMapuivCookie{cookie} +} + +// Request reply for GetPixelMapuiv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetPixelMapuivReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum uint32 + // padding: 12 bytes + Data []uint32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetPixelMapuiv +func (cook GetPixelMapuivCookie) Reply() (*GetPixelMapuivReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPixelMapuivReply(buf), nil +} + +// Read reply into structure from buffer for GetPixelMapuiv +func getPixelMapuivReply(buf []byte) *GetPixelMapuivReply { + v := new(GetPixelMapuivReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = xgb.Get32(buf[b:]) + b += 4 + + b += 12 // padding + + v.Data = make([]uint32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetPixelMapuiv +func getPixelMapuivRequest(c *xgb.Conn, ContextTag ContextTag, Map uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 126 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Map) + b += 4 + + return buf +} + +// Request GetPixelMapusv +// size: 12 +type GetPixelMapusvCookie struct { + *xgb.Cookie +} + +func GetPixelMapusv(c *xgb.Conn, ContextTag ContextTag, Map uint32) GetPixelMapusvCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getPixelMapusvRequest(c, ContextTag, Map), cookie) + return GetPixelMapusvCookie{cookie} +} + +func GetPixelMapusvUnchecked(c *xgb.Conn, ContextTag ContextTag, Map uint32) GetPixelMapusvCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getPixelMapusvRequest(c, ContextTag, Map), cookie) + return GetPixelMapusvCookie{cookie} +} + +// Request reply for GetPixelMapusv +// size: (34 + xgb.Pad((int(N) * 2))) +type GetPixelMapusvReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum uint16 + // padding: 16 bytes + Data []uint16 // size: xgb.Pad((int(N) * 2)) +} + +// Waits and reads reply data from request GetPixelMapusv +func (cook GetPixelMapusvCookie) Reply() (*GetPixelMapusvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPixelMapusvReply(buf), nil +} + +// Read reply into structure from buffer for GetPixelMapusv +func getPixelMapusvReply(buf []byte) *GetPixelMapusvReply { + v := new(GetPixelMapusvReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = xgb.Get16(buf[b:]) + b += 2 + + b += 16 // padding + + v.Data = make([]uint16, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetPixelMapusv +func getPixelMapusvRequest(c *xgb.Conn, ContextTag ContextTag, Map uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 127 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Map) + b += 4 + + return buf +} + +// Request GetPolygonStipple +// size: 12 +type GetPolygonStippleCookie struct { + *xgb.Cookie +} + +func GetPolygonStipple(c *xgb.Conn, ContextTag ContextTag, LsbFirst bool) GetPolygonStippleCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getPolygonStippleRequest(c, ContextTag, LsbFirst), cookie) + return GetPolygonStippleCookie{cookie} +} + +func GetPolygonStippleUnchecked(c *xgb.Conn, ContextTag ContextTag, LsbFirst bool) GetPolygonStippleCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getPolygonStippleRequest(c, ContextTag, LsbFirst), cookie) + return GetPolygonStippleCookie{cookie} +} + +// Request reply for GetPolygonStipple +// size: (32 + xgb.Pad(((int(Length) * 4) * 1))) +type GetPolygonStippleReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 24 bytes + Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) +} + +// Waits and reads reply data from request GetPolygonStipple +func (cook GetPolygonStippleCookie) Reply() (*GetPolygonStippleReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPolygonStippleReply(buf), nil +} + +// Read reply into structure from buffer for GetPolygonStipple +func getPolygonStippleReply(buf []byte) *GetPolygonStippleReply { + v := new(GetPolygonStippleReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 24 // padding + + v.Data = make([]byte, (int(v.Length) * 4)) + copy(v.Data[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) + + return v +} + +// Write request to wire for GetPolygonStipple +func getPolygonStippleRequest(c *xgb.Conn, ContextTag ContextTag, LsbFirst bool) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 128 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + if LsbFirst { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + return buf +} + +// Request GetString +// size: 12 +type GetStringCookie struct { + *xgb.Cookie +} + +func GetString(c *xgb.Conn, ContextTag ContextTag, Name uint32) GetStringCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getStringRequest(c, ContextTag, Name), cookie) + return GetStringCookie{cookie} +} + +func GetStringUnchecked(c *xgb.Conn, ContextTag ContextTag, Name uint32) GetStringCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getStringRequest(c, ContextTag, Name), cookie) + return GetStringCookie{cookie} +} + +// Request reply for GetString +// size: (32 + xgb.Pad((int(N) * 1))) +type GetStringReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + // padding: 16 bytes + String string // size: xgb.Pad((int(N) * 1)) +} + +// Waits and reads reply data from request GetString +func (cook GetStringCookie) Reply() (*GetStringReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getStringReply(buf), nil +} + +// Read reply into structure from buffer for GetString +func getStringReply(buf []byte) *GetStringReply { + v := new(GetStringReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + b += 16 // padding + + { + byteString := make([]byte, v.N) + copy(byteString[:v.N], buf[b:]) + v.String = string(byteString) + b += xgb.Pad(int(v.N)) + } + + return v +} + +// Write request to wire for GetString +func getStringRequest(c *xgb.Conn, ContextTag ContextTag, Name uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 129 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Name) + b += 4 + + return buf +} + +// Request GetTexEnvfv +// size: 16 +type GetTexEnvfvCookie struct { + *xgb.Cookie +} + +func GetTexEnvfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetTexEnvfvCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getTexEnvfvRequest(c, ContextTag, Target, Pname), cookie) + return GetTexEnvfvCookie{cookie} +} + +func GetTexEnvfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetTexEnvfvCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getTexEnvfvRequest(c, ContextTag, Target, Pname), cookie) + return GetTexEnvfvCookie{cookie} +} + +// Request reply for GetTexEnvfv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetTexEnvfvReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum Float32 + // padding: 12 bytes + Data []Float32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetTexEnvfv +func (cook GetTexEnvfvCookie) Reply() (*GetTexEnvfvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getTexEnvfvReply(buf), nil +} + +// Read reply into structure from buffer for GetTexEnvfv +func getTexEnvfvReply(buf []byte) *GetTexEnvfvReply { + v := new(GetTexEnvfvReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = Float32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]Float32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = Float32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetTexEnvfv +func getTexEnvfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 130 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetTexEnviv +// size: 16 +type GetTexEnvivCookie struct { + *xgb.Cookie +} + +func GetTexEnviv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetTexEnvivCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getTexEnvivRequest(c, ContextTag, Target, Pname), cookie) + return GetTexEnvivCookie{cookie} +} + +func GetTexEnvivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetTexEnvivCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getTexEnvivRequest(c, ContextTag, Target, Pname), cookie) + return GetTexEnvivCookie{cookie} +} + +// Request reply for GetTexEnviv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetTexEnvivReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetTexEnviv +func (cook GetTexEnvivCookie) Reply() (*GetTexEnvivReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getTexEnvivReply(buf), nil +} + +// Read reply into structure from buffer for GetTexEnviv +func getTexEnvivReply(buf []byte) *GetTexEnvivReply { + v := new(GetTexEnvivReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]int32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetTexEnviv +func getTexEnvivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 131 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetTexGendv +// size: 16 +type GetTexGendvCookie struct { + *xgb.Cookie +} + +func GetTexGendv(c *xgb.Conn, ContextTag ContextTag, Coord uint32, Pname uint32) GetTexGendvCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getTexGendvRequest(c, ContextTag, Coord, Pname), cookie) + return GetTexGendvCookie{cookie} +} + +func GetTexGendvUnchecked(c *xgb.Conn, ContextTag ContextTag, Coord uint32, Pname uint32) GetTexGendvCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getTexGendvRequest(c, ContextTag, Coord, Pname), cookie) + return GetTexGendvCookie{cookie} +} + +// Request reply for GetTexGendv +// size: (32 + xgb.Pad((int(N) * 8))) +type GetTexGendvReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum Float64 + // padding: 8 bytes + Data []Float64 // size: xgb.Pad((int(N) * 8)) +} + +// Waits and reads reply data from request GetTexGendv +func (cook GetTexGendvCookie) Reply() (*GetTexGendvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getTexGendvReply(buf), nil +} + +// Read reply into structure from buffer for GetTexGendv +func getTexGendvReply(buf []byte) *GetTexGendvReply { + v := new(GetTexGendvReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = Float64(xgb.Get64(buf[b:])) + b += 8 + + b += 8 // padding + + v.Data = make([]Float64, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = Float64(xgb.Get64(buf[b:])) + b += 8 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetTexGendv +func getTexGendvRequest(c *xgb.Conn, ContextTag ContextTag, Coord uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 132 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Coord) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetTexGenfv +// size: 16 +type GetTexGenfvCookie struct { + *xgb.Cookie +} + +func GetTexGenfv(c *xgb.Conn, ContextTag ContextTag, Coord uint32, Pname uint32) GetTexGenfvCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getTexGenfvRequest(c, ContextTag, Coord, Pname), cookie) + return GetTexGenfvCookie{cookie} +} + +func GetTexGenfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Coord uint32, Pname uint32) GetTexGenfvCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getTexGenfvRequest(c, ContextTag, Coord, Pname), cookie) + return GetTexGenfvCookie{cookie} +} + +// Request reply for GetTexGenfv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetTexGenfvReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum Float32 + // padding: 12 bytes + Data []Float32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetTexGenfv +func (cook GetTexGenfvCookie) Reply() (*GetTexGenfvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getTexGenfvReply(buf), nil +} + +// Read reply into structure from buffer for GetTexGenfv +func getTexGenfvReply(buf []byte) *GetTexGenfvReply { + v := new(GetTexGenfvReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = Float32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]Float32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = Float32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetTexGenfv +func getTexGenfvRequest(c *xgb.Conn, ContextTag ContextTag, Coord uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 133 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Coord) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetTexGeniv +// size: 16 +type GetTexGenivCookie struct { + *xgb.Cookie +} + +func GetTexGeniv(c *xgb.Conn, ContextTag ContextTag, Coord uint32, Pname uint32) GetTexGenivCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getTexGenivRequest(c, ContextTag, Coord, Pname), cookie) + return GetTexGenivCookie{cookie} +} + +func GetTexGenivUnchecked(c *xgb.Conn, ContextTag ContextTag, Coord uint32, Pname uint32) GetTexGenivCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getTexGenivRequest(c, ContextTag, Coord, Pname), cookie) + return GetTexGenivCookie{cookie} +} + +// Request reply for GetTexGeniv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetTexGenivReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetTexGeniv +func (cook GetTexGenivCookie) Reply() (*GetTexGenivReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getTexGenivReply(buf), nil +} + +// Read reply into structure from buffer for GetTexGeniv +func getTexGenivReply(buf []byte) *GetTexGenivReply { + v := new(GetTexGenivReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]int32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetTexGeniv +func getTexGenivRequest(c *xgb.Conn, ContextTag ContextTag, Coord uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 134 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Coord) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetTexImage +// size: 28 +type GetTexImageCookie struct { + *xgb.Cookie +} + +func GetTexImage(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Format uint32, Type uint32, SwapBytes bool) GetTexImageCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getTexImageRequest(c, ContextTag, Target, Level, Format, Type, SwapBytes), cookie) + return GetTexImageCookie{cookie} +} + +func GetTexImageUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Format uint32, Type uint32, SwapBytes bool) GetTexImageCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getTexImageRequest(c, ContextTag, Target, Level, Format, Type, SwapBytes), cookie) + return GetTexImageCookie{cookie} +} + +// Request reply for GetTexImage +// size: (32 + xgb.Pad(((int(Length) * 4) * 1))) +type GetTexImageReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 8 bytes + Width int32 + Height int32 + Depth int32 + // padding: 4 bytes + Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) +} + +// Waits and reads reply data from request GetTexImage +func (cook GetTexImageCookie) Reply() (*GetTexImageReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getTexImageReply(buf), nil +} + +// Read reply into structure from buffer for GetTexImage +func getTexImageReply(buf []byte) *GetTexImageReply { + v := new(GetTexImageReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 8 // padding + + v.Width = int32(xgb.Get32(buf[b:])) + b += 4 + + v.Height = int32(xgb.Get32(buf[b:])) + b += 4 + + v.Depth = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 4 // padding + + v.Data = make([]byte, (int(v.Length) * 4)) + copy(v.Data[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) + + return v +} + +// Write request to wire for GetTexImage +func getTexImageRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Format uint32, Type uint32, SwapBytes bool) []byte { + size := 28 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 135 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], uint32(Level)) + b += 4 + + xgb.Put32(buf[b:], Format) + b += 4 + + xgb.Put32(buf[b:], Type) + b += 4 + + if SwapBytes { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + return buf +} + +// Request GetTexParameterfv +// size: 16 +type GetTexParameterfvCookie struct { + *xgb.Cookie +} + +func GetTexParameterfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetTexParameterfvCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getTexParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetTexParameterfvCookie{cookie} +} + +func GetTexParameterfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetTexParameterfvCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getTexParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetTexParameterfvCookie{cookie} +} + +// Request reply for GetTexParameterfv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetTexParameterfvReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum Float32 + // padding: 12 bytes + Data []Float32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetTexParameterfv +func (cook GetTexParameterfvCookie) Reply() (*GetTexParameterfvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getTexParameterfvReply(buf), nil +} + +// Read reply into structure from buffer for GetTexParameterfv +func getTexParameterfvReply(buf []byte) *GetTexParameterfvReply { + v := new(GetTexParameterfvReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = Float32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]Float32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = Float32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetTexParameterfv +func getTexParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 136 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetTexParameteriv +// size: 16 +type GetTexParameterivCookie struct { + *xgb.Cookie +} + +func GetTexParameteriv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetTexParameterivCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getTexParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetTexParameterivCookie{cookie} +} + +func GetTexParameterivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetTexParameterivCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getTexParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetTexParameterivCookie{cookie} +} + +// Request reply for GetTexParameteriv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetTexParameterivReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetTexParameteriv +func (cook GetTexParameterivCookie) Reply() (*GetTexParameterivReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getTexParameterivReply(buf), nil +} + +// Read reply into structure from buffer for GetTexParameteriv +func getTexParameterivReply(buf []byte) *GetTexParameterivReply { + v := new(GetTexParameterivReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]int32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetTexParameteriv +func getTexParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 137 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetTexLevelParameterfv +// size: 20 +type GetTexLevelParameterfvCookie struct { + *xgb.Cookie +} + +func GetTexLevelParameterfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Pname uint32) GetTexLevelParameterfvCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getTexLevelParameterfvRequest(c, ContextTag, Target, Level, Pname), cookie) + return GetTexLevelParameterfvCookie{cookie} +} + +func GetTexLevelParameterfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Pname uint32) GetTexLevelParameterfvCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getTexLevelParameterfvRequest(c, ContextTag, Target, Level, Pname), cookie) + return GetTexLevelParameterfvCookie{cookie} +} + +// Request reply for GetTexLevelParameterfv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetTexLevelParameterfvReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum Float32 + // padding: 12 bytes + Data []Float32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetTexLevelParameterfv +func (cook GetTexLevelParameterfvCookie) Reply() (*GetTexLevelParameterfvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getTexLevelParameterfvReply(buf), nil +} + +// Read reply into structure from buffer for GetTexLevelParameterfv +func getTexLevelParameterfvReply(buf []byte) *GetTexLevelParameterfvReply { + v := new(GetTexLevelParameterfvReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = Float32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]Float32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = Float32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetTexLevelParameterfv +func getTexLevelParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Pname uint32) []byte { + size := 20 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 138 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], uint32(Level)) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetTexLevelParameteriv +// size: 20 +type GetTexLevelParameterivCookie struct { + *xgb.Cookie +} + +func GetTexLevelParameteriv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Pname uint32) GetTexLevelParameterivCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getTexLevelParameterivRequest(c, ContextTag, Target, Level, Pname), cookie) + return GetTexLevelParameterivCookie{cookie} +} + +func GetTexLevelParameterivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Pname uint32) GetTexLevelParameterivCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getTexLevelParameterivRequest(c, ContextTag, Target, Level, Pname), cookie) + return GetTexLevelParameterivCookie{cookie} +} + +// Request reply for GetTexLevelParameteriv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetTexLevelParameterivReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetTexLevelParameteriv +func (cook GetTexLevelParameterivCookie) Reply() (*GetTexLevelParameterivReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getTexLevelParameterivReply(buf), nil +} + +// Read reply into structure from buffer for GetTexLevelParameteriv +func getTexLevelParameterivReply(buf []byte) *GetTexLevelParameterivReply { + v := new(GetTexLevelParameterivReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]int32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetTexLevelParameteriv +func getTexLevelParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Pname uint32) []byte { + size := 20 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 139 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], uint32(Level)) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request IsList +// size: 12 +type IsListCookie struct { + *xgb.Cookie +} + +func IsList(c *xgb.Conn, ContextTag ContextTag, List uint32) IsListCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(isListRequest(c, ContextTag, List), cookie) + return IsListCookie{cookie} +} + +func IsListUnchecked(c *xgb.Conn, ContextTag ContextTag, List uint32) IsListCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(isListRequest(c, ContextTag, List), cookie) + return IsListCookie{cookie} +} + +// Request reply for IsList +// size: 12 +type IsListReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + RetVal Bool32 +} + +// Waits and reads reply data from request IsList +func (cook IsListCookie) Reply() (*IsListReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return isListReply(buf), nil +} + +// Read reply into structure from buffer for IsList +func isListReply(buf []byte) *IsListReply { + v := new(IsListReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.RetVal = Bool32(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Write request to wire for IsList +func isListRequest(c *xgb.Conn, ContextTag ContextTag, List uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 141 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], List) + b += 4 + + return buf +} + +// Request Flush +// size: 8 +type FlushCookie struct { + *xgb.Cookie +} + +// Write request to wire for Flush +func Flush(c *xgb.Conn, ContextTag ContextTag) FlushCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(flushRequest(c, ContextTag), cookie) + return FlushCookie{cookie} +} + +func FlushChecked(c *xgb.Conn, ContextTag ContextTag) FlushCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(flushRequest(c, ContextTag), cookie) + return FlushCookie{cookie} +} + +func (cook FlushCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for Flush +func flushRequest(c *xgb.Conn, ContextTag ContextTag) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 142 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + return buf +} + +// Request AreTexturesResident +// size: xgb.Pad((12 + xgb.Pad((int(N) * 4)))) +type AreTexturesResidentCookie struct { + *xgb.Cookie +} + +func AreTexturesResident(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) AreTexturesResidentCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(areTexturesResidentRequest(c, ContextTag, N, Textures), cookie) + return AreTexturesResidentCookie{cookie} +} + +func AreTexturesResidentUnchecked(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) AreTexturesResidentCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(areTexturesResidentRequest(c, ContextTag, N, Textures), cookie) + return AreTexturesResidentCookie{cookie} +} + +// Request reply for AreTexturesResident +// size: (32 + xgb.Pad(((int(Length) * 4) * 1))) +type AreTexturesResidentReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + RetVal Bool32 + // padding: 20 bytes + Data []bool // size: xgb.Pad(((int(Length) * 4) * 1)) +} + +// Waits and reads reply data from request AreTexturesResident +func (cook AreTexturesResidentCookie) Reply() (*AreTexturesResidentReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return areTexturesResidentReply(buf), nil +} + +// Read reply into structure from buffer for AreTexturesResident +func areTexturesResidentReply(buf []byte) *AreTexturesResidentReply { + v := new(AreTexturesResidentReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.RetVal = Bool32(xgb.Get32(buf[b:])) + b += 4 + + b += 20 // padding + + v.Data = make([]bool, (int(v.Length) * 4)) + for i := 0; i < int((int(v.Length) * 4)); i++ { + if buf[b] == 1 { + v.Data[i] = true + } else { + v.Data[i] = false + } + b += 1 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for AreTexturesResident +func areTexturesResidentRequest(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) []byte { + size := xgb.Pad((12 + xgb.Pad((int(N) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 143 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], uint32(N)) + b += 4 + + for i := 0; i < int(N); i++ { + xgb.Put32(buf[b:], Textures[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request DeleteTextures +// size: xgb.Pad((12 + xgb.Pad((int(N) * 4)))) +type DeleteTexturesCookie struct { + *xgb.Cookie +} + +// Write request to wire for DeleteTextures +func DeleteTextures(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) DeleteTexturesCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(deleteTexturesRequest(c, ContextTag, N, Textures), cookie) + return DeleteTexturesCookie{cookie} +} + +func DeleteTexturesChecked(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) DeleteTexturesCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(deleteTexturesRequest(c, ContextTag, N, Textures), cookie) + return DeleteTexturesCookie{cookie} +} + +func (cook DeleteTexturesCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DeleteTextures +func deleteTexturesRequest(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) []byte { + size := xgb.Pad((12 + xgb.Pad((int(N) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 144 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], uint32(N)) + b += 4 + + for i := 0; i < int(N); i++ { + xgb.Put32(buf[b:], Textures[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request GenTextures +// size: 12 +type GenTexturesCookie struct { + *xgb.Cookie +} + +func GenTextures(c *xgb.Conn, ContextTag ContextTag, N int32) GenTexturesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(genTexturesRequest(c, ContextTag, N), cookie) + return GenTexturesCookie{cookie} +} + +func GenTexturesUnchecked(c *xgb.Conn, ContextTag ContextTag, N int32) GenTexturesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(genTexturesRequest(c, ContextTag, N), cookie) + return GenTexturesCookie{cookie} +} + +// Request reply for GenTextures +// size: (32 + xgb.Pad((int(Length) * 4))) +type GenTexturesReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 24 bytes + Data []uint32 // size: xgb.Pad((int(Length) * 4)) +} + +// Waits and reads reply data from request GenTextures +func (cook GenTexturesCookie) Reply() (*GenTexturesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return genTexturesReply(buf), nil +} + +// Read reply into structure from buffer for GenTextures +func genTexturesReply(buf []byte) *GenTexturesReply { + v := new(GenTexturesReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 24 // padding + + v.Data = make([]uint32, v.Length) + for i := 0; i < int(v.Length); i++ { + v.Data[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GenTextures +func genTexturesRequest(c *xgb.Conn, ContextTag ContextTag, N int32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 145 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], uint32(N)) + b += 4 + + return buf +} + +// Request IsTexture +// size: 12 +type IsTextureCookie struct { + *xgb.Cookie +} + +func IsTexture(c *xgb.Conn, ContextTag ContextTag, Texture uint32) IsTextureCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(isTextureRequest(c, ContextTag, Texture), cookie) + return IsTextureCookie{cookie} +} + +func IsTextureUnchecked(c *xgb.Conn, ContextTag ContextTag, Texture uint32) IsTextureCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(isTextureRequest(c, ContextTag, Texture), cookie) + return IsTextureCookie{cookie} +} + +// Request reply for IsTexture +// size: 12 +type IsTextureReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + RetVal Bool32 +} + +// Waits and reads reply data from request IsTexture +func (cook IsTextureCookie) Reply() (*IsTextureReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return isTextureReply(buf), nil +} + +// Read reply into structure from buffer for IsTexture +func isTextureReply(buf []byte) *IsTextureReply { + v := new(IsTextureReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.RetVal = Bool32(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Write request to wire for IsTexture +func isTextureRequest(c *xgb.Conn, ContextTag ContextTag, Texture uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 146 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Texture) + b += 4 + + return buf +} + +// Request GetColorTable +// size: 24 +type GetColorTableCookie struct { + *xgb.Cookie +} + +func GetColorTable(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetColorTableCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getColorTableRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) + return GetColorTableCookie{cookie} +} + +func GetColorTableUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetColorTableCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getColorTableRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) + return GetColorTableCookie{cookie} +} + +// Request reply for GetColorTable +// size: (32 + xgb.Pad(((int(Length) * 4) * 1))) +type GetColorTableReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 8 bytes + Width int32 + // padding: 12 bytes + Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) +} + +// Waits and reads reply data from request GetColorTable +func (cook GetColorTableCookie) Reply() (*GetColorTableReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getColorTableReply(buf), nil +} + +// Read reply into structure from buffer for GetColorTable +func getColorTableReply(buf []byte) *GetColorTableReply { + v := new(GetColorTableReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 8 // padding + + v.Width = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]byte, (int(v.Length) * 4)) + copy(v.Data[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) + + return v +} + +// Write request to wire for GetColorTable +func getColorTableRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) []byte { + size := 24 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 147 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Format) + b += 4 + + xgb.Put32(buf[b:], Type) + b += 4 + + if SwapBytes { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + return buf +} + +// Request GetColorTableParameterfv +// size: 16 +type GetColorTableParameterfvCookie struct { + *xgb.Cookie +} + +func GetColorTableParameterfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetColorTableParameterfvCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getColorTableParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetColorTableParameterfvCookie{cookie} +} + +func GetColorTableParameterfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetColorTableParameterfvCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getColorTableParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetColorTableParameterfvCookie{cookie} +} + +// Request reply for GetColorTableParameterfv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetColorTableParameterfvReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum Float32 + // padding: 12 bytes + Data []Float32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetColorTableParameterfv +func (cook GetColorTableParameterfvCookie) Reply() (*GetColorTableParameterfvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getColorTableParameterfvReply(buf), nil +} + +// Read reply into structure from buffer for GetColorTableParameterfv +func getColorTableParameterfvReply(buf []byte) *GetColorTableParameterfvReply { + v := new(GetColorTableParameterfvReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = Float32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]Float32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = Float32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetColorTableParameterfv +func getColorTableParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 148 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetColorTableParameteriv +// size: 16 +type GetColorTableParameterivCookie struct { + *xgb.Cookie +} + +func GetColorTableParameteriv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetColorTableParameterivCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getColorTableParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetColorTableParameterivCookie{cookie} +} + +func GetColorTableParameterivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetColorTableParameterivCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getColorTableParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetColorTableParameterivCookie{cookie} +} + +// Request reply for GetColorTableParameteriv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetColorTableParameterivReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetColorTableParameteriv +func (cook GetColorTableParameterivCookie) Reply() (*GetColorTableParameterivReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getColorTableParameterivReply(buf), nil +} + +// Read reply into structure from buffer for GetColorTableParameteriv +func getColorTableParameterivReply(buf []byte) *GetColorTableParameterivReply { + v := new(GetColorTableParameterivReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]int32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetColorTableParameteriv +func getColorTableParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 149 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetConvolutionFilter +// size: 24 +type GetConvolutionFilterCookie struct { + *xgb.Cookie +} + +func GetConvolutionFilter(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetConvolutionFilterCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getConvolutionFilterRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) + return GetConvolutionFilterCookie{cookie} +} + +func GetConvolutionFilterUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetConvolutionFilterCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getConvolutionFilterRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) + return GetConvolutionFilterCookie{cookie} +} + +// Request reply for GetConvolutionFilter +// size: (32 + xgb.Pad(((int(Length) * 4) * 1))) +type GetConvolutionFilterReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 8 bytes + Width int32 + Height int32 + // padding: 8 bytes + Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) +} + +// Waits and reads reply data from request GetConvolutionFilter +func (cook GetConvolutionFilterCookie) Reply() (*GetConvolutionFilterReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getConvolutionFilterReply(buf), nil +} + +// Read reply into structure from buffer for GetConvolutionFilter +func getConvolutionFilterReply(buf []byte) *GetConvolutionFilterReply { + v := new(GetConvolutionFilterReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 8 // padding + + v.Width = int32(xgb.Get32(buf[b:])) + b += 4 + + v.Height = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 8 // padding + + v.Data = make([]byte, (int(v.Length) * 4)) + copy(v.Data[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) + + return v +} + +// Write request to wire for GetConvolutionFilter +func getConvolutionFilterRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) []byte { + size := 24 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 150 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Format) + b += 4 + + xgb.Put32(buf[b:], Type) + b += 4 + + if SwapBytes { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + return buf +} + +// Request GetConvolutionParameterfv +// size: 16 +type GetConvolutionParameterfvCookie struct { + *xgb.Cookie +} + +func GetConvolutionParameterfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetConvolutionParameterfvCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getConvolutionParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetConvolutionParameterfvCookie{cookie} +} + +func GetConvolutionParameterfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetConvolutionParameterfvCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getConvolutionParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetConvolutionParameterfvCookie{cookie} +} + +// Request reply for GetConvolutionParameterfv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetConvolutionParameterfvReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum Float32 + // padding: 12 bytes + Data []Float32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetConvolutionParameterfv +func (cook GetConvolutionParameterfvCookie) Reply() (*GetConvolutionParameterfvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getConvolutionParameterfvReply(buf), nil +} + +// Read reply into structure from buffer for GetConvolutionParameterfv +func getConvolutionParameterfvReply(buf []byte) *GetConvolutionParameterfvReply { + v := new(GetConvolutionParameterfvReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = Float32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]Float32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = Float32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetConvolutionParameterfv +func getConvolutionParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 151 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetConvolutionParameteriv +// size: 16 +type GetConvolutionParameterivCookie struct { + *xgb.Cookie +} + +func GetConvolutionParameteriv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetConvolutionParameterivCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getConvolutionParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetConvolutionParameterivCookie{cookie} +} + +func GetConvolutionParameterivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetConvolutionParameterivCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getConvolutionParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetConvolutionParameterivCookie{cookie} +} + +// Request reply for GetConvolutionParameteriv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetConvolutionParameterivReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetConvolutionParameteriv +func (cook GetConvolutionParameterivCookie) Reply() (*GetConvolutionParameterivReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getConvolutionParameterivReply(buf), nil +} + +// Read reply into structure from buffer for GetConvolutionParameteriv +func getConvolutionParameterivReply(buf []byte) *GetConvolutionParameterivReply { + v := new(GetConvolutionParameterivReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]int32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetConvolutionParameteriv +func getConvolutionParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 152 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetSeparableFilter +// size: 24 +type GetSeparableFilterCookie struct { + *xgb.Cookie +} + +func GetSeparableFilter(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetSeparableFilterCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getSeparableFilterRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) + return GetSeparableFilterCookie{cookie} +} + +func GetSeparableFilterUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetSeparableFilterCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getSeparableFilterRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) + return GetSeparableFilterCookie{cookie} +} + +// Request reply for GetSeparableFilter +// size: (32 + xgb.Pad(((int(Length) * 4) * 1))) +type GetSeparableFilterReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 8 bytes + RowW int32 + ColH int32 + // padding: 8 bytes + RowsAndCols []byte // size: xgb.Pad(((int(Length) * 4) * 1)) +} + +// Waits and reads reply data from request GetSeparableFilter +func (cook GetSeparableFilterCookie) Reply() (*GetSeparableFilterReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getSeparableFilterReply(buf), nil +} + +// Read reply into structure from buffer for GetSeparableFilter +func getSeparableFilterReply(buf []byte) *GetSeparableFilterReply { + v := new(GetSeparableFilterReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 8 // padding + + v.RowW = int32(xgb.Get32(buf[b:])) + b += 4 + + v.ColH = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 8 // padding + + v.RowsAndCols = make([]byte, (int(v.Length) * 4)) + copy(v.RowsAndCols[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) + + return v +} + +// Write request to wire for GetSeparableFilter +func getSeparableFilterRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) []byte { + size := 24 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 153 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Format) + b += 4 + + xgb.Put32(buf[b:], Type) + b += 4 + + if SwapBytes { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + return buf +} + +// Request GetHistogram +// size: 24 +type GetHistogramCookie struct { + *xgb.Cookie +} + +func GetHistogram(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) GetHistogramCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getHistogramRequest(c, ContextTag, Target, Format, Type, SwapBytes, Reset), cookie) + return GetHistogramCookie{cookie} +} + +func GetHistogramUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) GetHistogramCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getHistogramRequest(c, ContextTag, Target, Format, Type, SwapBytes, Reset), cookie) + return GetHistogramCookie{cookie} +} + +// Request reply for GetHistogram +// size: (32 + xgb.Pad(((int(Length) * 4) * 1))) +type GetHistogramReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 8 bytes + Width int32 + // padding: 12 bytes + Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) +} + +// Waits and reads reply data from request GetHistogram +func (cook GetHistogramCookie) Reply() (*GetHistogramReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getHistogramReply(buf), nil +} + +// Read reply into structure from buffer for GetHistogram +func getHistogramReply(buf []byte) *GetHistogramReply { + v := new(GetHistogramReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 8 // padding + + v.Width = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]byte, (int(v.Length) * 4)) + copy(v.Data[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) + + return v +} + +// Write request to wire for GetHistogram +func getHistogramRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) []byte { + size := 24 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 154 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Format) + b += 4 + + xgb.Put32(buf[b:], Type) + b += 4 + + if SwapBytes { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + if Reset { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + return buf +} + +// Request GetHistogramParameterfv +// size: 16 +type GetHistogramParameterfvCookie struct { + *xgb.Cookie +} + +func GetHistogramParameterfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetHistogramParameterfvCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getHistogramParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetHistogramParameterfvCookie{cookie} +} + +func GetHistogramParameterfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetHistogramParameterfvCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getHistogramParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetHistogramParameterfvCookie{cookie} +} + +// Request reply for GetHistogramParameterfv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetHistogramParameterfvReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum Float32 + // padding: 12 bytes + Data []Float32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetHistogramParameterfv +func (cook GetHistogramParameterfvCookie) Reply() (*GetHistogramParameterfvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getHistogramParameterfvReply(buf), nil +} + +// Read reply into structure from buffer for GetHistogramParameterfv +func getHistogramParameterfvReply(buf []byte) *GetHistogramParameterfvReply { + v := new(GetHistogramParameterfvReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = Float32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]Float32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = Float32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetHistogramParameterfv +func getHistogramParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 155 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetHistogramParameteriv +// size: 16 +type GetHistogramParameterivCookie struct { + *xgb.Cookie +} + +func GetHistogramParameteriv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetHistogramParameterivCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getHistogramParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetHistogramParameterivCookie{cookie} +} + +func GetHistogramParameterivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetHistogramParameterivCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getHistogramParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetHistogramParameterivCookie{cookie} +} + +// Request reply for GetHistogramParameteriv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetHistogramParameterivReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetHistogramParameteriv +func (cook GetHistogramParameterivCookie) Reply() (*GetHistogramParameterivReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getHistogramParameterivReply(buf), nil +} + +// Read reply into structure from buffer for GetHistogramParameteriv +func getHistogramParameterivReply(buf []byte) *GetHistogramParameterivReply { + v := new(GetHistogramParameterivReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]int32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetHistogramParameteriv +func getHistogramParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 156 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetMinmax +// size: 24 +type GetMinmaxCookie struct { + *xgb.Cookie +} + +func GetMinmax(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) GetMinmaxCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getMinmaxRequest(c, ContextTag, Target, Format, Type, SwapBytes, Reset), cookie) + return GetMinmaxCookie{cookie} +} + +func GetMinmaxUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) GetMinmaxCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getMinmaxRequest(c, ContextTag, Target, Format, Type, SwapBytes, Reset), cookie) + return GetMinmaxCookie{cookie} +} + +// Request reply for GetMinmax +// size: (32 + xgb.Pad(((int(Length) * 4) * 1))) +type GetMinmaxReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 24 bytes + Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) +} + +// Waits and reads reply data from request GetMinmax +func (cook GetMinmaxCookie) Reply() (*GetMinmaxReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getMinmaxReply(buf), nil +} + +// Read reply into structure from buffer for GetMinmax +func getMinmaxReply(buf []byte) *GetMinmaxReply { + v := new(GetMinmaxReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 24 // padding + + v.Data = make([]byte, (int(v.Length) * 4)) + copy(v.Data[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) + + return v +} + +// Write request to wire for GetMinmax +func getMinmaxRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) []byte { + size := 24 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 157 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Format) + b += 4 + + xgb.Put32(buf[b:], Type) + b += 4 + + if SwapBytes { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + if Reset { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + return buf +} + +// Request GetMinmaxParameterfv +// size: 16 +type GetMinmaxParameterfvCookie struct { + *xgb.Cookie +} + +func GetMinmaxParameterfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetMinmaxParameterfvCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getMinmaxParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetMinmaxParameterfvCookie{cookie} +} + +func GetMinmaxParameterfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetMinmaxParameterfvCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getMinmaxParameterfvRequest(c, ContextTag, Target, Pname), cookie) + return GetMinmaxParameterfvCookie{cookie} +} + +// Request reply for GetMinmaxParameterfv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetMinmaxParameterfvReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum Float32 + // padding: 12 bytes + Data []Float32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetMinmaxParameterfv +func (cook GetMinmaxParameterfvCookie) Reply() (*GetMinmaxParameterfvReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getMinmaxParameterfvReply(buf), nil +} + +// Read reply into structure from buffer for GetMinmaxParameterfv +func getMinmaxParameterfvReply(buf []byte) *GetMinmaxParameterfvReply { + v := new(GetMinmaxParameterfvReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = Float32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]Float32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = Float32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetMinmaxParameterfv +func getMinmaxParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 158 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetMinmaxParameteriv +// size: 16 +type GetMinmaxParameterivCookie struct { + *xgb.Cookie +} + +func GetMinmaxParameteriv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetMinmaxParameterivCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getMinmaxParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetMinmaxParameterivCookie{cookie} +} + +func GetMinmaxParameterivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetMinmaxParameterivCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getMinmaxParameterivRequest(c, ContextTag, Target, Pname), cookie) + return GetMinmaxParameterivCookie{cookie} +} + +// Request reply for GetMinmaxParameteriv +// size: (32 + xgb.Pad((int(N) * 4))) +type GetMinmaxParameterivReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetMinmaxParameteriv +func (cook GetMinmaxParameterivCookie) Reply() (*GetMinmaxParameterivReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getMinmaxParameterivReply(buf), nil +} + +// Read reply into structure from buffer for GetMinmaxParameteriv +func getMinmaxParameterivReply(buf []byte) *GetMinmaxParameterivReply { + v := new(GetMinmaxParameterivReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]int32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetMinmaxParameteriv +func getMinmaxParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 159 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetCompressedTexImageARB +// size: 16 +type GetCompressedTexImageARBCookie struct { + *xgb.Cookie +} + +func GetCompressedTexImageARB(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32) GetCompressedTexImageARBCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getCompressedTexImageARBRequest(c, ContextTag, Target, Level), cookie) + return GetCompressedTexImageARBCookie{cookie} +} + +func GetCompressedTexImageARBUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32) GetCompressedTexImageARBCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getCompressedTexImageARBRequest(c, ContextTag, Target, Level), cookie) + return GetCompressedTexImageARBCookie{cookie} +} + +// Request reply for GetCompressedTexImageARB +// size: (32 + xgb.Pad(((int(Length) * 4) * 1))) +type GetCompressedTexImageARBReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 8 bytes + Size int32 + // padding: 12 bytes + Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) +} + +// Waits and reads reply data from request GetCompressedTexImageARB +func (cook GetCompressedTexImageARBCookie) Reply() (*GetCompressedTexImageARBReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getCompressedTexImageARBReply(buf), nil +} + +// Read reply into structure from buffer for GetCompressedTexImageARB +func getCompressedTexImageARBReply(buf []byte) *GetCompressedTexImageARBReply { + v := new(GetCompressedTexImageARBReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 8 // padding + + v.Size = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]byte, (int(v.Length) * 4)) + copy(v.Data[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) + + return v +} + +// Write request to wire for GetCompressedTexImageARB +func getCompressedTexImageARBRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 160 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], uint32(Level)) + b += 4 + + return buf +} + +// Request DeleteQueriesARB +// size: xgb.Pad((12 + xgb.Pad((int(N) * 4)))) +type DeleteQueriesARBCookie struct { + *xgb.Cookie +} + +// Write request to wire for DeleteQueriesARB +func DeleteQueriesARB(c *xgb.Conn, ContextTag ContextTag, N int32, Ids []uint32) DeleteQueriesARBCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(deleteQueriesARBRequest(c, ContextTag, N, Ids), cookie) + return DeleteQueriesARBCookie{cookie} +} + +func DeleteQueriesARBChecked(c *xgb.Conn, ContextTag ContextTag, N int32, Ids []uint32) DeleteQueriesARBCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(deleteQueriesARBRequest(c, ContextTag, N, Ids), cookie) + return DeleteQueriesARBCookie{cookie} +} + +func (cook DeleteQueriesARBCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DeleteQueriesARB +func deleteQueriesARBRequest(c *xgb.Conn, ContextTag ContextTag, N int32, Ids []uint32) []byte { + size := xgb.Pad((12 + xgb.Pad((int(N) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 161 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], uint32(N)) + b += 4 + + for i := 0; i < int(N); i++ { + xgb.Put32(buf[b:], Ids[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request GenQueriesARB +// size: 12 +type GenQueriesARBCookie struct { + *xgb.Cookie +} + +func GenQueriesARB(c *xgb.Conn, ContextTag ContextTag, N int32) GenQueriesARBCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(genQueriesARBRequest(c, ContextTag, N), cookie) + return GenQueriesARBCookie{cookie} +} + +func GenQueriesARBUnchecked(c *xgb.Conn, ContextTag ContextTag, N int32) GenQueriesARBCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(genQueriesARBRequest(c, ContextTag, N), cookie) + return GenQueriesARBCookie{cookie} +} + +// Request reply for GenQueriesARB +// size: (32 + xgb.Pad((int(Length) * 4))) +type GenQueriesARBReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 24 bytes + Data []uint32 // size: xgb.Pad((int(Length) * 4)) +} + +// Waits and reads reply data from request GenQueriesARB +func (cook GenQueriesARBCookie) Reply() (*GenQueriesARBReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return genQueriesARBReply(buf), nil +} + +// Read reply into structure from buffer for GenQueriesARB +func genQueriesARBReply(buf []byte) *GenQueriesARBReply { + v := new(GenQueriesARBReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 24 // padding + + v.Data = make([]uint32, v.Length) + for i := 0; i < int(v.Length); i++ { + v.Data[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GenQueriesARB +func genQueriesARBRequest(c *xgb.Conn, ContextTag ContextTag, N int32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 162 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], uint32(N)) + b += 4 + + return buf +} + +// Request IsQueryARB +// size: 12 +type IsQueryARBCookie struct { + *xgb.Cookie +} + +func IsQueryARB(c *xgb.Conn, ContextTag ContextTag, Id uint32) IsQueryARBCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(isQueryARBRequest(c, ContextTag, Id), cookie) + return IsQueryARBCookie{cookie} +} + +func IsQueryARBUnchecked(c *xgb.Conn, ContextTag ContextTag, Id uint32) IsQueryARBCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(isQueryARBRequest(c, ContextTag, Id), cookie) + return IsQueryARBCookie{cookie} +} + +// Request reply for IsQueryARB +// size: 12 +type IsQueryARBReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + RetVal Bool32 +} + +// Waits and reads reply data from request IsQueryARB +func (cook IsQueryARBCookie) Reply() (*IsQueryARBReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return isQueryARBReply(buf), nil +} + +// Read reply into structure from buffer for IsQueryARB +func isQueryARBReply(buf []byte) *IsQueryARBReply { + v := new(IsQueryARBReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.RetVal = Bool32(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Write request to wire for IsQueryARB +func isQueryARBRequest(c *xgb.Conn, ContextTag ContextTag, Id uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 163 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Id) + b += 4 + + return buf +} + +// Request GetQueryivARB +// size: 16 +type GetQueryivARBCookie struct { + *xgb.Cookie +} + +func GetQueryivARB(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetQueryivARBCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getQueryivARBRequest(c, ContextTag, Target, Pname), cookie) + return GetQueryivARBCookie{cookie} +} + +func GetQueryivARBUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetQueryivARBCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getQueryivARBRequest(c, ContextTag, Target, Pname), cookie) + return GetQueryivARBCookie{cookie} +} + +// Request reply for GetQueryivARB +// size: (32 + xgb.Pad((int(N) * 4))) +type GetQueryivARBReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetQueryivARB +func (cook GetQueryivARBCookie) Reply() (*GetQueryivARBReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getQueryivARBReply(buf), nil +} + +// Read reply into structure from buffer for GetQueryivARB +func getQueryivARBReply(buf []byte) *GetQueryivARBReply { + v := new(GetQueryivARBReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]int32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetQueryivARB +func getQueryivARBRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 164 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Target) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetQueryObjectivARB +// size: 16 +type GetQueryObjectivARBCookie struct { + *xgb.Cookie +} + +func GetQueryObjectivARB(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) GetQueryObjectivARBCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getQueryObjectivARBRequest(c, ContextTag, Id, Pname), cookie) + return GetQueryObjectivARBCookie{cookie} +} + +func GetQueryObjectivARBUnchecked(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) GetQueryObjectivARBCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getQueryObjectivARBRequest(c, ContextTag, Id, Pname), cookie) + return GetQueryObjectivARBCookie{cookie} +} + +// Request reply for GetQueryObjectivARB +// size: (32 + xgb.Pad((int(N) * 4))) +type GetQueryObjectivARBReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum int32 + // padding: 12 bytes + Data []int32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetQueryObjectivARB +func (cook GetQueryObjectivARBCookie) Reply() (*GetQueryObjectivARBReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getQueryObjectivARBReply(buf), nil +} + +// Read reply into structure from buffer for GetQueryObjectivARB +func getQueryObjectivARBReply(buf []byte) *GetQueryObjectivARBReply { + v := new(GetQueryObjectivARBReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = int32(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + v.Data = make([]int32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetQueryObjectivARB +func getQueryObjectivARBRequest(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 165 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Id) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} + +// Request GetQueryObjectuivARB +// size: 16 +type GetQueryObjectuivARBCookie struct { + *xgb.Cookie +} + +func GetQueryObjectuivARB(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) GetQueryObjectuivARBCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getQueryObjectuivARBRequest(c, ContextTag, Id, Pname), cookie) + return GetQueryObjectuivARBCookie{cookie} +} + +func GetQueryObjectuivARBUnchecked(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) GetQueryObjectuivARBCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getQueryObjectuivARBRequest(c, ContextTag, Id, Pname), cookie) + return GetQueryObjectuivARBCookie{cookie} +} + +// Request reply for GetQueryObjectuivARB +// size: (32 + xgb.Pad((int(N) * 4))) +type GetQueryObjectuivARBReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 4 bytes + N uint32 + Datum uint32 + // padding: 12 bytes + Data []uint32 // size: xgb.Pad((int(N) * 4)) +} + +// Waits and reads reply data from request GetQueryObjectuivARB +func (cook GetQueryObjectuivARBCookie) Reply() (*GetQueryObjectuivARBReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getQueryObjectuivARBReply(buf), nil +} + +// Read reply into structure from buffer for GetQueryObjectuivARB +func getQueryObjectuivARBReply(buf []byte) *GetQueryObjectuivARBReply { + v := new(GetQueryObjectuivARBReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 4 // padding + + v.N = xgb.Get32(buf[b:]) + b += 4 + + v.Datum = xgb.Get32(buf[b:]) + b += 4 + + b += 12 // padding + + v.Data = make([]uint32, v.N) + for i := 0; i < int(v.N); i++ { + v.Data[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetQueryObjectuivARB +func getQueryObjectuivARBRequest(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["GLX"] + b += 1 + + buf[b] = 166 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextTag)) + b += 4 + + xgb.Put32(buf[b:], Id) + b += 4 + + xgb.Put32(buf[b:], Pname) + b += 4 + + return buf +} diff --git a/nexgb/randr/randr.go b/nexgb/randr/randr.go new file mode 100644 index 0000000..4d78691 --- /dev/null +++ b/nexgb/randr/randr.go @@ -0,0 +1,3964 @@ +package randr + +/* + This file was generated by randr.xml on May 10 2012 4:20:27pm EDT. + This file is automatically generated. Edit at your peril! +*/ + +import ( + "github.com/BurntSushi/xgb" + + "github.com/BurntSushi/xgb/render" + "github.com/BurntSushi/xgb/xproto" +) + +// Init must be called before using the RANDR extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 5, "RANDR").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named RANDR could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["RANDR"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["RANDR"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["RANDR"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["RANDR"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["RANDR"] = make(map[int]xgb.NewErrorFun) +} + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Bool' + +// Skipping definition for base type 'Float' + +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +const ( + RotationRotate0 = 1 + RotationRotate90 = 2 + RotationRotate180 = 4 + RotationRotate270 = 8 + RotationReflectX = 16 + RotationReflectY = 32 +) + +const ( + SetConfigSuccess = 0 + SetConfigInvalidConfigTime = 1 + SetConfigInvalidTime = 2 + SetConfigFailed = 3 +) + +const ( + NotifyMaskScreenChange = 1 + NotifyMaskCrtcChange = 2 + NotifyMaskOutputChange = 4 + NotifyMaskOutputProperty = 8 +) + +const ( + ModeFlagHsyncPositive = 1 + ModeFlagHsyncNegative = 2 + ModeFlagVsyncPositive = 4 + ModeFlagVsyncNegative = 8 + ModeFlagInterlace = 16 + ModeFlagDoubleScan = 32 + ModeFlagCsync = 64 + ModeFlagCsyncPositive = 128 + ModeFlagCsyncNegative = 256 + ModeFlagHskewPresent = 512 + ModeFlagBcast = 1024 + ModeFlagPixelMultiplex = 2048 + ModeFlagDoubleClock = 4096 + ModeFlagHalveClock = 8192 +) + +const ( + ConnectionConnected = 0 + ConnectionDisconnected = 1 + ConnectionUnknown = 2 +) + +const ( + NotifyCrtcChange = 0 + NotifyOutputChange = 1 + NotifyOutputProperty = 2 +) + +type Mode uint32 + +func NewModeId(c *xgb.Conn) (Mode, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Mode(id), nil +} + +type Crtc uint32 + +func NewCrtcId(c *xgb.Conn) (Crtc, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Crtc(id), nil +} + +type Output uint32 + +func NewOutputId(c *xgb.Conn) (Output, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Output(id), nil +} + +// 'ScreenSize' struct definition +// Size: 8 +type ScreenSize struct { + Width uint16 + Height uint16 + Mwidth uint16 + Mheight uint16 +} + +// Struct read ScreenSize +func ScreenSizeRead(buf []byte, v *ScreenSize) int { + b := 0 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.Mwidth = xgb.Get16(buf[b:]) + b += 2 + + v.Mheight = xgb.Get16(buf[b:]) + b += 2 + + return b +} + +// Struct list read ScreenSize +func ScreenSizeReadList(buf []byte, dest []ScreenSize) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = ScreenSize{} + b += ScreenSizeRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write ScreenSize +func (v ScreenSize) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + xgb.Put16(buf[b:], v.Mwidth) + b += 2 + + xgb.Put16(buf[b:], v.Mheight) + b += 2 + + return buf +} + +// Write struct list ScreenSize +func ScreenSizeListBytes(buf []byte, list []ScreenSize) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'RefreshRates' struct definition +// Size: (2 + xgb.Pad((int(NRates) * 2))) +type RefreshRates struct { + NRates uint16 + Rates []uint16 // size: xgb.Pad((int(NRates) * 2)) +} + +// Struct read RefreshRates +func RefreshRatesRead(buf []byte, v *RefreshRates) int { + b := 0 + + v.NRates = xgb.Get16(buf[b:]) + b += 2 + + v.Rates = make([]uint16, v.NRates) + for i := 0; i < int(v.NRates); i++ { + v.Rates[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) + + return b +} + +// Struct list read RefreshRates +func RefreshRatesReadList(buf []byte, dest []RefreshRates) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = RefreshRates{} + b += RefreshRatesRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write RefreshRates +func (v RefreshRates) Bytes() []byte { + buf := make([]byte, (2 + xgb.Pad((int(v.NRates) * 2)))) + b := 0 + + xgb.Put16(buf[b:], v.NRates) + b += 2 + + for i := 0; i < int(v.NRates); i++ { + xgb.Put16(buf[b:], v.Rates[i]) + b += 2 + } + b = xgb.Pad(b) + + return buf +} + +// Write struct list RefreshRates +func RefreshRatesListBytes(buf []byte, list []RefreshRates) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size RefreshRates +func RefreshRatesListSize(list []RefreshRates) int { + size := 0 + for _, item := range list { + size += (2 + xgb.Pad((int(item.NRates) * 2))) + } + return size +} + +// 'ModeInfo' struct definition +// Size: 32 +type ModeInfo struct { + Id uint32 + Width uint16 + Height uint16 + DotClock uint32 + HsyncStart uint16 + HsyncEnd uint16 + Htotal uint16 + Hskew uint16 + VsyncStart uint16 + VsyncEnd uint16 + Vtotal uint16 + NameLen uint16 + ModeFlags uint32 +} + +// Struct read ModeInfo +func ModeInfoRead(buf []byte, v *ModeInfo) int { + b := 0 + + v.Id = xgb.Get32(buf[b:]) + b += 4 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.DotClock = xgb.Get32(buf[b:]) + b += 4 + + v.HsyncStart = xgb.Get16(buf[b:]) + b += 2 + + v.HsyncEnd = xgb.Get16(buf[b:]) + b += 2 + + v.Htotal = xgb.Get16(buf[b:]) + b += 2 + + v.Hskew = xgb.Get16(buf[b:]) + b += 2 + + v.VsyncStart = xgb.Get16(buf[b:]) + b += 2 + + v.VsyncEnd = xgb.Get16(buf[b:]) + b += 2 + + v.Vtotal = xgb.Get16(buf[b:]) + b += 2 + + v.NameLen = xgb.Get16(buf[b:]) + b += 2 + + v.ModeFlags = xgb.Get32(buf[b:]) + b += 4 + + return b +} + +// Struct list read ModeInfo +func ModeInfoReadList(buf []byte, dest []ModeInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = ModeInfo{} + b += ModeInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write ModeInfo +func (v ModeInfo) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + xgb.Put32(buf[b:], v.Id) + b += 4 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + xgb.Put32(buf[b:], v.DotClock) + b += 4 + + xgb.Put16(buf[b:], v.HsyncStart) + b += 2 + + xgb.Put16(buf[b:], v.HsyncEnd) + b += 2 + + xgb.Put16(buf[b:], v.Htotal) + b += 2 + + xgb.Put16(buf[b:], v.Hskew) + b += 2 + + xgb.Put16(buf[b:], v.VsyncStart) + b += 2 + + xgb.Put16(buf[b:], v.VsyncEnd) + b += 2 + + xgb.Put16(buf[b:], v.Vtotal) + b += 2 + + xgb.Put16(buf[b:], v.NameLen) + b += 2 + + xgb.Put32(buf[b:], v.ModeFlags) + b += 4 + + return buf +} + +// Write struct list ModeInfo +func ModeInfoListBytes(buf []byte, list []ModeInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'CrtcChange' struct definition +// Size: 28 +type CrtcChange struct { + Timestamp xproto.Timestamp + Window xproto.Window + Crtc Crtc + Mode Mode + Rotation uint16 + // padding: 2 bytes + X int16 + Y int16 + Width uint16 + Height uint16 +} + +// Struct read CrtcChange +func CrtcChangeRead(buf []byte, v *CrtcChange) int { + b := 0 + + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Window = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.Crtc = Crtc(xgb.Get32(buf[b:])) + b += 4 + + v.Mode = Mode(xgb.Get32(buf[b:])) + b += 4 + + v.Rotation = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + return b +} + +// Struct list read CrtcChange +func CrtcChangeReadList(buf []byte, dest []CrtcChange) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = CrtcChange{} + b += CrtcChangeRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write CrtcChange +func (v CrtcChange) Bytes() []byte { + buf := make([]byte, 28) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Timestamp)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Crtc)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Mode)) + b += 4 + + xgb.Put16(buf[b:], v.Rotation) + b += 2 + + b += 2 // padding + + xgb.Put16(buf[b:], uint16(v.X)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + return buf +} + +// Write struct list CrtcChange +func CrtcChangeListBytes(buf []byte, list []CrtcChange) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'OutputChange' struct definition +// Size: 28 +type OutputChange struct { + Timestamp xproto.Timestamp + ConfigTimestamp xproto.Timestamp + Window xproto.Window + Output Output + Crtc Crtc + Mode Mode + Rotation uint16 + Connection byte + SubpixelOrder byte +} + +// Struct read OutputChange +func OutputChangeRead(buf []byte, v *OutputChange) int { + b := 0 + + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.ConfigTimestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Window = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.Output = Output(xgb.Get32(buf[b:])) + b += 4 + + v.Crtc = Crtc(xgb.Get32(buf[b:])) + b += 4 + + v.Mode = Mode(xgb.Get32(buf[b:])) + b += 4 + + v.Rotation = xgb.Get16(buf[b:]) + b += 2 + + v.Connection = buf[b] + b += 1 + + v.SubpixelOrder = buf[b] + b += 1 + + return b +} + +// Struct list read OutputChange +func OutputChangeReadList(buf []byte, dest []OutputChange) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = OutputChange{} + b += OutputChangeRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write OutputChange +func (v OutputChange) Bytes() []byte { + buf := make([]byte, 28) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Timestamp)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.ConfigTimestamp)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Output)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Crtc)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Mode)) + b += 4 + + xgb.Put16(buf[b:], v.Rotation) + b += 2 + + buf[b] = v.Connection + b += 1 + + buf[b] = v.SubpixelOrder + b += 1 + + return buf +} + +// Write struct list OutputChange +func OutputChangeListBytes(buf []byte, list []OutputChange) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'OutputProperty' struct definition +// Size: 28 +type OutputProperty struct { + Window xproto.Window + Output Output + Atom xproto.Atom + Timestamp xproto.Timestamp + Status byte + // padding: 11 bytes +} + +// Struct read OutputProperty +func OutputPropertyRead(buf []byte, v *OutputProperty) int { + b := 0 + + v.Window = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.Output = Output(xgb.Get32(buf[b:])) + b += 4 + + v.Atom = xproto.Atom(xgb.Get32(buf[b:])) + b += 4 + + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Status = buf[b] + b += 1 + + b += 11 // padding + + return b +} + +// Struct list read OutputProperty +func OutputPropertyReadList(buf []byte, dest []OutputProperty) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = OutputProperty{} + b += OutputPropertyRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write OutputProperty +func (v OutputProperty) Bytes() []byte { + buf := make([]byte, 28) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Output)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Atom)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Timestamp)) + b += 4 + + buf[b] = v.Status + b += 1 + + b += 11 // padding + + return buf +} + +// Write struct list OutputProperty +func OutputPropertyListBytes(buf []byte, list []OutputProperty) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Union definition NotifyDataUnion +// Note that to *create* a Union, you should *never* create +// this struct directly (unless you know what you're doing). +// Instead use one of the following constructors for 'NotifyDataUnion': +// NotifyDataUnionCcNew(Cc CrtcChange) NotifyDataUnion +// NotifyDataUnionOcNew(Oc OutputChange) NotifyDataUnion +// NotifyDataUnionOpNew(Op OutputProperty) NotifyDataUnion +type NotifyDataUnion struct { + Cc CrtcChange + Oc OutputChange + Op OutputProperty +} + +// Union constructor for NotifyDataUnion for field Cc. +func NotifyDataUnionCcNew(Cc CrtcChange) NotifyDataUnion { + var b int + buf := make([]byte, 28) + + { + structBytes := Cc.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + // Create the Union type + v := NotifyDataUnion{} + + // Now copy buf into all fields + + b = 0 // always read the same bytes + v.Cc = CrtcChange{} + b += CrtcChangeRead(buf[b:], &v.Cc) + + b = 0 // always read the same bytes + v.Oc = OutputChange{} + b += OutputChangeRead(buf[b:], &v.Oc) + + b = 0 // always read the same bytes + v.Op = OutputProperty{} + b += OutputPropertyRead(buf[b:], &v.Op) + + return v +} + +// Union constructor for NotifyDataUnion for field Oc. +func NotifyDataUnionOcNew(Oc OutputChange) NotifyDataUnion { + var b int + buf := make([]byte, 28) + + { + structBytes := Oc.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + // Create the Union type + v := NotifyDataUnion{} + + // Now copy buf into all fields + + b = 0 // always read the same bytes + v.Cc = CrtcChange{} + b += CrtcChangeRead(buf[b:], &v.Cc) + + b = 0 // always read the same bytes + v.Oc = OutputChange{} + b += OutputChangeRead(buf[b:], &v.Oc) + + b = 0 // always read the same bytes + v.Op = OutputProperty{} + b += OutputPropertyRead(buf[b:], &v.Op) + + return v +} + +// Union constructor for NotifyDataUnion for field Op. +func NotifyDataUnionOpNew(Op OutputProperty) NotifyDataUnion { + var b int + buf := make([]byte, 28) + + { + structBytes := Op.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + // Create the Union type + v := NotifyDataUnion{} + + // Now copy buf into all fields + + b = 0 // always read the same bytes + v.Cc = CrtcChange{} + b += CrtcChangeRead(buf[b:], &v.Cc) + + b = 0 // always read the same bytes + v.Oc = OutputChange{} + b += OutputChangeRead(buf[b:], &v.Oc) + + b = 0 // always read the same bytes + v.Op = OutputProperty{} + b += OutputPropertyRead(buf[b:], &v.Op) + + return v +} + +// Union read NotifyDataUnion +func NotifyDataUnionRead(buf []byte, v *NotifyDataUnion) int { + var b int + + b = 0 // re-read the same bytes + v.Cc = CrtcChange{} + b += CrtcChangeRead(buf[b:], &v.Cc) + + b = 0 // re-read the same bytes + v.Oc = OutputChange{} + b += OutputChangeRead(buf[b:], &v.Oc) + + b = 0 // re-read the same bytes + v.Op = OutputProperty{} + b += OutputPropertyRead(buf[b:], &v.Op) + + return 28 +} + +// Union list read NotifyDataUnion +func NotifyDataUnionReadList(buf []byte, dest []NotifyDataUnion) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = NotifyDataUnion{} + b += NotifyDataUnionRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Union write NotifyDataUnion +// Each field in a union must contain the same data. +// So simply pick the first field and write that to the wire. +func (v NotifyDataUnion) Bytes() []byte { + buf := make([]byte, 28) + b := 0 + + { + structBytes := v.Cc.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return buf +} + +// Union list write NotifyDataUnion +func NotifyDataUnionListBytes(buf []byte, list []NotifyDataUnion) int { + b := 0 + var unionBytes []byte + for _, item := range list { + unionBytes = item.Bytes() + copy(buf[b:], unionBytes) + b += xgb.Pad(len(unionBytes)) + } + return b +} + +// Event definition ScreenChangeNotify (0) +// Size: 32 + +const ScreenChangeNotify = 0 + +type ScreenChangeNotifyEvent struct { + Sequence uint16 + Rotation byte + Timestamp xproto.Timestamp + ConfigTimestamp xproto.Timestamp + Root xproto.Window + RequestWindow xproto.Window + SizeID uint16 + SubpixelOrder uint16 + Width uint16 + Height uint16 + Mwidth uint16 + Mheight uint16 +} + +// Event read ScreenChangeNotify +func ScreenChangeNotifyEventNew(buf []byte) xgb.Event { + v := ScreenChangeNotifyEvent{} + b := 1 // don't read event number + + v.Rotation = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.ConfigTimestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Root = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.RequestWindow = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.SizeID = xgb.Get16(buf[b:]) + b += 2 + + v.SubpixelOrder = xgb.Get16(buf[b:]) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.Mwidth = xgb.Get16(buf[b:]) + b += 2 + + v.Mheight = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Event write ScreenChangeNotify +func (v ScreenChangeNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 0 + b += 1 + + buf[b] = v.Rotation + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Timestamp)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.ConfigTimestamp)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Root)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.RequestWindow)) + b += 4 + + xgb.Put16(buf[b:], v.SizeID) + b += 2 + + xgb.Put16(buf[b:], v.SubpixelOrder) + b += 2 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + xgb.Put16(buf[b:], v.Mwidth) + b += 2 + + xgb.Put16(buf[b:], v.Mheight) + b += 2 + + return buf +} + +func (v ScreenChangeNotifyEvent) ImplementsEvent() {} + +func (v ScreenChangeNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v ScreenChangeNotifyEvent) String() string { + fieldVals := make([]string, 0, 11) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Rotation: %d", v.Rotation)) + fieldVals = append(fieldVals, xgb.Sprintf("Timestamp: %d", v.Timestamp)) + fieldVals = append(fieldVals, xgb.Sprintf("ConfigTimestamp: %d", v.ConfigTimestamp)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("RequestWindow: %d", v.RequestWindow)) + fieldVals = append(fieldVals, xgb.Sprintf("SizeID: %d", v.SizeID)) + fieldVals = append(fieldVals, xgb.Sprintf("SubpixelOrder: %d", v.SubpixelOrder)) + fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) + fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) + fieldVals = append(fieldVals, xgb.Sprintf("Mwidth: %d", v.Mwidth)) + fieldVals = append(fieldVals, xgb.Sprintf("Mheight: %d", v.Mheight)) + return "ScreenChangeNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["RANDR"][0] = ScreenChangeNotifyEventNew +} + +// Event definition Notify (1) +// Size: 32 + +const Notify = 1 + +type NotifyEvent struct { + Sequence uint16 + SubCode byte + U NotifyDataUnion +} + +// Event read Notify +func NotifyEventNew(buf []byte) xgb.Event { + v := NotifyEvent{} + b := 1 // don't read event number + + v.SubCode = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.U = NotifyDataUnion{} + b += NotifyDataUnionRead(buf[b:], &v.U) + + return v +} + +// Event write Notify +func (v NotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 1 + b += 1 + + buf[b] = v.SubCode + b += 1 + + b += 2 // skip sequence number + + { + unionBytes := v.U.Bytes() + copy(buf[b:], unionBytes) + b += xgb.Pad(len(unionBytes)) + } + + return buf +} + +func (v NotifyEvent) ImplementsEvent() {} + +func (v NotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v NotifyEvent) String() string { + fieldVals := make([]string, 0, 2) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("SubCode: %d", v.SubCode)) + return "Notify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["RANDR"][1] = NotifyEventNew +} + +// Error definition BadOutput (0) +// Size: 32 + +const BadBadOutput = 0 + +type BadOutputError struct { + Sequence uint16 + NiceName string +} + +// Error read BadOutput +func BadOutputErrorNew(buf []byte) xgb.Error { + v := BadOutputError{} + v.NiceName = "BadOutput" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err BadOutputError) ImplementsError() {} + +func (err BadOutputError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadOutputError) BadId() uint32 { + return 0 +} + +func (err BadOutputError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadOutput {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["RANDR"][0] = BadOutputErrorNew +} + +// Error definition BadCrtc (1) +// Size: 32 + +const BadBadCrtc = 1 + +type BadCrtcError struct { + Sequence uint16 + NiceName string +} + +// Error read BadCrtc +func BadCrtcErrorNew(buf []byte) xgb.Error { + v := BadCrtcError{} + v.NiceName = "BadCrtc" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err BadCrtcError) ImplementsError() {} + +func (err BadCrtcError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadCrtcError) BadId() uint32 { + return 0 +} + +func (err BadCrtcError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadCrtc {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["RANDR"][1] = BadCrtcErrorNew +} + +// Error definition BadMode (2) +// Size: 32 + +const BadBadMode = 2 + +type BadModeError struct { + Sequence uint16 + NiceName string +} + +// Error read BadMode +func BadModeErrorNew(buf []byte) xgb.Error { + v := BadModeError{} + v.NiceName = "BadMode" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err BadModeError) ImplementsError() {} + +func (err BadModeError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadModeError) BadId() uint32 { + return 0 +} + +func (err BadModeError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadMode {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["RANDR"][2] = BadModeErrorNew +} + +// Request QueryVersion +// size: 12 +type QueryVersionCookie struct { + *xgb.Cookie +} + +func QueryVersion(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) + return QueryVersionCookie{cookie} +} + +func QueryVersionUnchecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) + return QueryVersionCookie{cookie} +} + +// Request reply for QueryVersion +// size: 32 +type QueryVersionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + MajorVersion uint32 + MinorVersion uint32 + // padding: 16 bytes +} + +// Waits and reads reply data from request QueryVersion +func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryVersionReply(buf), nil +} + +// Read reply into structure from buffer for QueryVersion +func queryVersionReply(buf []byte) *QueryVersionReply { + v := new(QueryVersionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.MajorVersion = xgb.Get32(buf[b:]) + b += 4 + + v.MinorVersion = xgb.Get32(buf[b:]) + b += 4 + + b += 16 // padding + + return v +} + +// Write request to wire for QueryVersion +func queryVersionRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 0 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], MajorVersion) + b += 4 + + xgb.Put32(buf[b:], MinorVersion) + b += 4 + + return buf +} + +// Request SetScreenConfig +// size: 24 +type SetScreenConfigCookie struct { + *xgb.Cookie +} + +func SetScreenConfig(c *xgb.Conn, Window xproto.Window, Timestamp xproto.Timestamp, ConfigTimestamp xproto.Timestamp, SizeID uint16, Rotation uint16, Rate uint16) SetScreenConfigCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(setScreenConfigRequest(c, Window, Timestamp, ConfigTimestamp, SizeID, Rotation, Rate), cookie) + return SetScreenConfigCookie{cookie} +} + +func SetScreenConfigUnchecked(c *xgb.Conn, Window xproto.Window, Timestamp xproto.Timestamp, ConfigTimestamp xproto.Timestamp, SizeID uint16, Rotation uint16, Rate uint16) SetScreenConfigCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(setScreenConfigRequest(c, Window, Timestamp, ConfigTimestamp, SizeID, Rotation, Rate), cookie) + return SetScreenConfigCookie{cookie} +} + +// Request reply for SetScreenConfig +// size: 32 +type SetScreenConfigReply struct { + Sequence uint16 + Length uint32 + Status byte + NewTimestamp xproto.Timestamp + ConfigTimestamp xproto.Timestamp + Root xproto.Window + SubpixelOrder uint16 + // padding: 10 bytes +} + +// Waits and reads reply data from request SetScreenConfig +func (cook SetScreenConfigCookie) Reply() (*SetScreenConfigReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return setScreenConfigReply(buf), nil +} + +// Read reply into structure from buffer for SetScreenConfig +func setScreenConfigReply(buf []byte) *SetScreenConfigReply { + v := new(SetScreenConfigReply) + b := 1 // skip reply determinant + + v.Status = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NewTimestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.ConfigTimestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Root = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.SubpixelOrder = xgb.Get16(buf[b:]) + b += 2 + + b += 10 // padding + + return v +} + +// Write request to wire for SetScreenConfig +func setScreenConfigRequest(c *xgb.Conn, Window xproto.Window, Timestamp xproto.Timestamp, ConfigTimestamp xproto.Timestamp, SizeID uint16, Rotation uint16, Rate uint16) []byte { + size := 24 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 2 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(Timestamp)) + b += 4 + + xgb.Put32(buf[b:], uint32(ConfigTimestamp)) + b += 4 + + xgb.Put16(buf[b:], SizeID) + b += 2 + + xgb.Put16(buf[b:], Rotation) + b += 2 + + xgb.Put16(buf[b:], Rate) + b += 2 + + b += 2 // padding + + return buf +} + +// Request SelectInput +// size: 12 +type SelectInputCookie struct { + *xgb.Cookie +} + +// Write request to wire for SelectInput +func SelectInput(c *xgb.Conn, Window xproto.Window, Enable uint16) SelectInputCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(selectInputRequest(c, Window, Enable), cookie) + return SelectInputCookie{cookie} +} + +func SelectInputChecked(c *xgb.Conn, Window xproto.Window, Enable uint16) SelectInputCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(selectInputRequest(c, Window, Enable), cookie) + return SelectInputCookie{cookie} +} + +func (cook SelectInputCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SelectInput +func selectInputRequest(c *xgb.Conn, Window xproto.Window, Enable uint16) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 4 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put16(buf[b:], Enable) + b += 2 + + b += 2 // padding + + return buf +} + +// Request GetScreenInfo +// size: 8 +type GetScreenInfoCookie struct { + *xgb.Cookie +} + +func GetScreenInfo(c *xgb.Conn, Window xproto.Window) GetScreenInfoCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getScreenInfoRequest(c, Window), cookie) + return GetScreenInfoCookie{cookie} +} + +func GetScreenInfoUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenInfoCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getScreenInfoRequest(c, Window), cookie) + return GetScreenInfoCookie{cookie} +} + +// Request reply for GetScreenInfo +// size: ((32 + xgb.Pad((int(NSizes) * 8))) + RefreshRatesListSize(Rates)) +type GetScreenInfoReply struct { + Sequence uint16 + Length uint32 + Rotations byte + Root xproto.Window + Timestamp xproto.Timestamp + ConfigTimestamp xproto.Timestamp + NSizes uint16 + SizeID uint16 + Rotation uint16 + Rate uint16 + NInfo uint16 + // padding: 2 bytes + Sizes []ScreenSize // size: xgb.Pad((int(NSizes) * 8)) + Rates []RefreshRates // size: RefreshRatesListSize(Rates) +} + +// Waits and reads reply data from request GetScreenInfo +func (cook GetScreenInfoCookie) Reply() (*GetScreenInfoReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getScreenInfoReply(buf), nil +} + +// Read reply into structure from buffer for GetScreenInfo +func getScreenInfoReply(buf []byte) *GetScreenInfoReply { + v := new(GetScreenInfoReply) + b := 1 // skip reply determinant + + v.Rotations = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Root = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.ConfigTimestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.NSizes = xgb.Get16(buf[b:]) + b += 2 + + v.SizeID = xgb.Get16(buf[b:]) + b += 2 + + v.Rotation = xgb.Get16(buf[b:]) + b += 2 + + v.Rate = xgb.Get16(buf[b:]) + b += 2 + + v.NInfo = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + v.Sizes = make([]ScreenSize, v.NSizes) + b += ScreenSizeReadList(buf[b:], v.Sizes) + + v.Rates = make([]RefreshRates, (int(v.NInfo) - int(v.NSizes))) + b += RefreshRatesReadList(buf[b:], v.Rates) + + return v +} + +// Write request to wire for GetScreenInfo +func getScreenInfoRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 5 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + +// Request GetScreenSizeRange +// size: 8 +type GetScreenSizeRangeCookie struct { + *xgb.Cookie +} + +func GetScreenSizeRange(c *xgb.Conn, Window xproto.Window) GetScreenSizeRangeCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getScreenSizeRangeRequest(c, Window), cookie) + return GetScreenSizeRangeCookie{cookie} +} + +func GetScreenSizeRangeUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenSizeRangeCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getScreenSizeRangeRequest(c, Window), cookie) + return GetScreenSizeRangeCookie{cookie} +} + +// Request reply for GetScreenSizeRange +// size: 32 +type GetScreenSizeRangeReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + MinWidth uint16 + MinHeight uint16 + MaxWidth uint16 + MaxHeight uint16 + // padding: 16 bytes +} + +// Waits and reads reply data from request GetScreenSizeRange +func (cook GetScreenSizeRangeCookie) Reply() (*GetScreenSizeRangeReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getScreenSizeRangeReply(buf), nil +} + +// Read reply into structure from buffer for GetScreenSizeRange +func getScreenSizeRangeReply(buf []byte) *GetScreenSizeRangeReply { + v := new(GetScreenSizeRangeReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.MinWidth = xgb.Get16(buf[b:]) + b += 2 + + v.MinHeight = xgb.Get16(buf[b:]) + b += 2 + + v.MaxWidth = xgb.Get16(buf[b:]) + b += 2 + + v.MaxHeight = xgb.Get16(buf[b:]) + b += 2 + + b += 16 // padding + + return v +} + +// Write request to wire for GetScreenSizeRange +func getScreenSizeRangeRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 6 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + +// Request SetScreenSize +// size: 20 +type SetScreenSizeCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetScreenSize +func SetScreenSize(c *xgb.Conn, Window xproto.Window, Width uint16, Height uint16, MmWidth uint32, MmHeight uint32) SetScreenSizeCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setScreenSizeRequest(c, Window, Width, Height, MmWidth, MmHeight), cookie) + return SetScreenSizeCookie{cookie} +} + +func SetScreenSizeChecked(c *xgb.Conn, Window xproto.Window, Width uint16, Height uint16, MmWidth uint32, MmHeight uint32) SetScreenSizeCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setScreenSizeRequest(c, Window, Width, Height, MmWidth, MmHeight), cookie) + return SetScreenSizeCookie{cookie} +} + +func (cook SetScreenSizeCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetScreenSize +func setScreenSizeRequest(c *xgb.Conn, Window xproto.Window, Width uint16, Height uint16, MmWidth uint32, MmHeight uint32) []byte { + size := 20 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 7 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + xgb.Put32(buf[b:], MmWidth) + b += 4 + + xgb.Put32(buf[b:], MmHeight) + b += 4 + + return buf +} + +// Request GetScreenResources +// size: 8 +type GetScreenResourcesCookie struct { + *xgb.Cookie +} + +func GetScreenResources(c *xgb.Conn, Window xproto.Window) GetScreenResourcesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getScreenResourcesRequest(c, Window), cookie) + return GetScreenResourcesCookie{cookie} +} + +func GetScreenResourcesUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenResourcesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getScreenResourcesRequest(c, Window), cookie) + return GetScreenResourcesCookie{cookie} +} + +// Request reply for GetScreenResources +// size: ((((32 + xgb.Pad((int(NumCrtcs) * 4))) + xgb.Pad((int(NumOutputs) * 4))) + xgb.Pad((int(NumModes) * 32))) + xgb.Pad((int(NamesLen) * 1))) +type GetScreenResourcesReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Timestamp xproto.Timestamp + ConfigTimestamp xproto.Timestamp + NumCrtcs uint16 + NumOutputs uint16 + NumModes uint16 + NamesLen uint16 + // padding: 8 bytes + Crtcs []Crtc // size: xgb.Pad((int(NumCrtcs) * 4)) + Outputs []Output // size: xgb.Pad((int(NumOutputs) * 4)) + Modes []ModeInfo // size: xgb.Pad((int(NumModes) * 32)) + Names []byte // size: xgb.Pad((int(NamesLen) * 1)) +} + +// Waits and reads reply data from request GetScreenResources +func (cook GetScreenResourcesCookie) Reply() (*GetScreenResourcesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getScreenResourcesReply(buf), nil +} + +// Read reply into structure from buffer for GetScreenResources +func getScreenResourcesReply(buf []byte) *GetScreenResourcesReply { + v := new(GetScreenResourcesReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.ConfigTimestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.NumCrtcs = xgb.Get16(buf[b:]) + b += 2 + + v.NumOutputs = xgb.Get16(buf[b:]) + b += 2 + + v.NumModes = xgb.Get16(buf[b:]) + b += 2 + + v.NamesLen = xgb.Get16(buf[b:]) + b += 2 + + b += 8 // padding + + v.Crtcs = make([]Crtc, v.NumCrtcs) + for i := 0; i < int(v.NumCrtcs); i++ { + v.Crtcs[i] = Crtc(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + v.Outputs = make([]Output, v.NumOutputs) + for i := 0; i < int(v.NumOutputs); i++ { + v.Outputs[i] = Output(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + v.Modes = make([]ModeInfo, v.NumModes) + b += ModeInfoReadList(buf[b:], v.Modes) + + v.Names = make([]byte, v.NamesLen) + copy(v.Names[:v.NamesLen], buf[b:]) + b += xgb.Pad(int(v.NamesLen)) + + return v +} + +// Write request to wire for GetScreenResources +func getScreenResourcesRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 8 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + +// Request GetOutputInfo +// size: 12 +type GetOutputInfoCookie struct { + *xgb.Cookie +} + +func GetOutputInfo(c *xgb.Conn, Output Output, ConfigTimestamp xproto.Timestamp) GetOutputInfoCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getOutputInfoRequest(c, Output, ConfigTimestamp), cookie) + return GetOutputInfoCookie{cookie} +} + +func GetOutputInfoUnchecked(c *xgb.Conn, Output Output, ConfigTimestamp xproto.Timestamp) GetOutputInfoCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getOutputInfoRequest(c, Output, ConfigTimestamp), cookie) + return GetOutputInfoCookie{cookie} +} + +// Request reply for GetOutputInfo +// size: ((((36 + xgb.Pad((int(NumCrtcs) * 4))) + xgb.Pad((int(NumModes) * 4))) + xgb.Pad((int(NumClones) * 4))) + xgb.Pad((int(NameLen) * 1))) +type GetOutputInfoReply struct { + Sequence uint16 + Length uint32 + Status byte + Timestamp xproto.Timestamp + Crtc Crtc + MmWidth uint32 + MmHeight uint32 + Connection byte + SubpixelOrder byte + NumCrtcs uint16 + NumModes uint16 + NumPreferred uint16 + NumClones uint16 + NameLen uint16 + Crtcs []Crtc // size: xgb.Pad((int(NumCrtcs) * 4)) + Modes []Mode // size: xgb.Pad((int(NumModes) * 4)) + Clones []Output // size: xgb.Pad((int(NumClones) * 4)) + Name []byte // size: xgb.Pad((int(NameLen) * 1)) +} + +// Waits and reads reply data from request GetOutputInfo +func (cook GetOutputInfoCookie) Reply() (*GetOutputInfoReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getOutputInfoReply(buf), nil +} + +// Read reply into structure from buffer for GetOutputInfo +func getOutputInfoReply(buf []byte) *GetOutputInfoReply { + v := new(GetOutputInfoReply) + b := 1 // skip reply determinant + + v.Status = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Crtc = Crtc(xgb.Get32(buf[b:])) + b += 4 + + v.MmWidth = xgb.Get32(buf[b:]) + b += 4 + + v.MmHeight = xgb.Get32(buf[b:]) + b += 4 + + v.Connection = buf[b] + b += 1 + + v.SubpixelOrder = buf[b] + b += 1 + + v.NumCrtcs = xgb.Get16(buf[b:]) + b += 2 + + v.NumModes = xgb.Get16(buf[b:]) + b += 2 + + v.NumPreferred = xgb.Get16(buf[b:]) + b += 2 + + v.NumClones = xgb.Get16(buf[b:]) + b += 2 + + v.NameLen = xgb.Get16(buf[b:]) + b += 2 + + v.Crtcs = make([]Crtc, v.NumCrtcs) + for i := 0; i < int(v.NumCrtcs); i++ { + v.Crtcs[i] = Crtc(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + v.Modes = make([]Mode, v.NumModes) + for i := 0; i < int(v.NumModes); i++ { + v.Modes[i] = Mode(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + v.Clones = make([]Output, v.NumClones) + for i := 0; i < int(v.NumClones); i++ { + v.Clones[i] = Output(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + v.Name = make([]byte, v.NameLen) + copy(v.Name[:v.NameLen], buf[b:]) + b += xgb.Pad(int(v.NameLen)) + + return v +} + +// Write request to wire for GetOutputInfo +func getOutputInfoRequest(c *xgb.Conn, Output Output, ConfigTimestamp xproto.Timestamp) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 9 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Output)) + b += 4 + + xgb.Put32(buf[b:], uint32(ConfigTimestamp)) + b += 4 + + return buf +} + +// Request ListOutputProperties +// size: 8 +type ListOutputPropertiesCookie struct { + *xgb.Cookie +} + +func ListOutputProperties(c *xgb.Conn, Output Output) ListOutputPropertiesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(listOutputPropertiesRequest(c, Output), cookie) + return ListOutputPropertiesCookie{cookie} +} + +func ListOutputPropertiesUnchecked(c *xgb.Conn, Output Output) ListOutputPropertiesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(listOutputPropertiesRequest(c, Output), cookie) + return ListOutputPropertiesCookie{cookie} +} + +// Request reply for ListOutputProperties +// size: (32 + xgb.Pad((int(NumAtoms) * 4))) +type ListOutputPropertiesReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumAtoms uint16 + // padding: 22 bytes + Atoms []xproto.Atom // size: xgb.Pad((int(NumAtoms) * 4)) +} + +// Waits and reads reply data from request ListOutputProperties +func (cook ListOutputPropertiesCookie) Reply() (*ListOutputPropertiesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listOutputPropertiesReply(buf), nil +} + +// Read reply into structure from buffer for ListOutputProperties +func listOutputPropertiesReply(buf []byte) *ListOutputPropertiesReply { + v := new(ListOutputPropertiesReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NumAtoms = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + v.Atoms = make([]xproto.Atom, v.NumAtoms) + for i := 0; i < int(v.NumAtoms); i++ { + v.Atoms[i] = xproto.Atom(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for ListOutputProperties +func listOutputPropertiesRequest(c *xgb.Conn, Output Output) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 10 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Output)) + b += 4 + + return buf +} + +// Request QueryOutputProperty +// size: 12 +type QueryOutputPropertyCookie struct { + *xgb.Cookie +} + +func QueryOutputProperty(c *xgb.Conn, Output Output, Property xproto.Atom) QueryOutputPropertyCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryOutputPropertyRequest(c, Output, Property), cookie) + return QueryOutputPropertyCookie{cookie} +} + +func QueryOutputPropertyUnchecked(c *xgb.Conn, Output Output, Property xproto.Atom) QueryOutputPropertyCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryOutputPropertyRequest(c, Output, Property), cookie) + return QueryOutputPropertyCookie{cookie} +} + +// Request reply for QueryOutputProperty +// size: (32 + xgb.Pad((int(Length) * 4))) +type QueryOutputPropertyReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Pending bool + Range bool + Immutable bool + // padding: 21 bytes + ValidValues []int32 // size: xgb.Pad((int(Length) * 4)) +} + +// Waits and reads reply data from request QueryOutputProperty +func (cook QueryOutputPropertyCookie) Reply() (*QueryOutputPropertyReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryOutputPropertyReply(buf), nil +} + +// Read reply into structure from buffer for QueryOutputProperty +func queryOutputPropertyReply(buf []byte) *QueryOutputPropertyReply { + v := new(QueryOutputPropertyReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + if buf[b] == 1 { + v.Pending = true + } else { + v.Pending = false + } + b += 1 + + if buf[b] == 1 { + v.Range = true + } else { + v.Range = false + } + b += 1 + + if buf[b] == 1 { + v.Immutable = true + } else { + v.Immutable = false + } + b += 1 + + b += 21 // padding + + v.ValidValues = make([]int32, v.Length) + for i := 0; i < int(v.Length); i++ { + v.ValidValues[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for QueryOutputProperty +func queryOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 11 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Output)) + b += 4 + + xgb.Put32(buf[b:], uint32(Property)) + b += 4 + + return buf +} + +// Request ConfigureOutputProperty +// size: xgb.Pad((16 + xgb.Pad((len(Values) * 4)))) +type ConfigureOutputPropertyCookie struct { + *xgb.Cookie +} + +// Write request to wire for ConfigureOutputProperty +func ConfigureOutputProperty(c *xgb.Conn, Output Output, Property xproto.Atom, Pending bool, Range bool, Values []int32) ConfigureOutputPropertyCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(configureOutputPropertyRequest(c, Output, Property, Pending, Range, Values), cookie) + return ConfigureOutputPropertyCookie{cookie} +} + +func ConfigureOutputPropertyChecked(c *xgb.Conn, Output Output, Property xproto.Atom, Pending bool, Range bool, Values []int32) ConfigureOutputPropertyCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(configureOutputPropertyRequest(c, Output, Property, Pending, Range, Values), cookie) + return ConfigureOutputPropertyCookie{cookie} +} + +func (cook ConfigureOutputPropertyCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ConfigureOutputProperty +func configureOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom, Pending bool, Range bool, Values []int32) []byte { + size := xgb.Pad((16 + xgb.Pad((len(Values) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 12 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Output)) + b += 4 + + xgb.Put32(buf[b:], uint32(Property)) + b += 4 + + if Pending { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + if Range { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 2 // padding + + for i := 0; i < int(len(Values)); i++ { + xgb.Put32(buf[b:], uint32(Values[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request ChangeOutputProperty +// size: xgb.Pad((24 + xgb.Pad((((int(NumUnits) * int(Format)) / 8) * 1)))) +type ChangeOutputPropertyCookie struct { + *xgb.Cookie +} + +// Write request to wire for ChangeOutputProperty +func ChangeOutputProperty(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, Format byte, Mode byte, NumUnits uint32, Data []byte) ChangeOutputPropertyCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeOutputPropertyRequest(c, Output, Property, Type, Format, Mode, NumUnits, Data), cookie) + return ChangeOutputPropertyCookie{cookie} +} + +func ChangeOutputPropertyChecked(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, Format byte, Mode byte, NumUnits uint32, Data []byte) ChangeOutputPropertyCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeOutputPropertyRequest(c, Output, Property, Type, Format, Mode, NumUnits, Data), cookie) + return ChangeOutputPropertyCookie{cookie} +} + +func (cook ChangeOutputPropertyCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangeOutputProperty +func changeOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, Format byte, Mode byte, NumUnits uint32, Data []byte) []byte { + size := xgb.Pad((24 + xgb.Pad((((int(NumUnits) * int(Format)) / 8) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 13 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Output)) + b += 4 + + xgb.Put32(buf[b:], uint32(Property)) + b += 4 + + xgb.Put32(buf[b:], uint32(Type)) + b += 4 + + buf[b] = Format + b += 1 + + buf[b] = Mode + b += 1 + + b += 2 // padding + + xgb.Put32(buf[b:], NumUnits) + b += 4 + + copy(buf[b:], Data[:((int(NumUnits)*int(Format))/8)]) + b += xgb.Pad(int(((int(NumUnits) * int(Format)) / 8))) + + return buf +} + +// Request DeleteOutputProperty +// size: 12 +type DeleteOutputPropertyCookie struct { + *xgb.Cookie +} + +// Write request to wire for DeleteOutputProperty +func DeleteOutputProperty(c *xgb.Conn, Output Output, Property xproto.Atom) DeleteOutputPropertyCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(deleteOutputPropertyRequest(c, Output, Property), cookie) + return DeleteOutputPropertyCookie{cookie} +} + +func DeleteOutputPropertyChecked(c *xgb.Conn, Output Output, Property xproto.Atom) DeleteOutputPropertyCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(deleteOutputPropertyRequest(c, Output, Property), cookie) + return DeleteOutputPropertyCookie{cookie} +} + +func (cook DeleteOutputPropertyCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DeleteOutputProperty +func deleteOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 14 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Output)) + b += 4 + + xgb.Put32(buf[b:], uint32(Property)) + b += 4 + + return buf +} + +// Request GetOutputProperty +// size: 28 +type GetOutputPropertyCookie struct { + *xgb.Cookie +} + +func GetOutputProperty(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, LongOffset uint32, LongLength uint32, Delete bool, Pending bool) GetOutputPropertyCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getOutputPropertyRequest(c, Output, Property, Type, LongOffset, LongLength, Delete, Pending), cookie) + return GetOutputPropertyCookie{cookie} +} + +func GetOutputPropertyUnchecked(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, LongOffset uint32, LongLength uint32, Delete bool, Pending bool) GetOutputPropertyCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getOutputPropertyRequest(c, Output, Property, Type, LongOffset, LongLength, Delete, Pending), cookie) + return GetOutputPropertyCookie{cookie} +} + +// Request reply for GetOutputProperty +// size: (32 + xgb.Pad(((int(NumItems) * (int(Format) / 8)) * 1))) +type GetOutputPropertyReply struct { + Sequence uint16 + Length uint32 + Format byte + Type xproto.Atom + BytesAfter uint32 + NumItems uint32 + // padding: 12 bytes + Data []byte // size: xgb.Pad(((int(NumItems) * (int(Format) / 8)) * 1)) +} + +// Waits and reads reply data from request GetOutputProperty +func (cook GetOutputPropertyCookie) Reply() (*GetOutputPropertyReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getOutputPropertyReply(buf), nil +} + +// Read reply into structure from buffer for GetOutputProperty +func getOutputPropertyReply(buf []byte) *GetOutputPropertyReply { + v := new(GetOutputPropertyReply) + b := 1 // skip reply determinant + + v.Format = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Type = xproto.Atom(xgb.Get32(buf[b:])) + b += 4 + + v.BytesAfter = xgb.Get32(buf[b:]) + b += 4 + + v.NumItems = xgb.Get32(buf[b:]) + b += 4 + + b += 12 // padding + + v.Data = make([]byte, (int(v.NumItems) * (int(v.Format) / 8))) + copy(v.Data[:(int(v.NumItems)*(int(v.Format)/8))], buf[b:]) + b += xgb.Pad(int((int(v.NumItems) * (int(v.Format) / 8)))) + + return v +} + +// Write request to wire for GetOutputProperty +func getOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, LongOffset uint32, LongLength uint32, Delete bool, Pending bool) []byte { + size := 28 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 15 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Output)) + b += 4 + + xgb.Put32(buf[b:], uint32(Property)) + b += 4 + + xgb.Put32(buf[b:], uint32(Type)) + b += 4 + + xgb.Put32(buf[b:], LongOffset) + b += 4 + + xgb.Put32(buf[b:], LongLength) + b += 4 + + if Delete { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + if Pending { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 2 // padding + + return buf +} + +// Request CreateMode +// size: xgb.Pad((40 + xgb.Pad((len(Name) * 1)))) +type CreateModeCookie struct { + *xgb.Cookie +} + +func CreateMode(c *xgb.Conn, Window xproto.Window, ModeInfo ModeInfo, Name string) CreateModeCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(createModeRequest(c, Window, ModeInfo, Name), cookie) + return CreateModeCookie{cookie} +} + +func CreateModeUnchecked(c *xgb.Conn, Window xproto.Window, ModeInfo ModeInfo, Name string) CreateModeCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(createModeRequest(c, Window, ModeInfo, Name), cookie) + return CreateModeCookie{cookie} +} + +// Request reply for CreateMode +// size: 32 +type CreateModeReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Mode Mode + // padding: 20 bytes +} + +// Waits and reads reply data from request CreateMode +func (cook CreateModeCookie) Reply() (*CreateModeReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return createModeReply(buf), nil +} + +// Read reply into structure from buffer for CreateMode +func createModeReply(buf []byte) *CreateModeReply { + v := new(CreateModeReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Mode = Mode(xgb.Get32(buf[b:])) + b += 4 + + b += 20 // padding + + return v +} + +// Write request to wire for CreateMode +func createModeRequest(c *xgb.Conn, Window xproto.Window, ModeInfo ModeInfo, Name string) []byte { + size := xgb.Pad((40 + xgb.Pad((len(Name) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 16 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + { + structBytes := ModeInfo.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + copy(buf[b:], Name[:len(Name)]) + b += xgb.Pad(int(len(Name))) + + return buf +} + +// Request DestroyMode +// size: 8 +type DestroyModeCookie struct { + *xgb.Cookie +} + +// Write request to wire for DestroyMode +func DestroyMode(c *xgb.Conn, Mode Mode) DestroyModeCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroyModeRequest(c, Mode), cookie) + return DestroyModeCookie{cookie} +} + +func DestroyModeChecked(c *xgb.Conn, Mode Mode) DestroyModeCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(destroyModeRequest(c, Mode), cookie) + return DestroyModeCookie{cookie} +} + +func (cook DestroyModeCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DestroyMode +func destroyModeRequest(c *xgb.Conn, Mode Mode) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 17 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Mode)) + b += 4 + + return buf +} + +// Request AddOutputMode +// size: 12 +type AddOutputModeCookie struct { + *xgb.Cookie +} + +// Write request to wire for AddOutputMode +func AddOutputMode(c *xgb.Conn, Output Output, Mode Mode) AddOutputModeCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(addOutputModeRequest(c, Output, Mode), cookie) + return AddOutputModeCookie{cookie} +} + +func AddOutputModeChecked(c *xgb.Conn, Output Output, Mode Mode) AddOutputModeCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(addOutputModeRequest(c, Output, Mode), cookie) + return AddOutputModeCookie{cookie} +} + +func (cook AddOutputModeCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for AddOutputMode +func addOutputModeRequest(c *xgb.Conn, Output Output, Mode Mode) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 18 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Output)) + b += 4 + + xgb.Put32(buf[b:], uint32(Mode)) + b += 4 + + return buf +} + +// Request DeleteOutputMode +// size: 12 +type DeleteOutputModeCookie struct { + *xgb.Cookie +} + +// Write request to wire for DeleteOutputMode +func DeleteOutputMode(c *xgb.Conn, Output Output, Mode Mode) DeleteOutputModeCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(deleteOutputModeRequest(c, Output, Mode), cookie) + return DeleteOutputModeCookie{cookie} +} + +func DeleteOutputModeChecked(c *xgb.Conn, Output Output, Mode Mode) DeleteOutputModeCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(deleteOutputModeRequest(c, Output, Mode), cookie) + return DeleteOutputModeCookie{cookie} +} + +func (cook DeleteOutputModeCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DeleteOutputMode +func deleteOutputModeRequest(c *xgb.Conn, Output Output, Mode Mode) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 19 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Output)) + b += 4 + + xgb.Put32(buf[b:], uint32(Mode)) + b += 4 + + return buf +} + +// Request GetCrtcInfo +// size: 12 +type GetCrtcInfoCookie struct { + *xgb.Cookie +} + +func GetCrtcInfo(c *xgb.Conn, Crtc Crtc, ConfigTimestamp xproto.Timestamp) GetCrtcInfoCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getCrtcInfoRequest(c, Crtc, ConfigTimestamp), cookie) + return GetCrtcInfoCookie{cookie} +} + +func GetCrtcInfoUnchecked(c *xgb.Conn, Crtc Crtc, ConfigTimestamp xproto.Timestamp) GetCrtcInfoCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getCrtcInfoRequest(c, Crtc, ConfigTimestamp), cookie) + return GetCrtcInfoCookie{cookie} +} + +// Request reply for GetCrtcInfo +// size: ((32 + xgb.Pad((int(NumOutputs) * 4))) + xgb.Pad((int(NumPossibleOutputs) * 4))) +type GetCrtcInfoReply struct { + Sequence uint16 + Length uint32 + Status byte + Timestamp xproto.Timestamp + X int16 + Y int16 + Width uint16 + Height uint16 + Mode Mode + Rotation uint16 + Rotations uint16 + NumOutputs uint16 + NumPossibleOutputs uint16 + Outputs []Output // size: xgb.Pad((int(NumOutputs) * 4)) + Possible []Output // size: xgb.Pad((int(NumPossibleOutputs) * 4)) +} + +// Waits and reads reply data from request GetCrtcInfo +func (cook GetCrtcInfoCookie) Reply() (*GetCrtcInfoReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getCrtcInfoReply(buf), nil +} + +// Read reply into structure from buffer for GetCrtcInfo +func getCrtcInfoReply(buf []byte) *GetCrtcInfoReply { + v := new(GetCrtcInfoReply) + b := 1 // skip reply determinant + + v.Status = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.Mode = Mode(xgb.Get32(buf[b:])) + b += 4 + + v.Rotation = xgb.Get16(buf[b:]) + b += 2 + + v.Rotations = xgb.Get16(buf[b:]) + b += 2 + + v.NumOutputs = xgb.Get16(buf[b:]) + b += 2 + + v.NumPossibleOutputs = xgb.Get16(buf[b:]) + b += 2 + + v.Outputs = make([]Output, v.NumOutputs) + for i := 0; i < int(v.NumOutputs); i++ { + v.Outputs[i] = Output(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + v.Possible = make([]Output, v.NumPossibleOutputs) + for i := 0; i < int(v.NumPossibleOutputs); i++ { + v.Possible[i] = Output(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetCrtcInfo +func getCrtcInfoRequest(c *xgb.Conn, Crtc Crtc, ConfigTimestamp xproto.Timestamp) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 20 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Crtc)) + b += 4 + + xgb.Put32(buf[b:], uint32(ConfigTimestamp)) + b += 4 + + return buf +} + +// Request SetCrtcConfig +// size: xgb.Pad((28 + xgb.Pad((len(Outputs) * 4)))) +type SetCrtcConfigCookie struct { + *xgb.Cookie +} + +func SetCrtcConfig(c *xgb.Conn, Crtc Crtc, Timestamp xproto.Timestamp, ConfigTimestamp xproto.Timestamp, X int16, Y int16, Mode Mode, Rotation uint16, Outputs []Output) SetCrtcConfigCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(setCrtcConfigRequest(c, Crtc, Timestamp, ConfigTimestamp, X, Y, Mode, Rotation, Outputs), cookie) + return SetCrtcConfigCookie{cookie} +} + +func SetCrtcConfigUnchecked(c *xgb.Conn, Crtc Crtc, Timestamp xproto.Timestamp, ConfigTimestamp xproto.Timestamp, X int16, Y int16, Mode Mode, Rotation uint16, Outputs []Output) SetCrtcConfigCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(setCrtcConfigRequest(c, Crtc, Timestamp, ConfigTimestamp, X, Y, Mode, Rotation, Outputs), cookie) + return SetCrtcConfigCookie{cookie} +} + +// Request reply for SetCrtcConfig +// size: 32 +type SetCrtcConfigReply struct { + Sequence uint16 + Length uint32 + Status byte + Timestamp xproto.Timestamp + // padding: 20 bytes +} + +// Waits and reads reply data from request SetCrtcConfig +func (cook SetCrtcConfigCookie) Reply() (*SetCrtcConfigReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return setCrtcConfigReply(buf), nil +} + +// Read reply into structure from buffer for SetCrtcConfig +func setCrtcConfigReply(buf []byte) *SetCrtcConfigReply { + v := new(SetCrtcConfigReply) + b := 1 // skip reply determinant + + v.Status = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + b += 20 // padding + + return v +} + +// Write request to wire for SetCrtcConfig +func setCrtcConfigRequest(c *xgb.Conn, Crtc Crtc, Timestamp xproto.Timestamp, ConfigTimestamp xproto.Timestamp, X int16, Y int16, Mode Mode, Rotation uint16, Outputs []Output) []byte { + size := xgb.Pad((28 + xgb.Pad((len(Outputs) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 21 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Crtc)) + b += 4 + + xgb.Put32(buf[b:], uint32(Timestamp)) + b += 4 + + xgb.Put32(buf[b:], uint32(ConfigTimestamp)) + b += 4 + + xgb.Put16(buf[b:], uint16(X)) + b += 2 + + xgb.Put16(buf[b:], uint16(Y)) + b += 2 + + xgb.Put32(buf[b:], uint32(Mode)) + b += 4 + + xgb.Put16(buf[b:], Rotation) + b += 2 + + b += 2 // padding + + for i := 0; i < int(len(Outputs)); i++ { + xgb.Put32(buf[b:], uint32(Outputs[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request GetCrtcGammaSize +// size: 8 +type GetCrtcGammaSizeCookie struct { + *xgb.Cookie +} + +func GetCrtcGammaSize(c *xgb.Conn, Crtc Crtc) GetCrtcGammaSizeCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getCrtcGammaSizeRequest(c, Crtc), cookie) + return GetCrtcGammaSizeCookie{cookie} +} + +func GetCrtcGammaSizeUnchecked(c *xgb.Conn, Crtc Crtc) GetCrtcGammaSizeCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getCrtcGammaSizeRequest(c, Crtc), cookie) + return GetCrtcGammaSizeCookie{cookie} +} + +// Request reply for GetCrtcGammaSize +// size: 32 +type GetCrtcGammaSizeReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Size uint16 + // padding: 22 bytes +} + +// Waits and reads reply data from request GetCrtcGammaSize +func (cook GetCrtcGammaSizeCookie) Reply() (*GetCrtcGammaSizeReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getCrtcGammaSizeReply(buf), nil +} + +// Read reply into structure from buffer for GetCrtcGammaSize +func getCrtcGammaSizeReply(buf []byte) *GetCrtcGammaSizeReply { + v := new(GetCrtcGammaSizeReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Size = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + return v +} + +// Write request to wire for GetCrtcGammaSize +func getCrtcGammaSizeRequest(c *xgb.Conn, Crtc Crtc) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 22 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Crtc)) + b += 4 + + return buf +} + +// Request GetCrtcGamma +// size: 8 +type GetCrtcGammaCookie struct { + *xgb.Cookie +} + +func GetCrtcGamma(c *xgb.Conn, Crtc Crtc) GetCrtcGammaCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getCrtcGammaRequest(c, Crtc), cookie) + return GetCrtcGammaCookie{cookie} +} + +func GetCrtcGammaUnchecked(c *xgb.Conn, Crtc Crtc) GetCrtcGammaCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getCrtcGammaRequest(c, Crtc), cookie) + return GetCrtcGammaCookie{cookie} +} + +// Request reply for GetCrtcGamma +// size: (((32 + xgb.Pad((int(Size) * 2))) + xgb.Pad((int(Size) * 2))) + xgb.Pad((int(Size) * 2))) +type GetCrtcGammaReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Size uint16 + // padding: 22 bytes + Red []uint16 // size: xgb.Pad((int(Size) * 2)) + Green []uint16 // size: xgb.Pad((int(Size) * 2)) + Blue []uint16 // size: xgb.Pad((int(Size) * 2)) +} + +// Waits and reads reply data from request GetCrtcGamma +func (cook GetCrtcGammaCookie) Reply() (*GetCrtcGammaReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getCrtcGammaReply(buf), nil +} + +// Read reply into structure from buffer for GetCrtcGamma +func getCrtcGammaReply(buf []byte) *GetCrtcGammaReply { + v := new(GetCrtcGammaReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Size = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + v.Red = make([]uint16, v.Size) + for i := 0; i < int(v.Size); i++ { + v.Red[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) + + v.Green = make([]uint16, v.Size) + for i := 0; i < int(v.Size); i++ { + v.Green[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) + + v.Blue = make([]uint16, v.Size) + for i := 0; i < int(v.Size); i++ { + v.Blue[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetCrtcGamma +func getCrtcGammaRequest(c *xgb.Conn, Crtc Crtc) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 23 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Crtc)) + b += 4 + + return buf +} + +// Request SetCrtcGamma +// size: xgb.Pad((((12 + xgb.Pad((int(Size) * 2))) + xgb.Pad((int(Size) * 2))) + xgb.Pad((int(Size) * 2)))) +type SetCrtcGammaCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetCrtcGamma +func SetCrtcGamma(c *xgb.Conn, Crtc Crtc, Size uint16, Red []uint16, Green []uint16, Blue []uint16) SetCrtcGammaCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setCrtcGammaRequest(c, Crtc, Size, Red, Green, Blue), cookie) + return SetCrtcGammaCookie{cookie} +} + +func SetCrtcGammaChecked(c *xgb.Conn, Crtc Crtc, Size uint16, Red []uint16, Green []uint16, Blue []uint16) SetCrtcGammaCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setCrtcGammaRequest(c, Crtc, Size, Red, Green, Blue), cookie) + return SetCrtcGammaCookie{cookie} +} + +func (cook SetCrtcGammaCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetCrtcGamma +func setCrtcGammaRequest(c *xgb.Conn, Crtc Crtc, Size uint16, Red []uint16, Green []uint16, Blue []uint16) []byte { + size := xgb.Pad((((12 + xgb.Pad((int(Size) * 2))) + xgb.Pad((int(Size) * 2))) + xgb.Pad((int(Size) * 2)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 24 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Crtc)) + b += 4 + + xgb.Put16(buf[b:], Size) + b += 2 + + b += 2 // padding + + for i := 0; i < int(Size); i++ { + xgb.Put16(buf[b:], Red[i]) + b += 2 + } + b = xgb.Pad(b) + + for i := 0; i < int(Size); i++ { + xgb.Put16(buf[b:], Green[i]) + b += 2 + } + b = xgb.Pad(b) + + for i := 0; i < int(Size); i++ { + xgb.Put16(buf[b:], Blue[i]) + b += 2 + } + b = xgb.Pad(b) + + return buf +} + +// Request GetScreenResourcesCurrent +// size: 8 +type GetScreenResourcesCurrentCookie struct { + *xgb.Cookie +} + +func GetScreenResourcesCurrent(c *xgb.Conn, Window xproto.Window) GetScreenResourcesCurrentCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getScreenResourcesCurrentRequest(c, Window), cookie) + return GetScreenResourcesCurrentCookie{cookie} +} + +func GetScreenResourcesCurrentUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenResourcesCurrentCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getScreenResourcesCurrentRequest(c, Window), cookie) + return GetScreenResourcesCurrentCookie{cookie} +} + +// Request reply for GetScreenResourcesCurrent +// size: ((((32 + xgb.Pad((int(NumCrtcs) * 4))) + xgb.Pad((int(NumOutputs) * 4))) + xgb.Pad((int(NumModes) * 32))) + xgb.Pad((int(NamesLen) * 1))) +type GetScreenResourcesCurrentReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Timestamp xproto.Timestamp + ConfigTimestamp xproto.Timestamp + NumCrtcs uint16 + NumOutputs uint16 + NumModes uint16 + NamesLen uint16 + // padding: 8 bytes + Crtcs []Crtc // size: xgb.Pad((int(NumCrtcs) * 4)) + Outputs []Output // size: xgb.Pad((int(NumOutputs) * 4)) + Modes []ModeInfo // size: xgb.Pad((int(NumModes) * 32)) + Names []byte // size: xgb.Pad((int(NamesLen) * 1)) +} + +// Waits and reads reply data from request GetScreenResourcesCurrent +func (cook GetScreenResourcesCurrentCookie) Reply() (*GetScreenResourcesCurrentReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getScreenResourcesCurrentReply(buf), nil +} + +// Read reply into structure from buffer for GetScreenResourcesCurrent +func getScreenResourcesCurrentReply(buf []byte) *GetScreenResourcesCurrentReply { + v := new(GetScreenResourcesCurrentReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.ConfigTimestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.NumCrtcs = xgb.Get16(buf[b:]) + b += 2 + + v.NumOutputs = xgb.Get16(buf[b:]) + b += 2 + + v.NumModes = xgb.Get16(buf[b:]) + b += 2 + + v.NamesLen = xgb.Get16(buf[b:]) + b += 2 + + b += 8 // padding + + v.Crtcs = make([]Crtc, v.NumCrtcs) + for i := 0; i < int(v.NumCrtcs); i++ { + v.Crtcs[i] = Crtc(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + v.Outputs = make([]Output, v.NumOutputs) + for i := 0; i < int(v.NumOutputs); i++ { + v.Outputs[i] = Output(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + v.Modes = make([]ModeInfo, v.NumModes) + b += ModeInfoReadList(buf[b:], v.Modes) + + v.Names = make([]byte, v.NamesLen) + copy(v.Names[:v.NamesLen], buf[b:]) + b += xgb.Pad(int(v.NamesLen)) + + return v +} + +// Write request to wire for GetScreenResourcesCurrent +func getScreenResourcesCurrentRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 25 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + +// Request SetCrtcTransform +// size: xgb.Pad(((48 + xgb.Pad((int(FilterLen) * 1))) + xgb.Pad((len(FilterParams) * 4)))) +type SetCrtcTransformCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetCrtcTransform +func SetCrtcTransform(c *xgb.Conn, Crtc Crtc, Transform render.Transform, FilterLen uint16, FilterName string, FilterParams []render.Fixed) SetCrtcTransformCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setCrtcTransformRequest(c, Crtc, Transform, FilterLen, FilterName, FilterParams), cookie) + return SetCrtcTransformCookie{cookie} +} + +func SetCrtcTransformChecked(c *xgb.Conn, Crtc Crtc, Transform render.Transform, FilterLen uint16, FilterName string, FilterParams []render.Fixed) SetCrtcTransformCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setCrtcTransformRequest(c, Crtc, Transform, FilterLen, FilterName, FilterParams), cookie) + return SetCrtcTransformCookie{cookie} +} + +func (cook SetCrtcTransformCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetCrtcTransform +func setCrtcTransformRequest(c *xgb.Conn, Crtc Crtc, Transform render.Transform, FilterLen uint16, FilterName string, FilterParams []render.Fixed) []byte { + size := xgb.Pad(((48 + xgb.Pad((int(FilterLen) * 1))) + xgb.Pad((len(FilterParams) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 26 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Crtc)) + b += 4 + + { + structBytes := Transform.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + xgb.Put16(buf[b:], FilterLen) + b += 2 + + b += 2 // padding + + copy(buf[b:], FilterName[:FilterLen]) + b += xgb.Pad(int(FilterLen)) + + for i := 0; i < int(len(FilterParams)); i++ { + xgb.Put32(buf[b:], uint32(FilterParams[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request GetCrtcTransform +// size: 8 +type GetCrtcTransformCookie struct { + *xgb.Cookie +} + +func GetCrtcTransform(c *xgb.Conn, Crtc Crtc) GetCrtcTransformCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getCrtcTransformRequest(c, Crtc), cookie) + return GetCrtcTransformCookie{cookie} +} + +func GetCrtcTransformUnchecked(c *xgb.Conn, Crtc Crtc) GetCrtcTransformCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getCrtcTransformRequest(c, Crtc), cookie) + return GetCrtcTransformCookie{cookie} +} + +// Request reply for GetCrtcTransform +// size: ((((96 + xgb.Pad((int(PendingLen) * 1))) + xgb.Pad((int(PendingNparams) * 4))) + xgb.Pad((int(CurrentLen) * 1))) + xgb.Pad((int(CurrentNparams) * 4))) +type GetCrtcTransformReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + PendingTransform render.Transform + HasTransforms bool + // padding: 3 bytes + CurrentTransform render.Transform + // padding: 4 bytes + PendingLen uint16 + PendingNparams uint16 + CurrentLen uint16 + CurrentNparams uint16 + PendingFilterName string // size: xgb.Pad((int(PendingLen) * 1)) + PendingParams []render.Fixed // size: xgb.Pad((int(PendingNparams) * 4)) + CurrentFilterName string // size: xgb.Pad((int(CurrentLen) * 1)) + CurrentParams []render.Fixed // size: xgb.Pad((int(CurrentNparams) * 4)) +} + +// Waits and reads reply data from request GetCrtcTransform +func (cook GetCrtcTransformCookie) Reply() (*GetCrtcTransformReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getCrtcTransformReply(buf), nil +} + +// Read reply into structure from buffer for GetCrtcTransform +func getCrtcTransformReply(buf []byte) *GetCrtcTransformReply { + v := new(GetCrtcTransformReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.PendingTransform = render.Transform{} + b += render.TransformRead(buf[b:], &v.PendingTransform) + + if buf[b] == 1 { + v.HasTransforms = true + } else { + v.HasTransforms = false + } + b += 1 + + b += 3 // padding + + v.CurrentTransform = render.Transform{} + b += render.TransformRead(buf[b:], &v.CurrentTransform) + + b += 4 // padding + + v.PendingLen = xgb.Get16(buf[b:]) + b += 2 + + v.PendingNparams = xgb.Get16(buf[b:]) + b += 2 + + v.CurrentLen = xgb.Get16(buf[b:]) + b += 2 + + v.CurrentNparams = xgb.Get16(buf[b:]) + b += 2 + + { + byteString := make([]byte, v.PendingLen) + copy(byteString[:v.PendingLen], buf[b:]) + v.PendingFilterName = string(byteString) + b += xgb.Pad(int(v.PendingLen)) + } + + v.PendingParams = make([]render.Fixed, v.PendingNparams) + for i := 0; i < int(v.PendingNparams); i++ { + v.PendingParams[i] = render.Fixed(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + { + byteString := make([]byte, v.CurrentLen) + copy(byteString[:v.CurrentLen], buf[b:]) + v.CurrentFilterName = string(byteString) + b += xgb.Pad(int(v.CurrentLen)) + } + + v.CurrentParams = make([]render.Fixed, v.CurrentNparams) + for i := 0; i < int(v.CurrentNparams); i++ { + v.CurrentParams[i] = render.Fixed(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetCrtcTransform +func getCrtcTransformRequest(c *xgb.Conn, Crtc Crtc) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 27 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Crtc)) + b += 4 + + return buf +} + +// Request GetPanning +// size: 8 +type GetPanningCookie struct { + *xgb.Cookie +} + +func GetPanning(c *xgb.Conn, Crtc Crtc) GetPanningCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getPanningRequest(c, Crtc), cookie) + return GetPanningCookie{cookie} +} + +func GetPanningUnchecked(c *xgb.Conn, Crtc Crtc) GetPanningCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getPanningRequest(c, Crtc), cookie) + return GetPanningCookie{cookie} +} + +// Request reply for GetPanning +// size: 36 +type GetPanningReply struct { + Sequence uint16 + Length uint32 + Status byte + Timestamp xproto.Timestamp + Left uint16 + Top uint16 + Width uint16 + Height uint16 + TrackLeft uint16 + TrackTop uint16 + TrackWidth uint16 + TrackHeight uint16 + BorderLeft int16 + BorderTop int16 + BorderRight int16 + BorderBottom int16 +} + +// Waits and reads reply data from request GetPanning +func (cook GetPanningCookie) Reply() (*GetPanningReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPanningReply(buf), nil +} + +// Read reply into structure from buffer for GetPanning +func getPanningReply(buf []byte) *GetPanningReply { + v := new(GetPanningReply) + b := 1 // skip reply determinant + + v.Status = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Left = xgb.Get16(buf[b:]) + b += 2 + + v.Top = xgb.Get16(buf[b:]) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.TrackLeft = xgb.Get16(buf[b:]) + b += 2 + + v.TrackTop = xgb.Get16(buf[b:]) + b += 2 + + v.TrackWidth = xgb.Get16(buf[b:]) + b += 2 + + v.TrackHeight = xgb.Get16(buf[b:]) + b += 2 + + v.BorderLeft = int16(xgb.Get16(buf[b:])) + b += 2 + + v.BorderTop = int16(xgb.Get16(buf[b:])) + b += 2 + + v.BorderRight = int16(xgb.Get16(buf[b:])) + b += 2 + + v.BorderBottom = int16(xgb.Get16(buf[b:])) + b += 2 + + return v +} + +// Write request to wire for GetPanning +func getPanningRequest(c *xgb.Conn, Crtc Crtc) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 28 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Crtc)) + b += 4 + + return buf +} + +// Request SetPanning +// size: 36 +type SetPanningCookie struct { + *xgb.Cookie +} + +func SetPanning(c *xgb.Conn, Crtc Crtc, Timestamp xproto.Timestamp, Left uint16, Top uint16, Width uint16, Height uint16, TrackLeft uint16, TrackTop uint16, TrackWidth uint16, TrackHeight uint16, BorderLeft int16, BorderTop int16, BorderRight int16, BorderBottom int16) SetPanningCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(setPanningRequest(c, Crtc, Timestamp, Left, Top, Width, Height, TrackLeft, TrackTop, TrackWidth, TrackHeight, BorderLeft, BorderTop, BorderRight, BorderBottom), cookie) + return SetPanningCookie{cookie} +} + +func SetPanningUnchecked(c *xgb.Conn, Crtc Crtc, Timestamp xproto.Timestamp, Left uint16, Top uint16, Width uint16, Height uint16, TrackLeft uint16, TrackTop uint16, TrackWidth uint16, TrackHeight uint16, BorderLeft int16, BorderTop int16, BorderRight int16, BorderBottom int16) SetPanningCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(setPanningRequest(c, Crtc, Timestamp, Left, Top, Width, Height, TrackLeft, TrackTop, TrackWidth, TrackHeight, BorderLeft, BorderTop, BorderRight, BorderBottom), cookie) + return SetPanningCookie{cookie} +} + +// Request reply for SetPanning +// size: 12 +type SetPanningReply struct { + Sequence uint16 + Length uint32 + Status byte + Timestamp xproto.Timestamp +} + +// Waits and reads reply data from request SetPanning +func (cook SetPanningCookie) Reply() (*SetPanningReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return setPanningReply(buf), nil +} + +// Read reply into structure from buffer for SetPanning +func setPanningReply(buf []byte) *SetPanningReply { + v := new(SetPanningReply) + b := 1 // skip reply determinant + + v.Status = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Write request to wire for SetPanning +func setPanningRequest(c *xgb.Conn, Crtc Crtc, Timestamp xproto.Timestamp, Left uint16, Top uint16, Width uint16, Height uint16, TrackLeft uint16, TrackTop uint16, TrackWidth uint16, TrackHeight uint16, BorderLeft int16, BorderTop int16, BorderRight int16, BorderBottom int16) []byte { + size := 36 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 29 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Crtc)) + b += 4 + + xgb.Put32(buf[b:], uint32(Timestamp)) + b += 4 + + xgb.Put16(buf[b:], Left) + b += 2 + + xgb.Put16(buf[b:], Top) + b += 2 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + xgb.Put16(buf[b:], TrackLeft) + b += 2 + + xgb.Put16(buf[b:], TrackTop) + b += 2 + + xgb.Put16(buf[b:], TrackWidth) + b += 2 + + xgb.Put16(buf[b:], TrackHeight) + b += 2 + + xgb.Put16(buf[b:], uint16(BorderLeft)) + b += 2 + + xgb.Put16(buf[b:], uint16(BorderTop)) + b += 2 + + xgb.Put16(buf[b:], uint16(BorderRight)) + b += 2 + + xgb.Put16(buf[b:], uint16(BorderBottom)) + b += 2 + + return buf +} + +// Request SetOutputPrimary +// size: 12 +type SetOutputPrimaryCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetOutputPrimary +func SetOutputPrimary(c *xgb.Conn, Window xproto.Window, Output Output) SetOutputPrimaryCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setOutputPrimaryRequest(c, Window, Output), cookie) + return SetOutputPrimaryCookie{cookie} +} + +func SetOutputPrimaryChecked(c *xgb.Conn, Window xproto.Window, Output Output) SetOutputPrimaryCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setOutputPrimaryRequest(c, Window, Output), cookie) + return SetOutputPrimaryCookie{cookie} +} + +func (cook SetOutputPrimaryCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetOutputPrimary +func setOutputPrimaryRequest(c *xgb.Conn, Window xproto.Window, Output Output) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 30 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(Output)) + b += 4 + + return buf +} + +// Request GetOutputPrimary +// size: 8 +type GetOutputPrimaryCookie struct { + *xgb.Cookie +} + +func GetOutputPrimary(c *xgb.Conn, Window xproto.Window) GetOutputPrimaryCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getOutputPrimaryRequest(c, Window), cookie) + return GetOutputPrimaryCookie{cookie} +} + +func GetOutputPrimaryUnchecked(c *xgb.Conn, Window xproto.Window) GetOutputPrimaryCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getOutputPrimaryRequest(c, Window), cookie) + return GetOutputPrimaryCookie{cookie} +} + +// Request reply for GetOutputPrimary +// size: 12 +type GetOutputPrimaryReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Output Output +} + +// Waits and reads reply data from request GetOutputPrimary +func (cook GetOutputPrimaryCookie) Reply() (*GetOutputPrimaryReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getOutputPrimaryReply(buf), nil +} + +// Read reply into structure from buffer for GetOutputPrimary +func getOutputPrimaryReply(buf []byte) *GetOutputPrimaryReply { + v := new(GetOutputPrimaryReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Output = Output(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Write request to wire for GetOutputPrimary +func getOutputPrimaryRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RANDR"] + b += 1 + + buf[b] = 31 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} diff --git a/nexgb/record/record.go b/nexgb/record/record.go new file mode 100644 index 0000000..04d514b --- /dev/null +++ b/nexgb/record/record.go @@ -0,0 +1,1089 @@ +package record + +/* + This file was generated by record.xml on May 10 2012 4:20:28pm EDT. + This file is automatically generated. Edit at your peril! +*/ + +import ( + "github.com/BurntSushi/xgb" + + "github.com/BurntSushi/xgb/xproto" +) + +// Init must be called before using the RECORD extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 6, "RECORD").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named RECORD could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["RECORD"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["RECORD"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["RECORD"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["RECORD"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["RECORD"] = make(map[int]xgb.NewErrorFun) +} + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Bool' + +// Skipping definition for base type 'Float' + +// Skipping definition for base type 'Card8' + +const ( + HTypeFromServerTime = 1 + HTypeFromClientTime = 2 + HTypeFromClientSequence = 4 +) + +const ( + CsCurrentClients = 1 + CsFutureClients = 2 + CsAllClients = 3 +) + +type Context uint32 + +func NewContextId(c *xgb.Conn) (Context, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Context(id), nil +} + +type ElementHeader byte + +type ClientSpec uint32 + +// 'Range8' struct definition +// Size: 2 +type Range8 struct { + First byte + Last byte +} + +// Struct read Range8 +func Range8Read(buf []byte, v *Range8) int { + b := 0 + + v.First = buf[b] + b += 1 + + v.Last = buf[b] + b += 1 + + return b +} + +// Struct list read Range8 +func Range8ReadList(buf []byte, dest []Range8) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Range8{} + b += Range8Read(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Range8 +func (v Range8) Bytes() []byte { + buf := make([]byte, 2) + b := 0 + + buf[b] = v.First + b += 1 + + buf[b] = v.Last + b += 1 + + return buf +} + +// Write struct list Range8 +func Range8ListBytes(buf []byte, list []Range8) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Range16' struct definition +// Size: 4 +type Range16 struct { + First uint16 + Last uint16 +} + +// Struct read Range16 +func Range16Read(buf []byte, v *Range16) int { + b := 0 + + v.First = xgb.Get16(buf[b:]) + b += 2 + + v.Last = xgb.Get16(buf[b:]) + b += 2 + + return b +} + +// Struct list read Range16 +func Range16ReadList(buf []byte, dest []Range16) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Range16{} + b += Range16Read(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Range16 +func (v Range16) Bytes() []byte { + buf := make([]byte, 4) + b := 0 + + xgb.Put16(buf[b:], v.First) + b += 2 + + xgb.Put16(buf[b:], v.Last) + b += 2 + + return buf +} + +// Write struct list Range16 +func Range16ListBytes(buf []byte, list []Range16) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'ExtRange' struct definition +// Size: 6 +type ExtRange struct { + Major Range8 + Minor Range16 +} + +// Struct read ExtRange +func ExtRangeRead(buf []byte, v *ExtRange) int { + b := 0 + + v.Major = Range8{} + b += Range8Read(buf[b:], &v.Major) + + v.Minor = Range16{} + b += Range16Read(buf[b:], &v.Minor) + + return b +} + +// Struct list read ExtRange +func ExtRangeReadList(buf []byte, dest []ExtRange) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = ExtRange{} + b += ExtRangeRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write ExtRange +func (v ExtRange) Bytes() []byte { + buf := make([]byte, 6) + b := 0 + + { + structBytes := v.Major.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.Minor.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + return buf +} + +// Write struct list ExtRange +func ExtRangeListBytes(buf []byte, list []ExtRange) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Range' struct definition +// Size: 24 +type Range struct { + CoreRequests Range8 + CoreReplies Range8 + ExtRequests ExtRange + ExtReplies ExtRange + DeliveredEvents Range8 + DeviceEvents Range8 + Errors Range8 + ClientStarted bool + ClientDied bool +} + +// Struct read Range +func RangeRead(buf []byte, v *Range) int { + b := 0 + + v.CoreRequests = Range8{} + b += Range8Read(buf[b:], &v.CoreRequests) + + v.CoreReplies = Range8{} + b += Range8Read(buf[b:], &v.CoreReplies) + + v.ExtRequests = ExtRange{} + b += ExtRangeRead(buf[b:], &v.ExtRequests) + + v.ExtReplies = ExtRange{} + b += ExtRangeRead(buf[b:], &v.ExtReplies) + + v.DeliveredEvents = Range8{} + b += Range8Read(buf[b:], &v.DeliveredEvents) + + v.DeviceEvents = Range8{} + b += Range8Read(buf[b:], &v.DeviceEvents) + + v.Errors = Range8{} + b += Range8Read(buf[b:], &v.Errors) + + if buf[b] == 1 { + v.ClientStarted = true + } else { + v.ClientStarted = false + } + b += 1 + + if buf[b] == 1 { + v.ClientDied = true + } else { + v.ClientDied = false + } + b += 1 + + return b +} + +// Struct list read Range +func RangeReadList(buf []byte, dest []Range) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Range{} + b += RangeRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Range +func (v Range) Bytes() []byte { + buf := make([]byte, 24) + b := 0 + + { + structBytes := v.CoreRequests.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.CoreReplies.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.ExtRequests.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.ExtReplies.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.DeliveredEvents.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.DeviceEvents.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.Errors.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + if v.ClientStarted { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + if v.ClientDied { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + return buf +} + +// Write struct list Range +func RangeListBytes(buf []byte, list []Range) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'ClientInfo' struct definition +// Size: (8 + xgb.Pad((int(NumRanges) * 24))) +type ClientInfo struct { + ClientResource ClientSpec + NumRanges uint32 + Ranges []Range // size: xgb.Pad((int(NumRanges) * 24)) +} + +// Struct read ClientInfo +func ClientInfoRead(buf []byte, v *ClientInfo) int { + b := 0 + + v.ClientResource = ClientSpec(xgb.Get32(buf[b:])) + b += 4 + + v.NumRanges = xgb.Get32(buf[b:]) + b += 4 + + v.Ranges = make([]Range, v.NumRanges) + b += RangeReadList(buf[b:], v.Ranges) + + return b +} + +// Struct list read ClientInfo +func ClientInfoReadList(buf []byte, dest []ClientInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = ClientInfo{} + b += ClientInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write ClientInfo +func (v ClientInfo) Bytes() []byte { + buf := make([]byte, (8 + xgb.Pad((int(v.NumRanges) * 24)))) + b := 0 + + xgb.Put32(buf[b:], uint32(v.ClientResource)) + b += 4 + + xgb.Put32(buf[b:], v.NumRanges) + b += 4 + + b += RangeListBytes(buf[b:], v.Ranges) + + return buf +} + +// Write struct list ClientInfo +func ClientInfoListBytes(buf []byte, list []ClientInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size ClientInfo +func ClientInfoListSize(list []ClientInfo) int { + size := 0 + for _, item := range list { + size += (8 + xgb.Pad((int(item.NumRanges) * 24))) + } + return size +} + +// Error definition BadContext (0) +// Size: 32 + +const BadBadContext = 0 + +type BadContextError struct { + Sequence uint16 + NiceName string + InvalidRecord uint32 +} + +// Error read BadContext +func BadContextErrorNew(buf []byte) xgb.Error { + v := BadContextError{} + v.NiceName = "BadContext" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.InvalidRecord = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +func (err BadContextError) ImplementsError() {} + +func (err BadContextError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadContextError) BadId() uint32 { + return 0 +} + +func (err BadContextError) Error() string { + fieldVals := make([]string, 0, 1) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("InvalidRecord: %d", err.InvalidRecord)) + return "BadBadContext {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["RECORD"][0] = BadContextErrorNew +} + +// Request QueryVersion +// size: 8 +type QueryVersionCookie struct { + *xgb.Cookie +} + +func QueryVersion(c *xgb.Conn, MajorVersion uint16, MinorVersion uint16) QueryVersionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) + return QueryVersionCookie{cookie} +} + +func QueryVersionUnchecked(c *xgb.Conn, MajorVersion uint16, MinorVersion uint16) QueryVersionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) + return QueryVersionCookie{cookie} +} + +// Request reply for QueryVersion +// size: 12 +type QueryVersionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + MajorVersion uint16 + MinorVersion uint16 +} + +// Waits and reads reply data from request QueryVersion +func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryVersionReply(buf), nil +} + +// Read reply into structure from buffer for QueryVersion +func queryVersionReply(buf []byte) *QueryVersionReply { + v := new(QueryVersionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.MajorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.MinorVersion = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Write request to wire for QueryVersion +func queryVersionRequest(c *xgb.Conn, MajorVersion uint16, MinorVersion uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RECORD"] + b += 1 + + buf[b] = 0 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], MajorVersion) + b += 2 + + xgb.Put16(buf[b:], MinorVersion) + b += 2 + + return buf +} + +// Request CreateContext +// size: xgb.Pad(((20 + xgb.Pad((int(NumClientSpecs) * 4))) + xgb.Pad((int(NumRanges) * 24)))) +type CreateContextCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateContext +func CreateContext(c *xgb.Conn, Context Context, ElementHeader ElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []ClientSpec, Ranges []Range) CreateContextCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createContextRequest(c, Context, ElementHeader, NumClientSpecs, NumRanges, ClientSpecs, Ranges), cookie) + return CreateContextCookie{cookie} +} + +func CreateContextChecked(c *xgb.Conn, Context Context, ElementHeader ElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []ClientSpec, Ranges []Range) CreateContextCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createContextRequest(c, Context, ElementHeader, NumClientSpecs, NumRanges, ClientSpecs, Ranges), cookie) + return CreateContextCookie{cookie} +} + +func (cook CreateContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateContext +func createContextRequest(c *xgb.Conn, Context Context, ElementHeader ElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []ClientSpec, Ranges []Range) []byte { + size := xgb.Pad(((20 + xgb.Pad((int(NumClientSpecs) * 4))) + xgb.Pad((int(NumRanges) * 24)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RECORD"] + b += 1 + + buf[b] = 1 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + buf[b] = byte(ElementHeader) + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], NumClientSpecs) + b += 4 + + xgb.Put32(buf[b:], NumRanges) + b += 4 + + for i := 0; i < int(NumClientSpecs); i++ { + xgb.Put32(buf[b:], uint32(ClientSpecs[i])) + b += 4 + } + b = xgb.Pad(b) + + b += RangeListBytes(buf[b:], Ranges) + + return buf +} + +// Request RegisterClients +// size: xgb.Pad(((20 + xgb.Pad((int(NumClientSpecs) * 4))) + xgb.Pad((int(NumRanges) * 24)))) +type RegisterClientsCookie struct { + *xgb.Cookie +} + +// Write request to wire for RegisterClients +func RegisterClients(c *xgb.Conn, Context Context, ElementHeader ElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []ClientSpec, Ranges []Range) RegisterClientsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(registerClientsRequest(c, Context, ElementHeader, NumClientSpecs, NumRanges, ClientSpecs, Ranges), cookie) + return RegisterClientsCookie{cookie} +} + +func RegisterClientsChecked(c *xgb.Conn, Context Context, ElementHeader ElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []ClientSpec, Ranges []Range) RegisterClientsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(registerClientsRequest(c, Context, ElementHeader, NumClientSpecs, NumRanges, ClientSpecs, Ranges), cookie) + return RegisterClientsCookie{cookie} +} + +func (cook RegisterClientsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for RegisterClients +func registerClientsRequest(c *xgb.Conn, Context Context, ElementHeader ElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []ClientSpec, Ranges []Range) []byte { + size := xgb.Pad(((20 + xgb.Pad((int(NumClientSpecs) * 4))) + xgb.Pad((int(NumRanges) * 24)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RECORD"] + b += 1 + + buf[b] = 2 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + buf[b] = byte(ElementHeader) + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], NumClientSpecs) + b += 4 + + xgb.Put32(buf[b:], NumRanges) + b += 4 + + for i := 0; i < int(NumClientSpecs); i++ { + xgb.Put32(buf[b:], uint32(ClientSpecs[i])) + b += 4 + } + b = xgb.Pad(b) + + b += RangeListBytes(buf[b:], Ranges) + + return buf +} + +// Request UnregisterClients +// size: xgb.Pad((12 + xgb.Pad((int(NumClientSpecs) * 4)))) +type UnregisterClientsCookie struct { + *xgb.Cookie +} + +// Write request to wire for UnregisterClients +func UnregisterClients(c *xgb.Conn, Context Context, NumClientSpecs uint32, ClientSpecs []ClientSpec) UnregisterClientsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(unregisterClientsRequest(c, Context, NumClientSpecs, ClientSpecs), cookie) + return UnregisterClientsCookie{cookie} +} + +func UnregisterClientsChecked(c *xgb.Conn, Context Context, NumClientSpecs uint32, ClientSpecs []ClientSpec) UnregisterClientsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(unregisterClientsRequest(c, Context, NumClientSpecs, ClientSpecs), cookie) + return UnregisterClientsCookie{cookie} +} + +func (cook UnregisterClientsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for UnregisterClients +func unregisterClientsRequest(c *xgb.Conn, Context Context, NumClientSpecs uint32, ClientSpecs []ClientSpec) []byte { + size := xgb.Pad((12 + xgb.Pad((int(NumClientSpecs) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RECORD"] + b += 1 + + buf[b] = 3 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + xgb.Put32(buf[b:], NumClientSpecs) + b += 4 + + for i := 0; i < int(NumClientSpecs); i++ { + xgb.Put32(buf[b:], uint32(ClientSpecs[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request GetContext +// size: 8 +type GetContextCookie struct { + *xgb.Cookie +} + +func GetContext(c *xgb.Conn, Context Context) GetContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getContextRequest(c, Context), cookie) + return GetContextCookie{cookie} +} + +func GetContextUnchecked(c *xgb.Conn, Context Context) GetContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getContextRequest(c, Context), cookie) + return GetContextCookie{cookie} +} + +// Request reply for GetContext +// size: (32 + ClientInfoListSize(InterceptedClients)) +type GetContextReply struct { + Sequence uint16 + Length uint32 + Enabled bool + ElementHeader ElementHeader + // padding: 3 bytes + NumInterceptedClients uint32 + // padding: 16 bytes + InterceptedClients []ClientInfo // size: ClientInfoListSize(InterceptedClients) +} + +// Waits and reads reply data from request GetContext +func (cook GetContextCookie) Reply() (*GetContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getContextReply(buf), nil +} + +// Read reply into structure from buffer for GetContext +func getContextReply(buf []byte) *GetContextReply { + v := new(GetContextReply) + b := 1 // skip reply determinant + + if buf[b] == 1 { + v.Enabled = true + } else { + v.Enabled = false + } + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ElementHeader = ElementHeader(buf[b]) + b += 1 + + b += 3 // padding + + v.NumInterceptedClients = xgb.Get32(buf[b:]) + b += 4 + + b += 16 // padding + + v.InterceptedClients = make([]ClientInfo, v.NumInterceptedClients) + b += ClientInfoReadList(buf[b:], v.InterceptedClients) + + return v +} + +// Write request to wire for GetContext +func getContextRequest(c *xgb.Conn, Context Context) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RECORD"] + b += 1 + + buf[b] = 4 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + return buf +} + +// Request EnableContext +// size: 8 +type EnableContextCookie struct { + *xgb.Cookie +} + +func EnableContext(c *xgb.Conn, Context Context) EnableContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(enableContextRequest(c, Context), cookie) + return EnableContextCookie{cookie} +} + +func EnableContextUnchecked(c *xgb.Conn, Context Context) EnableContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(enableContextRequest(c, Context), cookie) + return EnableContextCookie{cookie} +} + +// Request reply for EnableContext +// size: (32 + xgb.Pad(((int(Length) * 4) * 1))) +type EnableContextReply struct { + Sequence uint16 + Length uint32 + Category byte + ElementHeader ElementHeader + ClientSwapped bool + // padding: 2 bytes + XidBase uint32 + ServerTime uint32 + RecSequenceNum uint32 + // padding: 8 bytes + Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) +} + +// Waits and reads reply data from request EnableContext +func (cook EnableContextCookie) Reply() (*EnableContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return enableContextReply(buf), nil +} + +// Read reply into structure from buffer for EnableContext +func enableContextReply(buf []byte) *EnableContextReply { + v := new(EnableContextReply) + b := 1 // skip reply determinant + + v.Category = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ElementHeader = ElementHeader(buf[b]) + b += 1 + + if buf[b] == 1 { + v.ClientSwapped = true + } else { + v.ClientSwapped = false + } + b += 1 + + b += 2 // padding + + v.XidBase = xgb.Get32(buf[b:]) + b += 4 + + v.ServerTime = xgb.Get32(buf[b:]) + b += 4 + + v.RecSequenceNum = xgb.Get32(buf[b:]) + b += 4 + + b += 8 // padding + + v.Data = make([]byte, (int(v.Length) * 4)) + copy(v.Data[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) + + return v +} + +// Write request to wire for EnableContext +func enableContextRequest(c *xgb.Conn, Context Context) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RECORD"] + b += 1 + + buf[b] = 5 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + return buf +} + +// Request DisableContext +// size: 8 +type DisableContextCookie struct { + *xgb.Cookie +} + +// Write request to wire for DisableContext +func DisableContext(c *xgb.Conn, Context Context) DisableContextCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(disableContextRequest(c, Context), cookie) + return DisableContextCookie{cookie} +} + +func DisableContextChecked(c *xgb.Conn, Context Context) DisableContextCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(disableContextRequest(c, Context), cookie) + return DisableContextCookie{cookie} +} + +func (cook DisableContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DisableContext +func disableContextRequest(c *xgb.Conn, Context Context) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RECORD"] + b += 1 + + buf[b] = 6 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + return buf +} + +// Request FreeContext +// size: 8 +type FreeContextCookie struct { + *xgb.Cookie +} + +// Write request to wire for FreeContext +func FreeContext(c *xgb.Conn, Context Context) FreeContextCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(freeContextRequest(c, Context), cookie) + return FreeContextCookie{cookie} +} + +func FreeContextChecked(c *xgb.Conn, Context Context) FreeContextCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(freeContextRequest(c, Context), cookie) + return FreeContextCookie{cookie} +} + +func (cook FreeContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for FreeContext +func freeContextRequest(c *xgb.Conn, Context Context) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RECORD"] + b += 1 + + buf[b] = 7 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + return buf +} diff --git a/nexgb/render/render.go b/nexgb/render/render.go new file mode 100644 index 0000000..a939ed9 --- /dev/null +++ b/nexgb/render/render.go @@ -0,0 +1,3542 @@ +package render + +/* + This file was generated by render.xml on May 10 2012 4:20:28pm EDT. + This file is automatically generated. Edit at your peril! +*/ + +import ( + "github.com/BurntSushi/xgb" + + "github.com/BurntSushi/xgb/xproto" +) + +// Init must be called before using the RENDER extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 6, "RENDER").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named RENDER could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["RENDER"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["RENDER"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["RENDER"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["RENDER"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["RENDER"] = make(map[int]xgb.NewErrorFun) +} + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Bool' + +// Skipping definition for base type 'Float' + +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +const ( + PictTypeIndexed = 0 + PictTypeDirect = 1 +) + +const ( + PictureNone = 0 +) + +const ( + PictOpClear = 0 + PictOpSrc = 1 + PictOpDst = 2 + PictOpOver = 3 + PictOpOverReverse = 4 + PictOpIn = 5 + PictOpInReverse = 6 + PictOpOut = 7 + PictOpOutReverse = 8 + PictOpAtop = 9 + PictOpAtopReverse = 10 + PictOpXor = 11 + PictOpAdd = 12 + PictOpSaturate = 13 + PictOpDisjointClear = 16 + PictOpDisjointSrc = 17 + PictOpDisjointDst = 18 + PictOpDisjointOver = 19 + PictOpDisjointOverReverse = 20 + PictOpDisjointIn = 21 + PictOpDisjointInReverse = 22 + PictOpDisjointOut = 23 + PictOpDisjointOutReverse = 24 + PictOpDisjointAtop = 25 + PictOpDisjointAtopReverse = 26 + PictOpDisjointXor = 27 + PictOpConjointClear = 32 + PictOpConjointSrc = 33 + PictOpConjointDst = 34 + PictOpConjointOver = 35 + PictOpConjointOverReverse = 36 + PictOpConjointIn = 37 + PictOpConjointInReverse = 38 + PictOpConjointOut = 39 + PictOpConjointOutReverse = 40 + PictOpConjointAtop = 41 + PictOpConjointAtopReverse = 42 + PictOpConjointXor = 43 + PictOpMultiply = 48 + PictOpScreen = 49 + PictOpOverlay = 50 + PictOpDarken = 51 + PictOpLighten = 52 + PictOpColorDodge = 53 + PictOpColorBurn = 54 + PictOpHardLight = 55 + PictOpSoftLight = 56 + PictOpDifference = 57 + PictOpExclusion = 58 + PictOpHSLHue = 59 + PictOpHSLSaturation = 60 + PictOpHSLColor = 61 + PictOpHSLLuminosity = 62 +) + +const ( + PolyEdgeSharp = 0 + PolyEdgeSmooth = 1 +) + +const ( + PolyModePrecise = 0 + PolyModeImprecise = 1 +) + +const ( + CpRepeat = 1 + CpAlphaMap = 2 + CpAlphaXOrigin = 4 + CpAlphaYOrigin = 8 + CpClipXOrigin = 16 + CpClipYOrigin = 32 + CpClipMask = 64 + CpGraphicsExposure = 128 + CpSubwindowMode = 256 + CpPolyEdge = 512 + CpPolyMode = 1024 + CpDither = 2048 + CpComponentAlpha = 4096 +) + +const ( + SubPixelUnknown = 0 + SubPixelHorizontalRGB = 1 + SubPixelHorizontalBGR = 2 + SubPixelVerticalRGB = 3 + SubPixelVerticalBGR = 4 + SubPixelNone = 5 +) + +const ( + RepeatNone = 0 + RepeatNormal = 1 + RepeatPad = 2 + RepeatReflect = 3 +) + +type Glyphset uint32 + +func NewGlyphsetId(c *xgb.Conn) (Glyphset, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Glyphset(id), nil +} + +type Picture uint32 + +func NewPictureId(c *xgb.Conn) (Picture, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Picture(id), nil +} + +type Pictformat uint32 + +func NewPictformatId(c *xgb.Conn) (Pictformat, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Pictformat(id), nil +} + +type Glyph uint32 + +type Fixed int32 + +// 'Directformat' struct definition +// Size: 16 +type Directformat struct { + RedShift uint16 + RedMask uint16 + GreenShift uint16 + GreenMask uint16 + BlueShift uint16 + BlueMask uint16 + AlphaShift uint16 + AlphaMask uint16 +} + +// Struct read Directformat +func DirectformatRead(buf []byte, v *Directformat) int { + b := 0 + + v.RedShift = xgb.Get16(buf[b:]) + b += 2 + + v.RedMask = xgb.Get16(buf[b:]) + b += 2 + + v.GreenShift = xgb.Get16(buf[b:]) + b += 2 + + v.GreenMask = xgb.Get16(buf[b:]) + b += 2 + + v.BlueShift = xgb.Get16(buf[b:]) + b += 2 + + v.BlueMask = xgb.Get16(buf[b:]) + b += 2 + + v.AlphaShift = xgb.Get16(buf[b:]) + b += 2 + + v.AlphaMask = xgb.Get16(buf[b:]) + b += 2 + + return b +} + +// Struct list read Directformat +func DirectformatReadList(buf []byte, dest []Directformat) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Directformat{} + b += DirectformatRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Directformat +func (v Directformat) Bytes() []byte { + buf := make([]byte, 16) + b := 0 + + xgb.Put16(buf[b:], v.RedShift) + b += 2 + + xgb.Put16(buf[b:], v.RedMask) + b += 2 + + xgb.Put16(buf[b:], v.GreenShift) + b += 2 + + xgb.Put16(buf[b:], v.GreenMask) + b += 2 + + xgb.Put16(buf[b:], v.BlueShift) + b += 2 + + xgb.Put16(buf[b:], v.BlueMask) + b += 2 + + xgb.Put16(buf[b:], v.AlphaShift) + b += 2 + + xgb.Put16(buf[b:], v.AlphaMask) + b += 2 + + return buf +} + +// Write struct list Directformat +func DirectformatListBytes(buf []byte, list []Directformat) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Pictforminfo' struct definition +// Size: 28 +type Pictforminfo struct { + Id Pictformat + Type byte + Depth byte + // padding: 2 bytes + Direct Directformat + Colormap xproto.Colormap +} + +// Struct read Pictforminfo +func PictforminfoRead(buf []byte, v *Pictforminfo) int { + b := 0 + + v.Id = Pictformat(xgb.Get32(buf[b:])) + b += 4 + + v.Type = buf[b] + b += 1 + + v.Depth = buf[b] + b += 1 + + b += 2 // padding + + v.Direct = Directformat{} + b += DirectformatRead(buf[b:], &v.Direct) + + v.Colormap = xproto.Colormap(xgb.Get32(buf[b:])) + b += 4 + + return b +} + +// Struct list read Pictforminfo +func PictforminfoReadList(buf []byte, dest []Pictforminfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Pictforminfo{} + b += PictforminfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Pictforminfo +func (v Pictforminfo) Bytes() []byte { + buf := make([]byte, 28) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Id)) + b += 4 + + buf[b] = v.Type + b += 1 + + buf[b] = v.Depth + b += 1 + + b += 2 // padding + + { + structBytes := v.Direct.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + xgb.Put32(buf[b:], uint32(v.Colormap)) + b += 4 + + return buf +} + +// Write struct list Pictforminfo +func PictforminfoListBytes(buf []byte, list []Pictforminfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Pictvisual' struct definition +// Size: 8 +type Pictvisual struct { + Visual xproto.Visualid + Format Pictformat +} + +// Struct read Pictvisual +func PictvisualRead(buf []byte, v *Pictvisual) int { + b := 0 + + v.Visual = xproto.Visualid(xgb.Get32(buf[b:])) + b += 4 + + v.Format = Pictformat(xgb.Get32(buf[b:])) + b += 4 + + return b +} + +// Struct list read Pictvisual +func PictvisualReadList(buf []byte, dest []Pictvisual) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Pictvisual{} + b += PictvisualRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Pictvisual +func (v Pictvisual) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Visual)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Format)) + b += 4 + + return buf +} + +// Write struct list Pictvisual +func PictvisualListBytes(buf []byte, list []Pictvisual) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Pictdepth' struct definition +// Size: (8 + xgb.Pad((int(NumVisuals) * 8))) +type Pictdepth struct { + Depth byte + // padding: 1 bytes + NumVisuals uint16 + // padding: 4 bytes + Visuals []Pictvisual // size: xgb.Pad((int(NumVisuals) * 8)) +} + +// Struct read Pictdepth +func PictdepthRead(buf []byte, v *Pictdepth) int { + b := 0 + + v.Depth = buf[b] + b += 1 + + b += 1 // padding + + v.NumVisuals = xgb.Get16(buf[b:]) + b += 2 + + b += 4 // padding + + v.Visuals = make([]Pictvisual, v.NumVisuals) + b += PictvisualReadList(buf[b:], v.Visuals) + + return b +} + +// Struct list read Pictdepth +func PictdepthReadList(buf []byte, dest []Pictdepth) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Pictdepth{} + b += PictdepthRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Pictdepth +func (v Pictdepth) Bytes() []byte { + buf := make([]byte, (8 + xgb.Pad((int(v.NumVisuals) * 8)))) + b := 0 + + buf[b] = v.Depth + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], v.NumVisuals) + b += 2 + + b += 4 // padding + + b += PictvisualListBytes(buf[b:], v.Visuals) + + return buf +} + +// Write struct list Pictdepth +func PictdepthListBytes(buf []byte, list []Pictdepth) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size Pictdepth +func PictdepthListSize(list []Pictdepth) int { + size := 0 + for _, item := range list { + size += (8 + xgb.Pad((int(item.NumVisuals) * 8))) + } + return size +} + +// 'Pictscreen' struct definition +// Size: (8 + PictdepthListSize(Depths)) +type Pictscreen struct { + NumDepths uint32 + Fallback Pictformat + Depths []Pictdepth // size: PictdepthListSize(Depths) +} + +// Struct read Pictscreen +func PictscreenRead(buf []byte, v *Pictscreen) int { + b := 0 + + v.NumDepths = xgb.Get32(buf[b:]) + b += 4 + + v.Fallback = Pictformat(xgb.Get32(buf[b:])) + b += 4 + + v.Depths = make([]Pictdepth, v.NumDepths) + b += PictdepthReadList(buf[b:], v.Depths) + + return b +} + +// Struct list read Pictscreen +func PictscreenReadList(buf []byte, dest []Pictscreen) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Pictscreen{} + b += PictscreenRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Pictscreen +func (v Pictscreen) Bytes() []byte { + buf := make([]byte, (8 + PictdepthListSize(v.Depths))) + b := 0 + + xgb.Put32(buf[b:], v.NumDepths) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Fallback)) + b += 4 + + b += PictdepthListBytes(buf[b:], v.Depths) + + return buf +} + +// Write struct list Pictscreen +func PictscreenListBytes(buf []byte, list []Pictscreen) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size Pictscreen +func PictscreenListSize(list []Pictscreen) int { + size := 0 + for _, item := range list { + size += (8 + PictdepthListSize(item.Depths)) + } + return size +} + +// 'Indexvalue' struct definition +// Size: 12 +type Indexvalue struct { + Pixel uint32 + Red uint16 + Green uint16 + Blue uint16 + Alpha uint16 +} + +// Struct read Indexvalue +func IndexvalueRead(buf []byte, v *Indexvalue) int { + b := 0 + + v.Pixel = xgb.Get32(buf[b:]) + b += 4 + + v.Red = xgb.Get16(buf[b:]) + b += 2 + + v.Green = xgb.Get16(buf[b:]) + b += 2 + + v.Blue = xgb.Get16(buf[b:]) + b += 2 + + v.Alpha = xgb.Get16(buf[b:]) + b += 2 + + return b +} + +// Struct list read Indexvalue +func IndexvalueReadList(buf []byte, dest []Indexvalue) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Indexvalue{} + b += IndexvalueRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Indexvalue +func (v Indexvalue) Bytes() []byte { + buf := make([]byte, 12) + b := 0 + + xgb.Put32(buf[b:], v.Pixel) + b += 4 + + xgb.Put16(buf[b:], v.Red) + b += 2 + + xgb.Put16(buf[b:], v.Green) + b += 2 + + xgb.Put16(buf[b:], v.Blue) + b += 2 + + xgb.Put16(buf[b:], v.Alpha) + b += 2 + + return buf +} + +// Write struct list Indexvalue +func IndexvalueListBytes(buf []byte, list []Indexvalue) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Color' struct definition +// Size: 8 +type Color struct { + Red uint16 + Green uint16 + Blue uint16 + Alpha uint16 +} + +// Struct read Color +func ColorRead(buf []byte, v *Color) int { + b := 0 + + v.Red = xgb.Get16(buf[b:]) + b += 2 + + v.Green = xgb.Get16(buf[b:]) + b += 2 + + v.Blue = xgb.Get16(buf[b:]) + b += 2 + + v.Alpha = xgb.Get16(buf[b:]) + b += 2 + + return b +} + +// Struct list read Color +func ColorReadList(buf []byte, dest []Color) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Color{} + b += ColorRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Color +func (v Color) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put16(buf[b:], v.Red) + b += 2 + + xgb.Put16(buf[b:], v.Green) + b += 2 + + xgb.Put16(buf[b:], v.Blue) + b += 2 + + xgb.Put16(buf[b:], v.Alpha) + b += 2 + + return buf +} + +// Write struct list Color +func ColorListBytes(buf []byte, list []Color) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Pointfix' struct definition +// Size: 8 +type Pointfix struct { + X Fixed + Y Fixed +} + +// Struct read Pointfix +func PointfixRead(buf []byte, v *Pointfix) int { + b := 0 + + v.X = Fixed(xgb.Get32(buf[b:])) + b += 4 + + v.Y = Fixed(xgb.Get32(buf[b:])) + b += 4 + + return b +} + +// Struct list read Pointfix +func PointfixReadList(buf []byte, dest []Pointfix) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Pointfix{} + b += PointfixRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Pointfix +func (v Pointfix) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put32(buf[b:], uint32(v.X)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Y)) + b += 4 + + return buf +} + +// Write struct list Pointfix +func PointfixListBytes(buf []byte, list []Pointfix) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Linefix' struct definition +// Size: 16 +type Linefix struct { + P1 Pointfix + P2 Pointfix +} + +// Struct read Linefix +func LinefixRead(buf []byte, v *Linefix) int { + b := 0 + + v.P1 = Pointfix{} + b += PointfixRead(buf[b:], &v.P1) + + v.P2 = Pointfix{} + b += PointfixRead(buf[b:], &v.P2) + + return b +} + +// Struct list read Linefix +func LinefixReadList(buf []byte, dest []Linefix) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Linefix{} + b += LinefixRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Linefix +func (v Linefix) Bytes() []byte { + buf := make([]byte, 16) + b := 0 + + { + structBytes := v.P1.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.P2.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + return buf +} + +// Write struct list Linefix +func LinefixListBytes(buf []byte, list []Linefix) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Triangle' struct definition +// Size: 24 +type Triangle struct { + P1 Pointfix + P2 Pointfix + P3 Pointfix +} + +// Struct read Triangle +func TriangleRead(buf []byte, v *Triangle) int { + b := 0 + + v.P1 = Pointfix{} + b += PointfixRead(buf[b:], &v.P1) + + v.P2 = Pointfix{} + b += PointfixRead(buf[b:], &v.P2) + + v.P3 = Pointfix{} + b += PointfixRead(buf[b:], &v.P3) + + return b +} + +// Struct list read Triangle +func TriangleReadList(buf []byte, dest []Triangle) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Triangle{} + b += TriangleRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Triangle +func (v Triangle) Bytes() []byte { + buf := make([]byte, 24) + b := 0 + + { + structBytes := v.P1.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.P2.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.P3.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + return buf +} + +// Write struct list Triangle +func TriangleListBytes(buf []byte, list []Triangle) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Trapezoid' struct definition +// Size: 40 +type Trapezoid struct { + Top Fixed + Bottom Fixed + Left Linefix + Right Linefix +} + +// Struct read Trapezoid +func TrapezoidRead(buf []byte, v *Trapezoid) int { + b := 0 + + v.Top = Fixed(xgb.Get32(buf[b:])) + b += 4 + + v.Bottom = Fixed(xgb.Get32(buf[b:])) + b += 4 + + v.Left = Linefix{} + b += LinefixRead(buf[b:], &v.Left) + + v.Right = Linefix{} + b += LinefixRead(buf[b:], &v.Right) + + return b +} + +// Struct list read Trapezoid +func TrapezoidReadList(buf []byte, dest []Trapezoid) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Trapezoid{} + b += TrapezoidRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Trapezoid +func (v Trapezoid) Bytes() []byte { + buf := make([]byte, 40) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Top)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Bottom)) + b += 4 + + { + structBytes := v.Left.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.Right.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + return buf +} + +// Write struct list Trapezoid +func TrapezoidListBytes(buf []byte, list []Trapezoid) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Glyphinfo' struct definition +// Size: 12 +type Glyphinfo struct { + Width uint16 + Height uint16 + X int16 + Y int16 + XOff int16 + YOff int16 +} + +// Struct read Glyphinfo +func GlyphinfoRead(buf []byte, v *Glyphinfo) int { + b := 0 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + + v.XOff = int16(xgb.Get16(buf[b:])) + b += 2 + + v.YOff = int16(xgb.Get16(buf[b:])) + b += 2 + + return b +} + +// Struct list read Glyphinfo +func GlyphinfoReadList(buf []byte, dest []Glyphinfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Glyphinfo{} + b += GlyphinfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Glyphinfo +func (v Glyphinfo) Bytes() []byte { + buf := make([]byte, 12) + b := 0 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + xgb.Put16(buf[b:], uint16(v.X)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.XOff)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.YOff)) + b += 2 + + return buf +} + +// Write struct list Glyphinfo +func GlyphinfoListBytes(buf []byte, list []Glyphinfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Transform' struct definition +// Size: 36 +type Transform struct { + Matrix11 Fixed + Matrix12 Fixed + Matrix13 Fixed + Matrix21 Fixed + Matrix22 Fixed + Matrix23 Fixed + Matrix31 Fixed + Matrix32 Fixed + Matrix33 Fixed +} + +// Struct read Transform +func TransformRead(buf []byte, v *Transform) int { + b := 0 + + v.Matrix11 = Fixed(xgb.Get32(buf[b:])) + b += 4 + + v.Matrix12 = Fixed(xgb.Get32(buf[b:])) + b += 4 + + v.Matrix13 = Fixed(xgb.Get32(buf[b:])) + b += 4 + + v.Matrix21 = Fixed(xgb.Get32(buf[b:])) + b += 4 + + v.Matrix22 = Fixed(xgb.Get32(buf[b:])) + b += 4 + + v.Matrix23 = Fixed(xgb.Get32(buf[b:])) + b += 4 + + v.Matrix31 = Fixed(xgb.Get32(buf[b:])) + b += 4 + + v.Matrix32 = Fixed(xgb.Get32(buf[b:])) + b += 4 + + v.Matrix33 = Fixed(xgb.Get32(buf[b:])) + b += 4 + + return b +} + +// Struct list read Transform +func TransformReadList(buf []byte, dest []Transform) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Transform{} + b += TransformRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Transform +func (v Transform) Bytes() []byte { + buf := make([]byte, 36) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Matrix11)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Matrix12)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Matrix13)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Matrix21)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Matrix22)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Matrix23)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Matrix31)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Matrix32)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Matrix33)) + b += 4 + + return buf +} + +// Write struct list Transform +func TransformListBytes(buf []byte, list []Transform) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Animcursorelt' struct definition +// Size: 8 +type Animcursorelt struct { + Cursor xproto.Cursor + Delay uint32 +} + +// Struct read Animcursorelt +func AnimcursoreltRead(buf []byte, v *Animcursorelt) int { + b := 0 + + v.Cursor = xproto.Cursor(xgb.Get32(buf[b:])) + b += 4 + + v.Delay = xgb.Get32(buf[b:]) + b += 4 + + return b +} + +// Struct list read Animcursorelt +func AnimcursoreltReadList(buf []byte, dest []Animcursorelt) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Animcursorelt{} + b += AnimcursoreltRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Animcursorelt +func (v Animcursorelt) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Cursor)) + b += 4 + + xgb.Put32(buf[b:], v.Delay) + b += 4 + + return buf +} + +// Write struct list Animcursorelt +func AnimcursoreltListBytes(buf []byte, list []Animcursorelt) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Spanfix' struct definition +// Size: 12 +type Spanfix struct { + L Fixed + R Fixed + Y Fixed +} + +// Struct read Spanfix +func SpanfixRead(buf []byte, v *Spanfix) int { + b := 0 + + v.L = Fixed(xgb.Get32(buf[b:])) + b += 4 + + v.R = Fixed(xgb.Get32(buf[b:])) + b += 4 + + v.Y = Fixed(xgb.Get32(buf[b:])) + b += 4 + + return b +} + +// Struct list read Spanfix +func SpanfixReadList(buf []byte, dest []Spanfix) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Spanfix{} + b += SpanfixRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Spanfix +func (v Spanfix) Bytes() []byte { + buf := make([]byte, 12) + b := 0 + + xgb.Put32(buf[b:], uint32(v.L)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.R)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Y)) + b += 4 + + return buf +} + +// Write struct list Spanfix +func SpanfixListBytes(buf []byte, list []Spanfix) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Trap' struct definition +// Size: 24 +type Trap struct { + Top Spanfix + Bot Spanfix +} + +// Struct read Trap +func TrapRead(buf []byte, v *Trap) int { + b := 0 + + v.Top = Spanfix{} + b += SpanfixRead(buf[b:], &v.Top) + + v.Bot = Spanfix{} + b += SpanfixRead(buf[b:], &v.Bot) + + return b +} + +// Struct list read Trap +func TrapReadList(buf []byte, dest []Trap) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Trap{} + b += TrapRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Trap +func (v Trap) Bytes() []byte { + buf := make([]byte, 24) + b := 0 + + { + structBytes := v.Top.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.Bot.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + return buf +} + +// Write struct list Trap +func TrapListBytes(buf []byte, list []Trap) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Error definition PictFormat (0) +// Size: 32 + +const BadPictFormat = 0 + +type PictFormatError struct { + Sequence uint16 + NiceName string +} + +// Error read PictFormat +func PictFormatErrorNew(buf []byte) xgb.Error { + v := PictFormatError{} + v.NiceName = "PictFormat" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err PictFormatError) ImplementsError() {} + +func (err PictFormatError) SequenceId() uint16 { + return err.Sequence +} + +func (err PictFormatError) BadId() uint32 { + return 0 +} + +func (err PictFormatError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadPictFormat {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["RENDER"][0] = PictFormatErrorNew +} + +// Error definition Picture (1) +// Size: 32 + +const BadPicture = 1 + +type PictureError struct { + Sequence uint16 + NiceName string +} + +// Error read Picture +func PictureErrorNew(buf []byte) xgb.Error { + v := PictureError{} + v.NiceName = "Picture" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err PictureError) ImplementsError() {} + +func (err PictureError) SequenceId() uint16 { + return err.Sequence +} + +func (err PictureError) BadId() uint32 { + return 0 +} + +func (err PictureError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadPicture {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["RENDER"][1] = PictureErrorNew +} + +// Error definition PictOp (2) +// Size: 32 + +const BadPictOp = 2 + +type PictOpError struct { + Sequence uint16 + NiceName string +} + +// Error read PictOp +func PictOpErrorNew(buf []byte) xgb.Error { + v := PictOpError{} + v.NiceName = "PictOp" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err PictOpError) ImplementsError() {} + +func (err PictOpError) SequenceId() uint16 { + return err.Sequence +} + +func (err PictOpError) BadId() uint32 { + return 0 +} + +func (err PictOpError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadPictOp {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["RENDER"][2] = PictOpErrorNew +} + +// Error definition GlyphSet (3) +// Size: 32 + +const BadGlyphSet = 3 + +type GlyphSetError struct { + Sequence uint16 + NiceName string +} + +// Error read GlyphSet +func GlyphSetErrorNew(buf []byte) xgb.Error { + v := GlyphSetError{} + v.NiceName = "GlyphSet" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err GlyphSetError) ImplementsError() {} + +func (err GlyphSetError) SequenceId() uint16 { + return err.Sequence +} + +func (err GlyphSetError) BadId() uint32 { + return 0 +} + +func (err GlyphSetError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadGlyphSet {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["RENDER"][3] = GlyphSetErrorNew +} + +// Error definition Glyph (4) +// Size: 32 + +const BadGlyph = 4 + +type GlyphError struct { + Sequence uint16 + NiceName string +} + +// Error read Glyph +func GlyphErrorNew(buf []byte) xgb.Error { + v := GlyphError{} + v.NiceName = "Glyph" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err GlyphError) ImplementsError() {} + +func (err GlyphError) SequenceId() uint16 { + return err.Sequence +} + +func (err GlyphError) BadId() uint32 { + return 0 +} + +func (err GlyphError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadGlyph {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["RENDER"][4] = GlyphErrorNew +} + +// Request QueryVersion +// size: 12 +type QueryVersionCookie struct { + *xgb.Cookie +} + +func QueryVersion(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return QueryVersionCookie{cookie} +} + +func QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return QueryVersionCookie{cookie} +} + +// Request reply for QueryVersion +// size: 32 +type QueryVersionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + MajorVersion uint32 + MinorVersion uint32 + // padding: 16 bytes +} + +// Waits and reads reply data from request QueryVersion +func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryVersionReply(buf), nil +} + +// Read reply into structure from buffer for QueryVersion +func queryVersionReply(buf []byte) *QueryVersionReply { + v := new(QueryVersionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.MajorVersion = xgb.Get32(buf[b:]) + b += 4 + + v.MinorVersion = xgb.Get32(buf[b:]) + b += 4 + + b += 16 // padding + + return v +} + +// Write request to wire for QueryVersion +func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 0 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], ClientMajorVersion) + b += 4 + + xgb.Put32(buf[b:], ClientMinorVersion) + b += 4 + + return buf +} + +// Request QueryPictFormats +// size: 4 +type QueryPictFormatsCookie struct { + *xgb.Cookie +} + +func QueryPictFormats(c *xgb.Conn) QueryPictFormatsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryPictFormatsRequest(c), cookie) + return QueryPictFormatsCookie{cookie} +} + +func QueryPictFormatsUnchecked(c *xgb.Conn) QueryPictFormatsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryPictFormatsRequest(c), cookie) + return QueryPictFormatsCookie{cookie} +} + +// Request reply for QueryPictFormats +// size: (((32 + xgb.Pad((int(NumFormats) * 28))) + PictscreenListSize(Screens)) + xgb.Pad((int(NumSubpixel) * 4))) +type QueryPictFormatsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumFormats uint32 + NumScreens uint32 + NumDepths uint32 + NumVisuals uint32 + NumSubpixel uint32 + // padding: 4 bytes + Formats []Pictforminfo // size: xgb.Pad((int(NumFormats) * 28)) + Screens []Pictscreen // size: PictscreenListSize(Screens) + Subpixels []uint32 // size: xgb.Pad((int(NumSubpixel) * 4)) +} + +// Waits and reads reply data from request QueryPictFormats +func (cook QueryPictFormatsCookie) Reply() (*QueryPictFormatsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryPictFormatsReply(buf), nil +} + +// Read reply into structure from buffer for QueryPictFormats +func queryPictFormatsReply(buf []byte) *QueryPictFormatsReply { + v := new(QueryPictFormatsReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NumFormats = xgb.Get32(buf[b:]) + b += 4 + + v.NumScreens = xgb.Get32(buf[b:]) + b += 4 + + v.NumDepths = xgb.Get32(buf[b:]) + b += 4 + + v.NumVisuals = xgb.Get32(buf[b:]) + b += 4 + + v.NumSubpixel = xgb.Get32(buf[b:]) + b += 4 + + b += 4 // padding + + v.Formats = make([]Pictforminfo, v.NumFormats) + b += PictforminfoReadList(buf[b:], v.Formats) + + v.Screens = make([]Pictscreen, v.NumScreens) + b += PictscreenReadList(buf[b:], v.Screens) + + v.Subpixels = make([]uint32, v.NumSubpixel) + for i := 0; i < int(v.NumSubpixel); i++ { + v.Subpixels[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for QueryPictFormats +func queryPictFormatsRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 1 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request QueryPictIndexValues +// size: 8 +type QueryPictIndexValuesCookie struct { + *xgb.Cookie +} + +func QueryPictIndexValues(c *xgb.Conn, Format Pictformat) QueryPictIndexValuesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryPictIndexValuesRequest(c, Format), cookie) + return QueryPictIndexValuesCookie{cookie} +} + +func QueryPictIndexValuesUnchecked(c *xgb.Conn, Format Pictformat) QueryPictIndexValuesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryPictIndexValuesRequest(c, Format), cookie) + return QueryPictIndexValuesCookie{cookie} +} + +// Request reply for QueryPictIndexValues +// size: (32 + xgb.Pad((int(NumValues) * 12))) +type QueryPictIndexValuesReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumValues uint32 + // padding: 20 bytes + Values []Indexvalue // size: xgb.Pad((int(NumValues) * 12)) +} + +// Waits and reads reply data from request QueryPictIndexValues +func (cook QueryPictIndexValuesCookie) Reply() (*QueryPictIndexValuesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryPictIndexValuesReply(buf), nil +} + +// Read reply into structure from buffer for QueryPictIndexValues +func queryPictIndexValuesReply(buf []byte) *QueryPictIndexValuesReply { + v := new(QueryPictIndexValuesReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NumValues = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Values = make([]Indexvalue, v.NumValues) + b += IndexvalueReadList(buf[b:], v.Values) + + return v +} + +// Write request to wire for QueryPictIndexValues +func queryPictIndexValuesRequest(c *xgb.Conn, Format Pictformat) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 2 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Format)) + b += 4 + + return buf +} + +// Request CreatePicture +// size: xgb.Pad((16 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +type CreatePictureCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreatePicture +func CreatePicture(c *xgb.Conn, Pid Picture, Drawable xproto.Drawable, Format Pictformat, ValueMask uint32, ValueList []uint32) CreatePictureCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createPictureRequest(c, Pid, Drawable, Format, ValueMask, ValueList), cookie) + return CreatePictureCookie{cookie} +} + +func CreatePictureChecked(c *xgb.Conn, Pid Picture, Drawable xproto.Drawable, Format Pictformat, ValueMask uint32, ValueList []uint32) CreatePictureCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createPictureRequest(c, Pid, Drawable, Format, ValueMask, ValueList), cookie) + return CreatePictureCookie{cookie} +} + +func (cook CreatePictureCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreatePicture +func createPictureRequest(c *xgb.Conn, Pid Picture, Drawable xproto.Drawable, Format Pictformat, ValueMask uint32, ValueList []uint32) []byte { + size := xgb.Pad((16 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 4 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Pid)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Format)) + b += 4 + + xgb.Put32(buf[b:], ValueMask) + b += 4 + for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { + xgb.Put32(buf[b:], ValueList[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request ChangePicture +// size: xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +type ChangePictureCookie struct { + *xgb.Cookie +} + +// Write request to wire for ChangePicture +func ChangePicture(c *xgb.Conn, Picture Picture, ValueMask uint32, ValueList []uint32) ChangePictureCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changePictureRequest(c, Picture, ValueMask, ValueList), cookie) + return ChangePictureCookie{cookie} +} + +func ChangePictureChecked(c *xgb.Conn, Picture Picture, ValueMask uint32, ValueList []uint32) ChangePictureCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changePictureRequest(c, Picture, ValueMask, ValueList), cookie) + return ChangePictureCookie{cookie} +} + +func (cook ChangePictureCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangePicture +func changePictureRequest(c *xgb.Conn, Picture Picture, ValueMask uint32, ValueList []uint32) []byte { + size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 5 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Picture)) + b += 4 + + xgb.Put32(buf[b:], ValueMask) + b += 4 + for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { + xgb.Put32(buf[b:], ValueList[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request SetPictureClipRectangles +// size: xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) +type SetPictureClipRectanglesCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetPictureClipRectangles +func SetPictureClipRectangles(c *xgb.Conn, Picture Picture, ClipXOrigin int16, ClipYOrigin int16, Rectangles []xproto.Rectangle) SetPictureClipRectanglesCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setPictureClipRectanglesRequest(c, Picture, ClipXOrigin, ClipYOrigin, Rectangles), cookie) + return SetPictureClipRectanglesCookie{cookie} +} + +func SetPictureClipRectanglesChecked(c *xgb.Conn, Picture Picture, ClipXOrigin int16, ClipYOrigin int16, Rectangles []xproto.Rectangle) SetPictureClipRectanglesCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setPictureClipRectanglesRequest(c, Picture, ClipXOrigin, ClipYOrigin, Rectangles), cookie) + return SetPictureClipRectanglesCookie{cookie} +} + +func (cook SetPictureClipRectanglesCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetPictureClipRectangles +func setPictureClipRectanglesRequest(c *xgb.Conn, Picture Picture, ClipXOrigin int16, ClipYOrigin int16, Rectangles []xproto.Rectangle) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 6 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Picture)) + b += 4 + + xgb.Put16(buf[b:], uint16(ClipXOrigin)) + b += 2 + + xgb.Put16(buf[b:], uint16(ClipYOrigin)) + b += 2 + + b += xproto.RectangleListBytes(buf[b:], Rectangles) + + return buf +} + +// Request FreePicture +// size: 8 +type FreePictureCookie struct { + *xgb.Cookie +} + +// Write request to wire for FreePicture +func FreePicture(c *xgb.Conn, Picture Picture) FreePictureCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(freePictureRequest(c, Picture), cookie) + return FreePictureCookie{cookie} +} + +func FreePictureChecked(c *xgb.Conn, Picture Picture) FreePictureCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(freePictureRequest(c, Picture), cookie) + return FreePictureCookie{cookie} +} + +func (cook FreePictureCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for FreePicture +func freePictureRequest(c *xgb.Conn, Picture Picture) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 7 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Picture)) + b += 4 + + return buf +} + +// Request Composite +// size: 36 +type CompositeCookie struct { + *xgb.Cookie +} + +// Write request to wire for Composite +func Composite(c *xgb.Conn, Op byte, Src Picture, Mask Picture, Dst Picture, SrcX int16, SrcY int16, MaskX int16, MaskY int16, DstX int16, DstY int16, Width uint16, Height uint16) CompositeCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(compositeRequest(c, Op, Src, Mask, Dst, SrcX, SrcY, MaskX, MaskY, DstX, DstY, Width, Height), cookie) + return CompositeCookie{cookie} +} + +func CompositeChecked(c *xgb.Conn, Op byte, Src Picture, Mask Picture, Dst Picture, SrcX int16, SrcY int16, MaskX int16, MaskY int16, DstX int16, DstY int16, Width uint16, Height uint16) CompositeCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(compositeRequest(c, Op, Src, Mask, Dst, SrcX, SrcY, MaskX, MaskY, DstX, DstY, Width, Height), cookie) + return CompositeCookie{cookie} +} + +func (cook CompositeCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for Composite +func compositeRequest(c *xgb.Conn, Op byte, Src Picture, Mask Picture, Dst Picture, SrcX int16, SrcY int16, MaskX int16, MaskY int16, DstX int16, DstY int16, Width uint16, Height uint16) []byte { + size := 36 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 8 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = Op + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], uint32(Src)) + b += 4 + + xgb.Put32(buf[b:], uint32(Mask)) + b += 4 + + xgb.Put32(buf[b:], uint32(Dst)) + b += 4 + + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 + + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 + + xgb.Put16(buf[b:], uint16(MaskX)) + b += 2 + + xgb.Put16(buf[b:], uint16(MaskY)) + b += 2 + + xgb.Put16(buf[b:], uint16(DstX)) + b += 2 + + xgb.Put16(buf[b:], uint16(DstY)) + b += 2 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + return buf +} + +// Request Trapezoids +// size: xgb.Pad((24 + xgb.Pad((len(Traps) * 40)))) +type TrapezoidsCookie struct { + *xgb.Cookie +} + +// Write request to wire for Trapezoids +func Trapezoids(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Traps []Trapezoid) TrapezoidsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(trapezoidsRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Traps), cookie) + return TrapezoidsCookie{cookie} +} + +func TrapezoidsChecked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Traps []Trapezoid) TrapezoidsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(trapezoidsRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Traps), cookie) + return TrapezoidsCookie{cookie} +} + +func (cook TrapezoidsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for Trapezoids +func trapezoidsRequest(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Traps []Trapezoid) []byte { + size := xgb.Pad((24 + xgb.Pad((len(Traps) * 40)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 10 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = Op + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], uint32(Src)) + b += 4 + + xgb.Put32(buf[b:], uint32(Dst)) + b += 4 + + xgb.Put32(buf[b:], uint32(MaskFormat)) + b += 4 + + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 + + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 + + b += TrapezoidListBytes(buf[b:], Traps) + + return buf +} + +// Request Triangles +// size: xgb.Pad((24 + xgb.Pad((len(Triangles) * 24)))) +type TrianglesCookie struct { + *xgb.Cookie +} + +// Write request to wire for Triangles +func Triangles(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Triangles []Triangle) TrianglesCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(trianglesRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Triangles), cookie) + return TrianglesCookie{cookie} +} + +func TrianglesChecked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Triangles []Triangle) TrianglesCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(trianglesRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Triangles), cookie) + return TrianglesCookie{cookie} +} + +func (cook TrianglesCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for Triangles +func trianglesRequest(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Triangles []Triangle) []byte { + size := xgb.Pad((24 + xgb.Pad((len(Triangles) * 24)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 11 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = Op + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], uint32(Src)) + b += 4 + + xgb.Put32(buf[b:], uint32(Dst)) + b += 4 + + xgb.Put32(buf[b:], uint32(MaskFormat)) + b += 4 + + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 + + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 + + b += TriangleListBytes(buf[b:], Triangles) + + return buf +} + +// Request TriStrip +// size: xgb.Pad((24 + xgb.Pad((len(Points) * 8)))) +type TriStripCookie struct { + *xgb.Cookie +} + +// Write request to wire for TriStrip +func TriStrip(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) TriStripCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(triStripRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie) + return TriStripCookie{cookie} +} + +func TriStripChecked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) TriStripCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(triStripRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie) + return TriStripCookie{cookie} +} + +func (cook TriStripCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for TriStrip +func triStripRequest(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) []byte { + size := xgb.Pad((24 + xgb.Pad((len(Points) * 8)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 12 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = Op + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], uint32(Src)) + b += 4 + + xgb.Put32(buf[b:], uint32(Dst)) + b += 4 + + xgb.Put32(buf[b:], uint32(MaskFormat)) + b += 4 + + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 + + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 + + b += PointfixListBytes(buf[b:], Points) + + return buf +} + +// Request TriFan +// size: xgb.Pad((24 + xgb.Pad((len(Points) * 8)))) +type TriFanCookie struct { + *xgb.Cookie +} + +// Write request to wire for TriFan +func TriFan(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) TriFanCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(triFanRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie) + return TriFanCookie{cookie} +} + +func TriFanChecked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) TriFanCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(triFanRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie) + return TriFanCookie{cookie} +} + +func (cook TriFanCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for TriFan +func triFanRequest(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) []byte { + size := xgb.Pad((24 + xgb.Pad((len(Points) * 8)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 13 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = Op + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], uint32(Src)) + b += 4 + + xgb.Put32(buf[b:], uint32(Dst)) + b += 4 + + xgb.Put32(buf[b:], uint32(MaskFormat)) + b += 4 + + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 + + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 + + b += PointfixListBytes(buf[b:], Points) + + return buf +} + +// Request CreateGlyphSet +// size: 12 +type CreateGlyphSetCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateGlyphSet +func CreateGlyphSet(c *xgb.Conn, Gsid Glyphset, Format Pictformat) CreateGlyphSetCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createGlyphSetRequest(c, Gsid, Format), cookie) + return CreateGlyphSetCookie{cookie} +} + +func CreateGlyphSetChecked(c *xgb.Conn, Gsid Glyphset, Format Pictformat) CreateGlyphSetCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createGlyphSetRequest(c, Gsid, Format), cookie) + return CreateGlyphSetCookie{cookie} +} + +func (cook CreateGlyphSetCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateGlyphSet +func createGlyphSetRequest(c *xgb.Conn, Gsid Glyphset, Format Pictformat) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 17 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Gsid)) + b += 4 + + xgb.Put32(buf[b:], uint32(Format)) + b += 4 + + return buf +} + +// Request ReferenceGlyphSet +// size: 12 +type ReferenceGlyphSetCookie struct { + *xgb.Cookie +} + +// Write request to wire for ReferenceGlyphSet +func ReferenceGlyphSet(c *xgb.Conn, Gsid Glyphset, Existing Glyphset) ReferenceGlyphSetCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(referenceGlyphSetRequest(c, Gsid, Existing), cookie) + return ReferenceGlyphSetCookie{cookie} +} + +func ReferenceGlyphSetChecked(c *xgb.Conn, Gsid Glyphset, Existing Glyphset) ReferenceGlyphSetCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(referenceGlyphSetRequest(c, Gsid, Existing), cookie) + return ReferenceGlyphSetCookie{cookie} +} + +func (cook ReferenceGlyphSetCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ReferenceGlyphSet +func referenceGlyphSetRequest(c *xgb.Conn, Gsid Glyphset, Existing Glyphset) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 18 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Gsid)) + b += 4 + + xgb.Put32(buf[b:], uint32(Existing)) + b += 4 + + return buf +} + +// Request FreeGlyphSet +// size: 8 +type FreeGlyphSetCookie struct { + *xgb.Cookie +} + +// Write request to wire for FreeGlyphSet +func FreeGlyphSet(c *xgb.Conn, Glyphset Glyphset) FreeGlyphSetCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(freeGlyphSetRequest(c, Glyphset), cookie) + return FreeGlyphSetCookie{cookie} +} + +func FreeGlyphSetChecked(c *xgb.Conn, Glyphset Glyphset) FreeGlyphSetCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(freeGlyphSetRequest(c, Glyphset), cookie) + return FreeGlyphSetCookie{cookie} +} + +func (cook FreeGlyphSetCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for FreeGlyphSet +func freeGlyphSetRequest(c *xgb.Conn, Glyphset Glyphset) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 19 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Glyphset)) + b += 4 + + return buf +} + +// Request AddGlyphs +// size: xgb.Pad((((12 + xgb.Pad((int(GlyphsLen) * 4))) + xgb.Pad((int(GlyphsLen) * 12))) + xgb.Pad((len(Data) * 1)))) +type AddGlyphsCookie struct { + *xgb.Cookie +} + +// Write request to wire for AddGlyphs +func AddGlyphs(c *xgb.Conn, Glyphset Glyphset, GlyphsLen uint32, Glyphids []uint32, Glyphs []Glyphinfo, Data []byte) AddGlyphsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(addGlyphsRequest(c, Glyphset, GlyphsLen, Glyphids, Glyphs, Data), cookie) + return AddGlyphsCookie{cookie} +} + +func AddGlyphsChecked(c *xgb.Conn, Glyphset Glyphset, GlyphsLen uint32, Glyphids []uint32, Glyphs []Glyphinfo, Data []byte) AddGlyphsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(addGlyphsRequest(c, Glyphset, GlyphsLen, Glyphids, Glyphs, Data), cookie) + return AddGlyphsCookie{cookie} +} + +func (cook AddGlyphsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for AddGlyphs +func addGlyphsRequest(c *xgb.Conn, Glyphset Glyphset, GlyphsLen uint32, Glyphids []uint32, Glyphs []Glyphinfo, Data []byte) []byte { + size := xgb.Pad((((12 + xgb.Pad((int(GlyphsLen) * 4))) + xgb.Pad((int(GlyphsLen) * 12))) + xgb.Pad((len(Data) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 20 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Glyphset)) + b += 4 + + xgb.Put32(buf[b:], GlyphsLen) + b += 4 + + for i := 0; i < int(GlyphsLen); i++ { + xgb.Put32(buf[b:], Glyphids[i]) + b += 4 + } + b = xgb.Pad(b) + + b += GlyphinfoListBytes(buf[b:], Glyphs) + + copy(buf[b:], Data[:len(Data)]) + b += xgb.Pad(int(len(Data))) + + return buf +} + +// Request FreeGlyphs +// size: xgb.Pad((8 + xgb.Pad((len(Glyphs) * 4)))) +type FreeGlyphsCookie struct { + *xgb.Cookie +} + +// Write request to wire for FreeGlyphs +func FreeGlyphs(c *xgb.Conn, Glyphset Glyphset, Glyphs []Glyph) FreeGlyphsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(freeGlyphsRequest(c, Glyphset, Glyphs), cookie) + return FreeGlyphsCookie{cookie} +} + +func FreeGlyphsChecked(c *xgb.Conn, Glyphset Glyphset, Glyphs []Glyph) FreeGlyphsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(freeGlyphsRequest(c, Glyphset, Glyphs), cookie) + return FreeGlyphsCookie{cookie} +} + +func (cook FreeGlyphsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for FreeGlyphs +func freeGlyphsRequest(c *xgb.Conn, Glyphset Glyphset, Glyphs []Glyph) []byte { + size := xgb.Pad((8 + xgb.Pad((len(Glyphs) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 22 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Glyphset)) + b += 4 + + for i := 0; i < int(len(Glyphs)); i++ { + xgb.Put32(buf[b:], uint32(Glyphs[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request CompositeGlyphs8 +// size: xgb.Pad((28 + xgb.Pad((len(Glyphcmds) * 1)))) +type CompositeGlyphs8Cookie struct { + *xgb.Cookie +} + +// Write request to wire for CompositeGlyphs8 +func CompositeGlyphs8(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs8Cookie { + cookie := c.NewCookie(false, false) + c.NewRequest(compositeGlyphs8Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) + return CompositeGlyphs8Cookie{cookie} +} + +func CompositeGlyphs8Checked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs8Cookie { + cookie := c.NewCookie(true, false) + c.NewRequest(compositeGlyphs8Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) + return CompositeGlyphs8Cookie{cookie} +} + +func (cook CompositeGlyphs8Cookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CompositeGlyphs8 +func compositeGlyphs8Request(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) []byte { + size := xgb.Pad((28 + xgb.Pad((len(Glyphcmds) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 23 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = Op + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], uint32(Src)) + b += 4 + + xgb.Put32(buf[b:], uint32(Dst)) + b += 4 + + xgb.Put32(buf[b:], uint32(MaskFormat)) + b += 4 + + xgb.Put32(buf[b:], uint32(Glyphset)) + b += 4 + + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 + + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 + + copy(buf[b:], Glyphcmds[:len(Glyphcmds)]) + b += xgb.Pad(int(len(Glyphcmds))) + + return buf +} + +// Request CompositeGlyphs16 +// size: xgb.Pad((28 + xgb.Pad((len(Glyphcmds) * 1)))) +type CompositeGlyphs16Cookie struct { + *xgb.Cookie +} + +// Write request to wire for CompositeGlyphs16 +func CompositeGlyphs16(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs16Cookie { + cookie := c.NewCookie(false, false) + c.NewRequest(compositeGlyphs16Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) + return CompositeGlyphs16Cookie{cookie} +} + +func CompositeGlyphs16Checked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs16Cookie { + cookie := c.NewCookie(true, false) + c.NewRequest(compositeGlyphs16Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) + return CompositeGlyphs16Cookie{cookie} +} + +func (cook CompositeGlyphs16Cookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CompositeGlyphs16 +func compositeGlyphs16Request(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) []byte { + size := xgb.Pad((28 + xgb.Pad((len(Glyphcmds) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 24 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = Op + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], uint32(Src)) + b += 4 + + xgb.Put32(buf[b:], uint32(Dst)) + b += 4 + + xgb.Put32(buf[b:], uint32(MaskFormat)) + b += 4 + + xgb.Put32(buf[b:], uint32(Glyphset)) + b += 4 + + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 + + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 + + copy(buf[b:], Glyphcmds[:len(Glyphcmds)]) + b += xgb.Pad(int(len(Glyphcmds))) + + return buf +} + +// Request CompositeGlyphs32 +// size: xgb.Pad((28 + xgb.Pad((len(Glyphcmds) * 1)))) +type CompositeGlyphs32Cookie struct { + *xgb.Cookie +} + +// Write request to wire for CompositeGlyphs32 +func CompositeGlyphs32(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs32Cookie { + cookie := c.NewCookie(false, false) + c.NewRequest(compositeGlyphs32Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) + return CompositeGlyphs32Cookie{cookie} +} + +func CompositeGlyphs32Checked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs32Cookie { + cookie := c.NewCookie(true, false) + c.NewRequest(compositeGlyphs32Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) + return CompositeGlyphs32Cookie{cookie} +} + +func (cook CompositeGlyphs32Cookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CompositeGlyphs32 +func compositeGlyphs32Request(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) []byte { + size := xgb.Pad((28 + xgb.Pad((len(Glyphcmds) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 25 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = Op + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], uint32(Src)) + b += 4 + + xgb.Put32(buf[b:], uint32(Dst)) + b += 4 + + xgb.Put32(buf[b:], uint32(MaskFormat)) + b += 4 + + xgb.Put32(buf[b:], uint32(Glyphset)) + b += 4 + + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 + + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 + + copy(buf[b:], Glyphcmds[:len(Glyphcmds)]) + b += xgb.Pad(int(len(Glyphcmds))) + + return buf +} + +// Request FillRectangles +// size: xgb.Pad((20 + xgb.Pad((len(Rects) * 8)))) +type FillRectanglesCookie struct { + *xgb.Cookie +} + +// Write request to wire for FillRectangles +func FillRectangles(c *xgb.Conn, Op byte, Dst Picture, Color Color, Rects []xproto.Rectangle) FillRectanglesCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(fillRectanglesRequest(c, Op, Dst, Color, Rects), cookie) + return FillRectanglesCookie{cookie} +} + +func FillRectanglesChecked(c *xgb.Conn, Op byte, Dst Picture, Color Color, Rects []xproto.Rectangle) FillRectanglesCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(fillRectanglesRequest(c, Op, Dst, Color, Rects), cookie) + return FillRectanglesCookie{cookie} +} + +func (cook FillRectanglesCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for FillRectangles +func fillRectanglesRequest(c *xgb.Conn, Op byte, Dst Picture, Color Color, Rects []xproto.Rectangle) []byte { + size := xgb.Pad((20 + xgb.Pad((len(Rects) * 8)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 26 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = Op + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], uint32(Dst)) + b += 4 + + { + structBytes := Color.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + b += xproto.RectangleListBytes(buf[b:], Rects) + + return buf +} + +// Request CreateCursor +// size: 16 +type CreateCursorCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateCursor +func CreateCursor(c *xgb.Conn, Cid xproto.Cursor, Source Picture, X uint16, Y uint16) CreateCursorCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createCursorRequest(c, Cid, Source, X, Y), cookie) + return CreateCursorCookie{cookie} +} + +func CreateCursorChecked(c *xgb.Conn, Cid xproto.Cursor, Source Picture, X uint16, Y uint16) CreateCursorCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createCursorRequest(c, Cid, Source, X, Y), cookie) + return CreateCursorCookie{cookie} +} + +func (cook CreateCursorCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateCursor +func createCursorRequest(c *xgb.Conn, Cid xproto.Cursor, Source Picture, X uint16, Y uint16) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 27 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cid)) + b += 4 + + xgb.Put32(buf[b:], uint32(Source)) + b += 4 + + xgb.Put16(buf[b:], X) + b += 2 + + xgb.Put16(buf[b:], Y) + b += 2 + + return buf +} + +// Request SetPictureTransform +// size: 44 +type SetPictureTransformCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetPictureTransform +func SetPictureTransform(c *xgb.Conn, Picture Picture, Transform Transform) SetPictureTransformCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setPictureTransformRequest(c, Picture, Transform), cookie) + return SetPictureTransformCookie{cookie} +} + +func SetPictureTransformChecked(c *xgb.Conn, Picture Picture, Transform Transform) SetPictureTransformCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setPictureTransformRequest(c, Picture, Transform), cookie) + return SetPictureTransformCookie{cookie} +} + +func (cook SetPictureTransformCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetPictureTransform +func setPictureTransformRequest(c *xgb.Conn, Picture Picture, Transform Transform) []byte { + size := 44 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 28 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Picture)) + b += 4 + + { + structBytes := Transform.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + return buf +} + +// Request QueryFilters +// size: 8 +type QueryFiltersCookie struct { + *xgb.Cookie +} + +func QueryFilters(c *xgb.Conn, Drawable xproto.Drawable) QueryFiltersCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryFiltersRequest(c, Drawable), cookie) + return QueryFiltersCookie{cookie} +} + +func QueryFiltersUnchecked(c *xgb.Conn, Drawable xproto.Drawable) QueryFiltersCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryFiltersRequest(c, Drawable), cookie) + return QueryFiltersCookie{cookie} +} + +// Request reply for QueryFilters +// size: ((32 + xgb.Pad((int(NumAliases) * 2))) + xproto.StrListSize(Filters)) +type QueryFiltersReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumAliases uint32 + NumFilters uint32 + // padding: 16 bytes + Aliases []uint16 // size: xgb.Pad((int(NumAliases) * 2)) + Filters []xproto.Str // size: xproto.StrListSize(Filters) +} + +// Waits and reads reply data from request QueryFilters +func (cook QueryFiltersCookie) Reply() (*QueryFiltersReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryFiltersReply(buf), nil +} + +// Read reply into structure from buffer for QueryFilters +func queryFiltersReply(buf []byte) *QueryFiltersReply { + v := new(QueryFiltersReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NumAliases = xgb.Get32(buf[b:]) + b += 4 + + v.NumFilters = xgb.Get32(buf[b:]) + b += 4 + + b += 16 // padding + + v.Aliases = make([]uint16, v.NumAliases) + for i := 0; i < int(v.NumAliases); i++ { + v.Aliases[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) + + v.Filters = make([]xproto.Str, v.NumFilters) + b += xproto.StrReadList(buf[b:], v.Filters) + + return v +} + +// Write request to wire for QueryFilters +func queryFiltersRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 29 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + return buf +} + +// Request SetPictureFilter +// size: xgb.Pad(((12 + xgb.Pad((int(FilterLen) * 1))) + xgb.Pad((len(Values) * 4)))) +type SetPictureFilterCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetPictureFilter +func SetPictureFilter(c *xgb.Conn, Picture Picture, FilterLen uint16, Filter string, Values []Fixed) SetPictureFilterCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setPictureFilterRequest(c, Picture, FilterLen, Filter, Values), cookie) + return SetPictureFilterCookie{cookie} +} + +func SetPictureFilterChecked(c *xgb.Conn, Picture Picture, FilterLen uint16, Filter string, Values []Fixed) SetPictureFilterCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setPictureFilterRequest(c, Picture, FilterLen, Filter, Values), cookie) + return SetPictureFilterCookie{cookie} +} + +func (cook SetPictureFilterCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetPictureFilter +func setPictureFilterRequest(c *xgb.Conn, Picture Picture, FilterLen uint16, Filter string, Values []Fixed) []byte { + size := xgb.Pad(((12 + xgb.Pad((int(FilterLen) * 1))) + xgb.Pad((len(Values) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 30 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Picture)) + b += 4 + + xgb.Put16(buf[b:], FilterLen) + b += 2 + + b += 2 // padding + + copy(buf[b:], Filter[:FilterLen]) + b += xgb.Pad(int(FilterLen)) + + for i := 0; i < int(len(Values)); i++ { + xgb.Put32(buf[b:], uint32(Values[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request CreateAnimCursor +// size: xgb.Pad((8 + xgb.Pad((len(Cursors) * 8)))) +type CreateAnimCursorCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateAnimCursor +func CreateAnimCursor(c *xgb.Conn, Cid xproto.Cursor, Cursors []Animcursorelt) CreateAnimCursorCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createAnimCursorRequest(c, Cid, Cursors), cookie) + return CreateAnimCursorCookie{cookie} +} + +func CreateAnimCursorChecked(c *xgb.Conn, Cid xproto.Cursor, Cursors []Animcursorelt) CreateAnimCursorCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createAnimCursorRequest(c, Cid, Cursors), cookie) + return CreateAnimCursorCookie{cookie} +} + +func (cook CreateAnimCursorCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateAnimCursor +func createAnimCursorRequest(c *xgb.Conn, Cid xproto.Cursor, Cursors []Animcursorelt) []byte { + size := xgb.Pad((8 + xgb.Pad((len(Cursors) * 8)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 31 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cid)) + b += 4 + + b += AnimcursoreltListBytes(buf[b:], Cursors) + + return buf +} + +// Request AddTraps +// size: xgb.Pad((12 + xgb.Pad((len(Traps) * 24)))) +type AddTrapsCookie struct { + *xgb.Cookie +} + +// Write request to wire for AddTraps +func AddTraps(c *xgb.Conn, Picture Picture, XOff int16, YOff int16, Traps []Trap) AddTrapsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(addTrapsRequest(c, Picture, XOff, YOff, Traps), cookie) + return AddTrapsCookie{cookie} +} + +func AddTrapsChecked(c *xgb.Conn, Picture Picture, XOff int16, YOff int16, Traps []Trap) AddTrapsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(addTrapsRequest(c, Picture, XOff, YOff, Traps), cookie) + return AddTrapsCookie{cookie} +} + +func (cook AddTrapsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for AddTraps +func addTrapsRequest(c *xgb.Conn, Picture Picture, XOff int16, YOff int16, Traps []Trap) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Traps) * 24)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 32 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Picture)) + b += 4 + + xgb.Put16(buf[b:], uint16(XOff)) + b += 2 + + xgb.Put16(buf[b:], uint16(YOff)) + b += 2 + + b += TrapListBytes(buf[b:], Traps) + + return buf +} + +// Request CreateSolidFill +// size: 16 +type CreateSolidFillCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateSolidFill +func CreateSolidFill(c *xgb.Conn, Picture Picture, Color Color) CreateSolidFillCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createSolidFillRequest(c, Picture, Color), cookie) + return CreateSolidFillCookie{cookie} +} + +func CreateSolidFillChecked(c *xgb.Conn, Picture Picture, Color Color) CreateSolidFillCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createSolidFillRequest(c, Picture, Color), cookie) + return CreateSolidFillCookie{cookie} +} + +func (cook CreateSolidFillCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateSolidFill +func createSolidFillRequest(c *xgb.Conn, Picture Picture, Color Color) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 33 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Picture)) + b += 4 + + { + structBytes := Color.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + return buf +} + +// Request CreateLinearGradient +// size: xgb.Pad(((28 + xgb.Pad((int(NumStops) * 4))) + xgb.Pad((int(NumStops) * 8)))) +type CreateLinearGradientCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateLinearGradient +func CreateLinearGradient(c *xgb.Conn, Picture Picture, P1 Pointfix, P2 Pointfix, NumStops uint32, Stops []Fixed, Colors []Color) CreateLinearGradientCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createLinearGradientRequest(c, Picture, P1, P2, NumStops, Stops, Colors), cookie) + return CreateLinearGradientCookie{cookie} +} + +func CreateLinearGradientChecked(c *xgb.Conn, Picture Picture, P1 Pointfix, P2 Pointfix, NumStops uint32, Stops []Fixed, Colors []Color) CreateLinearGradientCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createLinearGradientRequest(c, Picture, P1, P2, NumStops, Stops, Colors), cookie) + return CreateLinearGradientCookie{cookie} +} + +func (cook CreateLinearGradientCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateLinearGradient +func createLinearGradientRequest(c *xgb.Conn, Picture Picture, P1 Pointfix, P2 Pointfix, NumStops uint32, Stops []Fixed, Colors []Color) []byte { + size := xgb.Pad(((28 + xgb.Pad((int(NumStops) * 4))) + xgb.Pad((int(NumStops) * 8)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 34 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Picture)) + b += 4 + + { + structBytes := P1.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := P2.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + xgb.Put32(buf[b:], NumStops) + b += 4 + + for i := 0; i < int(NumStops); i++ { + xgb.Put32(buf[b:], uint32(Stops[i])) + b += 4 + } + b = xgb.Pad(b) + + b += ColorListBytes(buf[b:], Colors) + + return buf +} + +// Request CreateRadialGradient +// size: xgb.Pad(((36 + xgb.Pad((int(NumStops) * 4))) + xgb.Pad((int(NumStops) * 8)))) +type CreateRadialGradientCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateRadialGradient +func CreateRadialGradient(c *xgb.Conn, Picture Picture, Inner Pointfix, Outer Pointfix, InnerRadius Fixed, OuterRadius Fixed, NumStops uint32, Stops []Fixed, Colors []Color) CreateRadialGradientCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createRadialGradientRequest(c, Picture, Inner, Outer, InnerRadius, OuterRadius, NumStops, Stops, Colors), cookie) + return CreateRadialGradientCookie{cookie} +} + +func CreateRadialGradientChecked(c *xgb.Conn, Picture Picture, Inner Pointfix, Outer Pointfix, InnerRadius Fixed, OuterRadius Fixed, NumStops uint32, Stops []Fixed, Colors []Color) CreateRadialGradientCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createRadialGradientRequest(c, Picture, Inner, Outer, InnerRadius, OuterRadius, NumStops, Stops, Colors), cookie) + return CreateRadialGradientCookie{cookie} +} + +func (cook CreateRadialGradientCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateRadialGradient +func createRadialGradientRequest(c *xgb.Conn, Picture Picture, Inner Pointfix, Outer Pointfix, InnerRadius Fixed, OuterRadius Fixed, NumStops uint32, Stops []Fixed, Colors []Color) []byte { + size := xgb.Pad(((36 + xgb.Pad((int(NumStops) * 4))) + xgb.Pad((int(NumStops) * 8)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 35 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Picture)) + b += 4 + + { + structBytes := Inner.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := Outer.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + xgb.Put32(buf[b:], uint32(InnerRadius)) + b += 4 + + xgb.Put32(buf[b:], uint32(OuterRadius)) + b += 4 + + xgb.Put32(buf[b:], NumStops) + b += 4 + + for i := 0; i < int(NumStops); i++ { + xgb.Put32(buf[b:], uint32(Stops[i])) + b += 4 + } + b = xgb.Pad(b) + + b += ColorListBytes(buf[b:], Colors) + + return buf +} + +// Request CreateConicalGradient +// size: xgb.Pad(((24 + xgb.Pad((int(NumStops) * 4))) + xgb.Pad((int(NumStops) * 8)))) +type CreateConicalGradientCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateConicalGradient +func CreateConicalGradient(c *xgb.Conn, Picture Picture, Center Pointfix, Angle Fixed, NumStops uint32, Stops []Fixed, Colors []Color) CreateConicalGradientCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createConicalGradientRequest(c, Picture, Center, Angle, NumStops, Stops, Colors), cookie) + return CreateConicalGradientCookie{cookie} +} + +func CreateConicalGradientChecked(c *xgb.Conn, Picture Picture, Center Pointfix, Angle Fixed, NumStops uint32, Stops []Fixed, Colors []Color) CreateConicalGradientCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createConicalGradientRequest(c, Picture, Center, Angle, NumStops, Stops, Colors), cookie) + return CreateConicalGradientCookie{cookie} +} + +func (cook CreateConicalGradientCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateConicalGradient +func createConicalGradientRequest(c *xgb.Conn, Picture Picture, Center Pointfix, Angle Fixed, NumStops uint32, Stops []Fixed, Colors []Color) []byte { + size := xgb.Pad(((24 + xgb.Pad((int(NumStops) * 4))) + xgb.Pad((int(NumStops) * 8)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["RENDER"] + b += 1 + + buf[b] = 36 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Picture)) + b += 4 + + { + structBytes := Center.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + xgb.Put32(buf[b:], uint32(Angle)) + b += 4 + + xgb.Put32(buf[b:], NumStops) + b += 4 + + for i := 0; i < int(NumStops); i++ { + xgb.Put32(buf[b:], uint32(Stops[i])) + b += 4 + } + b = xgb.Pad(b) + + b += ColorListBytes(buf[b:], Colors) + + return buf +} diff --git a/nexgb/res/res.go b/nexgb/res/res.go new file mode 100644 index 0000000..aa958ab --- /dev/null +++ b/nexgb/res/res.go @@ -0,0 +1,514 @@ +package res + +/* + This file was generated by res.xml on May 10 2012 4:20:28pm EDT. + This file is automatically generated. Edit at your peril! +*/ + +import ( + "github.com/BurntSushi/xgb" + + "github.com/BurntSushi/xgb/xproto" +) + +// Init must be called before using the X-Resource extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 10, "X-Resource").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named X-Resource could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["X-Resource"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["X-Resource"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["X-Resource"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["X-Resource"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["X-Resource"] = make(map[int]xgb.NewErrorFun) +} + +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Bool' + +// Skipping definition for base type 'Float' + +// 'Client' struct definition +// Size: 8 +type Client struct { + ResourceBase uint32 + ResourceMask uint32 +} + +// Struct read Client +func ClientRead(buf []byte, v *Client) int { + b := 0 + + v.ResourceBase = xgb.Get32(buf[b:]) + b += 4 + + v.ResourceMask = xgb.Get32(buf[b:]) + b += 4 + + return b +} + +// Struct list read Client +func ClientReadList(buf []byte, dest []Client) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Client{} + b += ClientRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Client +func (v Client) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put32(buf[b:], v.ResourceBase) + b += 4 + + xgb.Put32(buf[b:], v.ResourceMask) + b += 4 + + return buf +} + +// Write struct list Client +func ClientListBytes(buf []byte, list []Client) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Type' struct definition +// Size: 8 +type Type struct { + ResourceType xproto.Atom + Count uint32 +} + +// Struct read Type +func TypeRead(buf []byte, v *Type) int { + b := 0 + + v.ResourceType = xproto.Atom(xgb.Get32(buf[b:])) + b += 4 + + v.Count = xgb.Get32(buf[b:]) + b += 4 + + return b +} + +// Struct list read Type +func TypeReadList(buf []byte, dest []Type) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Type{} + b += TypeRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Type +func (v Type) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put32(buf[b:], uint32(v.ResourceType)) + b += 4 + + xgb.Put32(buf[b:], v.Count) + b += 4 + + return buf +} + +// Write struct list Type +func TypeListBytes(buf []byte, list []Type) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Request QueryVersion +// size: 8 +type QueryVersionCookie struct { + *xgb.Cookie +} + +func QueryVersion(c *xgb.Conn, ClientMajor byte, ClientMinor byte) QueryVersionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c, ClientMajor, ClientMinor), cookie) + return QueryVersionCookie{cookie} +} + +func QueryVersionUnchecked(c *xgb.Conn, ClientMajor byte, ClientMinor byte) QueryVersionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c, ClientMajor, ClientMinor), cookie) + return QueryVersionCookie{cookie} +} + +// Request reply for QueryVersion +// size: 12 +type QueryVersionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ServerMajor uint16 + ServerMinor uint16 +} + +// Waits and reads reply data from request QueryVersion +func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryVersionReply(buf), nil +} + +// Read reply into structure from buffer for QueryVersion +func queryVersionReply(buf []byte) *QueryVersionReply { + v := new(QueryVersionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ServerMajor = xgb.Get16(buf[b:]) + b += 2 + + v.ServerMinor = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Write request to wire for QueryVersion +func queryVersionRequest(c *xgb.Conn, ClientMajor byte, ClientMinor byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["X-RESOURCE"] + b += 1 + + buf[b] = 0 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = ClientMajor + b += 1 + + buf[b] = ClientMinor + b += 1 + + return buf +} + +// Request QueryClients +// size: 4 +type QueryClientsCookie struct { + *xgb.Cookie +} + +func QueryClients(c *xgb.Conn) QueryClientsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryClientsRequest(c), cookie) + return QueryClientsCookie{cookie} +} + +func QueryClientsUnchecked(c *xgb.Conn) QueryClientsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryClientsRequest(c), cookie) + return QueryClientsCookie{cookie} +} + +// Request reply for QueryClients +// size: (32 + xgb.Pad((int(NumClients) * 8))) +type QueryClientsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumClients uint32 + // padding: 20 bytes + Clients []Client // size: xgb.Pad((int(NumClients) * 8)) +} + +// Waits and reads reply data from request QueryClients +func (cook QueryClientsCookie) Reply() (*QueryClientsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryClientsReply(buf), nil +} + +// Read reply into structure from buffer for QueryClients +func queryClientsReply(buf []byte) *QueryClientsReply { + v := new(QueryClientsReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NumClients = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Clients = make([]Client, v.NumClients) + b += ClientReadList(buf[b:], v.Clients) + + return v +} + +// Write request to wire for QueryClients +func queryClientsRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["X-RESOURCE"] + b += 1 + + buf[b] = 1 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request QueryClientResources +// size: 8 +type QueryClientResourcesCookie struct { + *xgb.Cookie +} + +func QueryClientResources(c *xgb.Conn, Xid uint32) QueryClientResourcesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryClientResourcesRequest(c, Xid), cookie) + return QueryClientResourcesCookie{cookie} +} + +func QueryClientResourcesUnchecked(c *xgb.Conn, Xid uint32) QueryClientResourcesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryClientResourcesRequest(c, Xid), cookie) + return QueryClientResourcesCookie{cookie} +} + +// Request reply for QueryClientResources +// size: (32 + xgb.Pad((int(NumTypes) * 8))) +type QueryClientResourcesReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumTypes uint32 + // padding: 20 bytes + Types []Type // size: xgb.Pad((int(NumTypes) * 8)) +} + +// Waits and reads reply data from request QueryClientResources +func (cook QueryClientResourcesCookie) Reply() (*QueryClientResourcesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryClientResourcesReply(buf), nil +} + +// Read reply into structure from buffer for QueryClientResources +func queryClientResourcesReply(buf []byte) *QueryClientResourcesReply { + v := new(QueryClientResourcesReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NumTypes = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Types = make([]Type, v.NumTypes) + b += TypeReadList(buf[b:], v.Types) + + return v +} + +// Write request to wire for QueryClientResources +func queryClientResourcesRequest(c *xgb.Conn, Xid uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["X-RESOURCE"] + b += 1 + + buf[b] = 2 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Xid) + b += 4 + + return buf +} + +// Request QueryClientPixmapBytes +// size: 8 +type QueryClientPixmapBytesCookie struct { + *xgb.Cookie +} + +func QueryClientPixmapBytes(c *xgb.Conn, Xid uint32) QueryClientPixmapBytesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryClientPixmapBytesRequest(c, Xid), cookie) + return QueryClientPixmapBytesCookie{cookie} +} + +func QueryClientPixmapBytesUnchecked(c *xgb.Conn, Xid uint32) QueryClientPixmapBytesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryClientPixmapBytesRequest(c, Xid), cookie) + return QueryClientPixmapBytesCookie{cookie} +} + +// Request reply for QueryClientPixmapBytes +// size: 16 +type QueryClientPixmapBytesReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Bytes uint32 + BytesOverflow uint32 +} + +// Waits and reads reply data from request QueryClientPixmapBytes +func (cook QueryClientPixmapBytesCookie) Reply() (*QueryClientPixmapBytesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryClientPixmapBytesReply(buf), nil +} + +// Read reply into structure from buffer for QueryClientPixmapBytes +func queryClientPixmapBytesReply(buf []byte) *QueryClientPixmapBytesReply { + v := new(QueryClientPixmapBytesReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Bytes = xgb.Get32(buf[b:]) + b += 4 + + v.BytesOverflow = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for QueryClientPixmapBytes +func queryClientPixmapBytesRequest(c *xgb.Conn, Xid uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["X-RESOURCE"] + b += 1 + + buf[b] = 3 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Xid) + b += 4 + + return buf +} diff --git a/nexgb/screensaver/screensaver.go b/nexgb/screensaver/screensaver.go new file mode 100644 index 0000000..d9353f2 --- /dev/null +++ b/nexgb/screensaver/screensaver.go @@ -0,0 +1,621 @@ +package screensaver + +/* + This file was generated by screensaver.xml on May 10 2012 4:20:28pm EDT. + This file is automatically generated. Edit at your peril! +*/ + +import ( + "github.com/BurntSushi/xgb" + + "github.com/BurntSushi/xgb/xproto" +) + +// Init must be called before using the MIT-SCREEN-SAVER extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 16, "MIT-SCREEN-SAVER").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named MIT-SCREEN-SAVER could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["MIT-SCREEN-SAVER"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["MIT-SCREEN-SAVER"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["MIT-SCREEN-SAVER"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["MIT-SCREEN-SAVER"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["MIT-SCREEN-SAVER"] = make(map[int]xgb.NewErrorFun) +} + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Bool' + +// Skipping definition for base type 'Float' + +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +const ( + KindBlanked = 0 + KindInternal = 1 + KindExternal = 2 +) + +const ( + EventNotifyMask = 1 + EventCycleMask = 2 +) + +const ( + StateOff = 0 + StateOn = 1 + StateCycle = 2 + StateDisabled = 3 +) + +// Event definition Notify (0) +// Size: 32 + +const Notify = 0 + +type NotifyEvent struct { + Sequence uint16 + Code byte + State byte + // padding: 1 bytes + SequenceNumber uint16 + Time xproto.Timestamp + Root xproto.Window + Window xproto.Window + Kind byte + Forced bool + // padding: 14 bytes +} + +// Event read Notify +func NotifyEventNew(buf []byte) xgb.Event { + v := NotifyEvent{} + b := 1 // don't read event number + + v.Code = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.State = buf[b] + b += 1 + + b += 1 // padding + + v.SequenceNumber = xgb.Get16(buf[b:]) + b += 2 + + v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Root = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.Window = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.Kind = buf[b] + b += 1 + + if buf[b] == 1 { + v.Forced = true + } else { + v.Forced = false + } + b += 1 + + b += 14 // padding + + return v +} + +// Event write Notify +func (v NotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 0 + b += 1 + + buf[b] = v.Code + b += 1 + + b += 2 // skip sequence number + + buf[b] = v.State + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], v.SequenceNumber) + b += 2 + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Root)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + buf[b] = v.Kind + b += 1 + + if v.Forced { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 14 // padding + + return buf +} + +func (v NotifyEvent) ImplementsEvent() {} + +func (v NotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v NotifyEvent) String() string { + fieldVals := make([]string, 0, 10) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Code: %d", v.Code)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SequenceNumber: %d", v.SequenceNumber)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("Kind: %d", v.Kind)) + fieldVals = append(fieldVals, xgb.Sprintf("Forced: %t", v.Forced)) + return "Notify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["MIT-SCREEN-SAVER"][0] = NotifyEventNew +} + +// Request QueryVersion +// size: 8 +type QueryVersionCookie struct { + *xgb.Cookie +} + +func QueryVersion(c *xgb.Conn, ClientMajorVersion byte, ClientMinorVersion byte) QueryVersionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return QueryVersionCookie{cookie} +} + +func QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion byte, ClientMinorVersion byte) QueryVersionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return QueryVersionCookie{cookie} +} + +// Request reply for QueryVersion +// size: 32 +type QueryVersionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ServerMajorVersion uint16 + ServerMinorVersion uint16 + // padding: 20 bytes +} + +// Waits and reads reply data from request QueryVersion +func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryVersionReply(buf), nil +} + +// Read reply into structure from buffer for QueryVersion +func queryVersionReply(buf []byte) *QueryVersionReply { + v := new(QueryVersionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ServerMajorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.ServerMinorVersion = xgb.Get16(buf[b:]) + b += 2 + + b += 20 // padding + + return v +} + +// Write request to wire for QueryVersion +func queryVersionRequest(c *xgb.Conn, ClientMajorVersion byte, ClientMinorVersion byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["MIT-SCREEN-SAVER"] + b += 1 + + buf[b] = 0 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = ClientMajorVersion + b += 1 + + buf[b] = ClientMinorVersion + b += 1 + + b += 2 // padding + + return buf +} + +// Request QueryInfo +// size: 8 +type QueryInfoCookie struct { + *xgb.Cookie +} + +func QueryInfo(c *xgb.Conn, Drawable xproto.Drawable) QueryInfoCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryInfoRequest(c, Drawable), cookie) + return QueryInfoCookie{cookie} +} + +func QueryInfoUnchecked(c *xgb.Conn, Drawable xproto.Drawable) QueryInfoCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryInfoRequest(c, Drawable), cookie) + return QueryInfoCookie{cookie} +} + +// Request reply for QueryInfo +// size: 32 +type QueryInfoReply struct { + Sequence uint16 + Length uint32 + State byte + SaverWindow xproto.Window + MsUntilServer uint32 + MsSinceUserInput uint32 + EventMask uint32 + Kind byte + // padding: 7 bytes +} + +// Waits and reads reply data from request QueryInfo +func (cook QueryInfoCookie) Reply() (*QueryInfoReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryInfoReply(buf), nil +} + +// Read reply into structure from buffer for QueryInfo +func queryInfoReply(buf []byte) *QueryInfoReply { + v := new(QueryInfoReply) + b := 1 // skip reply determinant + + v.State = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.SaverWindow = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.MsUntilServer = xgb.Get32(buf[b:]) + b += 4 + + v.MsSinceUserInput = xgb.Get32(buf[b:]) + b += 4 + + v.EventMask = xgb.Get32(buf[b:]) + b += 4 + + v.Kind = buf[b] + b += 1 + + b += 7 // padding + + return v +} + +// Write request to wire for QueryInfo +func queryInfoRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["MIT-SCREEN-SAVER"] + b += 1 + + buf[b] = 1 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + return buf +} + +// Request SelectInput +// size: 12 +type SelectInputCookie struct { + *xgb.Cookie +} + +// Write request to wire for SelectInput +func SelectInput(c *xgb.Conn, Drawable xproto.Drawable, EventMask uint32) SelectInputCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(selectInputRequest(c, Drawable, EventMask), cookie) + return SelectInputCookie{cookie} +} + +func SelectInputChecked(c *xgb.Conn, Drawable xproto.Drawable, EventMask uint32) SelectInputCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(selectInputRequest(c, Drawable, EventMask), cookie) + return SelectInputCookie{cookie} +} + +func (cook SelectInputCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SelectInput +func selectInputRequest(c *xgb.Conn, Drawable xproto.Drawable, EventMask uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["MIT-SCREEN-SAVER"] + b += 1 + + buf[b] = 2 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], EventMask) + b += 4 + + return buf +} + +// Request SetAttributes +// size: xgb.Pad((24 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +type SetAttributesCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetAttributes +func SetAttributes(c *xgb.Conn, Drawable xproto.Drawable, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class byte, Depth byte, Visual xproto.Visualid, ValueMask uint32, ValueList []uint32) SetAttributesCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setAttributesRequest(c, Drawable, X, Y, Width, Height, BorderWidth, Class, Depth, Visual, ValueMask, ValueList), cookie) + return SetAttributesCookie{cookie} +} + +func SetAttributesChecked(c *xgb.Conn, Drawable xproto.Drawable, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class byte, Depth byte, Visual xproto.Visualid, ValueMask uint32, ValueList []uint32) SetAttributesCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setAttributesRequest(c, Drawable, X, Y, Width, Height, BorderWidth, Class, Depth, Visual, ValueMask, ValueList), cookie) + return SetAttributesCookie{cookie} +} + +func (cook SetAttributesCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetAttributes +func setAttributesRequest(c *xgb.Conn, Drawable xproto.Drawable, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class byte, Depth byte, Visual xproto.Visualid, ValueMask uint32, ValueList []uint32) []byte { + size := xgb.Pad((24 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["MIT-SCREEN-SAVER"] + b += 1 + + buf[b] = 3 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put16(buf[b:], uint16(X)) + b += 2 + + xgb.Put16(buf[b:], uint16(Y)) + b += 2 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + xgb.Put16(buf[b:], BorderWidth) + b += 2 + + buf[b] = Class + b += 1 + + buf[b] = Depth + b += 1 + + xgb.Put32(buf[b:], uint32(Visual)) + b += 4 + + xgb.Put32(buf[b:], ValueMask) + b += 4 + for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { + xgb.Put32(buf[b:], ValueList[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request UnsetAttributes +// size: 8 +type UnsetAttributesCookie struct { + *xgb.Cookie +} + +// Write request to wire for UnsetAttributes +func UnsetAttributes(c *xgb.Conn, Drawable xproto.Drawable) UnsetAttributesCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(unsetAttributesRequest(c, Drawable), cookie) + return UnsetAttributesCookie{cookie} +} + +func UnsetAttributesChecked(c *xgb.Conn, Drawable xproto.Drawable) UnsetAttributesCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(unsetAttributesRequest(c, Drawable), cookie) + return UnsetAttributesCookie{cookie} +} + +func (cook UnsetAttributesCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for UnsetAttributes +func unsetAttributesRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["MIT-SCREEN-SAVER"] + b += 1 + + buf[b] = 4 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + return buf +} + +// Request Suspend +// size: 8 +type SuspendCookie struct { + *xgb.Cookie +} + +// Write request to wire for Suspend +func Suspend(c *xgb.Conn, Suspend bool) SuspendCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(suspendRequest(c, Suspend), cookie) + return SuspendCookie{cookie} +} + +func SuspendChecked(c *xgb.Conn, Suspend bool) SuspendCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(suspendRequest(c, Suspend), cookie) + return SuspendCookie{cookie} +} + +func (cook SuspendCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for Suspend +func suspendRequest(c *xgb.Conn, Suspend bool) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["MIT-SCREEN-SAVER"] + b += 1 + + buf[b] = 5 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + if Suspend { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding + + return buf +} diff --git a/nexgb/shape/shape.go b/nexgb/shape/shape.go new file mode 100644 index 0000000..5d9dbf3 --- /dev/null +++ b/nexgb/shape/shape.go @@ -0,0 +1,883 @@ +package shape + +/* + This file was generated by shape.xml on May 10 2012 4:20:28pm EDT. + This file is automatically generated. Edit at your peril! +*/ + +import ( + "github.com/BurntSushi/xgb" + + "github.com/BurntSushi/xgb/xproto" +) + +// Init must be called before using the SHAPE extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 5, "SHAPE").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named SHAPE could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["SHAPE"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["SHAPE"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["SHAPE"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["SHAPE"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["SHAPE"] = make(map[int]xgb.NewErrorFun) +} + +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Bool' + +// Skipping definition for base type 'Float' + +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Char' + +const ( + SoSet = 0 + SoUnion = 1 + SoIntersect = 2 + SoSubtract = 3 + SoInvert = 4 +) + +const ( + SkBounding = 0 + SkClip = 1 + SkInput = 2 +) + +type Op byte + +type Kind byte + +// Event definition Notify (0) +// Size: 32 + +const Notify = 0 + +type NotifyEvent struct { + Sequence uint16 + ShapeKind Kind + AffectedWindow xproto.Window + ExtentsX int16 + ExtentsY int16 + ExtentsWidth uint16 + ExtentsHeight uint16 + ServerTime xproto.Timestamp + Shaped bool + // padding: 11 bytes +} + +// Event read Notify +func NotifyEventNew(buf []byte) xgb.Event { + v := NotifyEvent{} + b := 1 // don't read event number + + v.ShapeKind = Kind(buf[b]) + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.AffectedWindow = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.ExtentsX = int16(xgb.Get16(buf[b:])) + b += 2 + + v.ExtentsY = int16(xgb.Get16(buf[b:])) + b += 2 + + v.ExtentsWidth = xgb.Get16(buf[b:]) + b += 2 + + v.ExtentsHeight = xgb.Get16(buf[b:]) + b += 2 + + v.ServerTime = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + if buf[b] == 1 { + v.Shaped = true + } else { + v.Shaped = false + } + b += 1 + + b += 11 // padding + + return v +} + +// Event write Notify +func (v NotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 0 + b += 1 + + buf[b] = byte(v.ShapeKind) + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.AffectedWindow)) + b += 4 + + xgb.Put16(buf[b:], uint16(v.ExtentsX)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.ExtentsY)) + b += 2 + + xgb.Put16(buf[b:], v.ExtentsWidth) + b += 2 + + xgb.Put16(buf[b:], v.ExtentsHeight) + b += 2 + + xgb.Put32(buf[b:], uint32(v.ServerTime)) + b += 4 + + if v.Shaped { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 11 // padding + + return buf +} + +func (v NotifyEvent) ImplementsEvent() {} + +func (v NotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v NotifyEvent) String() string { + fieldVals := make([]string, 0, 9) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("ShapeKind: %d", v.ShapeKind)) + fieldVals = append(fieldVals, xgb.Sprintf("AffectedWindow: %d", v.AffectedWindow)) + fieldVals = append(fieldVals, xgb.Sprintf("ExtentsX: %d", v.ExtentsX)) + fieldVals = append(fieldVals, xgb.Sprintf("ExtentsY: %d", v.ExtentsY)) + fieldVals = append(fieldVals, xgb.Sprintf("ExtentsWidth: %d", v.ExtentsWidth)) + fieldVals = append(fieldVals, xgb.Sprintf("ExtentsHeight: %d", v.ExtentsHeight)) + fieldVals = append(fieldVals, xgb.Sprintf("ServerTime: %d", v.ServerTime)) + fieldVals = append(fieldVals, xgb.Sprintf("Shaped: %t", v.Shaped)) + return "Notify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["SHAPE"][0] = NotifyEventNew +} + +// Request QueryVersion +// size: 4 +type QueryVersionCookie struct { + *xgb.Cookie +} + +func QueryVersion(c *xgb.Conn) QueryVersionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c), cookie) + return QueryVersionCookie{cookie} +} + +func QueryVersionUnchecked(c *xgb.Conn) QueryVersionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c), cookie) + return QueryVersionCookie{cookie} +} + +// Request reply for QueryVersion +// size: 12 +type QueryVersionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + MajorVersion uint16 + MinorVersion uint16 +} + +// Waits and reads reply data from request QueryVersion +func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryVersionReply(buf), nil +} + +// Read reply into structure from buffer for QueryVersion +func queryVersionReply(buf []byte) *QueryVersionReply { + v := new(QueryVersionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.MajorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.MinorVersion = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Write request to wire for QueryVersion +func queryVersionRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SHAPE"] + b += 1 + + buf[b] = 0 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request Rectangles +// size: xgb.Pad((16 + xgb.Pad((len(Rectangles) * 8)))) +type RectanglesCookie struct { + *xgb.Cookie +} + +// Write request to wire for Rectangles +func Rectangles(c *xgb.Conn, Operation Op, DestinationKind Kind, Ordering byte, DestinationWindow xproto.Window, XOffset int16, YOffset int16, Rectangles []xproto.Rectangle) RectanglesCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(rectanglesRequest(c, Operation, DestinationKind, Ordering, DestinationWindow, XOffset, YOffset, Rectangles), cookie) + return RectanglesCookie{cookie} +} + +func RectanglesChecked(c *xgb.Conn, Operation Op, DestinationKind Kind, Ordering byte, DestinationWindow xproto.Window, XOffset int16, YOffset int16, Rectangles []xproto.Rectangle) RectanglesCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(rectanglesRequest(c, Operation, DestinationKind, Ordering, DestinationWindow, XOffset, YOffset, Rectangles), cookie) + return RectanglesCookie{cookie} +} + +func (cook RectanglesCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for Rectangles +func rectanglesRequest(c *xgb.Conn, Operation Op, DestinationKind Kind, Ordering byte, DestinationWindow xproto.Window, XOffset int16, YOffset int16, Rectangles []xproto.Rectangle) []byte { + size := xgb.Pad((16 + xgb.Pad((len(Rectangles) * 8)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SHAPE"] + b += 1 + + buf[b] = 1 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = byte(Operation) + b += 1 + + buf[b] = byte(DestinationKind) + b += 1 + + buf[b] = Ordering + b += 1 + + b += 1 // padding + + xgb.Put32(buf[b:], uint32(DestinationWindow)) + b += 4 + + xgb.Put16(buf[b:], uint16(XOffset)) + b += 2 + + xgb.Put16(buf[b:], uint16(YOffset)) + b += 2 + + b += xproto.RectangleListBytes(buf[b:], Rectangles) + + return buf +} + +// Request Mask +// size: 20 +type MaskCookie struct { + *xgb.Cookie +} + +// Write request to wire for Mask +func Mask(c *xgb.Conn, Operation Op, DestinationKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16, SourceBitmap xproto.Pixmap) MaskCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(maskRequest(c, Operation, DestinationKind, DestinationWindow, XOffset, YOffset, SourceBitmap), cookie) + return MaskCookie{cookie} +} + +func MaskChecked(c *xgb.Conn, Operation Op, DestinationKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16, SourceBitmap xproto.Pixmap) MaskCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(maskRequest(c, Operation, DestinationKind, DestinationWindow, XOffset, YOffset, SourceBitmap), cookie) + return MaskCookie{cookie} +} + +func (cook MaskCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for Mask +func maskRequest(c *xgb.Conn, Operation Op, DestinationKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16, SourceBitmap xproto.Pixmap) []byte { + size := 20 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SHAPE"] + b += 1 + + buf[b] = 2 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = byte(Operation) + b += 1 + + buf[b] = byte(DestinationKind) + b += 1 + + b += 2 // padding + + xgb.Put32(buf[b:], uint32(DestinationWindow)) + b += 4 + + xgb.Put16(buf[b:], uint16(XOffset)) + b += 2 + + xgb.Put16(buf[b:], uint16(YOffset)) + b += 2 + + xgb.Put32(buf[b:], uint32(SourceBitmap)) + b += 4 + + return buf +} + +// Request Combine +// size: 20 +type CombineCookie struct { + *xgb.Cookie +} + +// Write request to wire for Combine +func Combine(c *xgb.Conn, Operation Op, DestinationKind Kind, SourceKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16, SourceWindow xproto.Window) CombineCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(combineRequest(c, Operation, DestinationKind, SourceKind, DestinationWindow, XOffset, YOffset, SourceWindow), cookie) + return CombineCookie{cookie} +} + +func CombineChecked(c *xgb.Conn, Operation Op, DestinationKind Kind, SourceKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16, SourceWindow xproto.Window) CombineCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(combineRequest(c, Operation, DestinationKind, SourceKind, DestinationWindow, XOffset, YOffset, SourceWindow), cookie) + return CombineCookie{cookie} +} + +func (cook CombineCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for Combine +func combineRequest(c *xgb.Conn, Operation Op, DestinationKind Kind, SourceKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16, SourceWindow xproto.Window) []byte { + size := 20 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SHAPE"] + b += 1 + + buf[b] = 3 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = byte(Operation) + b += 1 + + buf[b] = byte(DestinationKind) + b += 1 + + buf[b] = byte(SourceKind) + b += 1 + + b += 1 // padding + + xgb.Put32(buf[b:], uint32(DestinationWindow)) + b += 4 + + xgb.Put16(buf[b:], uint16(XOffset)) + b += 2 + + xgb.Put16(buf[b:], uint16(YOffset)) + b += 2 + + xgb.Put32(buf[b:], uint32(SourceWindow)) + b += 4 + + return buf +} + +// Request Offset +// size: 16 +type OffsetCookie struct { + *xgb.Cookie +} + +// Write request to wire for Offset +func Offset(c *xgb.Conn, DestinationKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16) OffsetCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(offsetRequest(c, DestinationKind, DestinationWindow, XOffset, YOffset), cookie) + return OffsetCookie{cookie} +} + +func OffsetChecked(c *xgb.Conn, DestinationKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16) OffsetCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(offsetRequest(c, DestinationKind, DestinationWindow, XOffset, YOffset), cookie) + return OffsetCookie{cookie} +} + +func (cook OffsetCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for Offset +func offsetRequest(c *xgb.Conn, DestinationKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SHAPE"] + b += 1 + + buf[b] = 4 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = byte(DestinationKind) + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], uint32(DestinationWindow)) + b += 4 + + xgb.Put16(buf[b:], uint16(XOffset)) + b += 2 + + xgb.Put16(buf[b:], uint16(YOffset)) + b += 2 + + return buf +} + +// Request QueryExtents +// size: 8 +type QueryExtentsCookie struct { + *xgb.Cookie +} + +func QueryExtents(c *xgb.Conn, DestinationWindow xproto.Window) QueryExtentsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryExtentsRequest(c, DestinationWindow), cookie) + return QueryExtentsCookie{cookie} +} + +func QueryExtentsUnchecked(c *xgb.Conn, DestinationWindow xproto.Window) QueryExtentsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryExtentsRequest(c, DestinationWindow), cookie) + return QueryExtentsCookie{cookie} +} + +// Request reply for QueryExtents +// size: 28 +type QueryExtentsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + BoundingShaped bool + ClipShaped bool + // padding: 2 bytes + BoundingShapeExtentsX int16 + BoundingShapeExtentsY int16 + BoundingShapeExtentsWidth uint16 + BoundingShapeExtentsHeight uint16 + ClipShapeExtentsX int16 + ClipShapeExtentsY int16 + ClipShapeExtentsWidth uint16 + ClipShapeExtentsHeight uint16 +} + +// Waits and reads reply data from request QueryExtents +func (cook QueryExtentsCookie) Reply() (*QueryExtentsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryExtentsReply(buf), nil +} + +// Read reply into structure from buffer for QueryExtents +func queryExtentsReply(buf []byte) *QueryExtentsReply { + v := new(QueryExtentsReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + if buf[b] == 1 { + v.BoundingShaped = true + } else { + v.BoundingShaped = false + } + b += 1 + + if buf[b] == 1 { + v.ClipShaped = true + } else { + v.ClipShaped = false + } + b += 1 + + b += 2 // padding + + v.BoundingShapeExtentsX = int16(xgb.Get16(buf[b:])) + b += 2 + + v.BoundingShapeExtentsY = int16(xgb.Get16(buf[b:])) + b += 2 + + v.BoundingShapeExtentsWidth = xgb.Get16(buf[b:]) + b += 2 + + v.BoundingShapeExtentsHeight = xgb.Get16(buf[b:]) + b += 2 + + v.ClipShapeExtentsX = int16(xgb.Get16(buf[b:])) + b += 2 + + v.ClipShapeExtentsY = int16(xgb.Get16(buf[b:])) + b += 2 + + v.ClipShapeExtentsWidth = xgb.Get16(buf[b:]) + b += 2 + + v.ClipShapeExtentsHeight = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Write request to wire for QueryExtents +func queryExtentsRequest(c *xgb.Conn, DestinationWindow xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SHAPE"] + b += 1 + + buf[b] = 5 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(DestinationWindow)) + b += 4 + + return buf +} + +// Request SelectInput +// size: 12 +type SelectInputCookie struct { + *xgb.Cookie +} + +// Write request to wire for SelectInput +func SelectInput(c *xgb.Conn, DestinationWindow xproto.Window, Enable bool) SelectInputCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(selectInputRequest(c, DestinationWindow, Enable), cookie) + return SelectInputCookie{cookie} +} + +func SelectInputChecked(c *xgb.Conn, DestinationWindow xproto.Window, Enable bool) SelectInputCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(selectInputRequest(c, DestinationWindow, Enable), cookie) + return SelectInputCookie{cookie} +} + +func (cook SelectInputCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SelectInput +func selectInputRequest(c *xgb.Conn, DestinationWindow xproto.Window, Enable bool) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SHAPE"] + b += 1 + + buf[b] = 6 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(DestinationWindow)) + b += 4 + + if Enable { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding + + return buf +} + +// Request InputSelected +// size: 8 +type InputSelectedCookie struct { + *xgb.Cookie +} + +func InputSelected(c *xgb.Conn, DestinationWindow xproto.Window) InputSelectedCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(inputSelectedRequest(c, DestinationWindow), cookie) + return InputSelectedCookie{cookie} +} + +func InputSelectedUnchecked(c *xgb.Conn, DestinationWindow xproto.Window) InputSelectedCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(inputSelectedRequest(c, DestinationWindow), cookie) + return InputSelectedCookie{cookie} +} + +// Request reply for InputSelected +// size: 8 +type InputSelectedReply struct { + Sequence uint16 + Length uint32 + Enabled bool +} + +// Waits and reads reply data from request InputSelected +func (cook InputSelectedCookie) Reply() (*InputSelectedReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return inputSelectedReply(buf), nil +} + +// Read reply into structure from buffer for InputSelected +func inputSelectedReply(buf []byte) *InputSelectedReply { + v := new(InputSelectedReply) + b := 1 // skip reply determinant + + if buf[b] == 1 { + v.Enabled = true + } else { + v.Enabled = false + } + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + return v +} + +// Write request to wire for InputSelected +func inputSelectedRequest(c *xgb.Conn, DestinationWindow xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SHAPE"] + b += 1 + + buf[b] = 7 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(DestinationWindow)) + b += 4 + + return buf +} + +// Request GetRectangles +// size: 12 +type GetRectanglesCookie struct { + *xgb.Cookie +} + +func GetRectangles(c *xgb.Conn, Window xproto.Window, SourceKind Kind) GetRectanglesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getRectanglesRequest(c, Window, SourceKind), cookie) + return GetRectanglesCookie{cookie} +} + +func GetRectanglesUnchecked(c *xgb.Conn, Window xproto.Window, SourceKind Kind) GetRectanglesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getRectanglesRequest(c, Window, SourceKind), cookie) + return GetRectanglesCookie{cookie} +} + +// Request reply for GetRectangles +// size: (32 + xgb.Pad((int(RectanglesLen) * 8))) +type GetRectanglesReply struct { + Sequence uint16 + Length uint32 + Ordering byte + RectanglesLen uint32 + // padding: 20 bytes + Rectangles []xproto.Rectangle // size: xgb.Pad((int(RectanglesLen) * 8)) +} + +// Waits and reads reply data from request GetRectangles +func (cook GetRectanglesCookie) Reply() (*GetRectanglesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getRectanglesReply(buf), nil +} + +// Read reply into structure from buffer for GetRectangles +func getRectanglesReply(buf []byte) *GetRectanglesReply { + v := new(GetRectanglesReply) + b := 1 // skip reply determinant + + v.Ordering = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.RectanglesLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Rectangles = make([]xproto.Rectangle, v.RectanglesLen) + b += xproto.RectangleReadList(buf[b:], v.Rectangles) + + return v +} + +// Write request to wire for GetRectangles +func getRectanglesRequest(c *xgb.Conn, Window xproto.Window, SourceKind Kind) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SHAPE"] + b += 1 + + buf[b] = 8 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + buf[b] = byte(SourceKind) + b += 1 + + b += 3 // padding + + return buf +} diff --git a/nexgb/shm/shm.go b/nexgb/shm/shm.go new file mode 100644 index 0000000..ecffafc --- /dev/null +++ b/nexgb/shm/shm.go @@ -0,0 +1,672 @@ +package shm + +/* + This file was generated by shm.xml on May 10 2012 4:20:28pm EDT. + This file is automatically generated. Edit at your peril! +*/ + +import ( + "github.com/BurntSushi/xgb" + + "github.com/BurntSushi/xgb/xproto" +) + +// Init must be called before using the MIT-SHM extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 7, "MIT-SHM").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named MIT-SHM could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["MIT-SHM"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["MIT-SHM"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["MIT-SHM"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["MIT-SHM"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["MIT-SHM"] = make(map[int]xgb.NewErrorFun) +} + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Bool' + +// Skipping definition for base type 'Float' + +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +type Seg uint32 + +func NewSegId(c *xgb.Conn) (Seg, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Seg(id), nil +} + +// Event definition Completion (0) +// Size: 32 + +const Completion = 0 + +type CompletionEvent struct { + Sequence uint16 + // padding: 1 bytes + Drawable xproto.Drawable + MinorEvent uint16 + MajorEvent byte + // padding: 1 bytes + Shmseg Seg + Offset uint32 +} + +// Event read Completion +func CompletionEventNew(buf []byte) xgb.Event { + v := CompletionEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Drawable = xproto.Drawable(xgb.Get32(buf[b:])) + b += 4 + + v.MinorEvent = xgb.Get16(buf[b:]) + b += 2 + + v.MajorEvent = buf[b] + b += 1 + + b += 1 // padding + + v.Shmseg = Seg(xgb.Get32(buf[b:])) + b += 4 + + v.Offset = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Event write Completion +func (v CompletionEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 0 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Drawable)) + b += 4 + + xgb.Put16(buf[b:], v.MinorEvent) + b += 2 + + buf[b] = v.MajorEvent + b += 1 + + b += 1 // padding + + xgb.Put32(buf[b:], uint32(v.Shmseg)) + b += 4 + + xgb.Put32(buf[b:], v.Offset) + b += 4 + + return buf +} + +func (v CompletionEvent) ImplementsEvent() {} + +func (v CompletionEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v CompletionEvent) String() string { + fieldVals := make([]string, 0, 7) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Drawable: %d", v.Drawable)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorEvent: %d", v.MinorEvent)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorEvent: %d", v.MajorEvent)) + fieldVals = append(fieldVals, xgb.Sprintf("Shmseg: %d", v.Shmseg)) + fieldVals = append(fieldVals, xgb.Sprintf("Offset: %d", v.Offset)) + return "Completion {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["MIT-SHM"][0] = CompletionEventNew +} + +// ErrorCopy definition BadSeg (0) + +const BadBadSeg = 0 + +type BadSegError xproto.ValueError + +func BadSegErrorNew(buf []byte) xgb.Error { + v := BadSegError(xproto.ValueErrorNew(buf).(xproto.ValueError)) + v.NiceName = "BadSeg" + return v +} + +func (err BadSegError) ImplementsError() {} + +func (err BadSegError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadSegError) BadId() uint32 { + return 0 +} + +func (err BadSegError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadBadSeg {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["MIT-SHM"][0] = BadSegErrorNew +} + +// Request QueryVersion +// size: 4 +type QueryVersionCookie struct { + *xgb.Cookie +} + +func QueryVersion(c *xgb.Conn) QueryVersionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c), cookie) + return QueryVersionCookie{cookie} +} + +func QueryVersionUnchecked(c *xgb.Conn) QueryVersionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c), cookie) + return QueryVersionCookie{cookie} +} + +// Request reply for QueryVersion +// size: 32 +type QueryVersionReply struct { + Sequence uint16 + Length uint32 + SharedPixmaps bool + MajorVersion uint16 + MinorVersion uint16 + Uid uint16 + Gid uint16 + PixmapFormat byte + // padding: 15 bytes +} + +// Waits and reads reply data from request QueryVersion +func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryVersionReply(buf), nil +} + +// Read reply into structure from buffer for QueryVersion +func queryVersionReply(buf []byte) *QueryVersionReply { + v := new(QueryVersionReply) + b := 1 // skip reply determinant + + if buf[b] == 1 { + v.SharedPixmaps = true + } else { + v.SharedPixmaps = false + } + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.MajorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.MinorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.Uid = xgb.Get16(buf[b:]) + b += 2 + + v.Gid = xgb.Get16(buf[b:]) + b += 2 + + v.PixmapFormat = buf[b] + b += 1 + + b += 15 // padding + + return v +} + +// Write request to wire for QueryVersion +func queryVersionRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["MIT-SHM"] + b += 1 + + buf[b] = 0 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request Attach +// size: 16 +type AttachCookie struct { + *xgb.Cookie +} + +// Write request to wire for Attach +func Attach(c *xgb.Conn, Shmseg Seg, Shmid uint32, ReadOnly bool) AttachCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(attachRequest(c, Shmseg, Shmid, ReadOnly), cookie) + return AttachCookie{cookie} +} + +func AttachChecked(c *xgb.Conn, Shmseg Seg, Shmid uint32, ReadOnly bool) AttachCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(attachRequest(c, Shmseg, Shmid, ReadOnly), cookie) + return AttachCookie{cookie} +} + +func (cook AttachCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for Attach +func attachRequest(c *xgb.Conn, Shmseg Seg, Shmid uint32, ReadOnly bool) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["MIT-SHM"] + b += 1 + + buf[b] = 1 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Shmseg)) + b += 4 + + xgb.Put32(buf[b:], Shmid) + b += 4 + + if ReadOnly { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding + + return buf +} + +// Request Detach +// size: 8 +type DetachCookie struct { + *xgb.Cookie +} + +// Write request to wire for Detach +func Detach(c *xgb.Conn, Shmseg Seg) DetachCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(detachRequest(c, Shmseg), cookie) + return DetachCookie{cookie} +} + +func DetachChecked(c *xgb.Conn, Shmseg Seg) DetachCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(detachRequest(c, Shmseg), cookie) + return DetachCookie{cookie} +} + +func (cook DetachCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for Detach +func detachRequest(c *xgb.Conn, Shmseg Seg) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["MIT-SHM"] + b += 1 + + buf[b] = 2 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Shmseg)) + b += 4 + + return buf +} + +// Request PutImage +// size: 40 +type PutImageCookie struct { + *xgb.Cookie +} + +// Write request to wire for PutImage +func PutImage(c *xgb.Conn, Drawable xproto.Drawable, Gc xproto.Gcontext, TotalWidth uint16, TotalHeight uint16, SrcX uint16, SrcY uint16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16, Depth byte, Format byte, SendEvent byte, Shmseg Seg, Offset uint32) PutImageCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(putImageRequest(c, Drawable, Gc, TotalWidth, TotalHeight, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY, Depth, Format, SendEvent, Shmseg, Offset), cookie) + return PutImageCookie{cookie} +} + +func PutImageChecked(c *xgb.Conn, Drawable xproto.Drawable, Gc xproto.Gcontext, TotalWidth uint16, TotalHeight uint16, SrcX uint16, SrcY uint16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16, Depth byte, Format byte, SendEvent byte, Shmseg Seg, Offset uint32) PutImageCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(putImageRequest(c, Drawable, Gc, TotalWidth, TotalHeight, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY, Depth, Format, SendEvent, Shmseg, Offset), cookie) + return PutImageCookie{cookie} +} + +func (cook PutImageCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PutImage +func putImageRequest(c *xgb.Conn, Drawable xproto.Drawable, Gc xproto.Gcontext, TotalWidth uint16, TotalHeight uint16, SrcX uint16, SrcY uint16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16, Depth byte, Format byte, SendEvent byte, Shmseg Seg, Offset uint32) []byte { + size := 40 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["MIT-SHM"] + b += 1 + + buf[b] = 3 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put16(buf[b:], TotalWidth) + b += 2 + + xgb.Put16(buf[b:], TotalHeight) + b += 2 + + xgb.Put16(buf[b:], SrcX) + b += 2 + + xgb.Put16(buf[b:], SrcY) + b += 2 + + xgb.Put16(buf[b:], SrcWidth) + b += 2 + + xgb.Put16(buf[b:], SrcHeight) + b += 2 + + xgb.Put16(buf[b:], uint16(DstX)) + b += 2 + + xgb.Put16(buf[b:], uint16(DstY)) + b += 2 + + buf[b] = Depth + b += 1 + + buf[b] = Format + b += 1 + + buf[b] = SendEvent + b += 1 + + b += 1 // padding + + xgb.Put32(buf[b:], uint32(Shmseg)) + b += 4 + + xgb.Put32(buf[b:], Offset) + b += 4 + + return buf +} + +// Request GetImage +// size: 32 +type GetImageCookie struct { + *xgb.Cookie +} + +func GetImage(c *xgb.Conn, Drawable xproto.Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32, Format byte, Shmseg Seg, Offset uint32) GetImageCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getImageRequest(c, Drawable, X, Y, Width, Height, PlaneMask, Format, Shmseg, Offset), cookie) + return GetImageCookie{cookie} +} + +func GetImageUnchecked(c *xgb.Conn, Drawable xproto.Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32, Format byte, Shmseg Seg, Offset uint32) GetImageCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getImageRequest(c, Drawable, X, Y, Width, Height, PlaneMask, Format, Shmseg, Offset), cookie) + return GetImageCookie{cookie} +} + +// Request reply for GetImage +// size: 16 +type GetImageReply struct { + Sequence uint16 + Length uint32 + Depth byte + Visual xproto.Visualid + Size uint32 +} + +// Waits and reads reply data from request GetImage +func (cook GetImageCookie) Reply() (*GetImageReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getImageReply(buf), nil +} + +// Read reply into structure from buffer for GetImage +func getImageReply(buf []byte) *GetImageReply { + v := new(GetImageReply) + b := 1 // skip reply determinant + + v.Depth = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Visual = xproto.Visualid(xgb.Get32(buf[b:])) + b += 4 + + v.Size = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for GetImage +func getImageRequest(c *xgb.Conn, Drawable xproto.Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32, Format byte, Shmseg Seg, Offset uint32) []byte { + size := 32 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["MIT-SHM"] + b += 1 + + buf[b] = 4 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put16(buf[b:], uint16(X)) + b += 2 + + xgb.Put16(buf[b:], uint16(Y)) + b += 2 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + xgb.Put32(buf[b:], PlaneMask) + b += 4 + + buf[b] = Format + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], uint32(Shmseg)) + b += 4 + + xgb.Put32(buf[b:], Offset) + b += 4 + + return buf +} + +// Request CreatePixmap +// size: 28 +type CreatePixmapCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreatePixmap +func CreatePixmap(c *xgb.Conn, Pid xproto.Pixmap, Drawable xproto.Drawable, Width uint16, Height uint16, Depth byte, Shmseg Seg, Offset uint32) CreatePixmapCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createPixmapRequest(c, Pid, Drawable, Width, Height, Depth, Shmseg, Offset), cookie) + return CreatePixmapCookie{cookie} +} + +func CreatePixmapChecked(c *xgb.Conn, Pid xproto.Pixmap, Drawable xproto.Drawable, Width uint16, Height uint16, Depth byte, Shmseg Seg, Offset uint32) CreatePixmapCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createPixmapRequest(c, Pid, Drawable, Width, Height, Depth, Shmseg, Offset), cookie) + return CreatePixmapCookie{cookie} +} + +func (cook CreatePixmapCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreatePixmap +func createPixmapRequest(c *xgb.Conn, Pid xproto.Pixmap, Drawable xproto.Drawable, Width uint16, Height uint16, Depth byte, Shmseg Seg, Offset uint32) []byte { + size := 28 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["MIT-SHM"] + b += 1 + + buf[b] = 5 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Pid)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + buf[b] = Depth + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], uint32(Shmseg)) + b += 4 + + xgb.Put32(buf[b:], Offset) + b += 4 + + return buf +} diff --git a/nexgb/sync.go b/nexgb/sync.go new file mode 100644 index 0000000..d671e62 --- /dev/null +++ b/nexgb/sync.go @@ -0,0 +1,29 @@ +package xgb + +// Sync sends a round trip request and wait for the response. +// This forces all pending cookies to be dealt with. +// You actually shouldn't need to use this like you might with Xlib. Namely, +// buffers are automatically flushed using Go's channels and round trip requests +// are forced where appropriate automatically. +func (c *Conn) Sync() { + cookie := c.NewCookie(true, true) + c.NewRequest(c.getInputFocusRequest(), cookie) + cookie.Reply() // wait for the buffer to clear +} + +// getInputFocusRequest writes the raw bytes to a buffer. +// It is duplicated from xproto/xproto.go. +func (c *Conn) getInputFocusRequest() []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 43 // request opcode + b += 1 + + b += 1 // padding + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} diff --git a/nexgb/sync/sync.go b/nexgb/sync/sync.go new file mode 100644 index 0000000..689a5c3 --- /dev/null +++ b/nexgb/sync/sync.go @@ -0,0 +1,1927 @@ +package sync + +/* + This file was generated by sync.xml on May 10 2012 4:20:28pm EDT. + This file is automatically generated. Edit at your peril! +*/ + +import ( + "github.com/BurntSushi/xgb" + + "github.com/BurntSushi/xgb/xproto" +) + +// Init must be called before using the SYNC extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 4, "SYNC").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named SYNC could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["SYNC"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["SYNC"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["SYNC"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["SYNC"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["SYNC"] = make(map[int]xgb.NewErrorFun) +} + +// Skipping definition for base type 'Bool' + +// Skipping definition for base type 'Float' + +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + +const ( + AlarmstateActive = 0 + AlarmstateInactive = 1 + AlarmstateDestroyed = 2 +) + +const ( + TesttypePositiveTransition = 0 + TesttypeNegativeTransition = 1 + TesttypePositiveComparison = 2 + TesttypeNegativeComparison = 3 +) + +const ( + ValuetypeAbsolute = 0 + ValuetypeRelative = 1 +) + +const ( + CaCounter = 1 + CaValueType = 2 + CaValue = 4 + CaTestType = 8 + CaDelta = 16 + CaEvents = 32 +) + +type Alarm uint32 + +func NewAlarmId(c *xgb.Conn) (Alarm, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Alarm(id), nil +} + +type Counter uint32 + +func NewCounterId(c *xgb.Conn) (Counter, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Counter(id), nil +} + +type Fence uint32 + +func NewFenceId(c *xgb.Conn) (Fence, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Fence(id), nil +} + +// 'Int64' struct definition +// Size: 8 +type Int64 struct { + Hi int32 + Lo uint32 +} + +// Struct read Int64 +func Int64Read(buf []byte, v *Int64) int { + b := 0 + + v.Hi = int32(xgb.Get32(buf[b:])) + b += 4 + + v.Lo = xgb.Get32(buf[b:]) + b += 4 + + return b +} + +// Struct list read Int64 +func Int64ReadList(buf []byte, dest []Int64) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Int64{} + b += Int64Read(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Int64 +func (v Int64) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Hi)) + b += 4 + + xgb.Put32(buf[b:], v.Lo) + b += 4 + + return buf +} + +// Write struct list Int64 +func Int64ListBytes(buf []byte, list []Int64) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Systemcounter' struct definition +// Size: (14 + xgb.Pad((int(NameLen) * 1))) +type Systemcounter struct { + Counter Counter + Resolution Int64 + NameLen uint16 + Name string // size: xgb.Pad((int(NameLen) * 1)) +} + +// Struct read Systemcounter +func SystemcounterRead(buf []byte, v *Systemcounter) int { + b := 0 + + v.Counter = Counter(xgb.Get32(buf[b:])) + b += 4 + + v.Resolution = Int64{} + b += Int64Read(buf[b:], &v.Resolution) + + v.NameLen = xgb.Get16(buf[b:]) + b += 2 + + { + byteString := make([]byte, v.NameLen) + copy(byteString[:v.NameLen], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.NameLen)) + } + + return b +} + +// Struct list read Systemcounter +func SystemcounterReadList(buf []byte, dest []Systemcounter) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Systemcounter{} + b += SystemcounterRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Systemcounter +func (v Systemcounter) Bytes() []byte { + buf := make([]byte, (14 + xgb.Pad((int(v.NameLen) * 1)))) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Counter)) + b += 4 + + { + structBytes := v.Resolution.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + xgb.Put16(buf[b:], v.NameLen) + b += 2 + + copy(buf[b:], v.Name[:v.NameLen]) + b += xgb.Pad(int(v.NameLen)) + + return buf +} + +// Write struct list Systemcounter +func SystemcounterListBytes(buf []byte, list []Systemcounter) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size Systemcounter +func SystemcounterListSize(list []Systemcounter) int { + size := 0 + for _, item := range list { + size += (14 + xgb.Pad((int(item.NameLen) * 1))) + } + return size +} + +// 'Trigger' struct definition +// Size: 20 +type Trigger struct { + Counter Counter + WaitType uint32 + WaitValue Int64 + TestType uint32 +} + +// Struct read Trigger +func TriggerRead(buf []byte, v *Trigger) int { + b := 0 + + v.Counter = Counter(xgb.Get32(buf[b:])) + b += 4 + + v.WaitType = xgb.Get32(buf[b:]) + b += 4 + + v.WaitValue = Int64{} + b += Int64Read(buf[b:], &v.WaitValue) + + v.TestType = xgb.Get32(buf[b:]) + b += 4 + + return b +} + +// Struct list read Trigger +func TriggerReadList(buf []byte, dest []Trigger) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Trigger{} + b += TriggerRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Trigger +func (v Trigger) Bytes() []byte { + buf := make([]byte, 20) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Counter)) + b += 4 + + xgb.Put32(buf[b:], v.WaitType) + b += 4 + + { + structBytes := v.WaitValue.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + xgb.Put32(buf[b:], v.TestType) + b += 4 + + return buf +} + +// Write struct list Trigger +func TriggerListBytes(buf []byte, list []Trigger) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Waitcondition' struct definition +// Size: 28 +type Waitcondition struct { + Trigger Trigger + EventThreshold Int64 +} + +// Struct read Waitcondition +func WaitconditionRead(buf []byte, v *Waitcondition) int { + b := 0 + + v.Trigger = Trigger{} + b += TriggerRead(buf[b:], &v.Trigger) + + v.EventThreshold = Int64{} + b += Int64Read(buf[b:], &v.EventThreshold) + + return b +} + +// Struct list read Waitcondition +func WaitconditionReadList(buf []byte, dest []Waitcondition) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Waitcondition{} + b += WaitconditionRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Waitcondition +func (v Waitcondition) Bytes() []byte { + buf := make([]byte, 28) + b := 0 + + { + structBytes := v.Trigger.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.EventThreshold.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + return buf +} + +// Write struct list Waitcondition +func WaitconditionListBytes(buf []byte, list []Waitcondition) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Event definition CounterNotify (0) +// Size: 32 + +const CounterNotify = 0 + +type CounterNotifyEvent struct { + Sequence uint16 + Kind byte + Counter Counter + WaitValue Int64 + CounterValue Int64 + Timestamp xproto.Timestamp + Count uint16 + Destroyed bool + // padding: 1 bytes +} + +// Event read CounterNotify +func CounterNotifyEventNew(buf []byte) xgb.Event { + v := CounterNotifyEvent{} + b := 1 // don't read event number + + v.Kind = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Counter = Counter(xgb.Get32(buf[b:])) + b += 4 + + v.WaitValue = Int64{} + b += Int64Read(buf[b:], &v.WaitValue) + + v.CounterValue = Int64{} + b += Int64Read(buf[b:], &v.CounterValue) + + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Count = xgb.Get16(buf[b:]) + b += 2 + + if buf[b] == 1 { + v.Destroyed = true + } else { + v.Destroyed = false + } + b += 1 + + b += 1 // padding + + return v +} + +// Event write CounterNotify +func (v CounterNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 0 + b += 1 + + buf[b] = v.Kind + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Counter)) + b += 4 + + { + structBytes := v.WaitValue.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.CounterValue.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + xgb.Put32(buf[b:], uint32(v.Timestamp)) + b += 4 + + xgb.Put16(buf[b:], v.Count) + b += 2 + + if v.Destroyed { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 1 // padding + + return buf +} + +func (v CounterNotifyEvent) ImplementsEvent() {} + +func (v CounterNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v CounterNotifyEvent) String() string { + fieldVals := make([]string, 0, 8) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Kind: %d", v.Kind)) + fieldVals = append(fieldVals, xgb.Sprintf("Counter: %d", v.Counter)) + fieldVals = append(fieldVals, xgb.Sprintf("Timestamp: %d", v.Timestamp)) + fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) + fieldVals = append(fieldVals, xgb.Sprintf("Destroyed: %t", v.Destroyed)) + return "CounterNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["SYNC"][0] = CounterNotifyEventNew +} + +// Event definition AlarmNotify (1) +// Size: 32 + +const AlarmNotify = 1 + +type AlarmNotifyEvent struct { + Sequence uint16 + Kind byte + Alarm Alarm + CounterValue Int64 + AlarmValue Int64 + Timestamp xproto.Timestamp + State byte + // padding: 3 bytes +} + +// Event read AlarmNotify +func AlarmNotifyEventNew(buf []byte) xgb.Event { + v := AlarmNotifyEvent{} + b := 1 // don't read event number + + v.Kind = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Alarm = Alarm(xgb.Get32(buf[b:])) + b += 4 + + v.CounterValue = Int64{} + b += Int64Read(buf[b:], &v.CounterValue) + + v.AlarmValue = Int64{} + b += Int64Read(buf[b:], &v.AlarmValue) + + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.State = buf[b] + b += 1 + + b += 3 // padding + + return v +} + +// Event write AlarmNotify +func (v AlarmNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 1 + b += 1 + + buf[b] = v.Kind + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Alarm)) + b += 4 + + { + structBytes := v.CounterValue.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + { + structBytes := v.AlarmValue.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + xgb.Put32(buf[b:], uint32(v.Timestamp)) + b += 4 + + buf[b] = v.State + b += 1 + + b += 3 // padding + + return buf +} + +func (v AlarmNotifyEvent) ImplementsEvent() {} + +func (v AlarmNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v AlarmNotifyEvent) String() string { + fieldVals := make([]string, 0, 7) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Kind: %d", v.Kind)) + fieldVals = append(fieldVals, xgb.Sprintf("Alarm: %d", v.Alarm)) + fieldVals = append(fieldVals, xgb.Sprintf("Timestamp: %d", v.Timestamp)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + return "AlarmNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["SYNC"][1] = AlarmNotifyEventNew +} + +// Error definition Counter (0) +// Size: 32 + +const BadCounter = 0 + +type CounterError struct { + Sequence uint16 + NiceName string + BadCounter uint32 + MinorOpcode uint16 + MajorOpcode byte +} + +// Error read Counter +func CounterErrorNew(buf []byte) xgb.Error { + v := CounterError{} + v.NiceName = "Counter" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.BadCounter = xgb.Get32(buf[b:]) + b += 4 + + v.MinorOpcode = xgb.Get16(buf[b:]) + b += 2 + + v.MajorOpcode = buf[b] + b += 1 + + return v +} + +func (err CounterError) ImplementsError() {} + +func (err CounterError) SequenceId() uint16 { + return err.Sequence +} + +func (err CounterError) BadId() uint32 { + return 0 +} + +func (err CounterError) Error() string { + fieldVals := make([]string, 0, 3) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadCounter: %d", err.BadCounter)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadCounter {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["SYNC"][0] = CounterErrorNew +} + +// Error definition Alarm (1) +// Size: 32 + +const BadAlarm = 1 + +type AlarmError struct { + Sequence uint16 + NiceName string + BadAlarm uint32 + MinorOpcode uint16 + MajorOpcode byte +} + +// Error read Alarm +func AlarmErrorNew(buf []byte) xgb.Error { + v := AlarmError{} + v.NiceName = "Alarm" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.BadAlarm = xgb.Get32(buf[b:]) + b += 4 + + v.MinorOpcode = xgb.Get16(buf[b:]) + b += 2 + + v.MajorOpcode = buf[b] + b += 1 + + return v +} + +func (err AlarmError) ImplementsError() {} + +func (err AlarmError) SequenceId() uint16 { + return err.Sequence +} + +func (err AlarmError) BadId() uint32 { + return 0 +} + +func (err AlarmError) Error() string { + fieldVals := make([]string, 0, 3) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadAlarm: %d", err.BadAlarm)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadAlarm {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["SYNC"][1] = AlarmErrorNew +} + +// Request Initialize +// size: 8 +type InitializeCookie struct { + *xgb.Cookie +} + +func Initialize(c *xgb.Conn, DesiredMajorVersion byte, DesiredMinorVersion byte) InitializeCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(initializeRequest(c, DesiredMajorVersion, DesiredMinorVersion), cookie) + return InitializeCookie{cookie} +} + +func InitializeUnchecked(c *xgb.Conn, DesiredMajorVersion byte, DesiredMinorVersion byte) InitializeCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(initializeRequest(c, DesiredMajorVersion, DesiredMinorVersion), cookie) + return InitializeCookie{cookie} +} + +// Request reply for Initialize +// size: 32 +type InitializeReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + MajorVersion byte + MinorVersion byte + // padding: 22 bytes +} + +// Waits and reads reply data from request Initialize +func (cook InitializeCookie) Reply() (*InitializeReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return initializeReply(buf), nil +} + +// Read reply into structure from buffer for Initialize +func initializeReply(buf []byte) *InitializeReply { + v := new(InitializeReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.MajorVersion = buf[b] + b += 1 + + v.MinorVersion = buf[b] + b += 1 + + b += 22 // padding + + return v +} + +// Write request to wire for Initialize +func initializeRequest(c *xgb.Conn, DesiredMajorVersion byte, DesiredMinorVersion byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + b += 1 + + buf[b] = 0 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = DesiredMajorVersion + b += 1 + + buf[b] = DesiredMinorVersion + b += 1 + + return buf +} + +// Request ListSystemCounters +// size: 4 +type ListSystemCountersCookie struct { + *xgb.Cookie +} + +func ListSystemCounters(c *xgb.Conn) ListSystemCountersCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(listSystemCountersRequest(c), cookie) + return ListSystemCountersCookie{cookie} +} + +func ListSystemCountersUnchecked(c *xgb.Conn) ListSystemCountersCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(listSystemCountersRequest(c), cookie) + return ListSystemCountersCookie{cookie} +} + +// Request reply for ListSystemCounters +// size: (32 + SystemcounterListSize(Counters)) +type ListSystemCountersReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + CountersLen uint32 + // padding: 20 bytes + Counters []Systemcounter // size: SystemcounterListSize(Counters) +} + +// Waits and reads reply data from request ListSystemCounters +func (cook ListSystemCountersCookie) Reply() (*ListSystemCountersReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listSystemCountersReply(buf), nil +} + +// Read reply into structure from buffer for ListSystemCounters +func listSystemCountersReply(buf []byte) *ListSystemCountersReply { + v := new(ListSystemCountersReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.CountersLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Counters = make([]Systemcounter, v.CountersLen) + b += SystemcounterReadList(buf[b:], v.Counters) + + return v +} + +// Write request to wire for ListSystemCounters +func listSystemCountersRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + b += 1 + + buf[b] = 1 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request CreateCounter +// size: 16 +type CreateCounterCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateCounter +func CreateCounter(c *xgb.Conn, Id Counter, InitialValue Int64) CreateCounterCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createCounterRequest(c, Id, InitialValue), cookie) + return CreateCounterCookie{cookie} +} + +func CreateCounterChecked(c *xgb.Conn, Id Counter, InitialValue Int64) CreateCounterCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createCounterRequest(c, Id, InitialValue), cookie) + return CreateCounterCookie{cookie} +} + +func (cook CreateCounterCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateCounter +func createCounterRequest(c *xgb.Conn, Id Counter, InitialValue Int64) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + b += 1 + + buf[b] = 2 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Id)) + b += 4 + + { + structBytes := InitialValue.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + return buf +} + +// Request DestroyCounter +// size: 8 +type DestroyCounterCookie struct { + *xgb.Cookie +} + +// Write request to wire for DestroyCounter +func DestroyCounter(c *xgb.Conn, Counter Counter) DestroyCounterCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroyCounterRequest(c, Counter), cookie) + return DestroyCounterCookie{cookie} +} + +func DestroyCounterChecked(c *xgb.Conn, Counter Counter) DestroyCounterCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(destroyCounterRequest(c, Counter), cookie) + return DestroyCounterCookie{cookie} +} + +func (cook DestroyCounterCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DestroyCounter +func destroyCounterRequest(c *xgb.Conn, Counter Counter) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + b += 1 + + buf[b] = 6 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Counter)) + b += 4 + + return buf +} + +// Request QueryCounter +// size: 8 +type QueryCounterCookie struct { + *xgb.Cookie +} + +func QueryCounter(c *xgb.Conn, Counter Counter) QueryCounterCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryCounterRequest(c, Counter), cookie) + return QueryCounterCookie{cookie} +} + +func QueryCounterUnchecked(c *xgb.Conn, Counter Counter) QueryCounterCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryCounterRequest(c, Counter), cookie) + return QueryCounterCookie{cookie} +} + +// Request reply for QueryCounter +// size: 16 +type QueryCounterReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + CounterValue Int64 +} + +// Waits and reads reply data from request QueryCounter +func (cook QueryCounterCookie) Reply() (*QueryCounterReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryCounterReply(buf), nil +} + +// Read reply into structure from buffer for QueryCounter +func queryCounterReply(buf []byte) *QueryCounterReply { + v := new(QueryCounterReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.CounterValue = Int64{} + b += Int64Read(buf[b:], &v.CounterValue) + + return v +} + +// Write request to wire for QueryCounter +func queryCounterRequest(c *xgb.Conn, Counter Counter) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + b += 1 + + buf[b] = 5 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Counter)) + b += 4 + + return buf +} + +// Request Await +// size: xgb.Pad((4 + xgb.Pad((len(WaitList) * 28)))) +type AwaitCookie struct { + *xgb.Cookie +} + +// Write request to wire for Await +func Await(c *xgb.Conn, WaitList []Waitcondition) AwaitCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(awaitRequest(c, WaitList), cookie) + return AwaitCookie{cookie} +} + +func AwaitChecked(c *xgb.Conn, WaitList []Waitcondition) AwaitCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(awaitRequest(c, WaitList), cookie) + return AwaitCookie{cookie} +} + +func (cook AwaitCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for Await +func awaitRequest(c *xgb.Conn, WaitList []Waitcondition) []byte { + size := xgb.Pad((4 + xgb.Pad((len(WaitList) * 28)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + b += 1 + + buf[b] = 7 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + b += WaitconditionListBytes(buf[b:], WaitList) + + return buf +} + +// Request ChangeCounter +// size: 16 +type ChangeCounterCookie struct { + *xgb.Cookie +} + +// Write request to wire for ChangeCounter +func ChangeCounter(c *xgb.Conn, Counter Counter, Amount Int64) ChangeCounterCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeCounterRequest(c, Counter, Amount), cookie) + return ChangeCounterCookie{cookie} +} + +func ChangeCounterChecked(c *xgb.Conn, Counter Counter, Amount Int64) ChangeCounterCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeCounterRequest(c, Counter, Amount), cookie) + return ChangeCounterCookie{cookie} +} + +func (cook ChangeCounterCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangeCounter +func changeCounterRequest(c *xgb.Conn, Counter Counter, Amount Int64) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + b += 1 + + buf[b] = 4 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Counter)) + b += 4 + + { + structBytes := Amount.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + return buf +} + +// Request SetCounter +// size: 16 +type SetCounterCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetCounter +func SetCounter(c *xgb.Conn, Counter Counter, Value Int64) SetCounterCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setCounterRequest(c, Counter, Value), cookie) + return SetCounterCookie{cookie} +} + +func SetCounterChecked(c *xgb.Conn, Counter Counter, Value Int64) SetCounterCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setCounterRequest(c, Counter, Value), cookie) + return SetCounterCookie{cookie} +} + +func (cook SetCounterCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetCounter +func setCounterRequest(c *xgb.Conn, Counter Counter, Value Int64) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + b += 1 + + buf[b] = 3 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Counter)) + b += 4 + + { + structBytes := Value.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + return buf +} + +// Request CreateAlarm +// size: xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +type CreateAlarmCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateAlarm +func CreateAlarm(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uint32) CreateAlarmCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createAlarmRequest(c, Id, ValueMask, ValueList), cookie) + return CreateAlarmCookie{cookie} +} + +func CreateAlarmChecked(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uint32) CreateAlarmCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createAlarmRequest(c, Id, ValueMask, ValueList), cookie) + return CreateAlarmCookie{cookie} +} + +func (cook CreateAlarmCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateAlarm +func createAlarmRequest(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uint32) []byte { + size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + b += 1 + + buf[b] = 8 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Id)) + b += 4 + + xgb.Put32(buf[b:], ValueMask) + b += 4 + for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { + xgb.Put32(buf[b:], ValueList[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request ChangeAlarm +// size: xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +type ChangeAlarmCookie struct { + *xgb.Cookie +} + +// Write request to wire for ChangeAlarm +func ChangeAlarm(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uint32) ChangeAlarmCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeAlarmRequest(c, Id, ValueMask, ValueList), cookie) + return ChangeAlarmCookie{cookie} +} + +func ChangeAlarmChecked(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uint32) ChangeAlarmCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeAlarmRequest(c, Id, ValueMask, ValueList), cookie) + return ChangeAlarmCookie{cookie} +} + +func (cook ChangeAlarmCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangeAlarm +func changeAlarmRequest(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uint32) []byte { + size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + b += 1 + + buf[b] = 9 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Id)) + b += 4 + + xgb.Put32(buf[b:], ValueMask) + b += 4 + for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { + xgb.Put32(buf[b:], ValueList[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request DestroyAlarm +// size: 8 +type DestroyAlarmCookie struct { + *xgb.Cookie +} + +// Write request to wire for DestroyAlarm +func DestroyAlarm(c *xgb.Conn, Alarm Alarm) DestroyAlarmCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroyAlarmRequest(c, Alarm), cookie) + return DestroyAlarmCookie{cookie} +} + +func DestroyAlarmChecked(c *xgb.Conn, Alarm Alarm) DestroyAlarmCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(destroyAlarmRequest(c, Alarm), cookie) + return DestroyAlarmCookie{cookie} +} + +func (cook DestroyAlarmCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DestroyAlarm +func destroyAlarmRequest(c *xgb.Conn, Alarm Alarm) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + b += 1 + + buf[b] = 11 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Alarm)) + b += 4 + + return buf +} + +// Request QueryAlarm +// size: 8 +type QueryAlarmCookie struct { + *xgb.Cookie +} + +func QueryAlarm(c *xgb.Conn, Alarm Alarm) QueryAlarmCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryAlarmRequest(c, Alarm), cookie) + return QueryAlarmCookie{cookie} +} + +func QueryAlarmUnchecked(c *xgb.Conn, Alarm Alarm) QueryAlarmCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryAlarmRequest(c, Alarm), cookie) + return QueryAlarmCookie{cookie} +} + +// Request reply for QueryAlarm +// size: 40 +type QueryAlarmReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Trigger Trigger + Delta Int64 + Events bool + State byte + // padding: 2 bytes +} + +// Waits and reads reply data from request QueryAlarm +func (cook QueryAlarmCookie) Reply() (*QueryAlarmReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryAlarmReply(buf), nil +} + +// Read reply into structure from buffer for QueryAlarm +func queryAlarmReply(buf []byte) *QueryAlarmReply { + v := new(QueryAlarmReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Trigger = Trigger{} + b += TriggerRead(buf[b:], &v.Trigger) + + v.Delta = Int64{} + b += Int64Read(buf[b:], &v.Delta) + + if buf[b] == 1 { + v.Events = true + } else { + v.Events = false + } + b += 1 + + v.State = buf[b] + b += 1 + + b += 2 // padding + + return v +} + +// Write request to wire for QueryAlarm +func queryAlarmRequest(c *xgb.Conn, Alarm Alarm) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + b += 1 + + buf[b] = 10 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Alarm)) + b += 4 + + return buf +} + +// Request SetPriority +// size: 12 +type SetPriorityCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetPriority +func SetPriority(c *xgb.Conn, Id uint32, Priority int32) SetPriorityCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setPriorityRequest(c, Id, Priority), cookie) + return SetPriorityCookie{cookie} +} + +func SetPriorityChecked(c *xgb.Conn, Id uint32, Priority int32) SetPriorityCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setPriorityRequest(c, Id, Priority), cookie) + return SetPriorityCookie{cookie} +} + +func (cook SetPriorityCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetPriority +func setPriorityRequest(c *xgb.Conn, Id uint32, Priority int32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + b += 1 + + buf[b] = 12 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Id) + b += 4 + + xgb.Put32(buf[b:], uint32(Priority)) + b += 4 + + return buf +} + +// Request GetPriority +// size: 8 +type GetPriorityCookie struct { + *xgb.Cookie +} + +func GetPriority(c *xgb.Conn, Id uint32) GetPriorityCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getPriorityRequest(c, Id), cookie) + return GetPriorityCookie{cookie} +} + +func GetPriorityUnchecked(c *xgb.Conn, Id uint32) GetPriorityCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getPriorityRequest(c, Id), cookie) + return GetPriorityCookie{cookie} +} + +// Request reply for GetPriority +// size: 12 +type GetPriorityReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Priority int32 +} + +// Waits and reads reply data from request GetPriority +func (cook GetPriorityCookie) Reply() (*GetPriorityReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPriorityReply(buf), nil +} + +// Read reply into structure from buffer for GetPriority +func getPriorityReply(buf []byte) *GetPriorityReply { + v := new(GetPriorityReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Priority = int32(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Write request to wire for GetPriority +func getPriorityRequest(c *xgb.Conn, Id uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + b += 1 + + buf[b] = 13 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Id) + b += 4 + + return buf +} + +// Request CreateFence +// size: 16 +type CreateFenceCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateFence +func CreateFence(c *xgb.Conn, Drawable xproto.Drawable, Fence Fence, InitiallyTriggered bool) CreateFenceCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createFenceRequest(c, Drawable, Fence, InitiallyTriggered), cookie) + return CreateFenceCookie{cookie} +} + +func CreateFenceChecked(c *xgb.Conn, Drawable xproto.Drawable, Fence Fence, InitiallyTriggered bool) CreateFenceCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createFenceRequest(c, Drawable, Fence, InitiallyTriggered), cookie) + return CreateFenceCookie{cookie} +} + +func (cook CreateFenceCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateFence +func createFenceRequest(c *xgb.Conn, Drawable xproto.Drawable, Fence Fence, InitiallyTriggered bool) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + b += 1 + + buf[b] = 14 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Fence)) + b += 4 + + if InitiallyTriggered { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + return buf +} + +// Request TriggerFence +// size: 8 +type TriggerFenceCookie struct { + *xgb.Cookie +} + +// Write request to wire for TriggerFence +func TriggerFence(c *xgb.Conn, Fence Fence) TriggerFenceCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(triggerFenceRequest(c, Fence), cookie) + return TriggerFenceCookie{cookie} +} + +func TriggerFenceChecked(c *xgb.Conn, Fence Fence) TriggerFenceCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(triggerFenceRequest(c, Fence), cookie) + return TriggerFenceCookie{cookie} +} + +func (cook TriggerFenceCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for TriggerFence +func triggerFenceRequest(c *xgb.Conn, Fence Fence) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + b += 1 + + buf[b] = 15 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Fence)) + b += 4 + + return buf +} + +// Request ResetFence +// size: 8 +type ResetFenceCookie struct { + *xgb.Cookie +} + +// Write request to wire for ResetFence +func ResetFence(c *xgb.Conn, Fence Fence) ResetFenceCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(resetFenceRequest(c, Fence), cookie) + return ResetFenceCookie{cookie} +} + +func ResetFenceChecked(c *xgb.Conn, Fence Fence) ResetFenceCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(resetFenceRequest(c, Fence), cookie) + return ResetFenceCookie{cookie} +} + +func (cook ResetFenceCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ResetFence +func resetFenceRequest(c *xgb.Conn, Fence Fence) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + b += 1 + + buf[b] = 16 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Fence)) + b += 4 + + return buf +} + +// Request DestroyFence +// size: 8 +type DestroyFenceCookie struct { + *xgb.Cookie +} + +// Write request to wire for DestroyFence +func DestroyFence(c *xgb.Conn, Fence Fence) DestroyFenceCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroyFenceRequest(c, Fence), cookie) + return DestroyFenceCookie{cookie} +} + +func DestroyFenceChecked(c *xgb.Conn, Fence Fence) DestroyFenceCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(destroyFenceRequest(c, Fence), cookie) + return DestroyFenceCookie{cookie} +} + +func (cook DestroyFenceCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DestroyFence +func destroyFenceRequest(c *xgb.Conn, Fence Fence) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + b += 1 + + buf[b] = 17 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Fence)) + b += 4 + + return buf +} + +// Request QueryFence +// size: 8 +type QueryFenceCookie struct { + *xgb.Cookie +} + +func QueryFence(c *xgb.Conn, Fence Fence) QueryFenceCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryFenceRequest(c, Fence), cookie) + return QueryFenceCookie{cookie} +} + +func QueryFenceUnchecked(c *xgb.Conn, Fence Fence) QueryFenceCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryFenceRequest(c, Fence), cookie) + return QueryFenceCookie{cookie} +} + +// Request reply for QueryFence +// size: 32 +type QueryFenceReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Triggered bool + // padding: 23 bytes +} + +// Waits and reads reply data from request QueryFence +func (cook QueryFenceCookie) Reply() (*QueryFenceReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryFenceReply(buf), nil +} + +// Read reply into structure from buffer for QueryFence +func queryFenceReply(buf []byte) *QueryFenceReply { + v := new(QueryFenceReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + if buf[b] == 1 { + v.Triggered = true + } else { + v.Triggered = false + } + b += 1 + + b += 23 // padding + + return v +} + +// Write request to wire for QueryFence +func queryFenceRequest(c *xgb.Conn, Fence Fence) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + b += 1 + + buf[b] = 18 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Fence)) + b += 4 + + return buf +} + +// Request AwaitFence +// size: xgb.Pad((4 + xgb.Pad((len(FenceList) * 4)))) +type AwaitFenceCookie struct { + *xgb.Cookie +} + +// Write request to wire for AwaitFence +func AwaitFence(c *xgb.Conn, FenceList []Fence) AwaitFenceCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(awaitFenceRequest(c, FenceList), cookie) + return AwaitFenceCookie{cookie} +} + +func AwaitFenceChecked(c *xgb.Conn, FenceList []Fence) AwaitFenceCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(awaitFenceRequest(c, FenceList), cookie) + return AwaitFenceCookie{cookie} +} + +func (cook AwaitFenceCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for AwaitFence +func awaitFenceRequest(c *xgb.Conn, FenceList []Fence) []byte { + size := xgb.Pad((4 + xgb.Pad((len(FenceList) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SYNC"] + b += 1 + + buf[b] = 19 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + for i := 0; i < int(len(FenceList)); i++ { + xgb.Put32(buf[b:], uint32(FenceList[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} diff --git a/nexgb/xcmisc/xcmisc.go b/nexgb/xcmisc/xcmisc.go new file mode 100644 index 0000000..324d455 --- /dev/null +++ b/nexgb/xcmisc/xcmisc.go @@ -0,0 +1,320 @@ +package xcmisc + +/* + This file was generated by xc_misc.xml on May 10 2012 4:20:28pm EDT. + This file is automatically generated. Edit at your peril! +*/ + +import ( + "github.com/BurntSushi/xgb" + + "github.com/BurntSushi/xgb/xproto" +) + +// Init must be called before using the XC-MISC extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 7, "XC-MISC").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named XC-MISC could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["XC-MISC"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["XC-MISC"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["XC-MISC"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["XC-MISC"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["XC-MISC"] = make(map[int]xgb.NewErrorFun) +} + +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Bool' + +// Skipping definition for base type 'Float' + +// Request GetVersion +// size: 8 +type GetVersionCookie struct { + *xgb.Cookie +} + +func GetVersion(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) GetVersionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return GetVersionCookie{cookie} +} + +func GetVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) GetVersionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return GetVersionCookie{cookie} +} + +// Request reply for GetVersion +// size: 12 +type GetVersionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ServerMajorVersion uint16 + ServerMinorVersion uint16 +} + +// Waits and reads reply data from request GetVersion +func (cook GetVersionCookie) Reply() (*GetVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getVersionReply(buf), nil +} + +// Read reply into structure from buffer for GetVersion +func getVersionReply(buf []byte) *GetVersionReply { + v := new(GetVersionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ServerMajorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.ServerMinorVersion = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Write request to wire for GetVersion +func getVersionRequest(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XC-MISC"] + b += 1 + + buf[b] = 0 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], ClientMajorVersion) + b += 2 + + xgb.Put16(buf[b:], ClientMinorVersion) + b += 2 + + return buf +} + +// Request GetXIDRange +// size: 4 +type GetXIDRangeCookie struct { + *xgb.Cookie +} + +func GetXIDRange(c *xgb.Conn) GetXIDRangeCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getXIDRangeRequest(c), cookie) + return GetXIDRangeCookie{cookie} +} + +func GetXIDRangeUnchecked(c *xgb.Conn) GetXIDRangeCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getXIDRangeRequest(c), cookie) + return GetXIDRangeCookie{cookie} +} + +// Request reply for GetXIDRange +// size: 16 +type GetXIDRangeReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + StartId uint32 + Count uint32 +} + +// Waits and reads reply data from request GetXIDRange +func (cook GetXIDRangeCookie) Reply() (*GetXIDRangeReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getXIDRangeReply(buf), nil +} + +// Read reply into structure from buffer for GetXIDRange +func getXIDRangeReply(buf []byte) *GetXIDRangeReply { + v := new(GetXIDRangeReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.StartId = xgb.Get32(buf[b:]) + b += 4 + + v.Count = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for GetXIDRange +func getXIDRangeRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XC-MISC"] + b += 1 + + buf[b] = 1 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request GetXIDList +// size: 8 +type GetXIDListCookie struct { + *xgb.Cookie +} + +func GetXIDList(c *xgb.Conn, Count uint32) GetXIDListCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getXIDListRequest(c, Count), cookie) + return GetXIDListCookie{cookie} +} + +func GetXIDListUnchecked(c *xgb.Conn, Count uint32) GetXIDListCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getXIDListRequest(c, Count), cookie) + return GetXIDListCookie{cookie} +} + +// Request reply for GetXIDList +// size: (32 + xgb.Pad((int(IdsLen) * 4))) +type GetXIDListReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + IdsLen uint32 + // padding: 20 bytes + Ids []uint32 // size: xgb.Pad((int(IdsLen) * 4)) +} + +// Waits and reads reply data from request GetXIDList +func (cook GetXIDListCookie) Reply() (*GetXIDListReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getXIDListReply(buf), nil +} + +// Read reply into structure from buffer for GetXIDList +func getXIDListReply(buf []byte) *GetXIDListReply { + v := new(GetXIDListReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.IdsLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Ids = make([]uint32, v.IdsLen) + for i := 0; i < int(v.IdsLen); i++ { + v.Ids[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetXIDList +func getXIDListRequest(c *xgb.Conn, Count uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XC-MISC"] + b += 1 + + buf[b] = 2 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Count) + b += 4 + + return buf +} diff --git a/nexgb/xevie/xevie.go b/nexgb/xevie/xevie.go new file mode 100644 index 0000000..c3943f9 --- /dev/null +++ b/nexgb/xevie/xevie.go @@ -0,0 +1,525 @@ +package xevie + +/* + This file was generated by xevie.xml on May 10 2012 4:20:28pm EDT. + This file is automatically generated. Edit at your peril! +*/ + +import ( + "github.com/BurntSushi/xgb" + + "github.com/BurntSushi/xgb/xproto" +) + +// Init must be called before using the XEVIE extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 5, "XEVIE").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named XEVIE could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["XEVIE"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["XEVIE"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["XEVIE"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["XEVIE"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["XEVIE"] = make(map[int]xgb.NewErrorFun) +} + +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Bool' + +// Skipping definition for base type 'Float' + +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + +const ( + DatatypeUnmodified = 0 + DatatypeModified = 1 +) + +// 'Event' struct definition +// Size: 32 +type Event struct { + // padding: 32 bytes +} + +// Struct read Event +func EventRead(buf []byte, v *Event) int { + b := 0 + + b += 32 // padding + + return b +} + +// Struct list read Event +func EventReadList(buf []byte, dest []Event) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Event{} + b += EventRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Event +func (v Event) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + b += 32 // padding + + return buf +} + +// Write struct list Event +func EventListBytes(buf []byte, list []Event) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Request QueryVersion +// size: 8 +type QueryVersionCookie struct { + *xgb.Cookie +} + +func QueryVersion(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) QueryVersionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return QueryVersionCookie{cookie} +} + +func QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) QueryVersionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return QueryVersionCookie{cookie} +} + +// Request reply for QueryVersion +// size: 32 +type QueryVersionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ServerMajorVersion uint16 + ServerMinorVersion uint16 + // padding: 20 bytes +} + +// Waits and reads reply data from request QueryVersion +func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryVersionReply(buf), nil +} + +// Read reply into structure from buffer for QueryVersion +func queryVersionReply(buf []byte) *QueryVersionReply { + v := new(QueryVersionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ServerMajorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.ServerMinorVersion = xgb.Get16(buf[b:]) + b += 2 + + b += 20 // padding + + return v +} + +// Write request to wire for QueryVersion +func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XEVIE"] + b += 1 + + buf[b] = 0 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], ClientMajorVersion) + b += 2 + + xgb.Put16(buf[b:], ClientMinorVersion) + b += 2 + + return buf +} + +// Request Start +// size: 8 +type StartCookie struct { + *xgb.Cookie +} + +func Start(c *xgb.Conn, Screen uint32) StartCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(startRequest(c, Screen), cookie) + return StartCookie{cookie} +} + +func StartUnchecked(c *xgb.Conn, Screen uint32) StartCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(startRequest(c, Screen), cookie) + return StartCookie{cookie} +} + +// Request reply for Start +// size: 32 +type StartReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 24 bytes +} + +// Waits and reads reply data from request Start +func (cook StartCookie) Reply() (*StartReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return startReply(buf), nil +} + +// Read reply into structure from buffer for Start +func startReply(buf []byte) *StartReply { + v := new(StartReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 24 // padding + + return v +} + +// Write request to wire for Start +func startRequest(c *xgb.Conn, Screen uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XEVIE"] + b += 1 + + buf[b] = 1 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + return buf +} + +// Request End +// size: 8 +type EndCookie struct { + *xgb.Cookie +} + +func End(c *xgb.Conn, Cmap uint32) EndCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(endRequest(c, Cmap), cookie) + return EndCookie{cookie} +} + +func EndUnchecked(c *xgb.Conn, Cmap uint32) EndCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(endRequest(c, Cmap), cookie) + return EndCookie{cookie} +} + +// Request reply for End +// size: 32 +type EndReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 24 bytes +} + +// Waits and reads reply data from request End +func (cook EndCookie) Reply() (*EndReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return endReply(buf), nil +} + +// Read reply into structure from buffer for End +func endReply(buf []byte) *EndReply { + v := new(EndReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 24 // padding + + return v +} + +// Write request to wire for End +func endRequest(c *xgb.Conn, Cmap uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XEVIE"] + b += 1 + + buf[b] = 2 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Cmap) + b += 4 + + return buf +} + +// Request Send +// size: 104 +type SendCookie struct { + *xgb.Cookie +} + +func Send(c *xgb.Conn, Event Event, DataType uint32) SendCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(sendRequest(c, Event, DataType), cookie) + return SendCookie{cookie} +} + +func SendUnchecked(c *xgb.Conn, Event Event, DataType uint32) SendCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(sendRequest(c, Event, DataType), cookie) + return SendCookie{cookie} +} + +// Request reply for Send +// size: 32 +type SendReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 24 bytes +} + +// Waits and reads reply data from request Send +func (cook SendCookie) Reply() (*SendReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return sendReply(buf), nil +} + +// Read reply into structure from buffer for Send +func sendReply(buf []byte) *SendReply { + v := new(SendReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 24 // padding + + return v +} + +// Write request to wire for Send +func sendRequest(c *xgb.Conn, Event Event, DataType uint32) []byte { + size := 104 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XEVIE"] + b += 1 + + buf[b] = 3 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + { + structBytes := Event.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + xgb.Put32(buf[b:], DataType) + b += 4 + + b += 64 // padding + + return buf +} + +// Request SelectInput +// size: 8 +type SelectInputCookie struct { + *xgb.Cookie +} + +func SelectInput(c *xgb.Conn, EventMask uint32) SelectInputCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(selectInputRequest(c, EventMask), cookie) + return SelectInputCookie{cookie} +} + +func SelectInputUnchecked(c *xgb.Conn, EventMask uint32) SelectInputCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(selectInputRequest(c, EventMask), cookie) + return SelectInputCookie{cookie} +} + +// Request reply for SelectInput +// size: 32 +type SelectInputReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 24 bytes +} + +// Waits and reads reply data from request SelectInput +func (cook SelectInputCookie) Reply() (*SelectInputReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return selectInputReply(buf), nil +} + +// Read reply into structure from buffer for SelectInput +func selectInputReply(buf []byte) *SelectInputReply { + v := new(SelectInputReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 24 // padding + + return v +} + +// Write request to wire for SelectInput +func selectInputRequest(c *xgb.Conn, EventMask uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XEVIE"] + b += 1 + + buf[b] = 4 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], EventMask) + b += 4 + + return buf +} diff --git a/nexgb/xf86dri/xf86dri.go b/nexgb/xf86dri/xf86dri.go new file mode 100644 index 0000000..0259729 --- /dev/null +++ b/nexgb/xf86dri/xf86dri.go @@ -0,0 +1,1121 @@ +package xf86dri + +/* + This file was generated by xf86dri.xml on May 10 2012 4:20:28pm EDT. + This file is automatically generated. Edit at your peril! +*/ + +import ( + "github.com/BurntSushi/xgb" + + "github.com/BurntSushi/xgb/xproto" +) + +// Init must be called before using the XFree86-DRI extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 11, "XFree86-DRI").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named XFree86-DRI could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["XFree86-DRI"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["XFree86-DRI"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["XFree86-DRI"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["XFree86-DRI"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["XFree86-DRI"] = make(map[int]xgb.NewErrorFun) +} + +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Bool' + +// Skipping definition for base type 'Float' + +// 'DrmClipRect' struct definition +// Size: 8 +type DrmClipRect struct { + X1 int16 + Y1 int16 + X2 int16 + X3 int16 +} + +// Struct read DrmClipRect +func DrmClipRectRead(buf []byte, v *DrmClipRect) int { + b := 0 + + v.X1 = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y1 = int16(xgb.Get16(buf[b:])) + b += 2 + + v.X2 = int16(xgb.Get16(buf[b:])) + b += 2 + + v.X3 = int16(xgb.Get16(buf[b:])) + b += 2 + + return b +} + +// Struct list read DrmClipRect +func DrmClipRectReadList(buf []byte, dest []DrmClipRect) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DrmClipRect{} + b += DrmClipRectRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write DrmClipRect +func (v DrmClipRect) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put16(buf[b:], uint16(v.X1)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y1)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.X2)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.X3)) + b += 2 + + return buf +} + +// Write struct list DrmClipRect +func DrmClipRectListBytes(buf []byte, list []DrmClipRect) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Request QueryVersion +// size: 4 +type QueryVersionCookie struct { + *xgb.Cookie +} + +func QueryVersion(c *xgb.Conn) QueryVersionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c), cookie) + return QueryVersionCookie{cookie} +} + +func QueryVersionUnchecked(c *xgb.Conn) QueryVersionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c), cookie) + return QueryVersionCookie{cookie} +} + +// Request reply for QueryVersion +// size: 16 +type QueryVersionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + DriMajorVersion uint16 + DriMinorVersion uint16 + DriMinorPatch uint32 +} + +// Waits and reads reply data from request QueryVersion +func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryVersionReply(buf), nil +} + +// Read reply into structure from buffer for QueryVersion +func queryVersionReply(buf []byte) *QueryVersionReply { + v := new(QueryVersionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.DriMajorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.DriMinorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.DriMinorPatch = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for QueryVersion +func queryVersionRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-DRI"] + b += 1 + + buf[b] = 0 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request QueryDirectRenderingCapable +// size: 8 +type QueryDirectRenderingCapableCookie struct { + *xgb.Cookie +} + +func QueryDirectRenderingCapable(c *xgb.Conn, Screen uint32) QueryDirectRenderingCapableCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryDirectRenderingCapableRequest(c, Screen), cookie) + return QueryDirectRenderingCapableCookie{cookie} +} + +func QueryDirectRenderingCapableUnchecked(c *xgb.Conn, Screen uint32) QueryDirectRenderingCapableCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryDirectRenderingCapableRequest(c, Screen), cookie) + return QueryDirectRenderingCapableCookie{cookie} +} + +// Request reply for QueryDirectRenderingCapable +// size: 9 +type QueryDirectRenderingCapableReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + IsCapable bool +} + +// Waits and reads reply data from request QueryDirectRenderingCapable +func (cook QueryDirectRenderingCapableCookie) Reply() (*QueryDirectRenderingCapableReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryDirectRenderingCapableReply(buf), nil +} + +// Read reply into structure from buffer for QueryDirectRenderingCapable +func queryDirectRenderingCapableReply(buf []byte) *QueryDirectRenderingCapableReply { + v := new(QueryDirectRenderingCapableReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + if buf[b] == 1 { + v.IsCapable = true + } else { + v.IsCapable = false + } + b += 1 + + return v +} + +// Write request to wire for QueryDirectRenderingCapable +func queryDirectRenderingCapableRequest(c *xgb.Conn, Screen uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-DRI"] + b += 1 + + buf[b] = 1 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + return buf +} + +// Request OpenConnection +// size: 8 +type OpenConnectionCookie struct { + *xgb.Cookie +} + +func OpenConnection(c *xgb.Conn, Screen uint32) OpenConnectionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(openConnectionRequest(c, Screen), cookie) + return OpenConnectionCookie{cookie} +} + +func OpenConnectionUnchecked(c *xgb.Conn, Screen uint32) OpenConnectionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(openConnectionRequest(c, Screen), cookie) + return OpenConnectionCookie{cookie} +} + +// Request reply for OpenConnection +// size: (32 + xgb.Pad((int(BusIdLen) * 1))) +type OpenConnectionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + SareaHandleLow uint32 + SareaHandleHigh uint32 + BusIdLen uint32 + // padding: 12 bytes + BusId string // size: xgb.Pad((int(BusIdLen) * 1)) +} + +// Waits and reads reply data from request OpenConnection +func (cook OpenConnectionCookie) Reply() (*OpenConnectionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return openConnectionReply(buf), nil +} + +// Read reply into structure from buffer for OpenConnection +func openConnectionReply(buf []byte) *OpenConnectionReply { + v := new(OpenConnectionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.SareaHandleLow = xgb.Get32(buf[b:]) + b += 4 + + v.SareaHandleHigh = xgb.Get32(buf[b:]) + b += 4 + + v.BusIdLen = xgb.Get32(buf[b:]) + b += 4 + + b += 12 // padding + + { + byteString := make([]byte, v.BusIdLen) + copy(byteString[:v.BusIdLen], buf[b:]) + v.BusId = string(byteString) + b += xgb.Pad(int(v.BusIdLen)) + } + + return v +} + +// Write request to wire for OpenConnection +func openConnectionRequest(c *xgb.Conn, Screen uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-DRI"] + b += 1 + + buf[b] = 2 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + return buf +} + +// Request CloseConnection +// size: 8 +type CloseConnectionCookie struct { + *xgb.Cookie +} + +// Write request to wire for CloseConnection +func CloseConnection(c *xgb.Conn, Screen uint32) CloseConnectionCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(closeConnectionRequest(c, Screen), cookie) + return CloseConnectionCookie{cookie} +} + +func CloseConnectionChecked(c *xgb.Conn, Screen uint32) CloseConnectionCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(closeConnectionRequest(c, Screen), cookie) + return CloseConnectionCookie{cookie} +} + +func (cook CloseConnectionCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CloseConnection +func closeConnectionRequest(c *xgb.Conn, Screen uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-DRI"] + b += 1 + + buf[b] = 3 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + return buf +} + +// Request GetClientDriverName +// size: 8 +type GetClientDriverNameCookie struct { + *xgb.Cookie +} + +func GetClientDriverName(c *xgb.Conn, Screen uint32) GetClientDriverNameCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getClientDriverNameRequest(c, Screen), cookie) + return GetClientDriverNameCookie{cookie} +} + +func GetClientDriverNameUnchecked(c *xgb.Conn, Screen uint32) GetClientDriverNameCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getClientDriverNameRequest(c, Screen), cookie) + return GetClientDriverNameCookie{cookie} +} + +// Request reply for GetClientDriverName +// size: (32 + xgb.Pad((int(ClientDriverNameLen) * 1))) +type GetClientDriverNameReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ClientDriverMajorVersion uint32 + ClientDriverMinorVersion uint32 + ClientDriverPatchVersion uint32 + ClientDriverNameLen uint32 + // padding: 8 bytes + ClientDriverName string // size: xgb.Pad((int(ClientDriverNameLen) * 1)) +} + +// Waits and reads reply data from request GetClientDriverName +func (cook GetClientDriverNameCookie) Reply() (*GetClientDriverNameReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getClientDriverNameReply(buf), nil +} + +// Read reply into structure from buffer for GetClientDriverName +func getClientDriverNameReply(buf []byte) *GetClientDriverNameReply { + v := new(GetClientDriverNameReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ClientDriverMajorVersion = xgb.Get32(buf[b:]) + b += 4 + + v.ClientDriverMinorVersion = xgb.Get32(buf[b:]) + b += 4 + + v.ClientDriverPatchVersion = xgb.Get32(buf[b:]) + b += 4 + + v.ClientDriverNameLen = xgb.Get32(buf[b:]) + b += 4 + + b += 8 // padding + + { + byteString := make([]byte, v.ClientDriverNameLen) + copy(byteString[:v.ClientDriverNameLen], buf[b:]) + v.ClientDriverName = string(byteString) + b += xgb.Pad(int(v.ClientDriverNameLen)) + } + + return v +} + +// Write request to wire for GetClientDriverName +func getClientDriverNameRequest(c *xgb.Conn, Screen uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-DRI"] + b += 1 + + buf[b] = 4 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + return buf +} + +// Request CreateContext +// size: 16 +type CreateContextCookie struct { + *xgb.Cookie +} + +func CreateContext(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) CreateContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(createContextRequest(c, Screen, Visual, Context), cookie) + return CreateContextCookie{cookie} +} + +func CreateContextUnchecked(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) CreateContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(createContextRequest(c, Screen, Visual, Context), cookie) + return CreateContextCookie{cookie} +} + +// Request reply for CreateContext +// size: 12 +type CreateContextReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + HwContext uint32 +} + +// Waits and reads reply data from request CreateContext +func (cook CreateContextCookie) Reply() (*CreateContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return createContextReply(buf), nil +} + +// Read reply into structure from buffer for CreateContext +func createContextReply(buf []byte) *CreateContextReply { + v := new(CreateContextReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.HwContext = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for CreateContext +func createContextRequest(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-DRI"] + b += 1 + + buf[b] = 5 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], Visual) + b += 4 + + xgb.Put32(buf[b:], Context) + b += 4 + + return buf +} + +// Request DestroyContext +// size: 12 +type DestroyContextCookie struct { + *xgb.Cookie +} + +// Write request to wire for DestroyContext +func DestroyContext(c *xgb.Conn, Screen uint32, Context uint32) DestroyContextCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroyContextRequest(c, Screen, Context), cookie) + return DestroyContextCookie{cookie} +} + +func DestroyContextChecked(c *xgb.Conn, Screen uint32, Context uint32) DestroyContextCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(destroyContextRequest(c, Screen, Context), cookie) + return DestroyContextCookie{cookie} +} + +func (cook DestroyContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DestroyContext +func destroyContextRequest(c *xgb.Conn, Screen uint32, Context uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-DRI"] + b += 1 + + buf[b] = 6 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], Context) + b += 4 + + return buf +} + +// Request CreateDrawable +// size: 12 +type CreateDrawableCookie struct { + *xgb.Cookie +} + +func CreateDrawable(c *xgb.Conn, Screen uint32, Drawable uint32) CreateDrawableCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(createDrawableRequest(c, Screen, Drawable), cookie) + return CreateDrawableCookie{cookie} +} + +func CreateDrawableUnchecked(c *xgb.Conn, Screen uint32, Drawable uint32) CreateDrawableCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(createDrawableRequest(c, Screen, Drawable), cookie) + return CreateDrawableCookie{cookie} +} + +// Request reply for CreateDrawable +// size: 12 +type CreateDrawableReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + HwDrawableHandle uint32 +} + +// Waits and reads reply data from request CreateDrawable +func (cook CreateDrawableCookie) Reply() (*CreateDrawableReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return createDrawableReply(buf), nil +} + +// Read reply into structure from buffer for CreateDrawable +func createDrawableReply(buf []byte) *CreateDrawableReply { + v := new(CreateDrawableReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.HwDrawableHandle = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for CreateDrawable +func createDrawableRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-DRI"] + b += 1 + + buf[b] = 7 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], Drawable) + b += 4 + + return buf +} + +// Request DestroyDrawable +// size: 12 +type DestroyDrawableCookie struct { + *xgb.Cookie +} + +// Write request to wire for DestroyDrawable +func DestroyDrawable(c *xgb.Conn, Screen uint32, Drawable uint32) DestroyDrawableCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroyDrawableRequest(c, Screen, Drawable), cookie) + return DestroyDrawableCookie{cookie} +} + +func DestroyDrawableChecked(c *xgb.Conn, Screen uint32, Drawable uint32) DestroyDrawableCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(destroyDrawableRequest(c, Screen, Drawable), cookie) + return DestroyDrawableCookie{cookie} +} + +func (cook DestroyDrawableCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DestroyDrawable +func destroyDrawableRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-DRI"] + b += 1 + + buf[b] = 8 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], Drawable) + b += 4 + + return buf +} + +// Request GetDrawableInfo +// size: 12 +type GetDrawableInfoCookie struct { + *xgb.Cookie +} + +func GetDrawableInfo(c *xgb.Conn, Screen uint32, Drawable uint32) GetDrawableInfoCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getDrawableInfoRequest(c, Screen, Drawable), cookie) + return GetDrawableInfoCookie{cookie} +} + +func GetDrawableInfoUnchecked(c *xgb.Conn, Screen uint32, Drawable uint32) GetDrawableInfoCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getDrawableInfoRequest(c, Screen, Drawable), cookie) + return GetDrawableInfoCookie{cookie} +} + +// Request reply for GetDrawableInfo +// size: ((36 + xgb.Pad((int(NumClipRects) * 8))) + xgb.Pad((int(NumBackClipRects) * 8))) +type GetDrawableInfoReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + DrawableTableIndex uint32 + DrawableTableStamp uint32 + DrawableOriginX int16 + DrawableOriginY int16 + DrawableSizeW int16 + DrawableSizeH int16 + NumClipRects uint32 + BackX int16 + BackY int16 + NumBackClipRects uint32 + ClipRects []DrmClipRect // size: xgb.Pad((int(NumClipRects) * 8)) + BackClipRects []DrmClipRect // size: xgb.Pad((int(NumBackClipRects) * 8)) +} + +// Waits and reads reply data from request GetDrawableInfo +func (cook GetDrawableInfoCookie) Reply() (*GetDrawableInfoReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDrawableInfoReply(buf), nil +} + +// Read reply into structure from buffer for GetDrawableInfo +func getDrawableInfoReply(buf []byte) *GetDrawableInfoReply { + v := new(GetDrawableInfoReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.DrawableTableIndex = xgb.Get32(buf[b:]) + b += 4 + + v.DrawableTableStamp = xgb.Get32(buf[b:]) + b += 4 + + v.DrawableOriginX = int16(xgb.Get16(buf[b:])) + b += 2 + + v.DrawableOriginY = int16(xgb.Get16(buf[b:])) + b += 2 + + v.DrawableSizeW = int16(xgb.Get16(buf[b:])) + b += 2 + + v.DrawableSizeH = int16(xgb.Get16(buf[b:])) + b += 2 + + v.NumClipRects = xgb.Get32(buf[b:]) + b += 4 + + v.BackX = int16(xgb.Get16(buf[b:])) + b += 2 + + v.BackY = int16(xgb.Get16(buf[b:])) + b += 2 + + v.NumBackClipRects = xgb.Get32(buf[b:]) + b += 4 + + v.ClipRects = make([]DrmClipRect, v.NumClipRects) + b += DrmClipRectReadList(buf[b:], v.ClipRects) + + v.BackClipRects = make([]DrmClipRect, v.NumBackClipRects) + b += DrmClipRectReadList(buf[b:], v.BackClipRects) + + return v +} + +// Write request to wire for GetDrawableInfo +func getDrawableInfoRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-DRI"] + b += 1 + + buf[b] = 9 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], Drawable) + b += 4 + + return buf +} + +// Request GetDeviceInfo +// size: 8 +type GetDeviceInfoCookie struct { + *xgb.Cookie +} + +func GetDeviceInfo(c *xgb.Conn, Screen uint32) GetDeviceInfoCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getDeviceInfoRequest(c, Screen), cookie) + return GetDeviceInfoCookie{cookie} +} + +func GetDeviceInfoUnchecked(c *xgb.Conn, Screen uint32) GetDeviceInfoCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getDeviceInfoRequest(c, Screen), cookie) + return GetDeviceInfoCookie{cookie} +} + +// Request reply for GetDeviceInfo +// size: (32 + xgb.Pad((int(DevicePrivateSize) * 4))) +type GetDeviceInfoReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + FramebufferHandleLow uint32 + FramebufferHandleHigh uint32 + FramebufferOriginOffset uint32 + FramebufferSize uint32 + FramebufferStride uint32 + DevicePrivateSize uint32 + DevicePrivate []uint32 // size: xgb.Pad((int(DevicePrivateSize) * 4)) +} + +// Waits and reads reply data from request GetDeviceInfo +func (cook GetDeviceInfoCookie) Reply() (*GetDeviceInfoReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDeviceInfoReply(buf), nil +} + +// Read reply into structure from buffer for GetDeviceInfo +func getDeviceInfoReply(buf []byte) *GetDeviceInfoReply { + v := new(GetDeviceInfoReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.FramebufferHandleLow = xgb.Get32(buf[b:]) + b += 4 + + v.FramebufferHandleHigh = xgb.Get32(buf[b:]) + b += 4 + + v.FramebufferOriginOffset = xgb.Get32(buf[b:]) + b += 4 + + v.FramebufferSize = xgb.Get32(buf[b:]) + b += 4 + + v.FramebufferStride = xgb.Get32(buf[b:]) + b += 4 + + v.DevicePrivateSize = xgb.Get32(buf[b:]) + b += 4 + + v.DevicePrivate = make([]uint32, v.DevicePrivateSize) + for i := 0; i < int(v.DevicePrivateSize); i++ { + v.DevicePrivate[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetDeviceInfo +func getDeviceInfoRequest(c *xgb.Conn, Screen uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-DRI"] + b += 1 + + buf[b] = 10 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + return buf +} + +// Request AuthConnection +// size: 12 +type AuthConnectionCookie struct { + *xgb.Cookie +} + +func AuthConnection(c *xgb.Conn, Screen uint32, Magic uint32) AuthConnectionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(authConnectionRequest(c, Screen, Magic), cookie) + return AuthConnectionCookie{cookie} +} + +func AuthConnectionUnchecked(c *xgb.Conn, Screen uint32, Magic uint32) AuthConnectionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(authConnectionRequest(c, Screen, Magic), cookie) + return AuthConnectionCookie{cookie} +} + +// Request reply for AuthConnection +// size: 12 +type AuthConnectionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Authenticated uint32 +} + +// Waits and reads reply data from request AuthConnection +func (cook AuthConnectionCookie) Reply() (*AuthConnectionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return authConnectionReply(buf), nil +} + +// Read reply into structure from buffer for AuthConnection +func authConnectionReply(buf []byte) *AuthConnectionReply { + v := new(AuthConnectionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Authenticated = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for AuthConnection +func authConnectionRequest(c *xgb.Conn, Screen uint32, Magic uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-DRI"] + b += 1 + + buf[b] = 11 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], Magic) + b += 4 + + return buf +} diff --git a/nexgb/xf86vidmode/xf86vidmode.go b/nexgb/xf86vidmode/xf86vidmode.go new file mode 100644 index 0000000..4137df8 --- /dev/null +++ b/nexgb/xf86vidmode/xf86vidmode.go @@ -0,0 +1,2360 @@ +package xf86vidmode + +/* + This file was generated by xf86vidmode.xml on May 10 2012 4:20:28pm EDT. + This file is automatically generated. Edit at your peril! +*/ + +import ( + "github.com/BurntSushi/xgb" + + "github.com/BurntSushi/xgb/xproto" +) + +// Init must be called before using the XFree86-VidModeExtension extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 24, "XFree86-VidModeExtension").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named XFree86-VidModeExtension could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["XFree86-VidModeExtension"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["XFree86-VidModeExtension"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["XFree86-VidModeExtension"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["XFree86-VidModeExtension"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["XFree86-VidModeExtension"] = make(map[int]xgb.NewErrorFun) +} + +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Bool' + +// Skipping definition for base type 'Float' + +const ( + ModeFlagPositiveHsync = 1 + ModeFlagNegativeHsync = 2 + ModeFlagPositiveVsync = 4 + ModeFlagNegativeVsync = 8 + ModeFlagInterlace = 16 + ModeFlagCompositeSync = 32 + ModeFlagPositiveCsync = 64 + ModeFlagNegativeCsync = 128 + ModeFlagHSkew = 256 + ModeFlagBroadcast = 512 + ModeFlagPixmux = 1024 + ModeFlagDoubleClock = 2048 + ModeFlagHalfClock = 4096 +) + +const ( + ClockFlagProgramable = 1 +) + +const ( + PermissionRead = 1 + PermissionWrite = 2 +) + +type Syncrange uint32 + +type Dotclock uint32 + +// 'ModeInfo' struct definition +// Size: 48 +type ModeInfo struct { + Dotclock Dotclock + Hdisplay uint16 + Hsyncstart uint16 + Hsyncend uint16 + Htotal uint16 + Hskew uint32 + Vdisplay uint16 + Vsyncstart uint16 + Vsyncend uint16 + Vtotal uint16 + // padding: 4 bytes + Flags uint32 + // padding: 12 bytes + Privsize uint32 +} + +// Struct read ModeInfo +func ModeInfoRead(buf []byte, v *ModeInfo) int { + b := 0 + + v.Dotclock = Dotclock(xgb.Get32(buf[b:])) + b += 4 + + v.Hdisplay = xgb.Get16(buf[b:]) + b += 2 + + v.Hsyncstart = xgb.Get16(buf[b:]) + b += 2 + + v.Hsyncend = xgb.Get16(buf[b:]) + b += 2 + + v.Htotal = xgb.Get16(buf[b:]) + b += 2 + + v.Hskew = xgb.Get32(buf[b:]) + b += 4 + + v.Vdisplay = xgb.Get16(buf[b:]) + b += 2 + + v.Vsyncstart = xgb.Get16(buf[b:]) + b += 2 + + v.Vsyncend = xgb.Get16(buf[b:]) + b += 2 + + v.Vtotal = xgb.Get16(buf[b:]) + b += 2 + + b += 4 // padding + + v.Flags = xgb.Get32(buf[b:]) + b += 4 + + b += 12 // padding + + v.Privsize = xgb.Get32(buf[b:]) + b += 4 + + return b +} + +// Struct list read ModeInfo +func ModeInfoReadList(buf []byte, dest []ModeInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = ModeInfo{} + b += ModeInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write ModeInfo +func (v ModeInfo) Bytes() []byte { + buf := make([]byte, 48) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Dotclock)) + b += 4 + + xgb.Put16(buf[b:], v.Hdisplay) + b += 2 + + xgb.Put16(buf[b:], v.Hsyncstart) + b += 2 + + xgb.Put16(buf[b:], v.Hsyncend) + b += 2 + + xgb.Put16(buf[b:], v.Htotal) + b += 2 + + xgb.Put32(buf[b:], v.Hskew) + b += 4 + + xgb.Put16(buf[b:], v.Vdisplay) + b += 2 + + xgb.Put16(buf[b:], v.Vsyncstart) + b += 2 + + xgb.Put16(buf[b:], v.Vsyncend) + b += 2 + + xgb.Put16(buf[b:], v.Vtotal) + b += 2 + + b += 4 // padding + + xgb.Put32(buf[b:], v.Flags) + b += 4 + + b += 12 // padding + + xgb.Put32(buf[b:], v.Privsize) + b += 4 + + return buf +} + +// Write struct list ModeInfo +func ModeInfoListBytes(buf []byte, list []ModeInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Error definition BadClock (0) +// Size: 32 + +const BadBadClock = 0 + +type BadClockError struct { + Sequence uint16 + NiceName string +} + +// Error read BadClock +func BadClockErrorNew(buf []byte) xgb.Error { + v := BadClockError{} + v.NiceName = "BadClock" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err BadClockError) ImplementsError() {} + +func (err BadClockError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadClockError) BadId() uint32 { + return 0 +} + +func (err BadClockError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadClock {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XFree86-VidModeExtension"][0] = BadClockErrorNew +} + +// Error definition BadHTimings (1) +// Size: 32 + +const BadBadHTimings = 1 + +type BadHTimingsError struct { + Sequence uint16 + NiceName string +} + +// Error read BadHTimings +func BadHTimingsErrorNew(buf []byte) xgb.Error { + v := BadHTimingsError{} + v.NiceName = "BadHTimings" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err BadHTimingsError) ImplementsError() {} + +func (err BadHTimingsError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadHTimingsError) BadId() uint32 { + return 0 +} + +func (err BadHTimingsError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadHTimings {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XFree86-VidModeExtension"][1] = BadHTimingsErrorNew +} + +// Error definition BadVTimings (2) +// Size: 32 + +const BadBadVTimings = 2 + +type BadVTimingsError struct { + Sequence uint16 + NiceName string +} + +// Error read BadVTimings +func BadVTimingsErrorNew(buf []byte) xgb.Error { + v := BadVTimingsError{} + v.NiceName = "BadVTimings" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err BadVTimingsError) ImplementsError() {} + +func (err BadVTimingsError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadVTimingsError) BadId() uint32 { + return 0 +} + +func (err BadVTimingsError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadVTimings {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XFree86-VidModeExtension"][2] = BadVTimingsErrorNew +} + +// Error definition ModeUnsuitable (3) +// Size: 32 + +const BadModeUnsuitable = 3 + +type ModeUnsuitableError struct { + Sequence uint16 + NiceName string +} + +// Error read ModeUnsuitable +func ModeUnsuitableErrorNew(buf []byte) xgb.Error { + v := ModeUnsuitableError{} + v.NiceName = "ModeUnsuitable" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err ModeUnsuitableError) ImplementsError() {} + +func (err ModeUnsuitableError) SequenceId() uint16 { + return err.Sequence +} + +func (err ModeUnsuitableError) BadId() uint32 { + return 0 +} + +func (err ModeUnsuitableError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadModeUnsuitable {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XFree86-VidModeExtension"][3] = ModeUnsuitableErrorNew +} + +// Error definition ExtensionDisabled (4) +// Size: 32 + +const BadExtensionDisabled = 4 + +type ExtensionDisabledError struct { + Sequence uint16 + NiceName string +} + +// Error read ExtensionDisabled +func ExtensionDisabledErrorNew(buf []byte) xgb.Error { + v := ExtensionDisabledError{} + v.NiceName = "ExtensionDisabled" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err ExtensionDisabledError) ImplementsError() {} + +func (err ExtensionDisabledError) SequenceId() uint16 { + return err.Sequence +} + +func (err ExtensionDisabledError) BadId() uint32 { + return 0 +} + +func (err ExtensionDisabledError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadExtensionDisabled {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XFree86-VidModeExtension"][4] = ExtensionDisabledErrorNew +} + +// Error definition ClientNotLocal (5) +// Size: 32 + +const BadClientNotLocal = 5 + +type ClientNotLocalError struct { + Sequence uint16 + NiceName string +} + +// Error read ClientNotLocal +func ClientNotLocalErrorNew(buf []byte) xgb.Error { + v := ClientNotLocalError{} + v.NiceName = "ClientNotLocal" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err ClientNotLocalError) ImplementsError() {} + +func (err ClientNotLocalError) SequenceId() uint16 { + return err.Sequence +} + +func (err ClientNotLocalError) BadId() uint32 { + return 0 +} + +func (err ClientNotLocalError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadClientNotLocal {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XFree86-VidModeExtension"][5] = ClientNotLocalErrorNew +} + +// Error definition ZoomLocked (6) +// Size: 32 + +const BadZoomLocked = 6 + +type ZoomLockedError struct { + Sequence uint16 + NiceName string +} + +// Error read ZoomLocked +func ZoomLockedErrorNew(buf []byte) xgb.Error { + v := ZoomLockedError{} + v.NiceName = "ZoomLocked" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err ZoomLockedError) ImplementsError() {} + +func (err ZoomLockedError) SequenceId() uint16 { + return err.Sequence +} + +func (err ZoomLockedError) BadId() uint32 { + return 0 +} + +func (err ZoomLockedError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadZoomLocked {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XFree86-VidModeExtension"][6] = ZoomLockedErrorNew +} + +// Request QueryVersion +// size: 4 +type QueryVersionCookie struct { + *xgb.Cookie +} + +func QueryVersion(c *xgb.Conn) QueryVersionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c), cookie) + return QueryVersionCookie{cookie} +} + +func QueryVersionUnchecked(c *xgb.Conn) QueryVersionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c), cookie) + return QueryVersionCookie{cookie} +} + +// Request reply for QueryVersion +// size: 12 +type QueryVersionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + MajorVersion uint16 + MinorVersion uint16 +} + +// Waits and reads reply data from request QueryVersion +func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryVersionReply(buf), nil +} + +// Read reply into structure from buffer for QueryVersion +func queryVersionReply(buf []byte) *QueryVersionReply { + v := new(QueryVersionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.MajorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.MinorVersion = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Write request to wire for QueryVersion +func queryVersionRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 + + buf[b] = 0 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request GetModeLine +// size: 8 +type GetModeLineCookie struct { + *xgb.Cookie +} + +func GetModeLine(c *xgb.Conn, Screen uint16) GetModeLineCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getModeLineRequest(c, Screen), cookie) + return GetModeLineCookie{cookie} +} + +func GetModeLineUnchecked(c *xgb.Conn, Screen uint16) GetModeLineCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getModeLineRequest(c, Screen), cookie) + return GetModeLineCookie{cookie} +} + +// Request reply for GetModeLine +// size: (52 + xgb.Pad((int(Privsize) * 1))) +type GetModeLineReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Dotclock Dotclock + Hdisplay uint16 + Hsyncstart uint16 + Hsyncend uint16 + Htotal uint16 + Hskew uint16 + Vdisplay uint16 + Vsyncstart uint16 + Vsyncend uint16 + Vtotal uint16 + // padding: 2 bytes + Flags uint32 + // padding: 12 bytes + Privsize uint32 + Private []byte // size: xgb.Pad((int(Privsize) * 1)) +} + +// Waits and reads reply data from request GetModeLine +func (cook GetModeLineCookie) Reply() (*GetModeLineReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getModeLineReply(buf), nil +} + +// Read reply into structure from buffer for GetModeLine +func getModeLineReply(buf []byte) *GetModeLineReply { + v := new(GetModeLineReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Dotclock = Dotclock(xgb.Get32(buf[b:])) + b += 4 + + v.Hdisplay = xgb.Get16(buf[b:]) + b += 2 + + v.Hsyncstart = xgb.Get16(buf[b:]) + b += 2 + + v.Hsyncend = xgb.Get16(buf[b:]) + b += 2 + + v.Htotal = xgb.Get16(buf[b:]) + b += 2 + + v.Hskew = xgb.Get16(buf[b:]) + b += 2 + + v.Vdisplay = xgb.Get16(buf[b:]) + b += 2 + + v.Vsyncstart = xgb.Get16(buf[b:]) + b += 2 + + v.Vsyncend = xgb.Get16(buf[b:]) + b += 2 + + v.Vtotal = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + v.Flags = xgb.Get32(buf[b:]) + b += 4 + + b += 12 // padding + + v.Privsize = xgb.Get32(buf[b:]) + b += 4 + + v.Private = make([]byte, v.Privsize) + copy(v.Private[:v.Privsize], buf[b:]) + b += xgb.Pad(int(v.Privsize)) + + return v +} + +// Write request to wire for GetModeLine +func getModeLineRequest(c *xgb.Conn, Screen uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 + + buf[b] = 1 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], Screen) + b += 2 + + b += 2 // padding + + return buf +} + +// Request ModModeLine +// size: xgb.Pad((48 + xgb.Pad((int(Privsize) * 1)))) +type ModModeLineCookie struct { + *xgb.Cookie +} + +// Write request to wire for ModModeLine +func ModModeLine(c *xgb.Conn, Screen uint32, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) ModModeLineCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(modModeLineRequest(c, Screen, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) + return ModModeLineCookie{cookie} +} + +func ModModeLineChecked(c *xgb.Conn, Screen uint32, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) ModModeLineCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(modModeLineRequest(c, Screen, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) + return ModModeLineCookie{cookie} +} + +func (cook ModModeLineCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ModModeLine +func modModeLineRequest(c *xgb.Conn, Screen uint32, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) []byte { + size := xgb.Pad((48 + xgb.Pad((int(Privsize) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 + + buf[b] = 2 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put16(buf[b:], Hdisplay) + b += 2 + + xgb.Put16(buf[b:], Hsyncstart) + b += 2 + + xgb.Put16(buf[b:], Hsyncend) + b += 2 + + xgb.Put16(buf[b:], Htotal) + b += 2 + + xgb.Put16(buf[b:], Hskew) + b += 2 + + xgb.Put16(buf[b:], Vdisplay) + b += 2 + + xgb.Put16(buf[b:], Vsyncstart) + b += 2 + + xgb.Put16(buf[b:], Vsyncend) + b += 2 + + xgb.Put16(buf[b:], Vtotal) + b += 2 + + b += 2 // padding + + xgb.Put32(buf[b:], Flags) + b += 4 + + b += 12 // padding + + xgb.Put32(buf[b:], Privsize) + b += 4 + + copy(buf[b:], Private[:Privsize]) + b += xgb.Pad(int(Privsize)) + + return buf +} + +// Request SwitchMode +// size: 8 +type SwitchModeCookie struct { + *xgb.Cookie +} + +// Write request to wire for SwitchMode +func SwitchMode(c *xgb.Conn, Screen uint16, Zoom uint16) SwitchModeCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(switchModeRequest(c, Screen, Zoom), cookie) + return SwitchModeCookie{cookie} +} + +func SwitchModeChecked(c *xgb.Conn, Screen uint16, Zoom uint16) SwitchModeCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(switchModeRequest(c, Screen, Zoom), cookie) + return SwitchModeCookie{cookie} +} + +func (cook SwitchModeCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SwitchMode +func switchModeRequest(c *xgb.Conn, Screen uint16, Zoom uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 + + buf[b] = 3 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], Screen) + b += 2 + + xgb.Put16(buf[b:], Zoom) + b += 2 + + return buf +} + +// Request GetMonitor +// size: 8 +type GetMonitorCookie struct { + *xgb.Cookie +} + +func GetMonitor(c *xgb.Conn, Screen uint16) GetMonitorCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getMonitorRequest(c, Screen), cookie) + return GetMonitorCookie{cookie} +} + +func GetMonitorUnchecked(c *xgb.Conn, Screen uint16) GetMonitorCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getMonitorRequest(c, Screen), cookie) + return GetMonitorCookie{cookie} +} + +// Request reply for GetMonitor +// size: (((((32 + xgb.Pad((int(NumHsync) * 4))) + xgb.Pad((int(NumVsync) * 4))) + xgb.Pad((int(VendorLength) * 1))) + xgb.Pad(((((int(VendorLength) + 3) & -4) - int(VendorLength)) * 1))) + xgb.Pad((int(ModelLength) * 1))) +type GetMonitorReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + VendorLength byte + ModelLength byte + NumHsync byte + NumVsync byte + // padding: 20 bytes + Hsync []Syncrange // size: xgb.Pad((int(NumHsync) * 4)) + Vsync []Syncrange // size: xgb.Pad((int(NumVsync) * 4)) + Vendor string // size: xgb.Pad((int(VendorLength) * 1)) + AlignmentPad []byte // size: xgb.Pad(((((int(VendorLength) + 3) & -4) - int(VendorLength)) * 1)) + Model string // size: xgb.Pad((int(ModelLength) * 1)) +} + +// Waits and reads reply data from request GetMonitor +func (cook GetMonitorCookie) Reply() (*GetMonitorReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getMonitorReply(buf), nil +} + +// Read reply into structure from buffer for GetMonitor +func getMonitorReply(buf []byte) *GetMonitorReply { + v := new(GetMonitorReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.VendorLength = buf[b] + b += 1 + + v.ModelLength = buf[b] + b += 1 + + v.NumHsync = buf[b] + b += 1 + + v.NumVsync = buf[b] + b += 1 + + b += 20 // padding + + v.Hsync = make([]Syncrange, v.NumHsync) + for i := 0; i < int(v.NumHsync); i++ { + v.Hsync[i] = Syncrange(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + v.Vsync = make([]Syncrange, v.NumVsync) + for i := 0; i < int(v.NumVsync); i++ { + v.Vsync[i] = Syncrange(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + { + byteString := make([]byte, v.VendorLength) + copy(byteString[:v.VendorLength], buf[b:]) + v.Vendor = string(byteString) + b += xgb.Pad(int(v.VendorLength)) + } + + v.AlignmentPad = make([]byte, (((int(v.VendorLength) + 3) & -4) - int(v.VendorLength))) + copy(v.AlignmentPad[:(((int(v.VendorLength)+3)&-4)-int(v.VendorLength))], buf[b:]) + b += xgb.Pad(int((((int(v.VendorLength) + 3) & -4) - int(v.VendorLength)))) + + { + byteString := make([]byte, v.ModelLength) + copy(byteString[:v.ModelLength], buf[b:]) + v.Model = string(byteString) + b += xgb.Pad(int(v.ModelLength)) + } + + return v +} + +// Write request to wire for GetMonitor +func getMonitorRequest(c *xgb.Conn, Screen uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 + + buf[b] = 4 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], Screen) + b += 2 + + b += 2 // padding + + return buf +} + +// Request LockModeSwitch +// size: 8 +type LockModeSwitchCookie struct { + *xgb.Cookie +} + +// Write request to wire for LockModeSwitch +func LockModeSwitch(c *xgb.Conn, Screen uint16, Lock uint16) LockModeSwitchCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(lockModeSwitchRequest(c, Screen, Lock), cookie) + return LockModeSwitchCookie{cookie} +} + +func LockModeSwitchChecked(c *xgb.Conn, Screen uint16, Lock uint16) LockModeSwitchCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(lockModeSwitchRequest(c, Screen, Lock), cookie) + return LockModeSwitchCookie{cookie} +} + +func (cook LockModeSwitchCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for LockModeSwitch +func lockModeSwitchRequest(c *xgb.Conn, Screen uint16, Lock uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 + + buf[b] = 5 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], Screen) + b += 2 + + xgb.Put16(buf[b:], Lock) + b += 2 + + return buf +} + +// Request GetAllModeLines +// size: 8 +type GetAllModeLinesCookie struct { + *xgb.Cookie +} + +func GetAllModeLines(c *xgb.Conn, Screen uint16) GetAllModeLinesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getAllModeLinesRequest(c, Screen), cookie) + return GetAllModeLinesCookie{cookie} +} + +func GetAllModeLinesUnchecked(c *xgb.Conn, Screen uint16) GetAllModeLinesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getAllModeLinesRequest(c, Screen), cookie) + return GetAllModeLinesCookie{cookie} +} + +// Request reply for GetAllModeLines +// size: (32 + xgb.Pad((int(Modecount) * 48))) +type GetAllModeLinesReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Modecount uint32 + // padding: 20 bytes + Modeinfo []ModeInfo // size: xgb.Pad((int(Modecount) * 48)) +} + +// Waits and reads reply data from request GetAllModeLines +func (cook GetAllModeLinesCookie) Reply() (*GetAllModeLinesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getAllModeLinesReply(buf), nil +} + +// Read reply into structure from buffer for GetAllModeLines +func getAllModeLinesReply(buf []byte) *GetAllModeLinesReply { + v := new(GetAllModeLinesReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Modecount = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Modeinfo = make([]ModeInfo, v.Modecount) + b += ModeInfoReadList(buf[b:], v.Modeinfo) + + return v +} + +// Write request to wire for GetAllModeLines +func getAllModeLinesRequest(c *xgb.Conn, Screen uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 + + buf[b] = 6 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], Screen) + b += 2 + + b += 2 // padding + + return buf +} + +// Request AddModeLine +// size: xgb.Pad((92 + xgb.Pad((int(Privsize) * 1)))) +type AddModeLineCookie struct { + *xgb.Cookie +} + +// Write request to wire for AddModeLine +func AddModeLine(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, AfterDotclock Dotclock, AfterHdisplay uint16, AfterHsyncstart uint16, AfterHsyncend uint16, AfterHtotal uint16, AfterHskew uint16, AfterVdisplay uint16, AfterVsyncstart uint16, AfterVsyncend uint16, AfterVtotal uint16, AfterFlags uint32, Private []byte) AddModeLineCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(addModeLineRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, AfterDotclock, AfterHdisplay, AfterHsyncstart, AfterHsyncend, AfterHtotal, AfterHskew, AfterVdisplay, AfterVsyncstart, AfterVsyncend, AfterVtotal, AfterFlags, Private), cookie) + return AddModeLineCookie{cookie} +} + +func AddModeLineChecked(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, AfterDotclock Dotclock, AfterHdisplay uint16, AfterHsyncstart uint16, AfterHsyncend uint16, AfterHtotal uint16, AfterHskew uint16, AfterVdisplay uint16, AfterVsyncstart uint16, AfterVsyncend uint16, AfterVtotal uint16, AfterFlags uint32, Private []byte) AddModeLineCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(addModeLineRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, AfterDotclock, AfterHdisplay, AfterHsyncstart, AfterHsyncend, AfterHtotal, AfterHskew, AfterVdisplay, AfterVsyncstart, AfterVsyncend, AfterVtotal, AfterFlags, Private), cookie) + return AddModeLineCookie{cookie} +} + +func (cook AddModeLineCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for AddModeLine +func addModeLineRequest(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, AfterDotclock Dotclock, AfterHdisplay uint16, AfterHsyncstart uint16, AfterHsyncend uint16, AfterHtotal uint16, AfterHskew uint16, AfterVdisplay uint16, AfterVsyncstart uint16, AfterVsyncend uint16, AfterVtotal uint16, AfterFlags uint32, Private []byte) []byte { + size := xgb.Pad((92 + xgb.Pad((int(Privsize) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 + + buf[b] = 7 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], uint32(Dotclock)) + b += 4 + + xgb.Put16(buf[b:], Hdisplay) + b += 2 + + xgb.Put16(buf[b:], Hsyncstart) + b += 2 + + xgb.Put16(buf[b:], Hsyncend) + b += 2 + + xgb.Put16(buf[b:], Htotal) + b += 2 + + xgb.Put16(buf[b:], Hskew) + b += 2 + + xgb.Put16(buf[b:], Vdisplay) + b += 2 + + xgb.Put16(buf[b:], Vsyncstart) + b += 2 + + xgb.Put16(buf[b:], Vsyncend) + b += 2 + + xgb.Put16(buf[b:], Vtotal) + b += 2 + + b += 2 // padding + + xgb.Put32(buf[b:], Flags) + b += 4 + + b += 12 // padding + + xgb.Put32(buf[b:], Privsize) + b += 4 + + xgb.Put32(buf[b:], uint32(AfterDotclock)) + b += 4 + + xgb.Put16(buf[b:], AfterHdisplay) + b += 2 + + xgb.Put16(buf[b:], AfterHsyncstart) + b += 2 + + xgb.Put16(buf[b:], AfterHsyncend) + b += 2 + + xgb.Put16(buf[b:], AfterHtotal) + b += 2 + + xgb.Put16(buf[b:], AfterHskew) + b += 2 + + xgb.Put16(buf[b:], AfterVdisplay) + b += 2 + + xgb.Put16(buf[b:], AfterVsyncstart) + b += 2 + + xgb.Put16(buf[b:], AfterVsyncend) + b += 2 + + xgb.Put16(buf[b:], AfterVtotal) + b += 2 + + b += 2 // padding + + xgb.Put32(buf[b:], AfterFlags) + b += 4 + + b += 12 // padding + + copy(buf[b:], Private[:Privsize]) + b += xgb.Pad(int(Privsize)) + + return buf +} + +// Request DeleteModeLine +// size: xgb.Pad((52 + xgb.Pad((int(Privsize) * 1)))) +type DeleteModeLineCookie struct { + *xgb.Cookie +} + +// Write request to wire for DeleteModeLine +func DeleteModeLine(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) DeleteModeLineCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(deleteModeLineRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) + return DeleteModeLineCookie{cookie} +} + +func DeleteModeLineChecked(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) DeleteModeLineCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(deleteModeLineRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) + return DeleteModeLineCookie{cookie} +} + +func (cook DeleteModeLineCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DeleteModeLine +func deleteModeLineRequest(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) []byte { + size := xgb.Pad((52 + xgb.Pad((int(Privsize) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 + + buf[b] = 8 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], uint32(Dotclock)) + b += 4 + + xgb.Put16(buf[b:], Hdisplay) + b += 2 + + xgb.Put16(buf[b:], Hsyncstart) + b += 2 + + xgb.Put16(buf[b:], Hsyncend) + b += 2 + + xgb.Put16(buf[b:], Htotal) + b += 2 + + xgb.Put16(buf[b:], Hskew) + b += 2 + + xgb.Put16(buf[b:], Vdisplay) + b += 2 + + xgb.Put16(buf[b:], Vsyncstart) + b += 2 + + xgb.Put16(buf[b:], Vsyncend) + b += 2 + + xgb.Put16(buf[b:], Vtotal) + b += 2 + + b += 2 // padding + + xgb.Put32(buf[b:], Flags) + b += 4 + + b += 12 // padding + + xgb.Put32(buf[b:], Privsize) + b += 4 + + copy(buf[b:], Private[:Privsize]) + b += xgb.Pad(int(Privsize)) + + return buf +} + +// Request ValidateModeLine +// size: xgb.Pad((52 + xgb.Pad((int(Privsize) * 1)))) +type ValidateModeLineCookie struct { + *xgb.Cookie +} + +func ValidateModeLine(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) ValidateModeLineCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(validateModeLineRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) + return ValidateModeLineCookie{cookie} +} + +func ValidateModeLineUnchecked(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) ValidateModeLineCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(validateModeLineRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) + return ValidateModeLineCookie{cookie} +} + +// Request reply for ValidateModeLine +// size: 32 +type ValidateModeLineReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Status uint32 + // padding: 20 bytes +} + +// Waits and reads reply data from request ValidateModeLine +func (cook ValidateModeLineCookie) Reply() (*ValidateModeLineReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return validateModeLineReply(buf), nil +} + +// Read reply into structure from buffer for ValidateModeLine +func validateModeLineReply(buf []byte) *ValidateModeLineReply { + v := new(ValidateModeLineReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Status = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + return v +} + +// Write request to wire for ValidateModeLine +func validateModeLineRequest(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) []byte { + size := xgb.Pad((52 + xgb.Pad((int(Privsize) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 + + buf[b] = 9 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], uint32(Dotclock)) + b += 4 + + xgb.Put16(buf[b:], Hdisplay) + b += 2 + + xgb.Put16(buf[b:], Hsyncstart) + b += 2 + + xgb.Put16(buf[b:], Hsyncend) + b += 2 + + xgb.Put16(buf[b:], Htotal) + b += 2 + + xgb.Put16(buf[b:], Hskew) + b += 2 + + xgb.Put16(buf[b:], Vdisplay) + b += 2 + + xgb.Put16(buf[b:], Vsyncstart) + b += 2 + + xgb.Put16(buf[b:], Vsyncend) + b += 2 + + xgb.Put16(buf[b:], Vtotal) + b += 2 + + b += 2 // padding + + xgb.Put32(buf[b:], Flags) + b += 4 + + b += 12 // padding + + xgb.Put32(buf[b:], Privsize) + b += 4 + + copy(buf[b:], Private[:Privsize]) + b += xgb.Pad(int(Privsize)) + + return buf +} + +// Request SwitchToMode +// size: xgb.Pad((52 + xgb.Pad((int(Privsize) * 1)))) +type SwitchToModeCookie struct { + *xgb.Cookie +} + +// Write request to wire for SwitchToMode +func SwitchToMode(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) SwitchToModeCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(switchToModeRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) + return SwitchToModeCookie{cookie} +} + +func SwitchToModeChecked(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) SwitchToModeCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(switchToModeRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) + return SwitchToModeCookie{cookie} +} + +func (cook SwitchToModeCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SwitchToMode +func switchToModeRequest(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) []byte { + size := xgb.Pad((52 + xgb.Pad((int(Privsize) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 + + buf[b] = 10 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], uint32(Dotclock)) + b += 4 + + xgb.Put16(buf[b:], Hdisplay) + b += 2 + + xgb.Put16(buf[b:], Hsyncstart) + b += 2 + + xgb.Put16(buf[b:], Hsyncend) + b += 2 + + xgb.Put16(buf[b:], Htotal) + b += 2 + + xgb.Put16(buf[b:], Hskew) + b += 2 + + xgb.Put16(buf[b:], Vdisplay) + b += 2 + + xgb.Put16(buf[b:], Vsyncstart) + b += 2 + + xgb.Put16(buf[b:], Vsyncend) + b += 2 + + xgb.Put16(buf[b:], Vtotal) + b += 2 + + b += 2 // padding + + xgb.Put32(buf[b:], Flags) + b += 4 + + b += 12 // padding + + xgb.Put32(buf[b:], Privsize) + b += 4 + + copy(buf[b:], Private[:Privsize]) + b += xgb.Pad(int(Privsize)) + + return buf +} + +// Request GetViewPort +// size: 8 +type GetViewPortCookie struct { + *xgb.Cookie +} + +func GetViewPort(c *xgb.Conn, Screen uint16) GetViewPortCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getViewPortRequest(c, Screen), cookie) + return GetViewPortCookie{cookie} +} + +func GetViewPortUnchecked(c *xgb.Conn, Screen uint16) GetViewPortCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getViewPortRequest(c, Screen), cookie) + return GetViewPortCookie{cookie} +} + +// Request reply for GetViewPort +// size: 32 +type GetViewPortReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + X uint32 + Y uint32 + // padding: 16 bytes +} + +// Waits and reads reply data from request GetViewPort +func (cook GetViewPortCookie) Reply() (*GetViewPortReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getViewPortReply(buf), nil +} + +// Read reply into structure from buffer for GetViewPort +func getViewPortReply(buf []byte) *GetViewPortReply { + v := new(GetViewPortReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.X = xgb.Get32(buf[b:]) + b += 4 + + v.Y = xgb.Get32(buf[b:]) + b += 4 + + b += 16 // padding + + return v +} + +// Write request to wire for GetViewPort +func getViewPortRequest(c *xgb.Conn, Screen uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 + + buf[b] = 11 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], Screen) + b += 2 + + b += 2 // padding + + return buf +} + +// Request SetViewPort +// size: 16 +type SetViewPortCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetViewPort +func SetViewPort(c *xgb.Conn, Screen uint16, X uint32, Y uint32) SetViewPortCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setViewPortRequest(c, Screen, X, Y), cookie) + return SetViewPortCookie{cookie} +} + +func SetViewPortChecked(c *xgb.Conn, Screen uint16, X uint32, Y uint32) SetViewPortCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setViewPortRequest(c, Screen, X, Y), cookie) + return SetViewPortCookie{cookie} +} + +func (cook SetViewPortCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetViewPort +func setViewPortRequest(c *xgb.Conn, Screen uint16, X uint32, Y uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 + + buf[b] = 12 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], Screen) + b += 2 + + b += 2 // padding + + xgb.Put32(buf[b:], X) + b += 4 + + xgb.Put32(buf[b:], Y) + b += 4 + + return buf +} + +// Request GetDotClocks +// size: 8 +type GetDotClocksCookie struct { + *xgb.Cookie +} + +func GetDotClocks(c *xgb.Conn, Screen uint16) GetDotClocksCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getDotClocksRequest(c, Screen), cookie) + return GetDotClocksCookie{cookie} +} + +func GetDotClocksUnchecked(c *xgb.Conn, Screen uint16) GetDotClocksCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getDotClocksRequest(c, Screen), cookie) + return GetDotClocksCookie{cookie} +} + +// Request reply for GetDotClocks +// size: (32 + xgb.Pad((((1 - (int(Flags) & 1)) * int(Clocks)) * 4))) +type GetDotClocksReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Flags uint32 + Clocks uint32 + Maxclocks uint32 + // padding: 12 bytes + Clock []uint32 // size: xgb.Pad((((1 - (int(Flags) & 1)) * int(Clocks)) * 4)) +} + +// Waits and reads reply data from request GetDotClocks +func (cook GetDotClocksCookie) Reply() (*GetDotClocksReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDotClocksReply(buf), nil +} + +// Read reply into structure from buffer for GetDotClocks +func getDotClocksReply(buf []byte) *GetDotClocksReply { + v := new(GetDotClocksReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Flags = xgb.Get32(buf[b:]) + b += 4 + + v.Clocks = xgb.Get32(buf[b:]) + b += 4 + + v.Maxclocks = xgb.Get32(buf[b:]) + b += 4 + + b += 12 // padding + + v.Clock = make([]uint32, ((1 - (int(v.Flags) & 1)) * int(v.Clocks))) + for i := 0; i < int(((1 - (int(v.Flags) & 1)) * int(v.Clocks))); i++ { + v.Clock[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetDotClocks +func getDotClocksRequest(c *xgb.Conn, Screen uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 + + buf[b] = 13 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], Screen) + b += 2 + + b += 2 // padding + + return buf +} + +// Request SetClientVersion +// size: 8 +type SetClientVersionCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetClientVersion +func SetClientVersion(c *xgb.Conn, Major uint16, Minor uint16) SetClientVersionCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setClientVersionRequest(c, Major, Minor), cookie) + return SetClientVersionCookie{cookie} +} + +func SetClientVersionChecked(c *xgb.Conn, Major uint16, Minor uint16) SetClientVersionCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setClientVersionRequest(c, Major, Minor), cookie) + return SetClientVersionCookie{cookie} +} + +func (cook SetClientVersionCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetClientVersion +func setClientVersionRequest(c *xgb.Conn, Major uint16, Minor uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 + + buf[b] = 14 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], Major) + b += 2 + + xgb.Put16(buf[b:], Minor) + b += 2 + + return buf +} + +// Request SetGamma +// size: 32 +type SetGammaCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetGamma +func SetGamma(c *xgb.Conn, Screen uint16, Red uint32, Green uint32, Blue uint32) SetGammaCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setGammaRequest(c, Screen, Red, Green, Blue), cookie) + return SetGammaCookie{cookie} +} + +func SetGammaChecked(c *xgb.Conn, Screen uint16, Red uint32, Green uint32, Blue uint32) SetGammaCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setGammaRequest(c, Screen, Red, Green, Blue), cookie) + return SetGammaCookie{cookie} +} + +func (cook SetGammaCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetGamma +func setGammaRequest(c *xgb.Conn, Screen uint16, Red uint32, Green uint32, Blue uint32) []byte { + size := 32 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 + + buf[b] = 15 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], Screen) + b += 2 + + b += 2 // padding + + xgb.Put32(buf[b:], Red) + b += 4 + + xgb.Put32(buf[b:], Green) + b += 4 + + xgb.Put32(buf[b:], Blue) + b += 4 + + b += 12 // padding + + return buf +} + +// Request GetGamma +// size: 32 +type GetGammaCookie struct { + *xgb.Cookie +} + +func GetGamma(c *xgb.Conn, Screen uint16) GetGammaCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getGammaRequest(c, Screen), cookie) + return GetGammaCookie{cookie} +} + +func GetGammaUnchecked(c *xgb.Conn, Screen uint16) GetGammaCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getGammaRequest(c, Screen), cookie) + return GetGammaCookie{cookie} +} + +// Request reply for GetGamma +// size: 32 +type GetGammaReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Red uint32 + Green uint32 + Blue uint32 + // padding: 12 bytes +} + +// Waits and reads reply data from request GetGamma +func (cook GetGammaCookie) Reply() (*GetGammaReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getGammaReply(buf), nil +} + +// Read reply into structure from buffer for GetGamma +func getGammaReply(buf []byte) *GetGammaReply { + v := new(GetGammaReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Red = xgb.Get32(buf[b:]) + b += 4 + + v.Green = xgb.Get32(buf[b:]) + b += 4 + + v.Blue = xgb.Get32(buf[b:]) + b += 4 + + b += 12 // padding + + return v +} + +// Write request to wire for GetGamma +func getGammaRequest(c *xgb.Conn, Screen uint16) []byte { + size := 32 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 + + buf[b] = 16 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], Screen) + b += 2 + + b += 26 // padding + + return buf +} + +// Request GetGammaRamp +// size: 8 +type GetGammaRampCookie struct { + *xgb.Cookie +} + +func GetGammaRamp(c *xgb.Conn, Screen uint16, Size uint16) GetGammaRampCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getGammaRampRequest(c, Screen, Size), cookie) + return GetGammaRampCookie{cookie} +} + +func GetGammaRampUnchecked(c *xgb.Conn, Screen uint16, Size uint16) GetGammaRampCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getGammaRampRequest(c, Screen, Size), cookie) + return GetGammaRampCookie{cookie} +} + +// Request reply for GetGammaRamp +// size: (((32 + xgb.Pad((((int(Size) + 1) & -2) * 2))) + xgb.Pad((((int(Size) + 1) & -2) * 2))) + xgb.Pad((((int(Size) + 1) & -2) * 2))) +type GetGammaRampReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Size uint16 + // padding: 22 bytes + Red []uint16 // size: xgb.Pad((((int(Size) + 1) & -2) * 2)) + Green []uint16 // size: xgb.Pad((((int(Size) + 1) & -2) * 2)) + Blue []uint16 // size: xgb.Pad((((int(Size) + 1) & -2) * 2)) +} + +// Waits and reads reply data from request GetGammaRamp +func (cook GetGammaRampCookie) Reply() (*GetGammaRampReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getGammaRampReply(buf), nil +} + +// Read reply into structure from buffer for GetGammaRamp +func getGammaRampReply(buf []byte) *GetGammaRampReply { + v := new(GetGammaRampReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Size = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + v.Red = make([]uint16, ((int(v.Size) + 1) & -2)) + for i := 0; i < int(((int(v.Size) + 1) & -2)); i++ { + v.Red[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) + + v.Green = make([]uint16, ((int(v.Size) + 1) & -2)) + for i := 0; i < int(((int(v.Size) + 1) & -2)); i++ { + v.Green[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) + + v.Blue = make([]uint16, ((int(v.Size) + 1) & -2)) + for i := 0; i < int(((int(v.Size) + 1) & -2)); i++ { + v.Blue[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetGammaRamp +func getGammaRampRequest(c *xgb.Conn, Screen uint16, Size uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 + + buf[b] = 17 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], Screen) + b += 2 + + xgb.Put16(buf[b:], Size) + b += 2 + + return buf +} + +// Request SetGammaRamp +// size: xgb.Pad((((8 + xgb.Pad((((int(Size) + 1) & -2) * 2))) + xgb.Pad((((int(Size) + 1) & -2) * 2))) + xgb.Pad((((int(Size) + 1) & -2) * 2)))) +type SetGammaRampCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetGammaRamp +func SetGammaRamp(c *xgb.Conn, Screen uint16, Size uint16, Red []uint16, Green []uint16, Blue []uint16) SetGammaRampCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setGammaRampRequest(c, Screen, Size, Red, Green, Blue), cookie) + return SetGammaRampCookie{cookie} +} + +func SetGammaRampChecked(c *xgb.Conn, Screen uint16, Size uint16, Red []uint16, Green []uint16, Blue []uint16) SetGammaRampCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setGammaRampRequest(c, Screen, Size, Red, Green, Blue), cookie) + return SetGammaRampCookie{cookie} +} + +func (cook SetGammaRampCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetGammaRamp +func setGammaRampRequest(c *xgb.Conn, Screen uint16, Size uint16, Red []uint16, Green []uint16, Blue []uint16) []byte { + size := xgb.Pad((((8 + xgb.Pad((((int(Size) + 1) & -2) * 2))) + xgb.Pad((((int(Size) + 1) & -2) * 2))) + xgb.Pad((((int(Size) + 1) & -2) * 2)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 + + buf[b] = 18 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], Screen) + b += 2 + + xgb.Put16(buf[b:], Size) + b += 2 + + for i := 0; i < int(((int(Size) + 1) & -2)); i++ { + xgb.Put16(buf[b:], Red[i]) + b += 2 + } + b = xgb.Pad(b) + + for i := 0; i < int(((int(Size) + 1) & -2)); i++ { + xgb.Put16(buf[b:], Green[i]) + b += 2 + } + b = xgb.Pad(b) + + for i := 0; i < int(((int(Size) + 1) & -2)); i++ { + xgb.Put16(buf[b:], Blue[i]) + b += 2 + } + b = xgb.Pad(b) + + return buf +} + +// Request GetGammaRampSize +// size: 8 +type GetGammaRampSizeCookie struct { + *xgb.Cookie +} + +func GetGammaRampSize(c *xgb.Conn, Screen uint16) GetGammaRampSizeCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getGammaRampSizeRequest(c, Screen), cookie) + return GetGammaRampSizeCookie{cookie} +} + +func GetGammaRampSizeUnchecked(c *xgb.Conn, Screen uint16) GetGammaRampSizeCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getGammaRampSizeRequest(c, Screen), cookie) + return GetGammaRampSizeCookie{cookie} +} + +// Request reply for GetGammaRampSize +// size: 32 +type GetGammaRampSizeReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Size uint16 + // padding: 22 bytes +} + +// Waits and reads reply data from request GetGammaRampSize +func (cook GetGammaRampSizeCookie) Reply() (*GetGammaRampSizeReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getGammaRampSizeReply(buf), nil +} + +// Read reply into structure from buffer for GetGammaRampSize +func getGammaRampSizeReply(buf []byte) *GetGammaRampSizeReply { + v := new(GetGammaRampSizeReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Size = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + return v +} + +// Write request to wire for GetGammaRampSize +func getGammaRampSizeRequest(c *xgb.Conn, Screen uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 + + buf[b] = 19 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], Screen) + b += 2 + + b += 2 // padding + + return buf +} + +// Request GetPermissions +// size: 8 +type GetPermissionsCookie struct { + *xgb.Cookie +} + +func GetPermissions(c *xgb.Conn, Screen uint16) GetPermissionsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getPermissionsRequest(c, Screen), cookie) + return GetPermissionsCookie{cookie} +} + +func GetPermissionsUnchecked(c *xgb.Conn, Screen uint16) GetPermissionsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getPermissionsRequest(c, Screen), cookie) + return GetPermissionsCookie{cookie} +} + +// Request reply for GetPermissions +// size: 32 +type GetPermissionsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Permissions uint32 + // padding: 20 bytes +} + +// Waits and reads reply data from request GetPermissions +func (cook GetPermissionsCookie) Reply() (*GetPermissionsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPermissionsReply(buf), nil +} + +// Read reply into structure from buffer for GetPermissions +func getPermissionsReply(buf []byte) *GetPermissionsReply { + v := new(GetPermissionsReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Permissions = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + return v +} + +// Write request to wire for GetPermissions +func getPermissionsRequest(c *xgb.Conn, Screen uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-VIDMODEEXTENSION"] + b += 1 + + buf[b] = 20 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], Screen) + b += 2 + + b += 2 // padding + + return buf +} diff --git a/nexgb/xfixes/xfixes.go b/nexgb/xfixes/xfixes.go new file mode 100644 index 0000000..7115e02 --- /dev/null +++ b/nexgb/xfixes/xfixes.go @@ -0,0 +1,2155 @@ +package xfixes + +/* + This file was generated by xfixes.xml on May 10 2012 4:20:28pm EDT. + This file is automatically generated. Edit at your peril! +*/ + +import ( + "github.com/BurntSushi/xgb" + + "github.com/BurntSushi/xgb/render" + "github.com/BurntSushi/xgb/shape" + "github.com/BurntSushi/xgb/xproto" +) + +// Init must be called before using the XFIXES extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 6, "XFIXES").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named XFIXES could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["XFIXES"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["XFIXES"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["XFIXES"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["XFIXES"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["XFIXES"] = make(map[int]xgb.NewErrorFun) +} + +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Bool' + +// Skipping definition for base type 'Float' + +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + +const ( + SaveSetModeInsert = 0 + SaveSetModeDelete = 1 +) + +const ( + SaveSetTargetNearest = 0 + SaveSetTargetRoot = 1 +) + +const ( + SaveSetMappingMap = 0 + SaveSetMappingUnmap = 1 +) + +const ( + SelectionEventSetSelectionOwner = 0 + SelectionEventSelectionWindowDestroy = 1 + SelectionEventSelectionClientClose = 2 +) + +const ( + SelectionEventMaskSetSelectionOwner = 1 + SelectionEventMaskSelectionWindowDestroy = 2 + SelectionEventMaskSelectionClientClose = 4 +) + +const ( + CursorNotifyDisplayCursor = 0 +) + +const ( + CursorNotifyMaskDisplayCursor = 1 +) + +const ( + RegionNone = 0 +) + +type Region uint32 + +func NewRegionId(c *xgb.Conn) (Region, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Region(id), nil +} + +// Event definition SelectionNotify (0) +// Size: 32 + +const SelectionNotify = 0 + +type SelectionNotifyEvent struct { + Sequence uint16 + Subtype byte + Window xproto.Window + Owner xproto.Window + Selection xproto.Atom + Timestamp xproto.Timestamp + SelectionTimestamp xproto.Timestamp + // padding: 8 bytes +} + +// Event read SelectionNotify +func SelectionNotifyEventNew(buf []byte) xgb.Event { + v := SelectionNotifyEvent{} + b := 1 // don't read event number + + v.Subtype = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Window = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.Owner = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.Selection = xproto.Atom(xgb.Get32(buf[b:])) + b += 4 + + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.SelectionTimestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + b += 8 // padding + + return v +} + +// Event write SelectionNotify +func (v SelectionNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 0 + b += 1 + + buf[b] = v.Subtype + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Owner)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Selection)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Timestamp)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.SelectionTimestamp)) + b += 4 + + b += 8 // padding + + return buf +} + +func (v SelectionNotifyEvent) ImplementsEvent() {} + +func (v SelectionNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v SelectionNotifyEvent) String() string { + fieldVals := make([]string, 0, 7) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Subtype: %d", v.Subtype)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("Owner: %d", v.Owner)) + fieldVals = append(fieldVals, xgb.Sprintf("Selection: %d", v.Selection)) + fieldVals = append(fieldVals, xgb.Sprintf("Timestamp: %d", v.Timestamp)) + fieldVals = append(fieldVals, xgb.Sprintf("SelectionTimestamp: %d", v.SelectionTimestamp)) + return "SelectionNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XFIXES"][0] = SelectionNotifyEventNew +} + +// Event definition CursorNotify (1) +// Size: 32 + +const CursorNotify = 1 + +type CursorNotifyEvent struct { + Sequence uint16 + Subtype byte + Window xproto.Window + CursorSerial uint32 + Timestamp xproto.Timestamp + Name xproto.Atom + // padding: 12 bytes +} + +// Event read CursorNotify +func CursorNotifyEventNew(buf []byte) xgb.Event { + v := CursorNotifyEvent{} + b := 1 // don't read event number + + v.Subtype = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Window = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.CursorSerial = xgb.Get32(buf[b:]) + b += 4 + + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Name = xproto.Atom(xgb.Get32(buf[b:])) + b += 4 + + b += 12 // padding + + return v +} + +// Event write CursorNotify +func (v CursorNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 1 + b += 1 + + buf[b] = v.Subtype + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + xgb.Put32(buf[b:], v.CursorSerial) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Timestamp)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Name)) + b += 4 + + b += 12 // padding + + return buf +} + +func (v CursorNotifyEvent) ImplementsEvent() {} + +func (v CursorNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v CursorNotifyEvent) String() string { + fieldVals := make([]string, 0, 6) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Subtype: %d", v.Subtype)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("CursorSerial: %d", v.CursorSerial)) + fieldVals = append(fieldVals, xgb.Sprintf("Timestamp: %d", v.Timestamp)) + fieldVals = append(fieldVals, xgb.Sprintf("Name: %d", v.Name)) + return "CursorNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XFIXES"][1] = CursorNotifyEventNew +} + +// Error definition BadRegion (0) +// Size: 32 + +const BadBadRegion = 0 + +type BadRegionError struct { + Sequence uint16 + NiceName string +} + +// Error read BadRegion +func BadRegionErrorNew(buf []byte) xgb.Error { + v := BadRegionError{} + v.NiceName = "BadRegion" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err BadRegionError) ImplementsError() {} + +func (err BadRegionError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadRegionError) BadId() uint32 { + return 0 +} + +func (err BadRegionError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadRegion {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XFIXES"][0] = BadRegionErrorNew +} + +// Request QueryVersion +// size: 12 +type QueryVersionCookie struct { + *xgb.Cookie +} + +func QueryVersion(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return QueryVersionCookie{cookie} +} + +func QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return QueryVersionCookie{cookie} +} + +// Request reply for QueryVersion +// size: 32 +type QueryVersionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + MajorVersion uint32 + MinorVersion uint32 + // padding: 16 bytes +} + +// Waits and reads reply data from request QueryVersion +func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryVersionReply(buf), nil +} + +// Read reply into structure from buffer for QueryVersion +func queryVersionReply(buf []byte) *QueryVersionReply { + v := new(QueryVersionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.MajorVersion = xgb.Get32(buf[b:]) + b += 4 + + v.MinorVersion = xgb.Get32(buf[b:]) + b += 4 + + b += 16 // padding + + return v +} + +// Write request to wire for QueryVersion +func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 0 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], ClientMajorVersion) + b += 4 + + xgb.Put32(buf[b:], ClientMinorVersion) + b += 4 + + return buf +} + +// Request ChangeSaveSet +// size: 12 +type ChangeSaveSetCookie struct { + *xgb.Cookie +} + +// Write request to wire for ChangeSaveSet +func ChangeSaveSet(c *xgb.Conn, Mode byte, Target byte, Map byte, Window xproto.Window) ChangeSaveSetCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeSaveSetRequest(c, Mode, Target, Map, Window), cookie) + return ChangeSaveSetCookie{cookie} +} + +func ChangeSaveSetChecked(c *xgb.Conn, Mode byte, Target byte, Map byte, Window xproto.Window) ChangeSaveSetCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeSaveSetRequest(c, Mode, Target, Map, Window), cookie) + return ChangeSaveSetCookie{cookie} +} + +func (cook ChangeSaveSetCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangeSaveSet +func changeSaveSetRequest(c *xgb.Conn, Mode byte, Target byte, Map byte, Window xproto.Window) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 1 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = Mode + b += 1 + + buf[b] = Target + b += 1 + + buf[b] = Map + b += 1 + + b += 1 // padding + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + +// Request SelectSelectionInput +// size: 16 +type SelectSelectionInputCookie struct { + *xgb.Cookie +} + +// Write request to wire for SelectSelectionInput +func SelectSelectionInput(c *xgb.Conn, Window xproto.Window, Selection xproto.Atom, EventMask uint32) SelectSelectionInputCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(selectSelectionInputRequest(c, Window, Selection, EventMask), cookie) + return SelectSelectionInputCookie{cookie} +} + +func SelectSelectionInputChecked(c *xgb.Conn, Window xproto.Window, Selection xproto.Atom, EventMask uint32) SelectSelectionInputCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(selectSelectionInputRequest(c, Window, Selection, EventMask), cookie) + return SelectSelectionInputCookie{cookie} +} + +func (cook SelectSelectionInputCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SelectSelectionInput +func selectSelectionInputRequest(c *xgb.Conn, Window xproto.Window, Selection xproto.Atom, EventMask uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 2 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(Selection)) + b += 4 + + xgb.Put32(buf[b:], EventMask) + b += 4 + + return buf +} + +// Request SelectCursorInput +// size: 12 +type SelectCursorInputCookie struct { + *xgb.Cookie +} + +// Write request to wire for SelectCursorInput +func SelectCursorInput(c *xgb.Conn, Window xproto.Window, EventMask uint32) SelectCursorInputCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(selectCursorInputRequest(c, Window, EventMask), cookie) + return SelectCursorInputCookie{cookie} +} + +func SelectCursorInputChecked(c *xgb.Conn, Window xproto.Window, EventMask uint32) SelectCursorInputCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(selectCursorInputRequest(c, Window, EventMask), cookie) + return SelectCursorInputCookie{cookie} +} + +func (cook SelectCursorInputCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SelectCursorInput +func selectCursorInputRequest(c *xgb.Conn, Window xproto.Window, EventMask uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 3 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put32(buf[b:], EventMask) + b += 4 + + return buf +} + +// Request GetCursorImage +// size: 4 +type GetCursorImageCookie struct { + *xgb.Cookie +} + +func GetCursorImage(c *xgb.Conn) GetCursorImageCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getCursorImageRequest(c), cookie) + return GetCursorImageCookie{cookie} +} + +func GetCursorImageUnchecked(c *xgb.Conn) GetCursorImageCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getCursorImageRequest(c), cookie) + return GetCursorImageCookie{cookie} +} + +// Request reply for GetCursorImage +// size: (32 + xgb.Pad(((int(Width) * int(Height)) * 4))) +type GetCursorImageReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + X int16 + Y int16 + Width uint16 + Height uint16 + Xhot uint16 + Yhot uint16 + CursorSerial uint32 + // padding: 8 bytes + CursorImage []uint32 // size: xgb.Pad(((int(Width) * int(Height)) * 4)) +} + +// Waits and reads reply data from request GetCursorImage +func (cook GetCursorImageCookie) Reply() (*GetCursorImageReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getCursorImageReply(buf), nil +} + +// Read reply into structure from buffer for GetCursorImage +func getCursorImageReply(buf []byte) *GetCursorImageReply { + v := new(GetCursorImageReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.Xhot = xgb.Get16(buf[b:]) + b += 2 + + v.Yhot = xgb.Get16(buf[b:]) + b += 2 + + v.CursorSerial = xgb.Get32(buf[b:]) + b += 4 + + b += 8 // padding + + v.CursorImage = make([]uint32, (int(v.Width) * int(v.Height))) + for i := 0; i < int((int(v.Width) * int(v.Height))); i++ { + v.CursorImage[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetCursorImage +func getCursorImageRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 4 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request CreateRegion +// size: xgb.Pad((8 + xgb.Pad((len(Rectangles) * 8)))) +type CreateRegionCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateRegion +func CreateRegion(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) CreateRegionCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createRegionRequest(c, Region, Rectangles), cookie) + return CreateRegionCookie{cookie} +} + +func CreateRegionChecked(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) CreateRegionCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createRegionRequest(c, Region, Rectangles), cookie) + return CreateRegionCookie{cookie} +} + +func (cook CreateRegionCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateRegion +func createRegionRequest(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) []byte { + size := xgb.Pad((8 + xgb.Pad((len(Rectangles) * 8)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 5 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Region)) + b += 4 + + b += xproto.RectangleListBytes(buf[b:], Rectangles) + + return buf +} + +// Request CreateRegionFromBitmap +// size: 12 +type CreateRegionFromBitmapCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateRegionFromBitmap +func CreateRegionFromBitmap(c *xgb.Conn, Region Region, Bitmap xproto.Pixmap) CreateRegionFromBitmapCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createRegionFromBitmapRequest(c, Region, Bitmap), cookie) + return CreateRegionFromBitmapCookie{cookie} +} + +func CreateRegionFromBitmapChecked(c *xgb.Conn, Region Region, Bitmap xproto.Pixmap) CreateRegionFromBitmapCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createRegionFromBitmapRequest(c, Region, Bitmap), cookie) + return CreateRegionFromBitmapCookie{cookie} +} + +func (cook CreateRegionFromBitmapCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateRegionFromBitmap +func createRegionFromBitmapRequest(c *xgb.Conn, Region Region, Bitmap xproto.Pixmap) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 6 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Region)) + b += 4 + + xgb.Put32(buf[b:], uint32(Bitmap)) + b += 4 + + return buf +} + +// Request CreateRegionFromWindow +// size: 16 +type CreateRegionFromWindowCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateRegionFromWindow +func CreateRegionFromWindow(c *xgb.Conn, Region Region, Window xproto.Window, Kind shape.Kind) CreateRegionFromWindowCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createRegionFromWindowRequest(c, Region, Window, Kind), cookie) + return CreateRegionFromWindowCookie{cookie} +} + +func CreateRegionFromWindowChecked(c *xgb.Conn, Region Region, Window xproto.Window, Kind shape.Kind) CreateRegionFromWindowCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createRegionFromWindowRequest(c, Region, Window, Kind), cookie) + return CreateRegionFromWindowCookie{cookie} +} + +func (cook CreateRegionFromWindowCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateRegionFromWindow +func createRegionFromWindowRequest(c *xgb.Conn, Region Region, Window xproto.Window, Kind shape.Kind) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 7 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Region)) + b += 4 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + buf[b] = byte(Kind) + b += 1 + + b += 3 // padding + + return buf +} + +// Request CreateRegionFromGC +// size: 12 +type CreateRegionFromGCCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateRegionFromGC +func CreateRegionFromGC(c *xgb.Conn, Region Region, Gc xproto.Gcontext) CreateRegionFromGCCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createRegionFromGCRequest(c, Region, Gc), cookie) + return CreateRegionFromGCCookie{cookie} +} + +func CreateRegionFromGCChecked(c *xgb.Conn, Region Region, Gc xproto.Gcontext) CreateRegionFromGCCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createRegionFromGCRequest(c, Region, Gc), cookie) + return CreateRegionFromGCCookie{cookie} +} + +func (cook CreateRegionFromGCCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateRegionFromGC +func createRegionFromGCRequest(c *xgb.Conn, Region Region, Gc xproto.Gcontext) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 8 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Region)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + return buf +} + +// Request CreateRegionFromPicture +// size: 12 +type CreateRegionFromPictureCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateRegionFromPicture +func CreateRegionFromPicture(c *xgb.Conn, Region Region, Picture render.Picture) CreateRegionFromPictureCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createRegionFromPictureRequest(c, Region, Picture), cookie) + return CreateRegionFromPictureCookie{cookie} +} + +func CreateRegionFromPictureChecked(c *xgb.Conn, Region Region, Picture render.Picture) CreateRegionFromPictureCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createRegionFromPictureRequest(c, Region, Picture), cookie) + return CreateRegionFromPictureCookie{cookie} +} + +func (cook CreateRegionFromPictureCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateRegionFromPicture +func createRegionFromPictureRequest(c *xgb.Conn, Region Region, Picture render.Picture) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 9 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Region)) + b += 4 + + xgb.Put32(buf[b:], uint32(Picture)) + b += 4 + + return buf +} + +// Request DestroyRegion +// size: 8 +type DestroyRegionCookie struct { + *xgb.Cookie +} + +// Write request to wire for DestroyRegion +func DestroyRegion(c *xgb.Conn, Region Region) DestroyRegionCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroyRegionRequest(c, Region), cookie) + return DestroyRegionCookie{cookie} +} + +func DestroyRegionChecked(c *xgb.Conn, Region Region) DestroyRegionCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(destroyRegionRequest(c, Region), cookie) + return DestroyRegionCookie{cookie} +} + +func (cook DestroyRegionCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DestroyRegion +func destroyRegionRequest(c *xgb.Conn, Region Region) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 10 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Region)) + b += 4 + + return buf +} + +// Request SetRegion +// size: xgb.Pad((8 + xgb.Pad((len(Rectangles) * 8)))) +type SetRegionCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetRegion +func SetRegion(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) SetRegionCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setRegionRequest(c, Region, Rectangles), cookie) + return SetRegionCookie{cookie} +} + +func SetRegionChecked(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) SetRegionCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setRegionRequest(c, Region, Rectangles), cookie) + return SetRegionCookie{cookie} +} + +func (cook SetRegionCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetRegion +func setRegionRequest(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) []byte { + size := xgb.Pad((8 + xgb.Pad((len(Rectangles) * 8)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 11 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Region)) + b += 4 + + b += xproto.RectangleListBytes(buf[b:], Rectangles) + + return buf +} + +// Request CopyRegion +// size: 12 +type CopyRegionCookie struct { + *xgb.Cookie +} + +// Write request to wire for CopyRegion +func CopyRegion(c *xgb.Conn, Source Region, Destination Region) CopyRegionCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(copyRegionRequest(c, Source, Destination), cookie) + return CopyRegionCookie{cookie} +} + +func CopyRegionChecked(c *xgb.Conn, Source Region, Destination Region) CopyRegionCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(copyRegionRequest(c, Source, Destination), cookie) + return CopyRegionCookie{cookie} +} + +func (cook CopyRegionCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CopyRegion +func copyRegionRequest(c *xgb.Conn, Source Region, Destination Region) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 12 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Source)) + b += 4 + + xgb.Put32(buf[b:], uint32(Destination)) + b += 4 + + return buf +} + +// Request UnionRegion +// size: 16 +type UnionRegionCookie struct { + *xgb.Cookie +} + +// Write request to wire for UnionRegion +func UnionRegion(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) UnionRegionCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(unionRegionRequest(c, Source1, Source2, Destination), cookie) + return UnionRegionCookie{cookie} +} + +func UnionRegionChecked(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) UnionRegionCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(unionRegionRequest(c, Source1, Source2, Destination), cookie) + return UnionRegionCookie{cookie} +} + +func (cook UnionRegionCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for UnionRegion +func unionRegionRequest(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 13 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Source1)) + b += 4 + + xgb.Put32(buf[b:], uint32(Source2)) + b += 4 + + xgb.Put32(buf[b:], uint32(Destination)) + b += 4 + + return buf +} + +// Request IntersectRegion +// size: 16 +type IntersectRegionCookie struct { + *xgb.Cookie +} + +// Write request to wire for IntersectRegion +func IntersectRegion(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) IntersectRegionCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(intersectRegionRequest(c, Source1, Source2, Destination), cookie) + return IntersectRegionCookie{cookie} +} + +func IntersectRegionChecked(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) IntersectRegionCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(intersectRegionRequest(c, Source1, Source2, Destination), cookie) + return IntersectRegionCookie{cookie} +} + +func (cook IntersectRegionCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for IntersectRegion +func intersectRegionRequest(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 14 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Source1)) + b += 4 + + xgb.Put32(buf[b:], uint32(Source2)) + b += 4 + + xgb.Put32(buf[b:], uint32(Destination)) + b += 4 + + return buf +} + +// Request SubtractRegion +// size: 16 +type SubtractRegionCookie struct { + *xgb.Cookie +} + +// Write request to wire for SubtractRegion +func SubtractRegion(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) SubtractRegionCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(subtractRegionRequest(c, Source1, Source2, Destination), cookie) + return SubtractRegionCookie{cookie} +} + +func SubtractRegionChecked(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) SubtractRegionCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(subtractRegionRequest(c, Source1, Source2, Destination), cookie) + return SubtractRegionCookie{cookie} +} + +func (cook SubtractRegionCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SubtractRegion +func subtractRegionRequest(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 15 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Source1)) + b += 4 + + xgb.Put32(buf[b:], uint32(Source2)) + b += 4 + + xgb.Put32(buf[b:], uint32(Destination)) + b += 4 + + return buf +} + +// Request InvertRegion +// size: 20 +type InvertRegionCookie struct { + *xgb.Cookie +} + +// Write request to wire for InvertRegion +func InvertRegion(c *xgb.Conn, Source Region, Bounds xproto.Rectangle, Destination Region) InvertRegionCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(invertRegionRequest(c, Source, Bounds, Destination), cookie) + return InvertRegionCookie{cookie} +} + +func InvertRegionChecked(c *xgb.Conn, Source Region, Bounds xproto.Rectangle, Destination Region) InvertRegionCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(invertRegionRequest(c, Source, Bounds, Destination), cookie) + return InvertRegionCookie{cookie} +} + +func (cook InvertRegionCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for InvertRegion +func invertRegionRequest(c *xgb.Conn, Source Region, Bounds xproto.Rectangle, Destination Region) []byte { + size := 20 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 16 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Source)) + b += 4 + + { + structBytes := Bounds.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + xgb.Put32(buf[b:], uint32(Destination)) + b += 4 + + return buf +} + +// Request TranslateRegion +// size: 12 +type TranslateRegionCookie struct { + *xgb.Cookie +} + +// Write request to wire for TranslateRegion +func TranslateRegion(c *xgb.Conn, Region Region, Dx int16, Dy int16) TranslateRegionCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(translateRegionRequest(c, Region, Dx, Dy), cookie) + return TranslateRegionCookie{cookie} +} + +func TranslateRegionChecked(c *xgb.Conn, Region Region, Dx int16, Dy int16) TranslateRegionCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(translateRegionRequest(c, Region, Dx, Dy), cookie) + return TranslateRegionCookie{cookie} +} + +func (cook TranslateRegionCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for TranslateRegion +func translateRegionRequest(c *xgb.Conn, Region Region, Dx int16, Dy int16) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 17 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Region)) + b += 4 + + xgb.Put16(buf[b:], uint16(Dx)) + b += 2 + + xgb.Put16(buf[b:], uint16(Dy)) + b += 2 + + return buf +} + +// Request RegionExtents +// size: 12 +type RegionExtentsCookie struct { + *xgb.Cookie +} + +// Write request to wire for RegionExtents +func RegionExtents(c *xgb.Conn, Source Region, Destination Region) RegionExtentsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(regionExtentsRequest(c, Source, Destination), cookie) + return RegionExtentsCookie{cookie} +} + +func RegionExtentsChecked(c *xgb.Conn, Source Region, Destination Region) RegionExtentsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(regionExtentsRequest(c, Source, Destination), cookie) + return RegionExtentsCookie{cookie} +} + +func (cook RegionExtentsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for RegionExtents +func regionExtentsRequest(c *xgb.Conn, Source Region, Destination Region) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 18 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Source)) + b += 4 + + xgb.Put32(buf[b:], uint32(Destination)) + b += 4 + + return buf +} + +// Request FetchRegion +// size: 8 +type FetchRegionCookie struct { + *xgb.Cookie +} + +func FetchRegion(c *xgb.Conn, Region Region) FetchRegionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(fetchRegionRequest(c, Region), cookie) + return FetchRegionCookie{cookie} +} + +func FetchRegionUnchecked(c *xgb.Conn, Region Region) FetchRegionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(fetchRegionRequest(c, Region), cookie) + return FetchRegionCookie{cookie} +} + +// Request reply for FetchRegion +// size: (32 + xgb.Pad(((int(Length) / 2) * 8))) +type FetchRegionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Extents xproto.Rectangle + // padding: 16 bytes + Rectangles []xproto.Rectangle // size: xgb.Pad(((int(Length) / 2) * 8)) +} + +// Waits and reads reply data from request FetchRegion +func (cook FetchRegionCookie) Reply() (*FetchRegionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return fetchRegionReply(buf), nil +} + +// Read reply into structure from buffer for FetchRegion +func fetchRegionReply(buf []byte) *FetchRegionReply { + v := new(FetchRegionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Extents = xproto.Rectangle{} + b += xproto.RectangleRead(buf[b:], &v.Extents) + + b += 16 // padding + + v.Rectangles = make([]xproto.Rectangle, (int(v.Length) / 2)) + b += xproto.RectangleReadList(buf[b:], v.Rectangles) + + return v +} + +// Write request to wire for FetchRegion +func fetchRegionRequest(c *xgb.Conn, Region Region) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 19 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Region)) + b += 4 + + return buf +} + +// Request SetGCClipRegion +// size: 16 +type SetGCClipRegionCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetGCClipRegion +func SetGCClipRegion(c *xgb.Conn, Gc xproto.Gcontext, Region Region, XOrigin int16, YOrigin int16) SetGCClipRegionCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setGCClipRegionRequest(c, Gc, Region, XOrigin, YOrigin), cookie) + return SetGCClipRegionCookie{cookie} +} + +func SetGCClipRegionChecked(c *xgb.Conn, Gc xproto.Gcontext, Region Region, XOrigin int16, YOrigin int16) SetGCClipRegionCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setGCClipRegionRequest(c, Gc, Region, XOrigin, YOrigin), cookie) + return SetGCClipRegionCookie{cookie} +} + +func (cook SetGCClipRegionCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetGCClipRegion +func setGCClipRegionRequest(c *xgb.Conn, Gc xproto.Gcontext, Region Region, XOrigin int16, YOrigin int16) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 20 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put32(buf[b:], uint32(Region)) + b += 4 + + xgb.Put16(buf[b:], uint16(XOrigin)) + b += 2 + + xgb.Put16(buf[b:], uint16(YOrigin)) + b += 2 + + return buf +} + +// Request SetWindowShapeRegion +// size: 20 +type SetWindowShapeRegionCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetWindowShapeRegion +func SetWindowShapeRegion(c *xgb.Conn, Dest xproto.Window, DestKind shape.Kind, XOffset int16, YOffset int16, Region Region) SetWindowShapeRegionCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setWindowShapeRegionRequest(c, Dest, DestKind, XOffset, YOffset, Region), cookie) + return SetWindowShapeRegionCookie{cookie} +} + +func SetWindowShapeRegionChecked(c *xgb.Conn, Dest xproto.Window, DestKind shape.Kind, XOffset int16, YOffset int16, Region Region) SetWindowShapeRegionCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setWindowShapeRegionRequest(c, Dest, DestKind, XOffset, YOffset, Region), cookie) + return SetWindowShapeRegionCookie{cookie} +} + +func (cook SetWindowShapeRegionCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetWindowShapeRegion +func setWindowShapeRegionRequest(c *xgb.Conn, Dest xproto.Window, DestKind shape.Kind, XOffset int16, YOffset int16, Region Region) []byte { + size := 20 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 21 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Dest)) + b += 4 + + buf[b] = byte(DestKind) + b += 1 + + b += 3 // padding + + xgb.Put16(buf[b:], uint16(XOffset)) + b += 2 + + xgb.Put16(buf[b:], uint16(YOffset)) + b += 2 + + xgb.Put32(buf[b:], uint32(Region)) + b += 4 + + return buf +} + +// Request SetPictureClipRegion +// size: 16 +type SetPictureClipRegionCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetPictureClipRegion +func SetPictureClipRegion(c *xgb.Conn, Picture render.Picture, Region Region, XOrigin int16, YOrigin int16) SetPictureClipRegionCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setPictureClipRegionRequest(c, Picture, Region, XOrigin, YOrigin), cookie) + return SetPictureClipRegionCookie{cookie} +} + +func SetPictureClipRegionChecked(c *xgb.Conn, Picture render.Picture, Region Region, XOrigin int16, YOrigin int16) SetPictureClipRegionCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setPictureClipRegionRequest(c, Picture, Region, XOrigin, YOrigin), cookie) + return SetPictureClipRegionCookie{cookie} +} + +func (cook SetPictureClipRegionCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetPictureClipRegion +func setPictureClipRegionRequest(c *xgb.Conn, Picture render.Picture, Region Region, XOrigin int16, YOrigin int16) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 22 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Picture)) + b += 4 + + xgb.Put32(buf[b:], uint32(Region)) + b += 4 + + xgb.Put16(buf[b:], uint16(XOrigin)) + b += 2 + + xgb.Put16(buf[b:], uint16(YOrigin)) + b += 2 + + return buf +} + +// Request SetCursorName +// size: xgb.Pad((12 + xgb.Pad((int(Nbytes) * 1)))) +type SetCursorNameCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetCursorName +func SetCursorName(c *xgb.Conn, Cursor xproto.Cursor, Nbytes uint16, Name string) SetCursorNameCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setCursorNameRequest(c, Cursor, Nbytes, Name), cookie) + return SetCursorNameCookie{cookie} +} + +func SetCursorNameChecked(c *xgb.Conn, Cursor xproto.Cursor, Nbytes uint16, Name string) SetCursorNameCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setCursorNameRequest(c, Cursor, Nbytes, Name), cookie) + return SetCursorNameCookie{cookie} +} + +func (cook SetCursorNameCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetCursorName +func setCursorNameRequest(c *xgb.Conn, Cursor xproto.Cursor, Nbytes uint16, Name string) []byte { + size := xgb.Pad((12 + xgb.Pad((int(Nbytes) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 23 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cursor)) + b += 4 + + xgb.Put16(buf[b:], Nbytes) + b += 2 + + b += 2 // padding + + copy(buf[b:], Name[:Nbytes]) + b += xgb.Pad(int(Nbytes)) + + return buf +} + +// Request GetCursorName +// size: 8 +type GetCursorNameCookie struct { + *xgb.Cookie +} + +func GetCursorName(c *xgb.Conn, Cursor xproto.Cursor) GetCursorNameCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getCursorNameRequest(c, Cursor), cookie) + return GetCursorNameCookie{cookie} +} + +func GetCursorNameUnchecked(c *xgb.Conn, Cursor xproto.Cursor) GetCursorNameCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getCursorNameRequest(c, Cursor), cookie) + return GetCursorNameCookie{cookie} +} + +// Request reply for GetCursorName +// size: (32 + xgb.Pad((int(Nbytes) * 1))) +type GetCursorNameReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Atom xproto.Atom + Nbytes uint16 + // padding: 18 bytes + Name string // size: xgb.Pad((int(Nbytes) * 1)) +} + +// Waits and reads reply data from request GetCursorName +func (cook GetCursorNameCookie) Reply() (*GetCursorNameReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getCursorNameReply(buf), nil +} + +// Read reply into structure from buffer for GetCursorName +func getCursorNameReply(buf []byte) *GetCursorNameReply { + v := new(GetCursorNameReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Atom = xproto.Atom(xgb.Get32(buf[b:])) + b += 4 + + v.Nbytes = xgb.Get16(buf[b:]) + b += 2 + + b += 18 // padding + + { + byteString := make([]byte, v.Nbytes) + copy(byteString[:v.Nbytes], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.Nbytes)) + } + + return v +} + +// Write request to wire for GetCursorName +func getCursorNameRequest(c *xgb.Conn, Cursor xproto.Cursor) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 24 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cursor)) + b += 4 + + return buf +} + +// Request GetCursorImageAndName +// size: 4 +type GetCursorImageAndNameCookie struct { + *xgb.Cookie +} + +func GetCursorImageAndName(c *xgb.Conn) GetCursorImageAndNameCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getCursorImageAndNameRequest(c), cookie) + return GetCursorImageAndNameCookie{cookie} +} + +func GetCursorImageAndNameUnchecked(c *xgb.Conn) GetCursorImageAndNameCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getCursorImageAndNameRequest(c), cookie) + return GetCursorImageAndNameCookie{cookie} +} + +// Request reply for GetCursorImageAndName +// size: ((32 + xgb.Pad((int(Nbytes) * 1))) + xgb.Pad(((int(Width) * int(Height)) * 4))) +type GetCursorImageAndNameReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + X int16 + Y int16 + Width uint16 + Height uint16 + Xhot uint16 + Yhot uint16 + CursorSerial uint32 + CursorAtom xproto.Atom + Nbytes uint16 + // padding: 2 bytes + Name string // size: xgb.Pad((int(Nbytes) * 1)) + CursorImage []uint32 // size: xgb.Pad(((int(Width) * int(Height)) * 4)) +} + +// Waits and reads reply data from request GetCursorImageAndName +func (cook GetCursorImageAndNameCookie) Reply() (*GetCursorImageAndNameReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getCursorImageAndNameReply(buf), nil +} + +// Read reply into structure from buffer for GetCursorImageAndName +func getCursorImageAndNameReply(buf []byte) *GetCursorImageAndNameReply { + v := new(GetCursorImageAndNameReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.Xhot = xgb.Get16(buf[b:]) + b += 2 + + v.Yhot = xgb.Get16(buf[b:]) + b += 2 + + v.CursorSerial = xgb.Get32(buf[b:]) + b += 4 + + v.CursorAtom = xproto.Atom(xgb.Get32(buf[b:])) + b += 4 + + v.Nbytes = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + { + byteString := make([]byte, v.Nbytes) + copy(byteString[:v.Nbytes], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.Nbytes)) + } + + v.CursorImage = make([]uint32, (int(v.Width) * int(v.Height))) + for i := 0; i < int((int(v.Width) * int(v.Height))); i++ { + v.CursorImage[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetCursorImageAndName +func getCursorImageAndNameRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 25 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request ChangeCursor +// size: 12 +type ChangeCursorCookie struct { + *xgb.Cookie +} + +// Write request to wire for ChangeCursor +func ChangeCursor(c *xgb.Conn, Source xproto.Cursor, Destination xproto.Cursor) ChangeCursorCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeCursorRequest(c, Source, Destination), cookie) + return ChangeCursorCookie{cookie} +} + +func ChangeCursorChecked(c *xgb.Conn, Source xproto.Cursor, Destination xproto.Cursor) ChangeCursorCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeCursorRequest(c, Source, Destination), cookie) + return ChangeCursorCookie{cookie} +} + +func (cook ChangeCursorCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangeCursor +func changeCursorRequest(c *xgb.Conn, Source xproto.Cursor, Destination xproto.Cursor) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 26 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Source)) + b += 4 + + xgb.Put32(buf[b:], uint32(Destination)) + b += 4 + + return buf +} + +// Request ChangeCursorByName +// size: xgb.Pad((12 + xgb.Pad((int(Nbytes) * 1)))) +type ChangeCursorByNameCookie struct { + *xgb.Cookie +} + +// Write request to wire for ChangeCursorByName +func ChangeCursorByName(c *xgb.Conn, Src xproto.Cursor, Nbytes uint16, Name string) ChangeCursorByNameCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeCursorByNameRequest(c, Src, Nbytes, Name), cookie) + return ChangeCursorByNameCookie{cookie} +} + +func ChangeCursorByNameChecked(c *xgb.Conn, Src xproto.Cursor, Nbytes uint16, Name string) ChangeCursorByNameCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeCursorByNameRequest(c, Src, Nbytes, Name), cookie) + return ChangeCursorByNameCookie{cookie} +} + +func (cook ChangeCursorByNameCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangeCursorByName +func changeCursorByNameRequest(c *xgb.Conn, Src xproto.Cursor, Nbytes uint16, Name string) []byte { + size := xgb.Pad((12 + xgb.Pad((int(Nbytes) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 27 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Src)) + b += 4 + + xgb.Put16(buf[b:], Nbytes) + b += 2 + + b += 2 // padding + + copy(buf[b:], Name[:Nbytes]) + b += xgb.Pad(int(Nbytes)) + + return buf +} + +// Request ExpandRegion +// size: 20 +type ExpandRegionCookie struct { + *xgb.Cookie +} + +// Write request to wire for ExpandRegion +func ExpandRegion(c *xgb.Conn, Source Region, Destination Region, Left uint16, Right uint16, Top uint16, Bottom uint16) ExpandRegionCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(expandRegionRequest(c, Source, Destination, Left, Right, Top, Bottom), cookie) + return ExpandRegionCookie{cookie} +} + +func ExpandRegionChecked(c *xgb.Conn, Source Region, Destination Region, Left uint16, Right uint16, Top uint16, Bottom uint16) ExpandRegionCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(expandRegionRequest(c, Source, Destination, Left, Right, Top, Bottom), cookie) + return ExpandRegionCookie{cookie} +} + +func (cook ExpandRegionCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ExpandRegion +func expandRegionRequest(c *xgb.Conn, Source Region, Destination Region, Left uint16, Right uint16, Top uint16, Bottom uint16) []byte { + size := 20 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 28 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Source)) + b += 4 + + xgb.Put32(buf[b:], uint32(Destination)) + b += 4 + + xgb.Put16(buf[b:], Left) + b += 2 + + xgb.Put16(buf[b:], Right) + b += 2 + + xgb.Put16(buf[b:], Top) + b += 2 + + xgb.Put16(buf[b:], Bottom) + b += 2 + + return buf +} + +// Request HideCursor +// size: 8 +type HideCursorCookie struct { + *xgb.Cookie +} + +// Write request to wire for HideCursor +func HideCursor(c *xgb.Conn, Window xproto.Window) HideCursorCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(hideCursorRequest(c, Window), cookie) + return HideCursorCookie{cookie} +} + +func HideCursorChecked(c *xgb.Conn, Window xproto.Window) HideCursorCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(hideCursorRequest(c, Window), cookie) + return HideCursorCookie{cookie} +} + +func (cook HideCursorCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for HideCursor +func hideCursorRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 29 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + +// Request ShowCursor +// size: 8 +type ShowCursorCookie struct { + *xgb.Cookie +} + +// Write request to wire for ShowCursor +func ShowCursor(c *xgb.Conn, Window xproto.Window) ShowCursorCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(showCursorRequest(c, Window), cookie) + return ShowCursorCookie{cookie} +} + +func ShowCursorChecked(c *xgb.Conn, Window xproto.Window) ShowCursorCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(showCursorRequest(c, Window), cookie) + return ShowCursorCookie{cookie} +} + +func (cook ShowCursorCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ShowCursor +func showCursorRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFIXES"] + b += 1 + + buf[b] = 30 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} diff --git a/nexgb/xgb.go b/nexgb/xgb.go index 6a71187..75af854 100644 --- a/nexgb/xgb.go +++ b/nexgb/xgb.go @@ -9,7 +9,14 @@ import ( "sync" ) -var logger = log.New(os.Stderr, "XGB: ", 0) +var ( + logger = log.New(os.Stderr, "XGB: ", 0) + + // ExtLock is a lock used whenever new extensions are initialized. + // It should not be used. It is exported for use in the extension + // sub-packages. + ExtLock sync.Mutex +) const ( // cookieBuffer represents the queue size of cookies existing at any @@ -44,17 +51,21 @@ type Conn struct { host string conn net.Conn display string - defaultScreen int - Setup SetupInfo + DefaultScreen int + SetupBytes []byte + + setupResourceIdBase uint32 + setupResourceIdMask uint32 eventChan chan eventOrError - cookieChan chan *cookie + cookieChan chan *Cookie xidChan chan xid seqChan chan uint16 reqChan chan *request - extLock sync.Mutex - extensions map[string]byte + // Extensions is a map from extension name to major opcode. It should + // not be used. It is exported for use in the extension sub-packages. + Extensions map[string]byte } // NewConn creates a new connection instance. It initializes locks, data @@ -83,9 +94,9 @@ func NewConnDisplay(display string) (*Conn, error) { return nil, err } - conn.extensions = make(map[string]byte) + conn.Extensions = make(map[string]byte) - conn.cookieChan = make(chan *cookie, cookieBuffer) + conn.cookieChan = make(chan *Cookie, cookieBuffer) conn.xidChan = make(chan xid, xidBuffer) conn.seqChan = make(chan uint16, seqBuffer) conn.reqChan = make(chan *request, reqBuffer) @@ -104,12 +115,6 @@ func (c *Conn) Close() { c.conn.Close() } -// DefaultScreen returns the Screen info for the default screen, which is -// 0 or the one given in the display argument to Dial. -func (c *Conn) DefaultScreen() *ScreenInfo { - return &c.Setup.Roots[c.defaultScreen] -} - // Event is an interface that can contain any of the events returned by the // server. Use a type assertion switch to extract the Event structs. type Event interface { @@ -118,16 +123,20 @@ type Event interface { String() string } -type newEventFun func(buf []byte) Event +// NewEventFun is the type of function use to construct events from raw bytes. +// It should not be used. It is exported for use in the extension sub-packages. +type NewEventFun func(buf []byte) Event -// newEventFuncs is a map from event numbers to functions that create -// the corresponding event. -var newEventFuncs = make(map[int]newEventFun) +// NewEventFuncs is a map from event numbers to functions that create +// the corresponding event. It should not be used. It is exported for use +// in the extension sub-packages. +var NewEventFuncs = make(map[int]NewEventFun) -// newExtEventFuncs is a temporary map that stores event constructor functions +// NewExtEventFuncs is a temporary map that stores event constructor functions // for each extension. When an extension is initialized, each event for that -// extension is added to the 'newEventFuncs' map. -var newExtEventFuncs = make(map[string]map[int]newEventFun) +// extension is added to the 'NewEventFuncs' map. It should not be used. It is +// exported for use in the extension sub-packages. +var NewExtEventFuncs = make(map[string]map[int]NewEventFun) // Error is an interface that can contain any of the errors returned by // the server. Use a type assertion switch to extract the Error structs. @@ -138,16 +147,20 @@ type Error interface { Error() string } -type newErrorFun func(buf []byte) Error +// NewErrorFun is the type of function use to construct errors from raw bytes. +// It should not be used. It is exported for use in the extension sub-packages. +type NewErrorFun func(buf []byte) Error -// newErrorFuncs is a map from error numbers to functions that create -// the corresponding error. -var newErrorFuncs = make(map[int]newErrorFun) +// NewErrorFuncs is a map from error numbers to functions that create +// the corresponding error. It should not be used. It is exported for use in +// the extension sub-packages. +var NewErrorFuncs = make(map[int]NewErrorFun) -// newExtErrorFuncs is a temporary map that stores error constructor functions +// NewExtErrorFuncs is a temporary map that stores error constructor functions // for each extension. When an extension is initialized, each error for that -// extension is added to the 'newErrorFuncs' map. -var newExtErrorFuncs = make(map[string]map[int]newErrorFun) +// extension is added to the 'NewErrorFuncs' map. It should not be used. It is +// exported for use in the extension sub-packages. +var NewExtErrorFuncs = make(map[string]map[int]NewErrorFun) // eventOrError corresponds to values that can be either an event or an // error. @@ -194,8 +207,8 @@ func (conn *Conn) generateXIds() { // 00111000 & 11001000 = 00001000. // And we use that value to increment the last resource id to get a new one. // (And then, of course, we OR it with resource-id-base.) - inc := conn.Setup.ResourceIdMask & -conn.Setup.ResourceIdMask - max := conn.Setup.ResourceIdMask + inc := conn.setupResourceIdMask & -conn.setupResourceIdMask + max := conn.setupResourceIdMask last := uint32(0) for { // TODO: Use the XC Misc extension to look for released ids. @@ -209,7 +222,7 @@ func (conn *Conn) generateXIds() { last += inc conn.xidChan <- xid{ - id: last | conn.Setup.ResourceIdBase, + id: last | conn.setupResourceIdBase, err: nil, } } @@ -244,14 +257,14 @@ func (c *Conn) generateSeqIds() { // The cookie is used to match up the reply/error. type request struct { buf []byte - cookie *cookie + cookie *Cookie } -// newRequest takes the bytes an a cookie, constructs a request type, +// NewRequest takes the bytes an a cookie, constructs a request type, // and sends it over the Conn.reqChan channel. // Note that the sequence number is added to the cookie after it is sent // over the request channel. -func (c *Conn) newRequest(buf []byte, cookie *cookie) { +func (c *Conn) NewRequest(buf []byte, cookie *Cookie) { c.reqChan <- &request{buf: buf, cookie: cookie} } @@ -264,11 +277,11 @@ func (c *Conn) sendRequests() { // Note that we circumvent the request channel, because we're *in* // the request channel. if len(c.cookieChan) == cookieBuffer-1 { - cookie := c.newCookie(true, true) + cookie := c.NewCookie(true, true) cookie.Sequence = c.newSequenceId() c.cookieChan <- cookie c.writeBuffer(c.getInputFocusRequest()) - GetInputFocusCookie{cookie}.Reply() // wait for the buffer to clear + cookie.Reply() // wait for the buffer to clear } req.cookie.Sequence = c.newSequenceId() @@ -315,7 +328,7 @@ func (c *Conn) readResponses() { case 0: // This is an error // Use the constructor function for this error (that is auto // generated) by looking it up by the error number. - newErrFun, ok := newErrorFuncs[int(buf[1])] + newErrFun, ok := NewErrorFuncs[int(buf[1])] if !ok { logger.Printf("BUG: Could not find error constructor function "+ "for error with number %d.", buf[1]) @@ -352,7 +365,7 @@ func (c *Conn) readResponses() { // the most significant bit (which is set when it was sent from // a SendEvent request). evNum := int(buf[0] & 127) - newEventFun, ok := newEventFuncs[evNum] + newEventFun, ok := NewEventFuncs[evNum] if !ok { logger.Printf("BUG: Could not find event construct function "+ "for event with number %d.", evNum) diff --git a/nexgb/xgb_help.go b/nexgb/xgb_help.go index 6c3b40a..36fe98b 100644 --- a/nexgb/xgb_help.go +++ b/nexgb/xgb_help.go @@ -5,30 +5,30 @@ import ( "strings" ) -// stringsJoin is an alias to strings.Join. It allows us to avoid having to +// StringsJoin is an alias to strings.Join. It allows us to avoid having to // import 'strings' in each of the generated Go files. -func stringsJoin(ss []string, sep string) string { +func StringsJoin(ss []string, sep string) string { return strings.Join(ss, sep) } -// sprintf is so we don't need to import 'fmt' in the generated Go files. -func sprintf(format string, v ...interface{}) string { +// Sprintf is so we don't need to import 'fmt' in the generated Go files. +func Sprintf(format string, v ...interface{}) string { return fmt.Sprintf(format, v...) } -// errorf is just a wrapper for fmt.Errorf. Exists for the same reason +// Errorf is just a wrapper for fmt.Errorf. Exists for the same reason // that 'stringsJoin' and 'sprintf' exists. -func errorf(format string, v ...interface{}) error { +func Errorf(format string, v ...interface{}) error { return fmt.Errorf(format, v...) } // Pad a length to align on 4 bytes. -func pad(n int) int { +func Pad(n int) int { return (n + 3) & ^3 } // popCount counts the number of bits set in a value list mask. -func popCount(mask0 int) int { +func PopCount(mask0 int) int { mask := uint32(mask0) n := 0 for i := uint32(0); i < 32; i++ { diff --git a/nexgb/xgb_test.go b/nexgb/xgb_test.go deleted file mode 100644 index d0e840a..0000000 --- a/nexgb/xgb_test.go +++ /dev/null @@ -1,376 +0,0 @@ -package xgb - -/* - Tests for XGB. - - These tests only test the core X protocol at the moment. It isn't even - close to complete coverage (and probably never will be), but it does test - a number of different corners: requests with no replies, requests without - replies, checked (i.e., synchronous) errors, unchecked (i.e., asynchronous) - errors, and sequence number wrapping. - - There are also a couple of benchmarks that show the difference between - correctly issuing lots of requests and gathering replies and - incorrectly doing the same. (This particular difference is one of the - claimed advantages of the XCB, and therefore XGB, family. -*/ - -import ( - "fmt" - "log" - "math/rand" - "testing" - "time" -) - -// The X connection used throughout testing. -var X *Conn - -// init initializes the X connection, seeds the RNG and starts waiting -// for events. -func init() { - var err error - - X, err = NewConn() - if err != nil { - log.Fatal(err) - } - - rand.Seed(time.Now().UnixNano()) - - go grabEvents() -} - -/******************************************************************************/ -// Tests -/******************************************************************************/ - -// TestSynchronousError purposefully causes a BadWindow error in a -// MapWindow request, and checks it synchronously. -func TestSynchronousError(t *testing.T) { - err := X.MapWindowChecked(0).Check() // resource id 0 is always invalid - if err == nil { - t.Fatalf("MapWindow: A MapWindow request that should return an " + - "error has returned a nil error.") - } - verifyMapWindowError(t, err) -} - -// TestAsynchronousError does the same thing as TestSynchronousError, but -// grabs the error asynchronously instead. -func TestAsynchronousError(t *testing.T) { - X.MapWindow(0) // resource id 0 is always invalid - - evOrErr := waitForEvent(t, 5) - if evOrErr.ev != nil { - t.Fatalf("After issuing an erroneous MapWindow request, we have "+ - "received an event rather than an error: %s", evOrErr.ev) - } - verifyMapWindowError(t, evOrErr.err) -} - -// TestCookieBuffer issues (2^16) + n requets *without* replies to guarantee -// that the sequence number wraps and that the cookie buffer will have to -// flush itself (since there are no replies coming in to flush it). -// And just like TestSequenceWrap, we issue another request with a reply -// at the end to make sure XGB is still working properly. -func TestCookieBuffer(t *testing.T) { - n := (1 << 16) + 10 - for i := 0; i < n; i++ { - X.NoOperation() - } - TestProperty(t) -} - -// TestSequenceWrap issues (2^16) + n requests w/ replies to guarantee that the -// sequence number (which is a 16 bit integer) will wrap. It then issues one -// final request to ensure things still work properly. -func TestSequenceWrap(t *testing.T) { - n := (1 << 16) + 10 - for i := 0; i < n; i++ { - _, err := X.InternAtom(false, 5, "RANDO").Reply() - if err != nil { - t.Fatalf("InternAtom: %s", err) - } - } - TestProperty(t) -} - -// TestProperty tests whether a random value can be set and read. -func TestProperty(t *testing.T) { - propName := randString(20) // whatevs - writeVal := randString(20) - readVal, err := changeAndGetProp(propName, writeVal) - if err != nil { - t.Error(err) - } - - if readVal != writeVal { - t.Errorf("The value written, '%s', is not the same as the "+ - "value read '%s'.", writeVal, readVal) - } -} - -// TestWindowEvents creates a window, maps it, listens for configure notify -// events, issues a configure request, and checks for the appropriate -// configure notify event. -// This probably violates the notion of "test one thing and test it well," -// but testing X stuff is unique since it involves so much state. -// Each request is checked to make sure there are no errors returned. If there -// is an error, the test is failed. -// You may see a window appear quickly and then disappear. Do not be alarmed :P -// It's possible that this test will yield a false negative because we cannot -// control our environment. That is, the window manager could override the -// placement set. However, we set override redirect on the window, so the -// window manager *shouldn't* touch our window if it is well-behaved. -func TestWindowEvents(t *testing.T) { - // The geometry to set the window. - gx, gy, gw, gh := 200, 400, 1000, 300 - - wid, err := X.NewWindowId() - if err != nil { - t.Fatalf("NewId: %s", err) - } - - screen := X.DefaultScreen() // alias - err = X.CreateWindowChecked(screen.RootDepth, wid, screen.Root, - 0, 0, 500, 500, 0, - WindowClassInputOutput, screen.RootVisual, - CwBackPixel|CwOverrideRedirect, []uint32{0xffffffff, 1}).Check() - if err != nil { - t.Fatalf("CreateWindow: %s", err) - } - - err = X.MapWindowChecked(wid).Check() - if err != nil { - t.Fatalf("MapWindow: %s", err) - } - - // We don't listen in the CreateWindow request so that we don't get - // a MapNotify event. - err = X.ChangeWindowAttributesChecked(wid, - CwEventMask, []uint32{EventMaskStructureNotify}).Check() - if err != nil { - t.Fatalf("ChangeWindowAttributes: %s", err) - } - - err = X.ConfigureWindowChecked(wid, - ConfigWindowX|ConfigWindowY| - ConfigWindowWidth|ConfigWindowHeight, - []uint32{uint32(gx), uint32(gy), uint32(gw), uint32(gh)}).Check() - if err != nil { - t.Fatalf("ConfigureWindow: %s", err) - } - - err = X.ConfigureWindowChecked(wid, - ConfigWindowX|ConfigWindowY| - ConfigWindowWidth|ConfigWindowHeight, - []uint32{uint32(gx + 2), uint32(gy), uint32(gw), uint32(gh)}).Check() - if err != nil { - t.Fatalf("ConfigureWindow: %s", err) - } - - err = X.ConfigureWindowChecked(wid, - ConfigWindowX|ConfigWindowY| - ConfigWindowWidth|ConfigWindowHeight, - []uint32{uint32(gx + 1), uint32(gy), uint32(gw), uint32(gh)}).Check() - if err != nil { - t.Fatalf("ConfigureWindow: %s", err) - } - - TestProperty(t) - - evOrErr := waitForEvent(t, 5) - switch event := evOrErr.ev.(type) { - case ConfigureNotifyEvent: - if event.X != int16(gx) { - t.Fatalf("x was set to %d but ConfigureNotify reports %d", - gx, event.X) - } - if event.Y != int16(gy) { - t.Fatalf("y was set to %d but ConfigureNotify reports %d", - gy, event.Y) - } - if event.Width != uint16(gw) { - t.Fatalf("width was set to %d but ConfigureNotify reports %d", - gw, event.Width) - } - if event.Height != uint16(gh) { - t.Fatalf("height was set to %d but ConfigureNotify reports %d", - gh, event.Height) - } - default: - t.Fatalf("Expected a ConfigureNotifyEvent but got %T instead.", event) - } - - // Okay, clean up! - err = X.ChangeWindowAttributesChecked(wid, - CwEventMask, []uint32{0}).Check() - if err != nil { - t.Fatalf("ChangeWindowAttributes: %s", err) - } - - err = X.DestroyWindowChecked(wid).Check() - if err != nil { - t.Fatalf("DestroyWindow: %s", err) - } -} - -/******************************************************************************/ -// Benchmarks -/******************************************************************************/ - -// BenchmarkInternAtomsGood shows how many requests with replies -// *should* be sent and gathered from the server. Namely, send as many -// requests as you can at once, then go back and gather up all the replies. -// More importantly, this approach can exploit parallelism when -// GOMAXPROCS > 1. -// Run with `go test -run 'nomatch' -bench '.*' -cpu 1,2,6` if you have -// multiple cores to see the improvement that parallelism brings. -func BenchmarkInternAtomsGood(b *testing.B) { - b.StopTimer() - names := seqNames(b.N) - - b.StartTimer() - cookies := make([]InternAtomCookie, b.N) - for i := 0; i < b.N; i++ { - cookies[i] = X.InternAtom(false, uint16(len(names[i])), names[i]) - } - for _, cookie := range cookies { - cookie.Reply() - } -} - -// BenchmarkInternAtomsBad shows how *not* to issue a lot of requests with -// replies. Namely, each subsequent request isn't issued *until* the last -// reply is made. This implies a round trip to the X server for every -// iteration. -func BenchmarkInternAtomsPoor(b *testing.B) { - b.StopTimer() - names := seqNames(b.N) - - b.StartTimer() - for i := 0; i < b.N; i++ { - X.InternAtom(false, uint16(len(names[i])), names[i]).Reply() - } -} - -/******************************************************************************/ -// Helper functions -/******************************************************************************/ - -// changeAndGetProp sets property 'prop' with value 'val'. -// It then gets the value of that property and returns it. -// (It's used to check that the 'val' going in is the same 'val' going out.) -// It tests both requests with and without replies (GetProperty and -// ChangeProperty respectively.) -func changeAndGetProp(prop, val string) (string, error) { - propAtom, err := X.InternAtom(false, uint16(len(prop)), prop).Reply() - if err != nil { - return "", fmt.Errorf("InternAtom: %s", err) - } - - typName := "UTF8_STRING" - typAtom, err := X.InternAtom(false, uint16(len(typName)), typName).Reply() - if err != nil { - return "", fmt.Errorf("InternAtom: %s", err) - } - - err = X.ChangePropertyChecked(PropModeReplace, X.DefaultScreen().Root, - propAtom.Atom, typAtom.Atom, 8, uint32(len(val)), []byte(val)).Check() - if err != nil { - return "", fmt.Errorf("ChangeProperty: %s", err) - } - - reply, err := X.GetProperty(false, X.DefaultScreen().Root, propAtom.Atom, - GetPropertyTypeAny, 0, (1<<32)-1).Reply() - if err != nil { - return "", fmt.Errorf("GetProperty: %s", err) - } - if reply.Format != 8 { - return "", fmt.Errorf("Property reply format is %d but it should be 8.", - reply.Format) - } - - return string(reply.Value), nil -} - -// verifyMapWindowError takes an error that is returned with an invalid -// MapWindow request with a window Id of 0 and makes sure the error is the -// right type and contains the correct values. -func verifyMapWindowError(t *testing.T, err error) { - switch e := err.(type) { - case WindowError: - if e.BadValue != 0 { - t.Fatalf("WindowError should report a bad value of 0 but "+ - "it reports %d instead.", e.BadValue) - } - if e.MajorOpcode != 8 { - t.Fatalf("WindowError should report a major opcode of 8 "+ - "(which is a MapWindow request), but it reports %d instead.", - e.MajorOpcode) - } - default: - t.Fatalf("Expected a WindowError but got %T instead.", e) - } -} - -// randString generates a random string of length n. -func randString(n int) string { - byts := make([]byte, n) - for i := 0; i < n; i++ { - rando := rand.Intn(53) - switch { - case rando <= 25: - byts[i] = byte(65 + rando) - case rando <= 51: - byts[i] = byte(97 + rando - 26) - default: - byts[i] = ' ' - } - } - return string(byts) -} - -// seqNames creates a slice of NAME0, NAME1, ..., NAMEN. -func seqNames(n int) []string { - names := make([]string, n) - for i := range names { - names[i] = fmt.Sprintf("NAME%d", i) - } - return names -} - -// evErr represents a value that is either an event or an error. -type evErr struct { - ev Event - err Error -} - -// channel used to pass evErrs. -var evOrErrChan = make(chan evErr, 0) - -// grabEvents is a goroutine that reads events off the wire. -// We used this instead of WaitForEvent directly in our tests so that -// we can timeout and fail a test. -func grabEvents() { - for { - ev, err := X.WaitForEvent() - evOrErrChan <- evErr{ev, err} - } -} - -// waitForEvent asks the evOrErrChan channel for an event. -// If it doesn't get an event in 'n' seconds, the current test is failed. -func waitForEvent(t *testing.T, n int) evErr { - var evOrErr evErr - - select { - case evOrErr = <-evOrErrChan: - case <-time.After(time.Second * 5): - t.Fatalf("After waiting 5 seconds for an event or an error, " + - "we have timed out.") - } - - return evOrErr -} diff --git a/nexgb/xgbgen/context.go b/nexgb/xgbgen/context.go index a7a1d1d..67699cf 100644 --- a/nexgb/xgbgen/context.go +++ b/nexgb/xgbgen/context.go @@ -5,7 +5,6 @@ import ( "encoding/xml" "fmt" "log" - "strings" "time" ) @@ -49,10 +48,10 @@ func (c *Context) Morph(xmlBytes []byte) { parsedXml.Imports.Eval() // Translate XML types to nice types - c.protocol = parsedXml.Translate() + c.protocol = parsedXml.Translate(nil) // Start with Go header. - c.Putln("package xgb") + c.Putln("package %s", c.protocol.PkgName()) c.Putln("") c.Putln("/*") c.Putln("\tThis file was generated by %s.xml on %s.", @@ -61,44 +60,53 @@ func (c *Context) Morph(xmlBytes []byte) { c.Putln("*/") c.Putln("") - // Write imports in comments - if len(c.protocol.Imports) > 0 { - c.Putln("// Imports are not necessary for XGB because everything is ") - c.Putln("// in one package. They are still listed here for reference.") - for _, imp := range c.protocol.Imports { - c.Putln("// import \"%s\"", imp.Name) + // Write imports. We always need to import at least xgb. + // We also need to import xproto if it's an extension. + c.Putln("import (") + c.Putln("\"github.com/BurntSushi/xgb\"") + c.Putln("") + if c.protocol.isExt() { + c.Putln("\"github.com/BurntSushi/xgb/xproto\"") + } + for _, imp := range c.protocol.Imports { + // We always import xproto, so skip it if it's explicitly imported + if imp.Name == "xproto" { + continue } - c.Putln("") + c.Putln("\"github.com/BurntSushi/xgb/%s\"", imp.Name) } + c.Putln(")") + c.Putln("") // If this is an extension, create a function to initialize the extension // before it can be used. if c.protocol.isExt() { - name := strings.Title(c.protocol.Name) + "Init" xname := c.protocol.ExtXName - c.Putln("// %s must be called before using the %s extension.", - name, xname) - c.Putln("func (c *Conn) %s() error {", name) - c.Putln("reply, err := c.QueryExtension(%d, \"%s\").Reply()", + c.Putln("// Init must be called before using the %s extension.", + xname) + c.Putln("func Init(c *xgb.Conn) error {") + c.Putln("reply, err := xproto.QueryExtension(c, %d, \"%s\").Reply()", len(xname), xname) c.Putln("switch {") c.Putln("case err != nil:") c.Putln("return err") c.Putln("case !reply.Present:") - c.Putln("return errorf(\"No extension named %s could be found on "+ + c.Putln("return xgb.Errorf(\"No extension named %s could be found on "+ "on the server.\")", xname) c.Putln("}") c.Putln("") - c.Putln("c.extLock.Lock()") - c.Putln("c.extensions[\"%s\"] = reply.MajorOpcode", xname) - c.Putln("for evNum, fun := range newExtEventFuncs[\"%s\"] {", xname) - c.Putln("newEventFuncs[int(reply.FirstEvent) + evNum] = fun") + c.Putln("xgb.ExtLock.Lock()") + c.Putln("c.Extensions[\"%s\"] = reply.MajorOpcode", xname) + c.Putln("for evNum, fun := range xgb.NewExtEventFuncs[\"%s\"] {", + xname) + c.Putln("xgb.NewEventFuncs[int(reply.FirstEvent) + evNum] = fun") c.Putln("}") - c.Putln("for errNum, fun := range newExtErrorFuncs[\"%s\"] {", xname) - c.Putln("newErrorFuncs[int(reply.FirstError) + errNum] = fun") + c.Putln("for errNum, fun := range xgb.NewExtErrorFuncs[\"%s\"] {", + xname) + c.Putln("xgb.NewErrorFuncs[int(reply.FirstError) + errNum] = fun") c.Putln("}") - c.Putln("c.extLock.Unlock()") + c.Putln("xgb.ExtLock.Unlock()") c.Putln("") c.Putln("return nil") c.Putln("}") @@ -107,8 +115,26 @@ func (c *Context) Morph(xmlBytes []byte) { // Make sure newExtEventFuncs["EXT_NAME"] map is initialized. // Same deal for newExtErrorFuncs["EXT_NAME"] c.Putln("func init() {") - c.Putln("newExtEventFuncs[\"%s\"] = make(map[int]newEventFun)", xname) - c.Putln("newExtErrorFuncs[\"%s\"] = make(map[int]newErrorFun)", xname) + c.Putln("xgb.NewExtEventFuncs[\"%s\"] = make(map[int]xgb.NewEventFun)", + xname) + c.Putln("xgb.NewExtErrorFuncs[\"%s\"] = make(map[int]xgb.NewErrorFun)", + xname) + c.Putln("}") + c.Putln("") + } else { + // In the xproto package, we must provide a Setup function that uses + // SetupBytes in xgb.Conn to return a SetupInfo structure. + c.Putln("// Setup parses the setup bytes retrieved when") + c.Putln("// connecting into a SetupInfo struct.") + c.Putln("func Setup(c *xgb.Conn) *SetupInfo {") + c.Putln("setup := new(SetupInfo)") + c.Putln("SetupInfoRead(c.SetupBytes, setup)") + c.Putln("return setup") + c.Putln("}") + c.Putln("") + c.Putln("// DefaultScreen gets the default screen info from SetupInfo.") + c.Putln("func (s *SetupInfo) DefaultScreen(c *xgb.Conn) *ScreenInfo {") + c.Putln("return &s.Roots[c.DefaultScreen]") c.Putln("}") c.Putln("") } diff --git a/nexgb/xgbgen/expression.go b/nexgb/xgbgen/expression.go index 0966b58..2047b5f 100644 --- a/nexgb/xgbgen/expression.go +++ b/nexgb/xgbgen/expression.go @@ -204,7 +204,7 @@ func (e *Padding) Reduce(prefix string) string { if e.Concrete() { return fmt.Sprintf("%d", e.Eval()) } - return fmt.Sprintf("pad(%s)", e.Expr.Reduce(prefix)) + return fmt.Sprintf("xgb.Pad(%s)", e.Expr.Reduce(prefix)) } func (e *Padding) String() string { @@ -233,7 +233,7 @@ func (e *PopCount) Reduce(prefix string) string { if e.Concrete() { return fmt.Sprintf("%d", e.Eval()) } - return fmt.Sprintf("popCount(%s)", e.Expr.Reduce(prefix)) + return fmt.Sprintf("xgb.PopCount(%s)", e.Expr.Reduce(prefix)) } func (e *PopCount) String() string { diff --git a/nexgb/xgbgen/field.go b/nexgb/xgbgen/field.go index 7c83f1a..78475f8 100644 --- a/nexgb/xgbgen/field.go +++ b/nexgb/xgbgen/field.go @@ -245,7 +245,7 @@ func (f *ValueField) SrcType() string { func (f *ValueField) Size() Size { maskSize := f.MaskType.Size() listSize := newExpressionSize(&Function{ - Name: "pad", + Name: "xgb.Pad", Expr: &BinaryOp{ Op: "*", Expr1: &Value{v: 4}, diff --git a/nexgb/xgbgen/go.go b/nexgb/xgbgen/go.go index 2b2c191..6c680e8 100644 --- a/nexgb/xgbgen/go.go +++ b/nexgb/xgbgen/go.go @@ -82,7 +82,7 @@ func (enum *Enum) Define(c *Context) { func (res *Resource) Define(c *Context) { c.Putln("type %s uint32", res.SrcName()) c.Putln("") - c.Putln("func (c *Conn) New%sId() (%s, error) {", + c.Putln("func New%sId(c *xgb.Conn) (%s, error) {", res.SrcName(), res.SrcName()) c.Putln("id, err := c.NewId()") c.Putln("if err != nil {") @@ -167,10 +167,10 @@ func (f *ValueField) Read(c *Context, prefix string) { c.Putln("%s%s = make([]uint32, %s)", prefix, f.ListName, f.ListLength().Reduce(prefix)) c.Putln("for i := 0; i < %s; i++ {", f.ListLength().Reduce(prefix)) - c.Putln("%s%s[i] = Get32(buf[b:])", prefix, f.ListName) + c.Putln("%s%s[i] = xgb.Get32(buf[b:])", prefix, f.ListName) c.Putln("b += 4") c.Putln("}") - c.Putln("b = pad(b)") + c.Putln("b = xgb.Pad(b)") } func (f *ValueField) Write(c *Context, prefix string) { @@ -180,10 +180,10 @@ func (f *ValueField) Write(c *Context, prefix string) { fmt.Sprintf("%s%s", prefix, f.MaskName), f.MaskType) } c.Putln("for i := 0; i < %s; i++ {", f.ListLength().Reduce(prefix)) - c.Putln("Put32(buf[b:], %s%s[i])", prefix, f.ListName) + c.Putln("xgb.Put32(buf[b:], %s%s[i])", prefix, f.ListName) c.Putln("b += 4") c.Putln("}") - c.Putln("b = pad(b)") + c.Putln("b = xgb.Pad(b)") } // Switch field diff --git a/nexgb/xgbgen/go_error.go b/nexgb/xgbgen/go_error.go index f4577ef..b7721be 100644 --- a/nexgb/xgbgen/go_error.go +++ b/nexgb/xgbgen/go_error.go @@ -30,10 +30,10 @@ func (e *Error) Define(c *Context) { // Let's the XGB event loop read this error. c.Putln("func init() {") if c.protocol.isExt() { - c.Putln("newExtErrorFuncs[\"%s\"][%d] = New%s", + c.Putln("xgb.NewExtErrorFuncs[\"%s\"][%d] = %sNew", c.protocol.ExtXName, e.Number, e.ErrType()) } else { - c.Putln("newErrorFuncs[%d] = New%s", e.Number, e.ErrType()) + c.Putln("xgb.NewErrorFuncs[%d] = %sNew", e.Number, e.ErrType()) } c.Putln("}") c.Putln("") @@ -41,14 +41,14 @@ func (e *Error) Define(c *Context) { func (e *Error) Read(c *Context) { c.Putln("// Error read %s", e.SrcName()) - c.Putln("func New%s(buf []byte) Error {", e.ErrType()) + c.Putln("func %sNew(buf []byte) xgb.Error {", e.ErrType()) c.Putln("v := %s{}", e.ErrType()) c.Putln("v.NiceName = \"%s\"", e.SrcName()) c.Putln("") c.Putln("b := 1 // skip error determinant") c.Putln("b += 1 // don't read error number") c.Putln("") - c.Putln("v.Sequence = Get16(buf[b:])") + c.Putln("v.Sequence = xgb.Get16(buf[b:])") c.Putln("b += 2") c.Putln("") for _, field := range e.Fields { @@ -101,18 +101,18 @@ func (e *ErrorCopy) Define(c *Context) { // Let's the XGB know how to read this error. c.Putln("func init() {") if c.protocol.isExt() { - c.Putln("newExtErrorFuncs[\"%s\"][%d] = New%s", + c.Putln("xgb.NewExtErrorFuncs[\"%s\"][%d] = %sNew", c.protocol.ExtXName, e.Number, e.ErrType()) } else { - c.Putln("newErrorFuncs[%d] = New%s", e.Number, e.ErrType()) + c.Putln("xgb.NewErrorFuncs[%d] = %sNew", e.Number, e.ErrType()) } c.Putln("}") c.Putln("") } func (e *ErrorCopy) Read(c *Context) { - c.Putln("func New%s(buf []byte) Error {", e.ErrType()) - c.Putln("v := %s(New%s(buf).(%s))", + c.Putln("func %sNew(buf []byte) xgb.Error {", e.ErrType()) + c.Putln("v := %s(%sNew(buf).(%s))", e.ErrType(), e.Old.(*Error).ErrType(), e.Old.(*Error).ErrType()) c.Putln("v.NiceName = \"%s\"", e.SrcName()) c.Putln("return v") @@ -148,7 +148,7 @@ func ErrorFieldString(c *Context, fields []Field, errName string) { c.Putln("fieldVals := make([]string, 0, %d)", len(fields)) c.Putln("fieldVals = append(fieldVals, \"NiceName: \" + err.NiceName)") c.Putln("fieldVals = append(fieldVals, "+ - "sprintf(\"Sequence: %s\", err.Sequence))", "%d") + "xgb.Sprintf(\"Sequence: %s\", err.Sequence))", "%d") for _, field := range fields { switch field.(type) { case *PadField: @@ -158,11 +158,12 @@ func ErrorFieldString(c *Context, fields []Field, errName string) { c.Putln("fieldVals = append(fieldVals, \"%s: \" + err.%s)", field.SrcName(), field.SrcName()) } else { - format := fmt.Sprintf("sprintf(\"%s: %s\", err.%s)", + format := fmt.Sprintf("xgb.Sprintf(\"%s: %s\", err.%s)", field.SrcName(), "%d", field.SrcName()) c.Putln("fieldVals = append(fieldVals, %s)", format) } } } - c.Putln("return \"%s {\" + stringsJoin(fieldVals, \", \") + \"}\"", errName) + c.Putln("return \"%s {\" + xgb.StringsJoin(fieldVals, \", \") + \"}\"", + errName) } diff --git a/nexgb/xgbgen/go_event.go b/nexgb/xgbgen/go_event.go index f55e26f..d7ef109 100644 --- a/nexgb/xgbgen/go_event.go +++ b/nexgb/xgbgen/go_event.go @@ -48,10 +48,10 @@ func (e *Event) Define(c *Context) { // Let's the XGB event loop read this event. c.Putln("func init() {") if c.protocol.isExt() { - c.Putln("newExtEventFuncs[\"%s\"][%d] = New%s", + c.Putln("xgb.NewExtEventFuncs[\"%s\"][%d] = %sNew", c.protocol.ExtXName, e.Number, e.EvType()) } else { - c.Putln("newEventFuncs[%d] = New%s", e.Number, e.EvType()) + c.Putln("xgb.NewEventFuncs[%d] = %sNew", e.Number, e.EvType()) } c.Putln("}") c.Putln("") @@ -59,13 +59,13 @@ func (e *Event) Define(c *Context) { func (e *Event) Read(c *Context) { c.Putln("// Event read %s", e.SrcName()) - c.Putln("func New%s(buf []byte) Event {", e.EvType()) + c.Putln("func %sNew(buf []byte) xgb.Event {", e.EvType()) c.Putln("v := %s{}", e.EvType()) c.Putln("b := 1 // don't read event number") c.Putln("") for i, field := range e.Fields { if i == 1 && !e.NoSequence { - c.Putln("v.Sequence = Get16(buf[b:])") + c.Putln("v.Sequence = xgb.Get16(buf[b:])") c.Putln("b += 2") c.Putln("") } @@ -136,18 +136,18 @@ func (e *EventCopy) Define(c *Context) { // Let's the XGB event loop read this event. c.Putln("func init() {") if c.protocol.isExt() { - c.Putln("newExtEventFuncs[\"%s\"][%d] = New%s", + c.Putln("xgb.NewExtEventFuncs[\"%s\"][%d] = %sNew", c.protocol.ExtXName, e.Number, e.EvType()) } else { - c.Putln("newEventFuncs[%d] = New%s", e.Number, e.EvType()) + c.Putln("xgb.NewEventFuncs[%d] = %sNew", e.Number, e.EvType()) } c.Putln("}") c.Putln("") } func (e *EventCopy) Read(c *Context) { - c.Putln("func New%s(buf []byte) Event {", e.EvType()) - c.Putln("return %s(New%s(buf).(%s))", + c.Putln("func %sNew(buf []byte) xgb.Event {", e.EvType()) + c.Putln("return %s(%sNew(buf).(%s))", e.EvType(), e.Old.(*Event).EvType(), e.Old.(*Event).EvType()) c.Putln("}") c.Putln("") @@ -166,7 +166,7 @@ func EventFieldString(c *Context, fields []Field, evName string) { c.Putln("fieldVals := make([]string, 0, %d)", len(fields)) if evName != "KeymapNotify" { c.Putln("fieldVals = append(fieldVals, "+ - "sprintf(\"Sequence: %s\", v.Sequence))", "%d") + "xgb.Sprintf(\"Sequence: %s\", v.Sequence))", "%d") } for _, field := range fields { switch f := field.(type) { @@ -183,19 +183,20 @@ func EventFieldString(c *Context, fields []Field, evName string) { switch field.SrcType() { case "string": - format := fmt.Sprintf("sprintf(\"%s: %s\", v.%s)", + format := fmt.Sprintf("xgb.Sprintf(\"%s: %s\", v.%s)", field.SrcName(), "%s", field.SrcName()) c.Putln("fieldVals = append(fieldVals, %s)", format) case "bool": - format := fmt.Sprintf("sprintf(\"%s: %s\", v.%s)", + format := fmt.Sprintf("xgb.Sprintf(\"%s: %s\", v.%s)", field.SrcName(), "%t", field.SrcName()) c.Putln("fieldVals = append(fieldVals, %s)", format) default: - format := fmt.Sprintf("sprintf(\"%s: %s\", v.%s)", + format := fmt.Sprintf("xgb.Sprintf(\"%s: %s\", v.%s)", field.SrcName(), "%d", field.SrcName()) c.Putln("fieldVals = append(fieldVals, %s)", format) } } } - c.Putln("return \"%s {\" + stringsJoin(fieldVals, \", \") + \"}\"", evName) + c.Putln("return \"%s {\" + xgb.StringsJoin(fieldVals, \", \") + \"}\"", + evName) } diff --git a/nexgb/xgbgen/go_list.go b/nexgb/xgbgen/go_list.go index b01519b..4cf962a 100644 --- a/nexgb/xgbgen/go_list.go +++ b/nexgb/xgbgen/go_list.go @@ -21,7 +21,7 @@ func (f *ListField) Read(c *Context, prefix string) { c.Putln("for i := 0; i < int(%s); i++ {", length) ReadSimpleSingleField(c, fmt.Sprintf("%s%s[i]", prefix, f.SrcName()), t) c.Putln("}") - c.Putln("b = pad(b)") + c.Putln("b = xgb.Pad(b)") case *Base: length := f.LengthExpr.Reduce(prefix) if strings.ToLower(t.XmlName()) == "char" { @@ -29,13 +29,13 @@ func (f *ListField) Read(c *Context, prefix string) { c.Putln("byteString := make([]%s, %s)", t.SrcName(), length) c.Putln("copy(byteString[:%s], buf[b:])", length) c.Putln("%s%s = string(byteString)", prefix, f.SrcName()) - c.Putln("b += pad(int(%s))", length) + c.Putln("b += xgb.Pad(int(%s))", length) c.Putln("}") } else if t.SrcName() == "byte" { c.Putln("%s%s = make([]%s, %s)", prefix, f.SrcName(), t.SrcName(), length) c.Putln("copy(%s%s[:%s], buf[b:])", prefix, f.SrcName(), length) - c.Putln("b += pad(int(%s))", length) + c.Putln("b += xgb.Pad(int(%s))", length) } else { c.Putln("%s%s = make([]%s, %s)", prefix, f.SrcName(), t.SrcName(), length) @@ -43,7 +43,7 @@ func (f *ListField) Read(c *Context, prefix string) { ReadSimpleSingleField(c, fmt.Sprintf("%s%s[i]", prefix, f.SrcName()), t) c.Putln("}") - c.Putln("b = pad(b)") + c.Putln("b = xgb.Pad(b)") } case *TypeDef: length := f.LengthExpr.Reduce(prefix) @@ -52,16 +52,16 @@ func (f *ListField) Read(c *Context, prefix string) { c.Putln("for i := 0; i < int(%s); i++ {", length) ReadSimpleSingleField(c, fmt.Sprintf("%s%s[i]", prefix, f.SrcName()), t) c.Putln("}") - c.Putln("b = pad(b)") + c.Putln("b = xgb.Pad(b)") case *Union: c.Putln("%s%s = make([]%s, %s)", prefix, f.SrcName(), t.SrcName(), f.LengthExpr.Reduce(prefix)) - c.Putln("b += Read%sList(buf[b:], %s%s)", + c.Putln("b += %sReadList(buf[b:], %s%s)", t.SrcName(), prefix, f.SrcName()) case *Struct: c.Putln("%s%s = make([]%s, %s)", prefix, f.SrcName(), t.SrcName(), f.LengthExpr.Reduce(prefix)) - c.Putln("b += Read%sList(buf[b:], %s%s)", + c.Putln("b += %sReadList(buf[b:], %s%s)", t.SrcName(), prefix, f.SrcName()) default: log.Panicf("Cannot read list field '%s' with %T type.", @@ -77,18 +77,18 @@ func (f *ListField) Write(c *Context, prefix string) { WriteSimpleSingleField(c, fmt.Sprintf("%s%s[i]", prefix, f.SrcName()), t) c.Putln("}") - c.Putln("b = pad(b)") + c.Putln("b = xgb.Pad(b)") case *Base: length := f.Length().Reduce(prefix) if t.SrcName() == "byte" { c.Putln("copy(buf[b:], %s%s[:%s])", prefix, f.SrcName(), length) - c.Putln("b += pad(int(%s))", length) + c.Putln("b += xgb.Pad(int(%s))", length) } else { c.Putln("for i := 0; i < int(%s); i++ {", length) WriteSimpleSingleField(c, fmt.Sprintf("%s%s[i]", prefix, f.SrcName()), t) c.Putln("}") - c.Putln("b = pad(b)") + c.Putln("b = xgb.Pad(b)") } case *TypeDef: length := f.Length().Reduce(prefix) @@ -96,7 +96,7 @@ func (f *ListField) Write(c *Context, prefix string) { WriteSimpleSingleField(c, fmt.Sprintf("%s%s[i]", prefix, f.SrcName()), t) c.Putln("}") - c.Putln("b = pad(b)") + c.Putln("b = xgb.Pad(b)") case *Union: c.Putln("b += %sListBytes(buf[b:], %s%s)", t.SrcName(), prefix, f.SrcName()) diff --git a/nexgb/xgbgen/go_request_reply.go b/nexgb/xgbgen/go_request_reply.go index a9e624d..200260c 100644 --- a/nexgb/xgbgen/go_request_reply.go +++ b/nexgb/xgbgen/go_request_reply.go @@ -9,22 +9,22 @@ func (r *Request) Define(c *Context) { c.Putln("// Request %s", r.SrcName()) c.Putln("// size: %s", r.Size(c)) c.Putln("type %s struct {", r.CookieName()) - c.Putln("*cookie") + c.Putln("*xgb.Cookie") c.Putln("}") c.Putln("") if r.Reply != nil { - c.Putln("func (c *Conn) %s(%s) %s {", + c.Putln("func %s(c *xgb.Conn, %s) %s {", r.SrcName(), r.ParamNameTypes(), r.CookieName()) - c.Putln("cookie := c.newCookie(true, true)") - c.Putln("c.newRequest(c.%s(%s), cookie)", r.ReqName(), r.ParamNames()) + c.Putln("cookie := c.NewCookie(true, true)") + c.Putln("c.NewRequest(%s(c, %s), cookie)", r.ReqName(), r.ParamNames()) c.Putln("return %s{cookie}", r.CookieName()) c.Putln("}") c.Putln("") - c.Putln("func (c *Conn) %sUnchecked(%s) %s {", + c.Putln("func %sUnchecked(c *xgb.Conn, %s) %s {", r.SrcName(), r.ParamNameTypes(), r.CookieName()) - c.Putln("cookie := c.newCookie(false, true)") - c.Putln("c.newRequest(c.%s(%s), cookie)", r.ReqName(), r.ParamNames()) + c.Putln("cookie := c.NewCookie(false, true)") + c.Putln("c.NewRequest(%s(c, %s), cookie)", r.ReqName(), r.ParamNames()) c.Putln("return %s{cookie}", r.CookieName()) c.Putln("}") c.Putln("") @@ -32,27 +32,27 @@ func (r *Request) Define(c *Context) { r.ReadReply(c) } else { c.Putln("// Write request to wire for %s", r.SrcName()) - c.Putln("func (c *Conn) %s(%s) %s {", + c.Putln("func %s(c *xgb.Conn, %s) %s {", r.SrcName(), r.ParamNameTypes(), r.CookieName()) - c.Putln("cookie := c.newCookie(false, false)") - c.Putln("c.newRequest(c.%s(%s), cookie)", r.ReqName(), r.ParamNames()) + c.Putln("cookie := c.NewCookie(false, false)") + c.Putln("c.NewRequest(%s(c, %s), cookie)", r.ReqName(), r.ParamNames()) c.Putln("return %s{cookie}", r.CookieName()) c.Putln("}") c.Putln("") - c.Putln("func (c *Conn) %sChecked(%s) %s {", + c.Putln("func %sChecked(c *xgb.Conn, %s) %s {", r.SrcName(), r.ParamNameTypes(), r.CookieName()) - c.Putln("cookie := c.newCookie(true, false)") - c.Putln("c.newRequest(c.%s(%s), cookie)", r.ReqName(), r.ParamNames()) + c.Putln("cookie := c.NewCookie(true, false)") + c.Putln("c.NewRequest(%s(c, %s), cookie)", r.ReqName(), r.ParamNames()) c.Putln("return %s{cookie}", r.CookieName()) c.Putln("}") c.Putln("") - } - c.Putln("func (cook %s) Check() error {", r.CookieName()) - c.Putln("return cook.check()") - c.Putln("}") - c.Putln("") + c.Putln("func (cook %s) Check() error {", r.CookieName()) + c.Putln("return cook.Cookie.Check()") + c.Putln("}") + c.Putln("") + } r.WriteRequest(c) } @@ -71,7 +71,7 @@ func (r *Request) ReadReply(c *Context) { c.Putln("// Waits and reads reply data from request %s", r.SrcName()) c.Putln("func (cook %s) Reply() (*%s, error) {", r.CookieName(), r.ReplyTypeName()) - c.Putln("buf, err := cook.reply()") + c.Putln("buf, err := cook.Cookie.Reply()") c.Putln("if err != nil {") c.Putln("return nil, err") c.Putln("}") @@ -92,10 +92,10 @@ func (r *Request) ReadReply(c *Context) { field.Read(c, "v.") c.Putln("") if i == 0 { - c.Putln("v.Sequence = Get16(buf[b:])") + c.Putln("v.Sequence = xgb.Get16(buf[b:])") c.Putln("b += 2") c.Putln("") - c.Putln("v.Length = Get32(buf[b:]) // 4-byte units") + c.Putln("v.Length = xgb.Get32(buf[b:]) // 4-byte units") c.Putln("b += 4") c.Putln("") } @@ -107,19 +107,20 @@ func (r *Request) ReadReply(c *Context) { func (r *Request) WriteRequest(c *Context) { writeSize := func() { - c.Putln("Put16(buf[b:], uint16(size / 4)) " + + c.Putln("xgb.Put16(buf[b:], uint16(size / 4)) " + "// write request size in 4-byte units") c.Putln("b += 2") c.Putln("") } c.Putln("// Write request to wire for %s", r.SrcName()) - c.Putln("func (c *Conn) %s(%s) []byte {", r.ReqName(), r.ParamNameTypes()) + c.Putln("func %s(c *xgb.Conn, %s) []byte {", + r.ReqName(), r.ParamNameTypes()) c.Putln("size := %s", r.Size(c)) c.Putln("b := 0") c.Putln("buf := make([]byte, size)") c.Putln("") if c.protocol.isExt() { - c.Putln("buf[b] = c.extensions[\"%s\"]", + c.Putln("buf[b] = c.Extensions[\"%s\"]", strings.ToUpper(c.protocol.ExtXName)) c.Putln("b += 1") c.Putln("") @@ -165,7 +166,7 @@ func (r *Request) ParamNames() string { names = append(names, fmt.Sprintf("%s", field.SrcName())) } } - return strings.Join(names, ",") + return strings.Join(names, ", ") } func (r *Request) ParamNameTypes() string { @@ -189,5 +190,5 @@ func (r *Request) ParamNameTypes() string { fmt.Sprintf("%s %s", field.SrcName(), field.SrcType())) } } - return strings.Join(nameTypes, ",") + return strings.Join(nameTypes, ", ") } diff --git a/nexgb/xgbgen/go_single_field.go b/nexgb/xgbgen/go_single_field.go index 433ebe3..3e3fa53 100644 --- a/nexgb/xgbgen/go_single_field.go +++ b/nexgb/xgbgen/go_single_field.go @@ -12,17 +12,17 @@ func (f *SingleField) Define(c *Context) { func ReadSimpleSingleField(c *Context, name string, typ Type) { switch t := typ.(type) { case *Resource: - c.Putln("%s = %s(Get32(buf[b:]))", name, t.SrcName()) + c.Putln("%s = %s(xgb.Get32(buf[b:]))", name, t.SrcName()) case *TypeDef: switch t.Size().Eval() { case 1: c.Putln("%s = %s(buf[b])", name, t.SrcName()) case 2: - c.Putln("%s = %s(Get16(buf[b:]))", name, t.SrcName()) + c.Putln("%s = %s(xgb.Get16(buf[b:]))", name, t.SrcName()) case 4: - c.Putln("%s = %s(Get32(buf[b:]))", name, t.SrcName()) + c.Putln("%s = %s(xgb.Get32(buf[b:]))", name, t.SrcName()) case 8: - c.Putln("%s = %s(Get64(buf[b:]))", name, t.SrcName()) + c.Putln("%s = %s(xgb.Get64(buf[b:]))", name, t.SrcName()) } case *Base: // If this is a bool, stop short and do something special. @@ -40,11 +40,11 @@ func ReadSimpleSingleField(c *Context, name string, typ Type) { case 1: val = fmt.Sprintf("buf[b]") case 2: - val = fmt.Sprintf("Get16(buf[b:])") + val = fmt.Sprintf("xgb.Get16(buf[b:])") case 4: - val = fmt.Sprintf("Get32(buf[b:])") + val = fmt.Sprintf("xgb.Get32(buf[b:])") case 8: - val = fmt.Sprintf("Get64(buf[b:])") + val = fmt.Sprintf("xgb.Get64(buf[b:])") } // We need to convert base types if they aren't uintXX or byte @@ -71,10 +71,10 @@ func (f *SingleField) Read(c *Context, prefix string) { ReadSimpleSingleField(c, fmt.Sprintf("%s%s", prefix, f.SrcName()), t) case *Struct: c.Putln("%s%s = %s{}", prefix, f.SrcName(), t.SrcName()) - c.Putln("b += Read%s(buf[b:], &%s%s)", t.SrcName(), prefix, f.SrcName()) + c.Putln("b += %sRead(buf[b:], &%s%s)", t.SrcName(), prefix, f.SrcName()) case *Union: c.Putln("%s%s = %s{}", prefix, f.SrcName(), t.SrcName()) - c.Putln("b += Read%s(buf[b:], &%s%s)", t.SrcName(), prefix, f.SrcName()) + c.Putln("b += %sRead(buf[b:], &%s%s)", t.SrcName(), prefix, f.SrcName()) default: log.Panicf("Cannot read field '%s' with %T type.", f.XmlName(), f.Type) } @@ -83,17 +83,17 @@ func (f *SingleField) Read(c *Context, prefix string) { func WriteSimpleSingleField(c *Context, name string, typ Type) { switch t := typ.(type) { case *Resource: - c.Putln("Put32(buf[b:], uint32(%s))", name) + c.Putln("xgb.Put32(buf[b:], uint32(%s))", name) case *TypeDef: switch t.Size().Eval() { case 1: c.Putln("buf[b] = byte(%s)", name) case 2: - c.Putln("Put16(buf[b:], uint16(%s))", name) + c.Putln("xgb.Put16(buf[b:], uint16(%s))", name) case 4: - c.Putln("Put32(buf[b:], uint32(%s))", name) + c.Putln("xgb.Put32(buf[b:], uint32(%s))", name) case 8: - c.Putln("Put64(buf[b:], uint64(%s))", name) + c.Putln("xgb.Put64(buf[b:], uint64(%s))", name) } case *Base: // If this is a bool, stop short and do something special. @@ -115,21 +115,21 @@ func WriteSimpleSingleField(c *Context, name string, typ Type) { } case 2: if t.SrcName() != "uint16" { - c.Putln("Put16(buf[b:], uint16(%s))", name) + c.Putln("xgb.Put16(buf[b:], uint16(%s))", name) } else { - c.Putln("Put16(buf[b:], %s)", name) + c.Putln("xgb.Put16(buf[b:], %s)", name) } case 4: if t.SrcName() != "uint32" { - c.Putln("Put32(buf[b:], uint32(%s))", name) + c.Putln("xgb.Put32(buf[b:], uint32(%s))", name) } else { - c.Putln("Put32(buf[b:], %s)", name) + c.Putln("xgb.Put32(buf[b:], %s)", name) } case 8: if t.SrcName() != "uint64" { - c.Putln("Put64(buf[b:], uint64(%s))", name) + c.Putln("xgb.Put64(buf[b:], uint64(%s))", name) } else { - c.Putln("Put64(buf[b:], %s)", name) + c.Putln("xgb.Put64(buf[b:], %s)", name) } } default: @@ -152,13 +152,13 @@ func (f *SingleField) Write(c *Context, prefix string) { c.Putln("{") c.Putln("unionBytes := %s%s.Bytes()", prefix, f.SrcName()) c.Putln("copy(buf[b:], unionBytes)") - c.Putln("b += pad(len(unionBytes))") + c.Putln("b += xgb.Pad(len(unionBytes))") c.Putln("}") case *Struct: c.Putln("{") c.Putln("structBytes := %s%s.Bytes()", prefix, f.SrcName()) c.Putln("copy(buf[b:], structBytes)") - c.Putln("b += pad(len(structBytes))") + c.Putln("b += xgb.Pad(len(structBytes))") c.Putln("}") default: log.Fatalf("Cannot read field '%s' with %T type.", f.XmlName(), f.Type) diff --git a/nexgb/xgbgen/go_struct.go b/nexgb/xgbgen/go_struct.go index 9884194..7f33b21 100644 --- a/nexgb/xgbgen/go_struct.go +++ b/nexgb/xgbgen/go_struct.go @@ -35,7 +35,7 @@ func (s *Struct) Define(c *Context) { // 'ReadStructName' should only be used to read raw reply data from the wire. func (s *Struct) Read(c *Context) { c.Putln("// Struct read %s", s.SrcName()) - c.Putln("func Read%s(buf []byte, v *%s) int {", s.SrcName(), s.SrcName()) + c.Putln("func %sRead(buf []byte, v *%s) int {", s.SrcName(), s.SrcName()) c.Putln("b := 0") c.Putln("") @@ -54,16 +54,16 @@ func (s *Struct) Read(c *Context) { // the number of bytes read from the byte slice. func (s *Struct) ReadList(c *Context) { c.Putln("// Struct list read %s", s.SrcName()) - c.Putln("func Read%sList(buf []byte, dest []%s) int {", + c.Putln("func %sReadList(buf []byte, dest []%s) int {", s.SrcName(), s.SrcName()) c.Putln("b := 0") c.Putln("for i := 0; i < len(dest); i++ {") c.Putln("dest[i] = %s{}", s.SrcName()) - c.Putln("b += Read%s(buf[b:], &dest[i])", s.SrcName()) + c.Putln("b += %sRead(buf[b:], &dest[i])", s.SrcName()) c.Putln("}") - c.Putln("return pad(b)") + c.Putln("return xgb.Pad(b)") c.Putln("}") c.Putln("") @@ -93,7 +93,7 @@ func (s *Struct) WriteList(c *Context) { c.Putln("for _, item := range list {") c.Putln("structBytes = item.Bytes()") c.Putln("copy(buf[b:], structBytes)") - c.Putln("b += pad(len(structBytes))") + c.Putln("b += xgb.Pad(len(structBytes))") c.Putln("}") c.Putln("return b") c.Putln("}") diff --git a/nexgb/xgbgen/go_union.go b/nexgb/xgbgen/go_union.go index 73e85f7..91300a2 100644 --- a/nexgb/xgbgen/go_union.go +++ b/nexgb/xgbgen/go_union.go @@ -8,7 +8,7 @@ func (u *Union) Define(c *Context) { c.Putln("// Instead use one of the following constructors for '%s':", u.SrcName()) for _, field := range u.Fields { - c.Putln("// New%s%s(%s %s) %s", u.SrcName(), field.SrcName(), + c.Putln("// %s%sNew(%s %s) %s", u.SrcName(), field.SrcName(), field.SrcName(), field.SrcType(), u.SrcName()) } @@ -40,7 +40,7 @@ func (u *Union) New(c *Context) { for _, field := range u.Fields { c.Putln("// Union constructor for %s for field %s.", u.SrcName(), field.SrcName()) - c.Putln("func New%s%s(%s %s) %s {", + c.Putln("func %s%sNew(%s %s) %s {", u.SrcName(), field.SrcName(), field.SrcName(), field.SrcType(), u.SrcName()) c.Putln("var b int") @@ -66,7 +66,7 @@ func (u *Union) New(c *Context) { func (u *Union) Read(c *Context) { c.Putln("// Union read %s", u.SrcName()) - c.Putln("func Read%s(buf []byte, v *%s) int {", u.SrcName(), u.SrcName()) + c.Putln("func %sRead(buf []byte, v *%s) int {", u.SrcName(), u.SrcName()) c.Putln("var b int") c.Putln("") for _, field := range u.Fields { @@ -81,14 +81,14 @@ func (u *Union) Read(c *Context) { func (u *Union) ReadList(c *Context) { c.Putln("// Union list read %s", u.SrcName()) - c.Putln("func Read%sList(buf []byte, dest []%s) int {", + c.Putln("func %sReadList(buf []byte, dest []%s) int {", u.SrcName(), u.SrcName()) c.Putln("b := 0") c.Putln("for i := 0; i < len(dest); i++ {") c.Putln("dest[i] = %s{}", u.SrcName()) - c.Putln("b += Read%s(buf[b:], &dest[i])", u.SrcName()) + c.Putln("b += %sRead(buf[b:], &dest[i])", u.SrcName()) c.Putln("}") - c.Putln("return pad(b)") + c.Putln("return xgb.Pad(b)") c.Putln("}") c.Putln("") } @@ -121,7 +121,7 @@ func (u *Union) WriteList(c *Context) { c.Putln("for _, item := range list {") c.Putln("unionBytes = item.Bytes()") c.Putln("copy(buf[b:], unionBytes)") - c.Putln("b += pad(len(unionBytes))") + c.Putln("b += xgb.Pad(len(unionBytes))") c.Putln("}") c.Putln("return b") c.Putln("}") diff --git a/nexgb/xgbgen/protocol.go b/nexgb/xgbgen/protocol.go index 83dde14..d56663d 100644 --- a/nexgb/xgbgen/protocol.go +++ b/nexgb/xgbgen/protocol.go @@ -1,6 +1,7 @@ package main import ( + "log" "strings" ) @@ -9,6 +10,7 @@ import ( // if this protocol imports other other extensions. The import relationship // is recursive. type Protocol struct { + Parent *Protocol Name string ExtXName string ExtName string @@ -33,6 +35,28 @@ func (p *Protocol) Initialize() { } } +// PkgName returns the name of this package. +// i.e., 'xproto' for the core X protocol, 'randr' for the RandR extension, etc. +func (p *Protocol) PkgName() string { + return strings.Replace(p.Name, "_", "", -1) +} + +// ProtocolGet searches the current context for the protocol with the given +// name. (i.e., the current protocol and its imports.) +// It is an error if one is not found. +func (p *Protocol) ProtocolFind(name string) *Protocol { + if p.Name == name { + return p // that was easy + } + for _, imp := range p.Imports { + if imp.Name == name { + return imp + } + } + log.Panicf("Could not find protocol with name '%s'.", name) + panic("unreachable") +} + // isExt returns true if this protocol is an extension. // i.e., it's name isn't "xproto". func (p *Protocol) isExt() bool { diff --git a/nexgb/xgbgen/request_reply.go b/nexgb/xgbgen/request_reply.go index 4daa4ac..637266b 100644 --- a/nexgb/xgbgen/request_reply.go +++ b/nexgb/xgbgen/request_reply.go @@ -3,7 +3,6 @@ package main import ( "fmt" "log" - "strings" "unicode" ) @@ -23,7 +22,7 @@ type Request struct { func (r *Request) Initialize(p *Protocol) { r.srcName = SrcName(p, r.xmlName) if p.isExt() { - r.srcName = strings.Title(strings.ToLower(p.Name)) + r.srcName + r.srcName = r.srcName } if r.Reply != nil { diff --git a/nexgb/xgbgen/translation.go b/nexgb/xgbgen/translation.go index 44d615d..0123669 100644 --- a/nexgb/xgbgen/translation.go +++ b/nexgb/xgbgen/translation.go @@ -18,8 +18,9 @@ import ( "strings" ) -func (xml *XML) Translate() *Protocol { +func (xml *XML) Translate(parent *Protocol) *Protocol { protocol := &Protocol{ + Parent: parent, Name: xml.Header, ExtXName: xml.ExtensionXName, ExtName: xml.ExtensionName, @@ -33,7 +34,8 @@ func (xml *XML) Translate() *Protocol { for _, imp := range xml.Imports { if imp.xml != nil { - protocol.Imports = append(protocol.Imports, imp.xml.Translate()) + protocol.Imports = append(protocol.Imports, + imp.xml.Translate(protocol)) } } @@ -209,7 +211,7 @@ func (x *XMLRequest) Translate() *Request { // The XML protocol description references 'string_len' in the // computation of the 'odd_length' field. However, 'string_len' is not // defined. Therefore, let's forcefully add it as a 'local field'. - // (i.e., a parameter in the caller but does not get send over the wire.) + // (i.e., a parameter in the caller but does not get sent over the wire.) if x.Name == "QueryTextExtents" { stringLenLocal := &LocalField{&SingleField{ xmlName: "string_len", @@ -399,27 +401,15 @@ func TypeSrcName(p *Protocol, typ Type) string { if colon := strings.Index(t, ":"); colon > -1 { namespace := t[:colon] rest := t[colon+1:] - return splitAndTitle(namespace) + splitAndTitle(rest) + return p.ProtocolFind(namespace).PkgName() + "." + splitAndTitle(rest) } - // Since there is no namespace, we need to look for a namespace - // in the current context. - niceType := splitAndTitle(t) - if p.isExt() { - for _, typ2 := range p.Types { - if t == typ2.XmlName() { - return strings.Title(p.Name) + niceType - } - } - for _, imp := range p.Imports { - for _, typ2 := range imp.Types { - if t == typ2.XmlName() { - return strings.Title(imp.Name) + niceType - } - } - } + // Since there's no namespace, we're left with the raw type name. + // If the type is part of the source we're generating (i.e., there is + // no parent protocol), then just return that type name. + // Otherwise, we must qualify it with a package name. + if p.Parent == nil { + return splitAndTitle(t) } - - // We couldn't find one, so return it without a prefix. - return niceType + return p.PkgName() + "." + splitAndTitle(t) } diff --git a/nexgb/xinerama/xinerama.go b/nexgb/xinerama/xinerama.go new file mode 100644 index 0000000..eb7cd9a --- /dev/null +++ b/nexgb/xinerama/xinerama.go @@ -0,0 +1,633 @@ +package xinerama + +/* + This file was generated by xinerama.xml on May 10 2012 4:20:28pm EDT. + This file is automatically generated. Edit at your peril! +*/ + +import ( + "github.com/BurntSushi/xgb" + + "github.com/BurntSushi/xgb/xproto" +) + +// Init must be called before using the XINERAMA extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 8, "XINERAMA").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named XINERAMA could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["XINERAMA"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["XINERAMA"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["XINERAMA"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["XINERAMA"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["XINERAMA"] = make(map[int]xgb.NewErrorFun) +} + +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Bool' + +// Skipping definition for base type 'Float' + +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + +// 'ScreenInfo' struct definition +// Size: 8 +type ScreenInfo struct { + XOrg int16 + YOrg int16 + Width uint16 + Height uint16 +} + +// Struct read ScreenInfo +func ScreenInfoRead(buf []byte, v *ScreenInfo) int { + b := 0 + + v.XOrg = int16(xgb.Get16(buf[b:])) + b += 2 + + v.YOrg = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + return b +} + +// Struct list read ScreenInfo +func ScreenInfoReadList(buf []byte, dest []ScreenInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = ScreenInfo{} + b += ScreenInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write ScreenInfo +func (v ScreenInfo) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put16(buf[b:], uint16(v.XOrg)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.YOrg)) + b += 2 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + return buf +} + +// Write struct list ScreenInfo +func ScreenInfoListBytes(buf []byte, list []ScreenInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Request QueryVersion +// size: 8 +type QueryVersionCookie struct { + *xgb.Cookie +} + +func QueryVersion(c *xgb.Conn, Major byte, Minor byte) QueryVersionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c, Major, Minor), cookie) + return QueryVersionCookie{cookie} +} + +func QueryVersionUnchecked(c *xgb.Conn, Major byte, Minor byte) QueryVersionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c, Major, Minor), cookie) + return QueryVersionCookie{cookie} +} + +// Request reply for QueryVersion +// size: 12 +type QueryVersionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Major uint16 + Minor uint16 +} + +// Waits and reads reply data from request QueryVersion +func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryVersionReply(buf), nil +} + +// Read reply into structure from buffer for QueryVersion +func queryVersionReply(buf []byte) *QueryVersionReply { + v := new(QueryVersionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Major = xgb.Get16(buf[b:]) + b += 2 + + v.Minor = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Write request to wire for QueryVersion +func queryVersionRequest(c *xgb.Conn, Major byte, Minor byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINERAMA"] + b += 1 + + buf[b] = 0 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = Major + b += 1 + + buf[b] = Minor + b += 1 + + return buf +} + +// Request GetState +// size: 8 +type GetStateCookie struct { + *xgb.Cookie +} + +func GetState(c *xgb.Conn, Window xproto.Window) GetStateCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getStateRequest(c, Window), cookie) + return GetStateCookie{cookie} +} + +func GetStateUnchecked(c *xgb.Conn, Window xproto.Window) GetStateCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getStateRequest(c, Window), cookie) + return GetStateCookie{cookie} +} + +// Request reply for GetState +// size: 12 +type GetStateReply struct { + Sequence uint16 + Length uint32 + State byte + Window xproto.Window +} + +// Waits and reads reply data from request GetState +func (cook GetStateCookie) Reply() (*GetStateReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getStateReply(buf), nil +} + +// Read reply into structure from buffer for GetState +func getStateReply(buf []byte) *GetStateReply { + v := new(GetStateReply) + b := 1 // skip reply determinant + + v.State = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Window = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Write request to wire for GetState +func getStateRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINERAMA"] + b += 1 + + buf[b] = 1 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + +// Request GetScreenCount +// size: 8 +type GetScreenCountCookie struct { + *xgb.Cookie +} + +func GetScreenCount(c *xgb.Conn, Window xproto.Window) GetScreenCountCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getScreenCountRequest(c, Window), cookie) + return GetScreenCountCookie{cookie} +} + +func GetScreenCountUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenCountCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getScreenCountRequest(c, Window), cookie) + return GetScreenCountCookie{cookie} +} + +// Request reply for GetScreenCount +// size: 12 +type GetScreenCountReply struct { + Sequence uint16 + Length uint32 + ScreenCount byte + Window xproto.Window +} + +// Waits and reads reply data from request GetScreenCount +func (cook GetScreenCountCookie) Reply() (*GetScreenCountReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getScreenCountReply(buf), nil +} + +// Read reply into structure from buffer for GetScreenCount +func getScreenCountReply(buf []byte) *GetScreenCountReply { + v := new(GetScreenCountReply) + b := 1 // skip reply determinant + + v.ScreenCount = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Window = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Write request to wire for GetScreenCount +func getScreenCountRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINERAMA"] + b += 1 + + buf[b] = 2 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + +// Request GetScreenSize +// size: 12 +type GetScreenSizeCookie struct { + *xgb.Cookie +} + +func GetScreenSize(c *xgb.Conn, Window xproto.Window, Screen uint32) GetScreenSizeCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getScreenSizeRequest(c, Window, Screen), cookie) + return GetScreenSizeCookie{cookie} +} + +func GetScreenSizeUnchecked(c *xgb.Conn, Window xproto.Window, Screen uint32) GetScreenSizeCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getScreenSizeRequest(c, Window, Screen), cookie) + return GetScreenSizeCookie{cookie} +} + +// Request reply for GetScreenSize +// size: 24 +type GetScreenSizeReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Width uint32 + Height uint32 + Window xproto.Window + Screen uint32 +} + +// Waits and reads reply data from request GetScreenSize +func (cook GetScreenSizeCookie) Reply() (*GetScreenSizeReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getScreenSizeReply(buf), nil +} + +// Read reply into structure from buffer for GetScreenSize +func getScreenSizeReply(buf []byte) *GetScreenSizeReply { + v := new(GetScreenSizeReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Width = xgb.Get32(buf[b:]) + b += 4 + + v.Height = xgb.Get32(buf[b:]) + b += 4 + + v.Window = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.Screen = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for GetScreenSize +func getScreenSizeRequest(c *xgb.Conn, Window xproto.Window, Screen uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINERAMA"] + b += 1 + + buf[b] = 3 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put32(buf[b:], Screen) + b += 4 + + return buf +} + +// Request IsActive +// size: 4 +type IsActiveCookie struct { + *xgb.Cookie +} + +func IsActive(c *xgb.Conn) IsActiveCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(isActiveRequest(c), cookie) + return IsActiveCookie{cookie} +} + +func IsActiveUnchecked(c *xgb.Conn) IsActiveCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(isActiveRequest(c), cookie) + return IsActiveCookie{cookie} +} + +// Request reply for IsActive +// size: 12 +type IsActiveReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + State uint32 +} + +// Waits and reads reply data from request IsActive +func (cook IsActiveCookie) Reply() (*IsActiveReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return isActiveReply(buf), nil +} + +// Read reply into structure from buffer for IsActive +func isActiveReply(buf []byte) *IsActiveReply { + v := new(IsActiveReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.State = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for IsActive +func isActiveRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINERAMA"] + b += 1 + + buf[b] = 4 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request QueryScreens +// size: 4 +type QueryScreensCookie struct { + *xgb.Cookie +} + +func QueryScreens(c *xgb.Conn) QueryScreensCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryScreensRequest(c), cookie) + return QueryScreensCookie{cookie} +} + +func QueryScreensUnchecked(c *xgb.Conn) QueryScreensCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryScreensRequest(c), cookie) + return QueryScreensCookie{cookie} +} + +// Request reply for QueryScreens +// size: (32 + xgb.Pad((int(Number) * 8))) +type QueryScreensReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Number uint32 + // padding: 20 bytes + ScreenInfo []ScreenInfo // size: xgb.Pad((int(Number) * 8)) +} + +// Waits and reads reply data from request QueryScreens +func (cook QueryScreensCookie) Reply() (*QueryScreensReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryScreensReply(buf), nil +} + +// Read reply into structure from buffer for QueryScreens +func queryScreensReply(buf []byte) *QueryScreensReply { + v := new(QueryScreensReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Number = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.ScreenInfo = make([]ScreenInfo, v.Number) + b += ScreenInfoReadList(buf[b:], v.ScreenInfo) + + return v +} + +// Write request to wire for QueryScreens +func queryScreensRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINERAMA"] + b += 1 + + buf[b] = 5 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} diff --git a/nexgb/xinput/xinput.go b/nexgb/xinput/xinput.go new file mode 100644 index 0000000..40635f3 --- /dev/null +++ b/nexgb/xinput/xinput.go @@ -0,0 +1,7219 @@ +package xinput + +/* + This file was generated by xinput.xml on May 10 2012 4:20:28pm EDT. + This file is automatically generated. Edit at your peril! +*/ + +import ( + "github.com/BurntSushi/xgb" + + "github.com/BurntSushi/xgb/xproto" +) + +// Init must be called before using the XInputExtension extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 15, "XInputExtension").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named XInputExtension could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["XInputExtension"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["XInputExtension"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["XInputExtension"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["XInputExtension"] = make(map[int]xgb.NewErrorFun) +} + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Bool' + +// Skipping definition for base type 'Float' + +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +const ( + ValuatorModeRelative = 0 + ValuatorModeAbsolute = 1 +) + +const ( + PropagateModeAddToList = 0 + PropagateModeDeleteFromList = 1 +) + +const ( + DeviceUseIsXPointer = 0 + DeviceUseIsXKeyboard = 1 + DeviceUseIsXExtensionDevice = 2 + DeviceUseIsXExtensionKeyboard = 3 + DeviceUseIsXExtensionPointer = 4 +) + +const ( + InputClassKey = 0 + InputClassButton = 1 + InputClassValuator = 2 + InputClassFeedback = 3 + InputClassProximity = 4 + InputClassFocus = 5 + InputClassOther = 6 +) + +const ( + DeviceInputModeAsyncThisDevice = 0 + DeviceInputModeSyncThisDevice = 1 + DeviceInputModeReplayThisDevice = 2 + DeviceInputModeAsyncOtherDevices = 3 + DeviceInputModeAsyncAll = 4 + DeviceInputModeSyncAll = 5 +) + +const ( + FeedbackClassKeyboard = 0 + FeedbackClassPointer = 1 + FeedbackClassString = 2 + FeedbackClassInteger = 3 + FeedbackClassLed = 4 + FeedbackClassBell = 5 +) + +type KeyCode byte + +type EventClass uint32 + +// 'DeviceInfo' struct definition +// Size: 8 +type DeviceInfo struct { + DeviceType xproto.Atom + DeviceId byte + NumClassInfo byte + DeviceUse byte + // padding: 1 bytes +} + +// Struct read DeviceInfo +func DeviceInfoRead(buf []byte, v *DeviceInfo) int { + b := 0 + + v.DeviceType = xproto.Atom(xgb.Get32(buf[b:])) + b += 4 + + v.DeviceId = buf[b] + b += 1 + + v.NumClassInfo = buf[b] + b += 1 + + v.DeviceUse = buf[b] + b += 1 + + b += 1 // padding + + return b +} + +// Struct list read DeviceInfo +func DeviceInfoReadList(buf []byte, dest []DeviceInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DeviceInfo{} + b += DeviceInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write DeviceInfo +func (v DeviceInfo) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put32(buf[b:], uint32(v.DeviceType)) + b += 4 + + buf[b] = v.DeviceId + b += 1 + + buf[b] = v.NumClassInfo + b += 1 + + buf[b] = v.DeviceUse + b += 1 + + b += 1 // padding + + return buf +} + +// Write struct list DeviceInfo +func DeviceInfoListBytes(buf []byte, list []DeviceInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'InputInfo' struct definition +// Size: 2 +type InputInfo struct { + ClassId byte + Len byte +} + +// Struct read InputInfo +func InputInfoRead(buf []byte, v *InputInfo) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Len = buf[b] + b += 1 + + return b +} + +// Struct list read InputInfo +func InputInfoReadList(buf []byte, dest []InputInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = InputInfo{} + b += InputInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write InputInfo +func (v InputInfo) Bytes() []byte { + buf := make([]byte, 2) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Len + b += 1 + + return buf +} + +// Write struct list InputInfo +func InputInfoListBytes(buf []byte, list []InputInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'KeyInfo' struct definition +// Size: 8 +type KeyInfo struct { + ClassId byte + Len byte + MinKeycode KeyCode + MaxKeycode KeyCode + NumKeys uint16 + // padding: 2 bytes +} + +// Struct read KeyInfo +func KeyInfoRead(buf []byte, v *KeyInfo) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Len = buf[b] + b += 1 + + v.MinKeycode = KeyCode(buf[b]) + b += 1 + + v.MaxKeycode = KeyCode(buf[b]) + b += 1 + + v.NumKeys = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + return b +} + +// Struct list read KeyInfo +func KeyInfoReadList(buf []byte, dest []KeyInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = KeyInfo{} + b += KeyInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write KeyInfo +func (v KeyInfo) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Len + b += 1 + + buf[b] = byte(v.MinKeycode) + b += 1 + + buf[b] = byte(v.MaxKeycode) + b += 1 + + xgb.Put16(buf[b:], v.NumKeys) + b += 2 + + b += 2 // padding + + return buf +} + +// Write struct list KeyInfo +func KeyInfoListBytes(buf []byte, list []KeyInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'ButtonInfo' struct definition +// Size: 4 +type ButtonInfo struct { + ClassId byte + Len byte + NumButtons uint16 +} + +// Struct read ButtonInfo +func ButtonInfoRead(buf []byte, v *ButtonInfo) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Len = buf[b] + b += 1 + + v.NumButtons = xgb.Get16(buf[b:]) + b += 2 + + return b +} + +// Struct list read ButtonInfo +func ButtonInfoReadList(buf []byte, dest []ButtonInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = ButtonInfo{} + b += ButtonInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write ButtonInfo +func (v ButtonInfo) Bytes() []byte { + buf := make([]byte, 4) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Len + b += 1 + + xgb.Put16(buf[b:], v.NumButtons) + b += 2 + + return buf +} + +// Write struct list ButtonInfo +func ButtonInfoListBytes(buf []byte, list []ButtonInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'AxisInfo' struct definition +// Size: 12 +type AxisInfo struct { + Resolution uint32 + Minimum int32 + Maximum int32 +} + +// Struct read AxisInfo +func AxisInfoRead(buf []byte, v *AxisInfo) int { + b := 0 + + v.Resolution = xgb.Get32(buf[b:]) + b += 4 + + v.Minimum = int32(xgb.Get32(buf[b:])) + b += 4 + + v.Maximum = int32(xgb.Get32(buf[b:])) + b += 4 + + return b +} + +// Struct list read AxisInfo +func AxisInfoReadList(buf []byte, dest []AxisInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = AxisInfo{} + b += AxisInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write AxisInfo +func (v AxisInfo) Bytes() []byte { + buf := make([]byte, 12) + b := 0 + + xgb.Put32(buf[b:], v.Resolution) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Minimum)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Maximum)) + b += 4 + + return buf +} + +// Write struct list AxisInfo +func AxisInfoListBytes(buf []byte, list []AxisInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'ValuatorInfo' struct definition +// Size: (8 + xgb.Pad((int(AxesLen) * 12))) +type ValuatorInfo struct { + ClassId byte + Len byte + AxesLen byte + Mode byte + MotionSize uint32 + Axes []AxisInfo // size: xgb.Pad((int(AxesLen) * 12)) +} + +// Struct read ValuatorInfo +func ValuatorInfoRead(buf []byte, v *ValuatorInfo) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Len = buf[b] + b += 1 + + v.AxesLen = buf[b] + b += 1 + + v.Mode = buf[b] + b += 1 + + v.MotionSize = xgb.Get32(buf[b:]) + b += 4 + + v.Axes = make([]AxisInfo, v.AxesLen) + b += AxisInfoReadList(buf[b:], v.Axes) + + return b +} + +// Struct list read ValuatorInfo +func ValuatorInfoReadList(buf []byte, dest []ValuatorInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = ValuatorInfo{} + b += ValuatorInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write ValuatorInfo +func (v ValuatorInfo) Bytes() []byte { + buf := make([]byte, (8 + xgb.Pad((int(v.AxesLen) * 12)))) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Len + b += 1 + + buf[b] = v.AxesLen + b += 1 + + buf[b] = v.Mode + b += 1 + + xgb.Put32(buf[b:], v.MotionSize) + b += 4 + + b += AxisInfoListBytes(buf[b:], v.Axes) + + return buf +} + +// Write struct list ValuatorInfo +func ValuatorInfoListBytes(buf []byte, list []ValuatorInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size ValuatorInfo +func ValuatorInfoListSize(list []ValuatorInfo) int { + size := 0 + for _, item := range list { + size += (8 + xgb.Pad((int(item.AxesLen) * 12))) + } + return size +} + +// 'InputClassInfo' struct definition +// Size: 2 +type InputClassInfo struct { + ClassId byte + EventTypeBase byte +} + +// Struct read InputClassInfo +func InputClassInfoRead(buf []byte, v *InputClassInfo) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.EventTypeBase = buf[b] + b += 1 + + return b +} + +// Struct list read InputClassInfo +func InputClassInfoReadList(buf []byte, dest []InputClassInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = InputClassInfo{} + b += InputClassInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write InputClassInfo +func (v InputClassInfo) Bytes() []byte { + buf := make([]byte, 2) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.EventTypeBase + b += 1 + + return buf +} + +// Write struct list InputClassInfo +func InputClassInfoListBytes(buf []byte, list []InputClassInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'DeviceTimeCoord' struct definition +// Size: 4 +type DeviceTimeCoord struct { + Time xproto.Timestamp +} + +// Struct read DeviceTimeCoord +func DeviceTimeCoordRead(buf []byte, v *DeviceTimeCoord) int { + b := 0 + + v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + return b +} + +// Struct list read DeviceTimeCoord +func DeviceTimeCoordReadList(buf []byte, dest []DeviceTimeCoord) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DeviceTimeCoord{} + b += DeviceTimeCoordRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write DeviceTimeCoord +func (v DeviceTimeCoord) Bytes() []byte { + buf := make([]byte, 4) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + return buf +} + +// Write struct list DeviceTimeCoord +func DeviceTimeCoordListBytes(buf []byte, list []DeviceTimeCoord) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'FeedbackState' struct definition +// Size: 4 +type FeedbackState struct { + ClassId byte + Id byte + Len uint16 +} + +// Struct read FeedbackState +func FeedbackStateRead(buf []byte, v *FeedbackState) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Id = buf[b] + b += 1 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + return b +} + +// Struct list read FeedbackState +func FeedbackStateReadList(buf []byte, dest []FeedbackState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = FeedbackState{} + b += FeedbackStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write FeedbackState +func (v FeedbackState) Bytes() []byte { + buf := make([]byte, 4) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Id + b += 1 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + return buf +} + +// Write struct list FeedbackState +func FeedbackStateListBytes(buf []byte, list []FeedbackState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'KbdFeedbackState' struct definition +// Size: 52 +type KbdFeedbackState struct { + ClassId byte + Id byte + Len uint16 + Pitch uint16 + Duration uint16 + LedMask uint32 + LedValues uint32 + GlobalAutoRepeat bool + Click byte + Percent byte + // padding: 1 bytes + AutoRepeats []byte // size: 32 +} + +// Struct read KbdFeedbackState +func KbdFeedbackStateRead(buf []byte, v *KbdFeedbackState) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Id = buf[b] + b += 1 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.Pitch = xgb.Get16(buf[b:]) + b += 2 + + v.Duration = xgb.Get16(buf[b:]) + b += 2 + + v.LedMask = xgb.Get32(buf[b:]) + b += 4 + + v.LedValues = xgb.Get32(buf[b:]) + b += 4 + + if buf[b] == 1 { + v.GlobalAutoRepeat = true + } else { + v.GlobalAutoRepeat = false + } + b += 1 + + v.Click = buf[b] + b += 1 + + v.Percent = buf[b] + b += 1 + + b += 1 // padding + + v.AutoRepeats = make([]byte, 32) + copy(v.AutoRepeats[:32], buf[b:]) + b += xgb.Pad(int(32)) + + return b +} + +// Struct list read KbdFeedbackState +func KbdFeedbackStateReadList(buf []byte, dest []KbdFeedbackState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = KbdFeedbackState{} + b += KbdFeedbackStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write KbdFeedbackState +func (v KbdFeedbackState) Bytes() []byte { + buf := make([]byte, 52) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Id + b += 1 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + xgb.Put16(buf[b:], v.Pitch) + b += 2 + + xgb.Put16(buf[b:], v.Duration) + b += 2 + + xgb.Put32(buf[b:], v.LedMask) + b += 4 + + xgb.Put32(buf[b:], v.LedValues) + b += 4 + + if v.GlobalAutoRepeat { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + buf[b] = v.Click + b += 1 + + buf[b] = v.Percent + b += 1 + + b += 1 // padding + + copy(buf[b:], v.AutoRepeats[:32]) + b += xgb.Pad(int(32)) + + return buf +} + +// Write struct list KbdFeedbackState +func KbdFeedbackStateListBytes(buf []byte, list []KbdFeedbackState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size KbdFeedbackState +func KbdFeedbackStateListSize(list []KbdFeedbackState) int { + size := 0 + for _ = range list { + size += 52 + } + return size +} + +// 'PtrFeedbackState' struct definition +// Size: 12 +type PtrFeedbackState struct { + ClassId byte + Id byte + Len uint16 + // padding: 2 bytes + AccelNum uint16 + AccelDenom uint16 + Threshold uint16 +} + +// Struct read PtrFeedbackState +func PtrFeedbackStateRead(buf []byte, v *PtrFeedbackState) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Id = buf[b] + b += 1 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + v.AccelNum = xgb.Get16(buf[b:]) + b += 2 + + v.AccelDenom = xgb.Get16(buf[b:]) + b += 2 + + v.Threshold = xgb.Get16(buf[b:]) + b += 2 + + return b +} + +// Struct list read PtrFeedbackState +func PtrFeedbackStateReadList(buf []byte, dest []PtrFeedbackState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = PtrFeedbackState{} + b += PtrFeedbackStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write PtrFeedbackState +func (v PtrFeedbackState) Bytes() []byte { + buf := make([]byte, 12) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Id + b += 1 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + b += 2 // padding + + xgb.Put16(buf[b:], v.AccelNum) + b += 2 + + xgb.Put16(buf[b:], v.AccelDenom) + b += 2 + + xgb.Put16(buf[b:], v.Threshold) + b += 2 + + return buf +} + +// Write struct list PtrFeedbackState +func PtrFeedbackStateListBytes(buf []byte, list []PtrFeedbackState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'IntegerFeedbackState' struct definition +// Size: 16 +type IntegerFeedbackState struct { + ClassId byte + Id byte + Len uint16 + Resolution uint32 + MinValue int32 + MaxValue int32 +} + +// Struct read IntegerFeedbackState +func IntegerFeedbackStateRead(buf []byte, v *IntegerFeedbackState) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Id = buf[b] + b += 1 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.Resolution = xgb.Get32(buf[b:]) + b += 4 + + v.MinValue = int32(xgb.Get32(buf[b:])) + b += 4 + + v.MaxValue = int32(xgb.Get32(buf[b:])) + b += 4 + + return b +} + +// Struct list read IntegerFeedbackState +func IntegerFeedbackStateReadList(buf []byte, dest []IntegerFeedbackState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = IntegerFeedbackState{} + b += IntegerFeedbackStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write IntegerFeedbackState +func (v IntegerFeedbackState) Bytes() []byte { + buf := make([]byte, 16) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Id + b += 1 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + xgb.Put32(buf[b:], v.Resolution) + b += 4 + + xgb.Put32(buf[b:], uint32(v.MinValue)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.MaxValue)) + b += 4 + + return buf +} + +// Write struct list IntegerFeedbackState +func IntegerFeedbackStateListBytes(buf []byte, list []IntegerFeedbackState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'StringFeedbackState' struct definition +// Size: (8 + xgb.Pad((int(NumKeysyms) * 4))) +type StringFeedbackState struct { + ClassId byte + Id byte + Len uint16 + MaxSymbols uint16 + NumKeysyms uint16 + Keysyms []xproto.Keysym // size: xgb.Pad((int(NumKeysyms) * 4)) +} + +// Struct read StringFeedbackState +func StringFeedbackStateRead(buf []byte, v *StringFeedbackState) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Id = buf[b] + b += 1 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.MaxSymbols = xgb.Get16(buf[b:]) + b += 2 + + v.NumKeysyms = xgb.Get16(buf[b:]) + b += 2 + + v.Keysyms = make([]xproto.Keysym, v.NumKeysyms) + for i := 0; i < int(v.NumKeysyms); i++ { + v.Keysyms[i] = xproto.Keysym(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return b +} + +// Struct list read StringFeedbackState +func StringFeedbackStateReadList(buf []byte, dest []StringFeedbackState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = StringFeedbackState{} + b += StringFeedbackStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write StringFeedbackState +func (v StringFeedbackState) Bytes() []byte { + buf := make([]byte, (8 + xgb.Pad((int(v.NumKeysyms) * 4)))) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Id + b += 1 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + xgb.Put16(buf[b:], v.MaxSymbols) + b += 2 + + xgb.Put16(buf[b:], v.NumKeysyms) + b += 2 + + for i := 0; i < int(v.NumKeysyms); i++ { + xgb.Put32(buf[b:], uint32(v.Keysyms[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Write struct list StringFeedbackState +func StringFeedbackStateListBytes(buf []byte, list []StringFeedbackState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size StringFeedbackState +func StringFeedbackStateListSize(list []StringFeedbackState) int { + size := 0 + for _, item := range list { + size += (8 + xgb.Pad((int(item.NumKeysyms) * 4))) + } + return size +} + +// 'BellFeedbackState' struct definition +// Size: 12 +type BellFeedbackState struct { + ClassId byte + Id byte + Len uint16 + Percent byte + // padding: 3 bytes + Pitch uint16 + Duration uint16 +} + +// Struct read BellFeedbackState +func BellFeedbackStateRead(buf []byte, v *BellFeedbackState) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Id = buf[b] + b += 1 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.Percent = buf[b] + b += 1 + + b += 3 // padding + + v.Pitch = xgb.Get16(buf[b:]) + b += 2 + + v.Duration = xgb.Get16(buf[b:]) + b += 2 + + return b +} + +// Struct list read BellFeedbackState +func BellFeedbackStateReadList(buf []byte, dest []BellFeedbackState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = BellFeedbackState{} + b += BellFeedbackStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write BellFeedbackState +func (v BellFeedbackState) Bytes() []byte { + buf := make([]byte, 12) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Id + b += 1 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + buf[b] = v.Percent + b += 1 + + b += 3 // padding + + xgb.Put16(buf[b:], v.Pitch) + b += 2 + + xgb.Put16(buf[b:], v.Duration) + b += 2 + + return buf +} + +// Write struct list BellFeedbackState +func BellFeedbackStateListBytes(buf []byte, list []BellFeedbackState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'LedFeedbackState' struct definition +// Size: 12 +type LedFeedbackState struct { + ClassId byte + Id byte + Len uint16 + LedMask uint32 + LedValues uint32 +} + +// Struct read LedFeedbackState +func LedFeedbackStateRead(buf []byte, v *LedFeedbackState) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Id = buf[b] + b += 1 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.LedMask = xgb.Get32(buf[b:]) + b += 4 + + v.LedValues = xgb.Get32(buf[b:]) + b += 4 + + return b +} + +// Struct list read LedFeedbackState +func LedFeedbackStateReadList(buf []byte, dest []LedFeedbackState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = LedFeedbackState{} + b += LedFeedbackStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write LedFeedbackState +func (v LedFeedbackState) Bytes() []byte { + buf := make([]byte, 12) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Id + b += 1 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + xgb.Put32(buf[b:], v.LedMask) + b += 4 + + xgb.Put32(buf[b:], v.LedValues) + b += 4 + + return buf +} + +// Write struct list LedFeedbackState +func LedFeedbackStateListBytes(buf []byte, list []LedFeedbackState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'FeedbackCtl' struct definition +// Size: 4 +type FeedbackCtl struct { + ClassId byte + Id byte + Len uint16 +} + +// Struct read FeedbackCtl +func FeedbackCtlRead(buf []byte, v *FeedbackCtl) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Id = buf[b] + b += 1 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + return b +} + +// Struct list read FeedbackCtl +func FeedbackCtlReadList(buf []byte, dest []FeedbackCtl) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = FeedbackCtl{} + b += FeedbackCtlRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write FeedbackCtl +func (v FeedbackCtl) Bytes() []byte { + buf := make([]byte, 4) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Id + b += 1 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + return buf +} + +// Write struct list FeedbackCtl +func FeedbackCtlListBytes(buf []byte, list []FeedbackCtl) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'KbdFeedbackCtl' struct definition +// Size: 20 +type KbdFeedbackCtl struct { + ClassId byte + Id byte + Len uint16 + Key KeyCode + AutoRepeatMode byte + KeyClickPercent int8 + BellPercent int8 + BellPitch int16 + BellDuration int16 + LedMask uint32 + LedValues uint32 +} + +// Struct read KbdFeedbackCtl +func KbdFeedbackCtlRead(buf []byte, v *KbdFeedbackCtl) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Id = buf[b] + b += 1 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.Key = KeyCode(buf[b]) + b += 1 + + v.AutoRepeatMode = buf[b] + b += 1 + + v.KeyClickPercent = int8(buf[b]) + b += 1 + + v.BellPercent = int8(buf[b]) + b += 1 + + v.BellPitch = int16(xgb.Get16(buf[b:])) + b += 2 + + v.BellDuration = int16(xgb.Get16(buf[b:])) + b += 2 + + v.LedMask = xgb.Get32(buf[b:]) + b += 4 + + v.LedValues = xgb.Get32(buf[b:]) + b += 4 + + return b +} + +// Struct list read KbdFeedbackCtl +func KbdFeedbackCtlReadList(buf []byte, dest []KbdFeedbackCtl) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = KbdFeedbackCtl{} + b += KbdFeedbackCtlRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write KbdFeedbackCtl +func (v KbdFeedbackCtl) Bytes() []byte { + buf := make([]byte, 20) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Id + b += 1 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + buf[b] = byte(v.Key) + b += 1 + + buf[b] = v.AutoRepeatMode + b += 1 + + buf[b] = byte(v.KeyClickPercent) + b += 1 + + buf[b] = byte(v.BellPercent) + b += 1 + + xgb.Put16(buf[b:], uint16(v.BellPitch)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.BellDuration)) + b += 2 + + xgb.Put32(buf[b:], v.LedMask) + b += 4 + + xgb.Put32(buf[b:], v.LedValues) + b += 4 + + return buf +} + +// Write struct list KbdFeedbackCtl +func KbdFeedbackCtlListBytes(buf []byte, list []KbdFeedbackCtl) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'PtrFeedbackCtl' struct definition +// Size: 12 +type PtrFeedbackCtl struct { + ClassId byte + Id byte + Len uint16 + // padding: 2 bytes + Num int16 + Denom int16 + Threshold int16 +} + +// Struct read PtrFeedbackCtl +func PtrFeedbackCtlRead(buf []byte, v *PtrFeedbackCtl) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Id = buf[b] + b += 1 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + v.Num = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Denom = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Threshold = int16(xgb.Get16(buf[b:])) + b += 2 + + return b +} + +// Struct list read PtrFeedbackCtl +func PtrFeedbackCtlReadList(buf []byte, dest []PtrFeedbackCtl) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = PtrFeedbackCtl{} + b += PtrFeedbackCtlRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write PtrFeedbackCtl +func (v PtrFeedbackCtl) Bytes() []byte { + buf := make([]byte, 12) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Id + b += 1 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + b += 2 // padding + + xgb.Put16(buf[b:], uint16(v.Num)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Denom)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Threshold)) + b += 2 + + return buf +} + +// Write struct list PtrFeedbackCtl +func PtrFeedbackCtlListBytes(buf []byte, list []PtrFeedbackCtl) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'IntegerFeedbackCtl' struct definition +// Size: 8 +type IntegerFeedbackCtl struct { + ClassId byte + Id byte + Len uint16 + IntToDisplay int32 +} + +// Struct read IntegerFeedbackCtl +func IntegerFeedbackCtlRead(buf []byte, v *IntegerFeedbackCtl) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Id = buf[b] + b += 1 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.IntToDisplay = int32(xgb.Get32(buf[b:])) + b += 4 + + return b +} + +// Struct list read IntegerFeedbackCtl +func IntegerFeedbackCtlReadList(buf []byte, dest []IntegerFeedbackCtl) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = IntegerFeedbackCtl{} + b += IntegerFeedbackCtlRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write IntegerFeedbackCtl +func (v IntegerFeedbackCtl) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Id + b += 1 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + xgb.Put32(buf[b:], uint32(v.IntToDisplay)) + b += 4 + + return buf +} + +// Write struct list IntegerFeedbackCtl +func IntegerFeedbackCtlListBytes(buf []byte, list []IntegerFeedbackCtl) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'StringFeedbackCtl' struct definition +// Size: (8 + xgb.Pad((int(NumKeysyms) * 4))) +type StringFeedbackCtl struct { + ClassId byte + Id byte + Len uint16 + // padding: 2 bytes + NumKeysyms uint16 + Keysyms []xproto.Keysym // size: xgb.Pad((int(NumKeysyms) * 4)) +} + +// Struct read StringFeedbackCtl +func StringFeedbackCtlRead(buf []byte, v *StringFeedbackCtl) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Id = buf[b] + b += 1 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + v.NumKeysyms = xgb.Get16(buf[b:]) + b += 2 + + v.Keysyms = make([]xproto.Keysym, v.NumKeysyms) + for i := 0; i < int(v.NumKeysyms); i++ { + v.Keysyms[i] = xproto.Keysym(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return b +} + +// Struct list read StringFeedbackCtl +func StringFeedbackCtlReadList(buf []byte, dest []StringFeedbackCtl) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = StringFeedbackCtl{} + b += StringFeedbackCtlRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write StringFeedbackCtl +func (v StringFeedbackCtl) Bytes() []byte { + buf := make([]byte, (8 + xgb.Pad((int(v.NumKeysyms) * 4)))) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Id + b += 1 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + b += 2 // padding + + xgb.Put16(buf[b:], v.NumKeysyms) + b += 2 + + for i := 0; i < int(v.NumKeysyms); i++ { + xgb.Put32(buf[b:], uint32(v.Keysyms[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Write struct list StringFeedbackCtl +func StringFeedbackCtlListBytes(buf []byte, list []StringFeedbackCtl) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size StringFeedbackCtl +func StringFeedbackCtlListSize(list []StringFeedbackCtl) int { + size := 0 + for _, item := range list { + size += (8 + xgb.Pad((int(item.NumKeysyms) * 4))) + } + return size +} + +// 'BellFeedbackCtl' struct definition +// Size: 12 +type BellFeedbackCtl struct { + ClassId byte + Id byte + Len uint16 + Percent int8 + // padding: 3 bytes + Pitch int16 + Duration int16 +} + +// Struct read BellFeedbackCtl +func BellFeedbackCtlRead(buf []byte, v *BellFeedbackCtl) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Id = buf[b] + b += 1 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.Percent = int8(buf[b]) + b += 1 + + b += 3 // padding + + v.Pitch = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Duration = int16(xgb.Get16(buf[b:])) + b += 2 + + return b +} + +// Struct list read BellFeedbackCtl +func BellFeedbackCtlReadList(buf []byte, dest []BellFeedbackCtl) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = BellFeedbackCtl{} + b += BellFeedbackCtlRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write BellFeedbackCtl +func (v BellFeedbackCtl) Bytes() []byte { + buf := make([]byte, 12) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Id + b += 1 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + buf[b] = byte(v.Percent) + b += 1 + + b += 3 // padding + + xgb.Put16(buf[b:], uint16(v.Pitch)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Duration)) + b += 2 + + return buf +} + +// Write struct list BellFeedbackCtl +func BellFeedbackCtlListBytes(buf []byte, list []BellFeedbackCtl) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'LedFeedbackCtl' struct definition +// Size: 12 +type LedFeedbackCtl struct { + ClassId byte + Id byte + Len uint16 + LedMask uint32 + LedValues uint32 +} + +// Struct read LedFeedbackCtl +func LedFeedbackCtlRead(buf []byte, v *LedFeedbackCtl) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Id = buf[b] + b += 1 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.LedMask = xgb.Get32(buf[b:]) + b += 4 + + v.LedValues = xgb.Get32(buf[b:]) + b += 4 + + return b +} + +// Struct list read LedFeedbackCtl +func LedFeedbackCtlReadList(buf []byte, dest []LedFeedbackCtl) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = LedFeedbackCtl{} + b += LedFeedbackCtlRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write LedFeedbackCtl +func (v LedFeedbackCtl) Bytes() []byte { + buf := make([]byte, 12) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Id + b += 1 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + xgb.Put32(buf[b:], v.LedMask) + b += 4 + + xgb.Put32(buf[b:], v.LedValues) + b += 4 + + return buf +} + +// Write struct list LedFeedbackCtl +func LedFeedbackCtlListBytes(buf []byte, list []LedFeedbackCtl) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'InputState' struct definition +// Size: 3 +type InputState struct { + ClassId byte + Len byte + NumItems byte +} + +// Struct read InputState +func InputStateRead(buf []byte, v *InputState) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Len = buf[b] + b += 1 + + v.NumItems = buf[b] + b += 1 + + return b +} + +// Struct list read InputState +func InputStateReadList(buf []byte, dest []InputState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = InputState{} + b += InputStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write InputState +func (v InputState) Bytes() []byte { + buf := make([]byte, 3) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Len + b += 1 + + buf[b] = v.NumItems + b += 1 + + return buf +} + +// Write struct list InputState +func InputStateListBytes(buf []byte, list []InputState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'KeyState' struct definition +// Size: 36 +type KeyState struct { + ClassId byte + Len byte + NumKeys byte + // padding: 1 bytes + Keys []byte // size: 32 +} + +// Struct read KeyState +func KeyStateRead(buf []byte, v *KeyState) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Len = buf[b] + b += 1 + + v.NumKeys = buf[b] + b += 1 + + b += 1 // padding + + v.Keys = make([]byte, 32) + copy(v.Keys[:32], buf[b:]) + b += xgb.Pad(int(32)) + + return b +} + +// Struct list read KeyState +func KeyStateReadList(buf []byte, dest []KeyState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = KeyState{} + b += KeyStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write KeyState +func (v KeyState) Bytes() []byte { + buf := make([]byte, 36) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Len + b += 1 + + buf[b] = v.NumKeys + b += 1 + + b += 1 // padding + + copy(buf[b:], v.Keys[:32]) + b += xgb.Pad(int(32)) + + return buf +} + +// Write struct list KeyState +func KeyStateListBytes(buf []byte, list []KeyState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size KeyState +func KeyStateListSize(list []KeyState) int { + size := 0 + for _ = range list { + size += 36 + } + return size +} + +// 'ButtonState' struct definition +// Size: 36 +type ButtonState struct { + ClassId byte + Len byte + NumButtons byte + // padding: 1 bytes + Buttons []byte // size: 32 +} + +// Struct read ButtonState +func ButtonStateRead(buf []byte, v *ButtonState) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Len = buf[b] + b += 1 + + v.NumButtons = buf[b] + b += 1 + + b += 1 // padding + + v.Buttons = make([]byte, 32) + copy(v.Buttons[:32], buf[b:]) + b += xgb.Pad(int(32)) + + return b +} + +// Struct list read ButtonState +func ButtonStateReadList(buf []byte, dest []ButtonState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = ButtonState{} + b += ButtonStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write ButtonState +func (v ButtonState) Bytes() []byte { + buf := make([]byte, 36) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Len + b += 1 + + buf[b] = v.NumButtons + b += 1 + + b += 1 // padding + + copy(buf[b:], v.Buttons[:32]) + b += xgb.Pad(int(32)) + + return buf +} + +// Write struct list ButtonState +func ButtonStateListBytes(buf []byte, list []ButtonState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size ButtonState +func ButtonStateListSize(list []ButtonState) int { + size := 0 + for _ = range list { + size += 36 + } + return size +} + +// 'ValuatorState' struct definition +// Size: (4 + xgb.Pad((int(NumValuators) * 4))) +type ValuatorState struct { + ClassId byte + Len byte + NumValuators byte + Mode byte + Valuators []uint32 // size: xgb.Pad((int(NumValuators) * 4)) +} + +// Struct read ValuatorState +func ValuatorStateRead(buf []byte, v *ValuatorState) int { + b := 0 + + v.ClassId = buf[b] + b += 1 + + v.Len = buf[b] + b += 1 + + v.NumValuators = buf[b] + b += 1 + + v.Mode = buf[b] + b += 1 + + v.Valuators = make([]uint32, v.NumValuators) + for i := 0; i < int(v.NumValuators); i++ { + v.Valuators[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return b +} + +// Struct list read ValuatorState +func ValuatorStateReadList(buf []byte, dest []ValuatorState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = ValuatorState{} + b += ValuatorStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write ValuatorState +func (v ValuatorState) Bytes() []byte { + buf := make([]byte, (4 + xgb.Pad((int(v.NumValuators) * 4)))) + b := 0 + + buf[b] = v.ClassId + b += 1 + + buf[b] = v.Len + b += 1 + + buf[b] = v.NumValuators + b += 1 + + buf[b] = v.Mode + b += 1 + + for i := 0; i < int(v.NumValuators); i++ { + xgb.Put32(buf[b:], v.Valuators[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Write struct list ValuatorState +func ValuatorStateListBytes(buf []byte, list []ValuatorState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size ValuatorState +func ValuatorStateListSize(list []ValuatorState) int { + size := 0 + for _, item := range list { + size += (4 + xgb.Pad((int(item.NumValuators) * 4))) + } + return size +} + +// 'DeviceState' struct definition +// Size: 4 +type DeviceState struct { + ControlId uint16 + Len uint16 +} + +// Struct read DeviceState +func DeviceStateRead(buf []byte, v *DeviceState) int { + b := 0 + + v.ControlId = xgb.Get16(buf[b:]) + b += 2 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + return b +} + +// Struct list read DeviceState +func DeviceStateReadList(buf []byte, dest []DeviceState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DeviceState{} + b += DeviceStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write DeviceState +func (v DeviceState) Bytes() []byte { + buf := make([]byte, 4) + b := 0 + + xgb.Put16(buf[b:], v.ControlId) + b += 2 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + return buf +} + +// Write struct list DeviceState +func DeviceStateListBytes(buf []byte, list []DeviceState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'DeviceResolutionState' struct definition +// Size: (((8 + xgb.Pad((int(NumValuators) * 4))) + xgb.Pad((int(NumValuators) * 4))) + xgb.Pad((int(NumValuators) * 4))) +type DeviceResolutionState struct { + ControlId uint16 + Len uint16 + NumValuators uint32 + ResolutionValues []uint32 // size: xgb.Pad((int(NumValuators) * 4)) + ResolutionMin []uint32 // size: xgb.Pad((int(NumValuators) * 4)) + ResolutionMax []uint32 // size: xgb.Pad((int(NumValuators) * 4)) +} + +// Struct read DeviceResolutionState +func DeviceResolutionStateRead(buf []byte, v *DeviceResolutionState) int { + b := 0 + + v.ControlId = xgb.Get16(buf[b:]) + b += 2 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.NumValuators = xgb.Get32(buf[b:]) + b += 4 + + v.ResolutionValues = make([]uint32, v.NumValuators) + for i := 0; i < int(v.NumValuators); i++ { + v.ResolutionValues[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + v.ResolutionMin = make([]uint32, v.NumValuators) + for i := 0; i < int(v.NumValuators); i++ { + v.ResolutionMin[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + v.ResolutionMax = make([]uint32, v.NumValuators) + for i := 0; i < int(v.NumValuators); i++ { + v.ResolutionMax[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return b +} + +// Struct list read DeviceResolutionState +func DeviceResolutionStateReadList(buf []byte, dest []DeviceResolutionState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DeviceResolutionState{} + b += DeviceResolutionStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write DeviceResolutionState +func (v DeviceResolutionState) Bytes() []byte { + buf := make([]byte, (((8 + xgb.Pad((int(v.NumValuators) * 4))) + xgb.Pad((int(v.NumValuators) * 4))) + xgb.Pad((int(v.NumValuators) * 4)))) + b := 0 + + xgb.Put16(buf[b:], v.ControlId) + b += 2 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + xgb.Put32(buf[b:], v.NumValuators) + b += 4 + + for i := 0; i < int(v.NumValuators); i++ { + xgb.Put32(buf[b:], v.ResolutionValues[i]) + b += 4 + } + b = xgb.Pad(b) + + for i := 0; i < int(v.NumValuators); i++ { + xgb.Put32(buf[b:], v.ResolutionMin[i]) + b += 4 + } + b = xgb.Pad(b) + + for i := 0; i < int(v.NumValuators); i++ { + xgb.Put32(buf[b:], v.ResolutionMax[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Write struct list DeviceResolutionState +func DeviceResolutionStateListBytes(buf []byte, list []DeviceResolutionState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size DeviceResolutionState +func DeviceResolutionStateListSize(list []DeviceResolutionState) int { + size := 0 + for _, item := range list { + size += (((8 + xgb.Pad((int(item.NumValuators) * 4))) + xgb.Pad((int(item.NumValuators) * 4))) + xgb.Pad((int(item.NumValuators) * 4))) + } + return size +} + +// 'DeviceAbsCalibState' struct definition +// Size: 36 +type DeviceAbsCalibState struct { + ControlId uint16 + Len uint16 + MinX int32 + MaxX int32 + MinY int32 + MaxY int32 + FlipX uint32 + FlipY uint32 + Rotation uint32 + ButtonThreshold uint32 +} + +// Struct read DeviceAbsCalibState +func DeviceAbsCalibStateRead(buf []byte, v *DeviceAbsCalibState) int { + b := 0 + + v.ControlId = xgb.Get16(buf[b:]) + b += 2 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.MinX = int32(xgb.Get32(buf[b:])) + b += 4 + + v.MaxX = int32(xgb.Get32(buf[b:])) + b += 4 + + v.MinY = int32(xgb.Get32(buf[b:])) + b += 4 + + v.MaxY = int32(xgb.Get32(buf[b:])) + b += 4 + + v.FlipX = xgb.Get32(buf[b:]) + b += 4 + + v.FlipY = xgb.Get32(buf[b:]) + b += 4 + + v.Rotation = xgb.Get32(buf[b:]) + b += 4 + + v.ButtonThreshold = xgb.Get32(buf[b:]) + b += 4 + + return b +} + +// Struct list read DeviceAbsCalibState +func DeviceAbsCalibStateReadList(buf []byte, dest []DeviceAbsCalibState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DeviceAbsCalibState{} + b += DeviceAbsCalibStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write DeviceAbsCalibState +func (v DeviceAbsCalibState) Bytes() []byte { + buf := make([]byte, 36) + b := 0 + + xgb.Put16(buf[b:], v.ControlId) + b += 2 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + xgb.Put32(buf[b:], uint32(v.MinX)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.MaxX)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.MinY)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.MaxY)) + b += 4 + + xgb.Put32(buf[b:], v.FlipX) + b += 4 + + xgb.Put32(buf[b:], v.FlipY) + b += 4 + + xgb.Put32(buf[b:], v.Rotation) + b += 4 + + xgb.Put32(buf[b:], v.ButtonThreshold) + b += 4 + + return buf +} + +// Write struct list DeviceAbsCalibState +func DeviceAbsCalibStateListBytes(buf []byte, list []DeviceAbsCalibState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'DeviceAbsAreaState' struct definition +// Size: 28 +type DeviceAbsAreaState struct { + ControlId uint16 + Len uint16 + OffsetX uint32 + OffsetY uint32 + Width uint32 + Height uint32 + Screen uint32 + Following uint32 +} + +// Struct read DeviceAbsAreaState +func DeviceAbsAreaStateRead(buf []byte, v *DeviceAbsAreaState) int { + b := 0 + + v.ControlId = xgb.Get16(buf[b:]) + b += 2 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.OffsetX = xgb.Get32(buf[b:]) + b += 4 + + v.OffsetY = xgb.Get32(buf[b:]) + b += 4 + + v.Width = xgb.Get32(buf[b:]) + b += 4 + + v.Height = xgb.Get32(buf[b:]) + b += 4 + + v.Screen = xgb.Get32(buf[b:]) + b += 4 + + v.Following = xgb.Get32(buf[b:]) + b += 4 + + return b +} + +// Struct list read DeviceAbsAreaState +func DeviceAbsAreaStateReadList(buf []byte, dest []DeviceAbsAreaState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DeviceAbsAreaState{} + b += DeviceAbsAreaStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write DeviceAbsAreaState +func (v DeviceAbsAreaState) Bytes() []byte { + buf := make([]byte, 28) + b := 0 + + xgb.Put16(buf[b:], v.ControlId) + b += 2 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + xgb.Put32(buf[b:], v.OffsetX) + b += 4 + + xgb.Put32(buf[b:], v.OffsetY) + b += 4 + + xgb.Put32(buf[b:], v.Width) + b += 4 + + xgb.Put32(buf[b:], v.Height) + b += 4 + + xgb.Put32(buf[b:], v.Screen) + b += 4 + + xgb.Put32(buf[b:], v.Following) + b += 4 + + return buf +} + +// Write struct list DeviceAbsAreaState +func DeviceAbsAreaStateListBytes(buf []byte, list []DeviceAbsAreaState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'DeviceCoreState' struct definition +// Size: 8 +type DeviceCoreState struct { + ControlId uint16 + Len uint16 + Status byte + Iscore byte + // padding: 2 bytes +} + +// Struct read DeviceCoreState +func DeviceCoreStateRead(buf []byte, v *DeviceCoreState) int { + b := 0 + + v.ControlId = xgb.Get16(buf[b:]) + b += 2 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.Status = buf[b] + b += 1 + + v.Iscore = buf[b] + b += 1 + + b += 2 // padding + + return b +} + +// Struct list read DeviceCoreState +func DeviceCoreStateReadList(buf []byte, dest []DeviceCoreState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DeviceCoreState{} + b += DeviceCoreStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write DeviceCoreState +func (v DeviceCoreState) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put16(buf[b:], v.ControlId) + b += 2 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + buf[b] = v.Status + b += 1 + + buf[b] = v.Iscore + b += 1 + + b += 2 // padding + + return buf +} + +// Write struct list DeviceCoreState +func DeviceCoreStateListBytes(buf []byte, list []DeviceCoreState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'DeviceEnableState' struct definition +// Size: 8 +type DeviceEnableState struct { + ControlId uint16 + Len uint16 + Enable byte + // padding: 3 bytes +} + +// Struct read DeviceEnableState +func DeviceEnableStateRead(buf []byte, v *DeviceEnableState) int { + b := 0 + + v.ControlId = xgb.Get16(buf[b:]) + b += 2 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.Enable = buf[b] + b += 1 + + b += 3 // padding + + return b +} + +// Struct list read DeviceEnableState +func DeviceEnableStateReadList(buf []byte, dest []DeviceEnableState) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DeviceEnableState{} + b += DeviceEnableStateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write DeviceEnableState +func (v DeviceEnableState) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put16(buf[b:], v.ControlId) + b += 2 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + buf[b] = v.Enable + b += 1 + + b += 3 // padding + + return buf +} + +// Write struct list DeviceEnableState +func DeviceEnableStateListBytes(buf []byte, list []DeviceEnableState) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'DeviceCtl' struct definition +// Size: 4 +type DeviceCtl struct { + ControlId uint16 + Len uint16 +} + +// Struct read DeviceCtl +func DeviceCtlRead(buf []byte, v *DeviceCtl) int { + b := 0 + + v.ControlId = xgb.Get16(buf[b:]) + b += 2 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + return b +} + +// Struct list read DeviceCtl +func DeviceCtlReadList(buf []byte, dest []DeviceCtl) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DeviceCtl{} + b += DeviceCtlRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write DeviceCtl +func (v DeviceCtl) Bytes() []byte { + buf := make([]byte, 4) + b := 0 + + xgb.Put16(buf[b:], v.ControlId) + b += 2 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + return buf +} + +// Write struct list DeviceCtl +func DeviceCtlListBytes(buf []byte, list []DeviceCtl) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'DeviceResolutionCtl' struct definition +// Size: (6 + xgb.Pad((int(NumValuators) * 4))) +type DeviceResolutionCtl struct { + ControlId uint16 + Len uint16 + FirstValuator byte + NumValuators byte + ResolutionValues []uint32 // size: xgb.Pad((int(NumValuators) * 4)) +} + +// Struct read DeviceResolutionCtl +func DeviceResolutionCtlRead(buf []byte, v *DeviceResolutionCtl) int { + b := 0 + + v.ControlId = xgb.Get16(buf[b:]) + b += 2 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.FirstValuator = buf[b] + b += 1 + + v.NumValuators = buf[b] + b += 1 + + v.ResolutionValues = make([]uint32, v.NumValuators) + for i := 0; i < int(v.NumValuators); i++ { + v.ResolutionValues[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return b +} + +// Struct list read DeviceResolutionCtl +func DeviceResolutionCtlReadList(buf []byte, dest []DeviceResolutionCtl) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DeviceResolutionCtl{} + b += DeviceResolutionCtlRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write DeviceResolutionCtl +func (v DeviceResolutionCtl) Bytes() []byte { + buf := make([]byte, (6 + xgb.Pad((int(v.NumValuators) * 4)))) + b := 0 + + xgb.Put16(buf[b:], v.ControlId) + b += 2 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + buf[b] = v.FirstValuator + b += 1 + + buf[b] = v.NumValuators + b += 1 + + for i := 0; i < int(v.NumValuators); i++ { + xgb.Put32(buf[b:], v.ResolutionValues[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Write struct list DeviceResolutionCtl +func DeviceResolutionCtlListBytes(buf []byte, list []DeviceResolutionCtl) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size DeviceResolutionCtl +func DeviceResolutionCtlListSize(list []DeviceResolutionCtl) int { + size := 0 + for _, item := range list { + size += (6 + xgb.Pad((int(item.NumValuators) * 4))) + } + return size +} + +// 'DeviceAbsCalibCtl' struct definition +// Size: 36 +type DeviceAbsCalibCtl struct { + ControlId uint16 + Len uint16 + MinX int32 + MaxX int32 + MinY int32 + MaxY int32 + FlipX uint32 + FlipY uint32 + Rotation uint32 + ButtonThreshold uint32 +} + +// Struct read DeviceAbsCalibCtl +func DeviceAbsCalibCtlRead(buf []byte, v *DeviceAbsCalibCtl) int { + b := 0 + + v.ControlId = xgb.Get16(buf[b:]) + b += 2 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.MinX = int32(xgb.Get32(buf[b:])) + b += 4 + + v.MaxX = int32(xgb.Get32(buf[b:])) + b += 4 + + v.MinY = int32(xgb.Get32(buf[b:])) + b += 4 + + v.MaxY = int32(xgb.Get32(buf[b:])) + b += 4 + + v.FlipX = xgb.Get32(buf[b:]) + b += 4 + + v.FlipY = xgb.Get32(buf[b:]) + b += 4 + + v.Rotation = xgb.Get32(buf[b:]) + b += 4 + + v.ButtonThreshold = xgb.Get32(buf[b:]) + b += 4 + + return b +} + +// Struct list read DeviceAbsCalibCtl +func DeviceAbsCalibCtlReadList(buf []byte, dest []DeviceAbsCalibCtl) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DeviceAbsCalibCtl{} + b += DeviceAbsCalibCtlRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write DeviceAbsCalibCtl +func (v DeviceAbsCalibCtl) Bytes() []byte { + buf := make([]byte, 36) + b := 0 + + xgb.Put16(buf[b:], v.ControlId) + b += 2 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + xgb.Put32(buf[b:], uint32(v.MinX)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.MaxX)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.MinY)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.MaxY)) + b += 4 + + xgb.Put32(buf[b:], v.FlipX) + b += 4 + + xgb.Put32(buf[b:], v.FlipY) + b += 4 + + xgb.Put32(buf[b:], v.Rotation) + b += 4 + + xgb.Put32(buf[b:], v.ButtonThreshold) + b += 4 + + return buf +} + +// Write struct list DeviceAbsCalibCtl +func DeviceAbsCalibCtlListBytes(buf []byte, list []DeviceAbsCalibCtl) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'DeviceAbsAreaCtrl' struct definition +// Size: 28 +type DeviceAbsAreaCtrl struct { + ControlId uint16 + Len uint16 + OffsetX uint32 + OffsetY uint32 + Width int32 + Height int32 + Screen int32 + Following uint32 +} + +// Struct read DeviceAbsAreaCtrl +func DeviceAbsAreaCtrlRead(buf []byte, v *DeviceAbsAreaCtrl) int { + b := 0 + + v.ControlId = xgb.Get16(buf[b:]) + b += 2 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.OffsetX = xgb.Get32(buf[b:]) + b += 4 + + v.OffsetY = xgb.Get32(buf[b:]) + b += 4 + + v.Width = int32(xgb.Get32(buf[b:])) + b += 4 + + v.Height = int32(xgb.Get32(buf[b:])) + b += 4 + + v.Screen = int32(xgb.Get32(buf[b:])) + b += 4 + + v.Following = xgb.Get32(buf[b:]) + b += 4 + + return b +} + +// Struct list read DeviceAbsAreaCtrl +func DeviceAbsAreaCtrlReadList(buf []byte, dest []DeviceAbsAreaCtrl) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DeviceAbsAreaCtrl{} + b += DeviceAbsAreaCtrlRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write DeviceAbsAreaCtrl +func (v DeviceAbsAreaCtrl) Bytes() []byte { + buf := make([]byte, 28) + b := 0 + + xgb.Put16(buf[b:], v.ControlId) + b += 2 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + xgb.Put32(buf[b:], v.OffsetX) + b += 4 + + xgb.Put32(buf[b:], v.OffsetY) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Width)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Height)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Screen)) + b += 4 + + xgb.Put32(buf[b:], v.Following) + b += 4 + + return buf +} + +// Write struct list DeviceAbsAreaCtrl +func DeviceAbsAreaCtrlListBytes(buf []byte, list []DeviceAbsAreaCtrl) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'DeviceCoreCtrl' struct definition +// Size: 8 +type DeviceCoreCtrl struct { + ControlId uint16 + Len uint16 + Status byte + // padding: 3 bytes +} + +// Struct read DeviceCoreCtrl +func DeviceCoreCtrlRead(buf []byte, v *DeviceCoreCtrl) int { + b := 0 + + v.ControlId = xgb.Get16(buf[b:]) + b += 2 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.Status = buf[b] + b += 1 + + b += 3 // padding + + return b +} + +// Struct list read DeviceCoreCtrl +func DeviceCoreCtrlReadList(buf []byte, dest []DeviceCoreCtrl) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DeviceCoreCtrl{} + b += DeviceCoreCtrlRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write DeviceCoreCtrl +func (v DeviceCoreCtrl) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put16(buf[b:], v.ControlId) + b += 2 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + buf[b] = v.Status + b += 1 + + b += 3 // padding + + return buf +} + +// Write struct list DeviceCoreCtrl +func DeviceCoreCtrlListBytes(buf []byte, list []DeviceCoreCtrl) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'DeviceEnableCtrl' struct definition +// Size: 8 +type DeviceEnableCtrl struct { + ControlId uint16 + Len uint16 + Enable byte + // padding: 3 bytes +} + +// Struct read DeviceEnableCtrl +func DeviceEnableCtrlRead(buf []byte, v *DeviceEnableCtrl) int { + b := 0 + + v.ControlId = xgb.Get16(buf[b:]) + b += 2 + + v.Len = xgb.Get16(buf[b:]) + b += 2 + + v.Enable = buf[b] + b += 1 + + b += 3 // padding + + return b +} + +// Struct list read DeviceEnableCtrl +func DeviceEnableCtrlReadList(buf []byte, dest []DeviceEnableCtrl) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DeviceEnableCtrl{} + b += DeviceEnableCtrlRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write DeviceEnableCtrl +func (v DeviceEnableCtrl) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put16(buf[b:], v.ControlId) + b += 2 + + xgb.Put16(buf[b:], v.Len) + b += 2 + + buf[b] = v.Enable + b += 1 + + b += 3 // padding + + return buf +} + +// Write struct list DeviceEnableCtrl +func DeviceEnableCtrlListBytes(buf []byte, list []DeviceEnableCtrl) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Event definition DeviceValuator (0) +// Size: 32 + +const DeviceValuator = 0 + +type DeviceValuatorEvent struct { + Sequence uint16 + DeviceId byte + DeviceState uint16 + NumValuators byte + FirstValuator byte + Valuators []int32 // size: 24 +} + +// Event read DeviceValuator +func DeviceValuatorEventNew(buf []byte) xgb.Event { + v := DeviceValuatorEvent{} + b := 1 // don't read event number + + v.DeviceId = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.DeviceState = xgb.Get16(buf[b:]) + b += 2 + + v.NumValuators = buf[b] + b += 1 + + v.FirstValuator = buf[b] + b += 1 + + v.Valuators = make([]int32, 6) + for i := 0; i < int(6); i++ { + v.Valuators[i] = int32(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Event write DeviceValuator +func (v DeviceValuatorEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 0 + b += 1 + + buf[b] = v.DeviceId + b += 1 + + b += 2 // skip sequence number + + xgb.Put16(buf[b:], v.DeviceState) + b += 2 + + buf[b] = v.NumValuators + b += 1 + + buf[b] = v.FirstValuator + b += 1 + + for i := 0; i < int(6); i++ { + xgb.Put32(buf[b:], uint32(v.Valuators[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +func (v DeviceValuatorEvent) ImplementsEvent() {} + +func (v DeviceValuatorEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v DeviceValuatorEvent) String() string { + fieldVals := make([]string, 0, 5) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceState: %d", v.DeviceState)) + fieldVals = append(fieldVals, xgb.Sprintf("NumValuators: %d", v.NumValuators)) + fieldVals = append(fieldVals, xgb.Sprintf("FirstValuator: %d", v.FirstValuator)) + return "DeviceValuator {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"][0] = DeviceValuatorEventNew +} + +// Event definition DeviceKeyPress (1) +// Size: 32 + +const DeviceKeyPress = 1 + +type DeviceKeyPressEvent struct { + Sequence uint16 + Detail byte + Time xproto.Timestamp + Root xproto.Window + Event xproto.Window + Child xproto.Window + RootX int16 + RootY int16 + EventX int16 + EventY int16 + State uint16 + SameScreen bool + DeviceId byte +} + +// Event read DeviceKeyPress +func DeviceKeyPressEventNew(buf []byte) xgb.Event { + v := DeviceKeyPressEvent{} + b := 1 // don't read event number + + v.Detail = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Root = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.Event = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.Child = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.RootX = int16(xgb.Get16(buf[b:])) + b += 2 + + v.RootY = int16(xgb.Get16(buf[b:])) + b += 2 + + v.EventX = int16(xgb.Get16(buf[b:])) + b += 2 + + v.EventY = int16(xgb.Get16(buf[b:])) + b += 2 + + v.State = xgb.Get16(buf[b:]) + b += 2 + + if buf[b] == 1 { + v.SameScreen = true + } else { + v.SameScreen = false + } + b += 1 + + v.DeviceId = buf[b] + b += 1 + + return v +} + +// Event write DeviceKeyPress +func (v DeviceKeyPressEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 1 + b += 1 + + buf[b] = v.Detail + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Root)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Child)) + b += 4 + + xgb.Put16(buf[b:], uint16(v.RootX)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.RootY)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.EventX)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.EventY)) + b += 2 + + xgb.Put16(buf[b:], v.State) + b += 2 + + if v.SameScreen { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + buf[b] = v.DeviceId + b += 1 + + return buf +} + +func (v DeviceKeyPressEvent) ImplementsEvent() {} + +func (v DeviceKeyPressEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v DeviceKeyPressEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + return "DeviceKeyPress {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"][1] = DeviceKeyPressEventNew +} + +// Event definition FocusIn (6) +// Size: 32 + +const FocusIn = 6 + +type FocusInEvent struct { + Sequence uint16 + Detail byte + Time xproto.Timestamp + Window xproto.Window + Mode byte + DeviceId byte + // padding: 18 bytes +} + +// Event read FocusIn +func FocusInEventNew(buf []byte) xgb.Event { + v := FocusInEvent{} + b := 1 // don't read event number + + v.Detail = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Window = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.Mode = buf[b] + b += 1 + + v.DeviceId = buf[b] + b += 1 + + b += 18 // padding + + return v +} + +// Event write FocusIn +func (v FocusInEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 6 + b += 1 + + buf[b] = v.Detail + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + buf[b] = v.Mode + b += 1 + + buf[b] = v.DeviceId + b += 1 + + b += 18 // padding + + return buf +} + +func (v FocusInEvent) ImplementsEvent() {} + +func (v FocusInEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v FocusInEvent) String() string { + fieldVals := make([]string, 0, 6) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("Mode: %d", v.Mode)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + return "FocusIn {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"][6] = FocusInEventNew +} + +// Event definition DeviceStateNotify (10) +// Size: 32 + +const DeviceStateNotify = 10 + +type DeviceStateNotifyEvent struct { + Sequence uint16 + DeviceId byte + Time xproto.Timestamp + NumKeys byte + NumButtons byte + NumValuators byte + ClassesReported byte + Buttons []byte // size: 4 + Keys []byte // size: 4 + Valuators []uint32 // size: 12 +} + +// Event read DeviceStateNotify +func DeviceStateNotifyEventNew(buf []byte) xgb.Event { + v := DeviceStateNotifyEvent{} + b := 1 // don't read event number + + v.DeviceId = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.NumKeys = buf[b] + b += 1 + + v.NumButtons = buf[b] + b += 1 + + v.NumValuators = buf[b] + b += 1 + + v.ClassesReported = buf[b] + b += 1 + + v.Buttons = make([]byte, 4) + copy(v.Buttons[:4], buf[b:]) + b += xgb.Pad(int(4)) + + v.Keys = make([]byte, 4) + copy(v.Keys[:4], buf[b:]) + b += xgb.Pad(int(4)) + + v.Valuators = make([]uint32, 3) + for i := 0; i < int(3); i++ { + v.Valuators[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Event write DeviceStateNotify +func (v DeviceStateNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 10 + b += 1 + + buf[b] = v.DeviceId + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + buf[b] = v.NumKeys + b += 1 + + buf[b] = v.NumButtons + b += 1 + + buf[b] = v.NumValuators + b += 1 + + buf[b] = v.ClassesReported + b += 1 + + copy(buf[b:], v.Buttons[:4]) + b += xgb.Pad(int(4)) + + copy(buf[b:], v.Keys[:4]) + b += xgb.Pad(int(4)) + + for i := 0; i < int(3); i++ { + xgb.Put32(buf[b:], v.Valuators[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +func (v DeviceStateNotifyEvent) ImplementsEvent() {} + +func (v DeviceStateNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v DeviceStateNotifyEvent) String() string { + fieldVals := make([]string, 0, 9) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("NumKeys: %d", v.NumKeys)) + fieldVals = append(fieldVals, xgb.Sprintf("NumButtons: %d", v.NumButtons)) + fieldVals = append(fieldVals, xgb.Sprintf("NumValuators: %d", v.NumValuators)) + fieldVals = append(fieldVals, xgb.Sprintf("ClassesReported: %d", v.ClassesReported)) + return "DeviceStateNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"][10] = DeviceStateNotifyEventNew +} + +// Event definition DeviceMappingNotify (11) +// Size: 32 + +const DeviceMappingNotify = 11 + +type DeviceMappingNotifyEvent struct { + Sequence uint16 + DeviceId byte + Request byte + FirstKeycode KeyCode + Count byte + // padding: 1 bytes + Time xproto.Timestamp + // padding: 20 bytes +} + +// Event read DeviceMappingNotify +func DeviceMappingNotifyEventNew(buf []byte) xgb.Event { + v := DeviceMappingNotifyEvent{} + b := 1 // don't read event number + + v.DeviceId = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Request = buf[b] + b += 1 + + v.FirstKeycode = KeyCode(buf[b]) + b += 1 + + v.Count = buf[b] + b += 1 + + b += 1 // padding + + v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + b += 20 // padding + + return v +} + +// Event write DeviceMappingNotify +func (v DeviceMappingNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 11 + b += 1 + + buf[b] = v.DeviceId + b += 1 + + b += 2 // skip sequence number + + buf[b] = v.Request + b += 1 + + buf[b] = byte(v.FirstKeycode) + b += 1 + + buf[b] = v.Count + b += 1 + + b += 1 // padding + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + b += 20 // padding + + return buf +} + +func (v DeviceMappingNotifyEvent) ImplementsEvent() {} + +func (v DeviceMappingNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v DeviceMappingNotifyEvent) String() string { + fieldVals := make([]string, 0, 7) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + fieldVals = append(fieldVals, xgb.Sprintf("Request: %d", v.Request)) + fieldVals = append(fieldVals, xgb.Sprintf("FirstKeycode: %d", v.FirstKeycode)) + fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + return "DeviceMappingNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"][11] = DeviceMappingNotifyEventNew +} + +// Event definition ChangeDeviceNotify (12) +// Size: 32 + +const ChangeDeviceNotify = 12 + +type ChangeDeviceNotifyEvent struct { + Sequence uint16 + DeviceId byte + Time xproto.Timestamp + Request byte + // padding: 23 bytes +} + +// Event read ChangeDeviceNotify +func ChangeDeviceNotifyEventNew(buf []byte) xgb.Event { + v := ChangeDeviceNotifyEvent{} + b := 1 // don't read event number + + v.DeviceId = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Request = buf[b] + b += 1 + + b += 23 // padding + + return v +} + +// Event write ChangeDeviceNotify +func (v ChangeDeviceNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 12 + b += 1 + + buf[b] = v.DeviceId + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + buf[b] = v.Request + b += 1 + + b += 23 // padding + + return buf +} + +func (v ChangeDeviceNotifyEvent) ImplementsEvent() {} + +func (v ChangeDeviceNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v ChangeDeviceNotifyEvent) String() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Request: %d", v.Request)) + return "ChangeDeviceNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"][12] = ChangeDeviceNotifyEventNew +} + +// Event definition DeviceKeyStateNotify (13) +// Size: 32 + +const DeviceKeyStateNotify = 13 + +type DeviceKeyStateNotifyEvent struct { + Sequence uint16 + DeviceId byte + Keys []byte // size: 28 +} + +// Event read DeviceKeyStateNotify +func DeviceKeyStateNotifyEventNew(buf []byte) xgb.Event { + v := DeviceKeyStateNotifyEvent{} + b := 1 // don't read event number + + v.DeviceId = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Keys = make([]byte, 28) + copy(v.Keys[:28], buf[b:]) + b += xgb.Pad(int(28)) + + return v +} + +// Event write DeviceKeyStateNotify +func (v DeviceKeyStateNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 13 + b += 1 + + buf[b] = v.DeviceId + b += 1 + + b += 2 // skip sequence number + + copy(buf[b:], v.Keys[:28]) + b += xgb.Pad(int(28)) + + return buf +} + +func (v DeviceKeyStateNotifyEvent) ImplementsEvent() {} + +func (v DeviceKeyStateNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v DeviceKeyStateNotifyEvent) String() string { + fieldVals := make([]string, 0, 2) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + return "DeviceKeyStateNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"][13] = DeviceKeyStateNotifyEventNew +} + +// Event definition DeviceButtonStateNotify (14) +// Size: 32 + +const DeviceButtonStateNotify = 14 + +type DeviceButtonStateNotifyEvent struct { + Sequence uint16 + DeviceId byte + Buttons []byte // size: 28 +} + +// Event read DeviceButtonStateNotify +func DeviceButtonStateNotifyEventNew(buf []byte) xgb.Event { + v := DeviceButtonStateNotifyEvent{} + b := 1 // don't read event number + + v.DeviceId = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Buttons = make([]byte, 28) + copy(v.Buttons[:28], buf[b:]) + b += xgb.Pad(int(28)) + + return v +} + +// Event write DeviceButtonStateNotify +func (v DeviceButtonStateNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 14 + b += 1 + + buf[b] = v.DeviceId + b += 1 + + b += 2 // skip sequence number + + copy(buf[b:], v.Buttons[:28]) + b += xgb.Pad(int(28)) + + return buf +} + +func (v DeviceButtonStateNotifyEvent) ImplementsEvent() {} + +func (v DeviceButtonStateNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v DeviceButtonStateNotifyEvent) String() string { + fieldVals := make([]string, 0, 2) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + return "DeviceButtonStateNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"][14] = DeviceButtonStateNotifyEventNew +} + +// Event definition DevicePresenceNotify (15) +// Size: 32 + +const DevicePresenceNotify = 15 + +type DevicePresenceNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Time xproto.Timestamp + Devchange byte + DeviceId byte + Control uint16 + // padding: 20 bytes +} + +// Event read DevicePresenceNotify +func DevicePresenceNotifyEventNew(buf []byte) xgb.Event { + v := DevicePresenceNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Devchange = buf[b] + b += 1 + + v.DeviceId = buf[b] + b += 1 + + v.Control = xgb.Get16(buf[b:]) + b += 2 + + b += 20 // padding + + return v +} + +// Event write DevicePresenceNotify +func (v DevicePresenceNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 15 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + buf[b] = v.Devchange + b += 1 + + buf[b] = v.DeviceId + b += 1 + + xgb.Put16(buf[b:], v.Control) + b += 2 + + b += 20 // padding + + return buf +} + +func (v DevicePresenceNotifyEvent) ImplementsEvent() {} + +func (v DevicePresenceNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v DevicePresenceNotifyEvent) String() string { + fieldVals := make([]string, 0, 6) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Devchange: %d", v.Devchange)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + fieldVals = append(fieldVals, xgb.Sprintf("Control: %d", v.Control)) + return "DevicePresenceNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"][15] = DevicePresenceNotifyEventNew +} + +// EventCopy definition DeviceKeyRelease (2) + +const DeviceKeyRelease = 2 + +type DeviceKeyReleaseEvent DeviceKeyPressEvent + +func DeviceKeyReleaseEventNew(buf []byte) xgb.Event { + return DeviceKeyReleaseEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) +} + +func (v DeviceKeyReleaseEvent) Bytes() []byte { + return DeviceKeyPressEvent(v).Bytes() +} + +func (v DeviceKeyReleaseEvent) ImplementsEvent() {} + +func (v DeviceKeyReleaseEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v DeviceKeyReleaseEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + return "DeviceKeyRelease {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"][2] = DeviceKeyReleaseEventNew +} + +// EventCopy definition DeviceButtonPress (3) + +const DeviceButtonPress = 3 + +type DeviceButtonPressEvent DeviceKeyPressEvent + +func DeviceButtonPressEventNew(buf []byte) xgb.Event { + return DeviceButtonPressEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) +} + +func (v DeviceButtonPressEvent) Bytes() []byte { + return DeviceKeyPressEvent(v).Bytes() +} + +func (v DeviceButtonPressEvent) ImplementsEvent() {} + +func (v DeviceButtonPressEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v DeviceButtonPressEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + return "DeviceButtonPress {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"][3] = DeviceButtonPressEventNew +} + +// EventCopy definition DeviceButtonRelease (4) + +const DeviceButtonRelease = 4 + +type DeviceButtonReleaseEvent DeviceKeyPressEvent + +func DeviceButtonReleaseEventNew(buf []byte) xgb.Event { + return DeviceButtonReleaseEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) +} + +func (v DeviceButtonReleaseEvent) Bytes() []byte { + return DeviceKeyPressEvent(v).Bytes() +} + +func (v DeviceButtonReleaseEvent) ImplementsEvent() {} + +func (v DeviceButtonReleaseEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v DeviceButtonReleaseEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + return "DeviceButtonRelease {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"][4] = DeviceButtonReleaseEventNew +} + +// EventCopy definition DeviceMotionNotify (5) + +const DeviceMotionNotify = 5 + +type DeviceMotionNotifyEvent DeviceKeyPressEvent + +func DeviceMotionNotifyEventNew(buf []byte) xgb.Event { + return DeviceMotionNotifyEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) +} + +func (v DeviceMotionNotifyEvent) Bytes() []byte { + return DeviceKeyPressEvent(v).Bytes() +} + +func (v DeviceMotionNotifyEvent) ImplementsEvent() {} + +func (v DeviceMotionNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v DeviceMotionNotifyEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + return "DeviceMotionNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"][5] = DeviceMotionNotifyEventNew +} + +// EventCopy definition ProximityIn (8) + +const ProximityIn = 8 + +type ProximityInEvent DeviceKeyPressEvent + +func ProximityInEventNew(buf []byte) xgb.Event { + return ProximityInEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) +} + +func (v ProximityInEvent) Bytes() []byte { + return DeviceKeyPressEvent(v).Bytes() +} + +func (v ProximityInEvent) ImplementsEvent() {} + +func (v ProximityInEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v ProximityInEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + return "ProximityIn {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"][8] = ProximityInEventNew +} + +// EventCopy definition ProximityOut (9) + +const ProximityOut = 9 + +type ProximityOutEvent DeviceKeyPressEvent + +func ProximityOutEventNew(buf []byte) xgb.Event { + return ProximityOutEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) +} + +func (v ProximityOutEvent) Bytes() []byte { + return DeviceKeyPressEvent(v).Bytes() +} + +func (v ProximityOutEvent) ImplementsEvent() {} + +func (v ProximityOutEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v ProximityOutEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + return "ProximityOut {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"][9] = ProximityOutEventNew +} + +// EventCopy definition FocusOut (7) + +const FocusOut = 7 + +type FocusOutEvent FocusInEvent + +func FocusOutEventNew(buf []byte) xgb.Event { + return FocusOutEvent(FocusInEventNew(buf).(FocusInEvent)) +} + +func (v FocusOutEvent) Bytes() []byte { + return FocusInEvent(v).Bytes() +} + +func (v FocusOutEvent) ImplementsEvent() {} + +func (v FocusOutEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v FocusOutEvent) String() string { + fieldVals := make([]string, 0, 6) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("Mode: %d", v.Mode)) + fieldVals = append(fieldVals, xgb.Sprintf("DeviceId: %d", v.DeviceId)) + return "FocusOut {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XInputExtension"][7] = FocusOutEventNew +} + +// Error definition Device (0) +// Size: 32 + +const BadDevice = 0 + +type DeviceError struct { + Sequence uint16 + NiceName string +} + +// Error read Device +func DeviceErrorNew(buf []byte) xgb.Error { + v := DeviceError{} + v.NiceName = "Device" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err DeviceError) ImplementsError() {} + +func (err DeviceError) SequenceId() uint16 { + return err.Sequence +} + +func (err DeviceError) BadId() uint32 { + return 0 +} + +func (err DeviceError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadDevice {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XInputExtension"][0] = DeviceErrorNew +} + +// Error definition Event (1) +// Size: 32 + +const BadEvent = 1 + +type EventError struct { + Sequence uint16 + NiceName string +} + +// Error read Event +func EventErrorNew(buf []byte) xgb.Error { + v := EventError{} + v.NiceName = "Event" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err EventError) ImplementsError() {} + +func (err EventError) SequenceId() uint16 { + return err.Sequence +} + +func (err EventError) BadId() uint32 { + return 0 +} + +func (err EventError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadEvent {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XInputExtension"][1] = EventErrorNew +} + +// Error definition Mode (2) +// Size: 32 + +const BadMode = 2 + +type ModeError struct { + Sequence uint16 + NiceName string +} + +// Error read Mode +func ModeErrorNew(buf []byte) xgb.Error { + v := ModeError{} + v.NiceName = "Mode" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err ModeError) ImplementsError() {} + +func (err ModeError) SequenceId() uint16 { + return err.Sequence +} + +func (err ModeError) BadId() uint32 { + return 0 +} + +func (err ModeError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadMode {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XInputExtension"][2] = ModeErrorNew +} + +// Error definition DeviceBusy (3) +// Size: 32 + +const BadDeviceBusy = 3 + +type DeviceBusyError struct { + Sequence uint16 + NiceName string +} + +// Error read DeviceBusy +func DeviceBusyErrorNew(buf []byte) xgb.Error { + v := DeviceBusyError{} + v.NiceName = "DeviceBusy" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err DeviceBusyError) ImplementsError() {} + +func (err DeviceBusyError) SequenceId() uint16 { + return err.Sequence +} + +func (err DeviceBusyError) BadId() uint32 { + return 0 +} + +func (err DeviceBusyError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadDeviceBusy {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XInputExtension"][3] = DeviceBusyErrorNew +} + +// Error definition Class (4) +// Size: 32 + +const BadClass = 4 + +type ClassError struct { + Sequence uint16 + NiceName string +} + +// Error read Class +func ClassErrorNew(buf []byte) xgb.Error { + v := ClassError{} + v.NiceName = "Class" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err ClassError) ImplementsError() {} + +func (err ClassError) SequenceId() uint16 { + return err.Sequence +} + +func (err ClassError) BadId() uint32 { + return 0 +} + +func (err ClassError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadClass {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XInputExtension"][4] = ClassErrorNew +} + +// Request GetExtensionVersion +// size: xgb.Pad((8 + xgb.Pad((int(NameLen) * 1)))) +type GetExtensionVersionCookie struct { + *xgb.Cookie +} + +func GetExtensionVersion(c *xgb.Conn, NameLen uint16, Name string) GetExtensionVersionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getExtensionVersionRequest(c, NameLen, Name), cookie) + return GetExtensionVersionCookie{cookie} +} + +func GetExtensionVersionUnchecked(c *xgb.Conn, NameLen uint16, Name string) GetExtensionVersionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getExtensionVersionRequest(c, NameLen, Name), cookie) + return GetExtensionVersionCookie{cookie} +} + +// Request reply for GetExtensionVersion +// size: 32 +type GetExtensionVersionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ServerMajor uint16 + ServerMinor uint16 + Present bool + // padding: 19 bytes +} + +// Waits and reads reply data from request GetExtensionVersion +func (cook GetExtensionVersionCookie) Reply() (*GetExtensionVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getExtensionVersionReply(buf), nil +} + +// Read reply into structure from buffer for GetExtensionVersion +func getExtensionVersionReply(buf []byte) *GetExtensionVersionReply { + v := new(GetExtensionVersionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ServerMajor = xgb.Get16(buf[b:]) + b += 2 + + v.ServerMinor = xgb.Get16(buf[b:]) + b += 2 + + if buf[b] == 1 { + v.Present = true + } else { + v.Present = false + } + b += 1 + + b += 19 // padding + + return v +} + +// Write request to wire for GetExtensionVersion +func getExtensionVersionRequest(c *xgb.Conn, NameLen uint16, Name string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(NameLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 1 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], NameLen) + b += 2 + + b += 2 // padding + + copy(buf[b:], Name[:NameLen]) + b += xgb.Pad(int(NameLen)) + + return buf +} + +// Request ListInputDevices +// size: 4 +type ListInputDevicesCookie struct { + *xgb.Cookie +} + +func ListInputDevices(c *xgb.Conn) ListInputDevicesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(listInputDevicesRequest(c), cookie) + return ListInputDevicesCookie{cookie} +} + +func ListInputDevicesUnchecked(c *xgb.Conn) ListInputDevicesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(listInputDevicesRequest(c), cookie) + return ListInputDevicesCookie{cookie} +} + +// Request reply for ListInputDevices +// size: (32 + xgb.Pad((int(DevicesLen) * 8))) +type ListInputDevicesReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + DevicesLen byte + // padding: 23 bytes + Devices []DeviceInfo // size: xgb.Pad((int(DevicesLen) * 8)) +} + +// Waits and reads reply data from request ListInputDevices +func (cook ListInputDevicesCookie) Reply() (*ListInputDevicesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listInputDevicesReply(buf), nil +} + +// Read reply into structure from buffer for ListInputDevices +func listInputDevicesReply(buf []byte) *ListInputDevicesReply { + v := new(ListInputDevicesReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.DevicesLen = buf[b] + b += 1 + + b += 23 // padding + + v.Devices = make([]DeviceInfo, v.DevicesLen) + b += DeviceInfoReadList(buf[b:], v.Devices) + + return v +} + +// Write request to wire for ListInputDevices +func listInputDevicesRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 2 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request OpenDevice +// size: 8 +type OpenDeviceCookie struct { + *xgb.Cookie +} + +func OpenDevice(c *xgb.Conn, DeviceId byte) OpenDeviceCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(openDeviceRequest(c, DeviceId), cookie) + return OpenDeviceCookie{cookie} +} + +func OpenDeviceUnchecked(c *xgb.Conn, DeviceId byte) OpenDeviceCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(openDeviceRequest(c, DeviceId), cookie) + return OpenDeviceCookie{cookie} +} + +// Request reply for OpenDevice +// size: (32 + xgb.Pad((int(NumClasses) * 2))) +type OpenDeviceReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumClasses byte + // padding: 23 bytes + ClassInfo []InputClassInfo // size: xgb.Pad((int(NumClasses) * 2)) +} + +// Waits and reads reply data from request OpenDevice +func (cook OpenDeviceCookie) Reply() (*OpenDeviceReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return openDeviceReply(buf), nil +} + +// Read reply into structure from buffer for OpenDevice +func openDeviceReply(buf []byte) *OpenDeviceReply { + v := new(OpenDeviceReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NumClasses = buf[b] + b += 1 + + b += 23 // padding + + v.ClassInfo = make([]InputClassInfo, v.NumClasses) + b += InputClassInfoReadList(buf[b:], v.ClassInfo) + + return v +} + +// Write request to wire for OpenDevice +func openDeviceRequest(c *xgb.Conn, DeviceId byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 3 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = DeviceId + b += 1 + + b += 3 // padding + + return buf +} + +// Request CloseDevice +// size: 8 +type CloseDeviceCookie struct { + *xgb.Cookie +} + +// Write request to wire for CloseDevice +func CloseDevice(c *xgb.Conn, DeviceId byte) CloseDeviceCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(closeDeviceRequest(c, DeviceId), cookie) + return CloseDeviceCookie{cookie} +} + +func CloseDeviceChecked(c *xgb.Conn, DeviceId byte) CloseDeviceCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(closeDeviceRequest(c, DeviceId), cookie) + return CloseDeviceCookie{cookie} +} + +func (cook CloseDeviceCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CloseDevice +func closeDeviceRequest(c *xgb.Conn, DeviceId byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 4 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = DeviceId + b += 1 + + b += 3 // padding + + return buf +} + +// Request SetDeviceMode +// size: 8 +type SetDeviceModeCookie struct { + *xgb.Cookie +} + +func SetDeviceMode(c *xgb.Conn, DeviceId byte, Mode byte) SetDeviceModeCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(setDeviceModeRequest(c, DeviceId, Mode), cookie) + return SetDeviceModeCookie{cookie} +} + +func SetDeviceModeUnchecked(c *xgb.Conn, DeviceId byte, Mode byte) SetDeviceModeCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(setDeviceModeRequest(c, DeviceId, Mode), cookie) + return SetDeviceModeCookie{cookie} +} + +// Request reply for SetDeviceMode +// size: 32 +type SetDeviceModeReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Status byte + // padding: 23 bytes +} + +// Waits and reads reply data from request SetDeviceMode +func (cook SetDeviceModeCookie) Reply() (*SetDeviceModeReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return setDeviceModeReply(buf), nil +} + +// Read reply into structure from buffer for SetDeviceMode +func setDeviceModeReply(buf []byte) *SetDeviceModeReply { + v := new(SetDeviceModeReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Status = buf[b] + b += 1 + + b += 23 // padding + + return v +} + +// Write request to wire for SetDeviceMode +func setDeviceModeRequest(c *xgb.Conn, DeviceId byte, Mode byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 5 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = DeviceId + b += 1 + + buf[b] = Mode + b += 1 + + b += 2 // padding + + return buf +} + +// Request SelectExtensionEvent +// size: xgb.Pad((12 + xgb.Pad((int(NumClasses) * 4)))) +type SelectExtensionEventCookie struct { + *xgb.Cookie +} + +// Write request to wire for SelectExtensionEvent +func SelectExtensionEvent(c *xgb.Conn, Window xproto.Window, NumClasses uint16, Classes []EventClass) SelectExtensionEventCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(selectExtensionEventRequest(c, Window, NumClasses, Classes), cookie) + return SelectExtensionEventCookie{cookie} +} + +func SelectExtensionEventChecked(c *xgb.Conn, Window xproto.Window, NumClasses uint16, Classes []EventClass) SelectExtensionEventCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(selectExtensionEventRequest(c, Window, NumClasses, Classes), cookie) + return SelectExtensionEventCookie{cookie} +} + +func (cook SelectExtensionEventCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SelectExtensionEvent +func selectExtensionEventRequest(c *xgb.Conn, Window xproto.Window, NumClasses uint16, Classes []EventClass) []byte { + size := xgb.Pad((12 + xgb.Pad((int(NumClasses) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 6 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put16(buf[b:], NumClasses) + b += 2 + + b += 2 // padding + + for i := 0; i < int(NumClasses); i++ { + xgb.Put32(buf[b:], uint32(Classes[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request GetSelectedExtensionEvents +// size: 8 +type GetSelectedExtensionEventsCookie struct { + *xgb.Cookie +} + +func GetSelectedExtensionEvents(c *xgb.Conn, Window xproto.Window) GetSelectedExtensionEventsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getSelectedExtensionEventsRequest(c, Window), cookie) + return GetSelectedExtensionEventsCookie{cookie} +} + +func GetSelectedExtensionEventsUnchecked(c *xgb.Conn, Window xproto.Window) GetSelectedExtensionEventsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getSelectedExtensionEventsRequest(c, Window), cookie) + return GetSelectedExtensionEventsCookie{cookie} +} + +// Request reply for GetSelectedExtensionEvents +// size: ((32 + xgb.Pad((int(NumThisClasses) * 4))) + xgb.Pad((int(NumAllClasses) * 4))) +type GetSelectedExtensionEventsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumThisClasses uint16 + NumAllClasses uint16 + // padding: 20 bytes + ThisClasses []EventClass // size: xgb.Pad((int(NumThisClasses) * 4)) + AllClasses []EventClass // size: xgb.Pad((int(NumAllClasses) * 4)) +} + +// Waits and reads reply data from request GetSelectedExtensionEvents +func (cook GetSelectedExtensionEventsCookie) Reply() (*GetSelectedExtensionEventsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getSelectedExtensionEventsReply(buf), nil +} + +// Read reply into structure from buffer for GetSelectedExtensionEvents +func getSelectedExtensionEventsReply(buf []byte) *GetSelectedExtensionEventsReply { + v := new(GetSelectedExtensionEventsReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NumThisClasses = xgb.Get16(buf[b:]) + b += 2 + + v.NumAllClasses = xgb.Get16(buf[b:]) + b += 2 + + b += 20 // padding + + v.ThisClasses = make([]EventClass, v.NumThisClasses) + for i := 0; i < int(v.NumThisClasses); i++ { + v.ThisClasses[i] = EventClass(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + v.AllClasses = make([]EventClass, v.NumAllClasses) + for i := 0; i < int(v.NumAllClasses); i++ { + v.AllClasses[i] = EventClass(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetSelectedExtensionEvents +func getSelectedExtensionEventsRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 7 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + +// Request ChangeDeviceDontPropagateList +// size: xgb.Pad((12 + xgb.Pad((int(NumClasses) * 4)))) +type ChangeDeviceDontPropagateListCookie struct { + *xgb.Cookie +} + +// Write request to wire for ChangeDeviceDontPropagateList +func ChangeDeviceDontPropagateList(c *xgb.Conn, Window xproto.Window, NumClasses uint16, Mode byte, Classes []EventClass) ChangeDeviceDontPropagateListCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeDeviceDontPropagateListRequest(c, Window, NumClasses, Mode, Classes), cookie) + return ChangeDeviceDontPropagateListCookie{cookie} +} + +func ChangeDeviceDontPropagateListChecked(c *xgb.Conn, Window xproto.Window, NumClasses uint16, Mode byte, Classes []EventClass) ChangeDeviceDontPropagateListCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeDeviceDontPropagateListRequest(c, Window, NumClasses, Mode, Classes), cookie) + return ChangeDeviceDontPropagateListCookie{cookie} +} + +func (cook ChangeDeviceDontPropagateListCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangeDeviceDontPropagateList +func changeDeviceDontPropagateListRequest(c *xgb.Conn, Window xproto.Window, NumClasses uint16, Mode byte, Classes []EventClass) []byte { + size := xgb.Pad((12 + xgb.Pad((int(NumClasses) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 8 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put16(buf[b:], NumClasses) + b += 2 + + buf[b] = Mode + b += 1 + + b += 1 // padding + + for i := 0; i < int(NumClasses); i++ { + xgb.Put32(buf[b:], uint32(Classes[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request GetDeviceDontPropagateList +// size: 8 +type GetDeviceDontPropagateListCookie struct { + *xgb.Cookie +} + +func GetDeviceDontPropagateList(c *xgb.Conn, Window xproto.Window) GetDeviceDontPropagateListCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getDeviceDontPropagateListRequest(c, Window), cookie) + return GetDeviceDontPropagateListCookie{cookie} +} + +func GetDeviceDontPropagateListUnchecked(c *xgb.Conn, Window xproto.Window) GetDeviceDontPropagateListCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getDeviceDontPropagateListRequest(c, Window), cookie) + return GetDeviceDontPropagateListCookie{cookie} +} + +// Request reply for GetDeviceDontPropagateList +// size: (32 + xgb.Pad((int(NumClasses) * 4))) +type GetDeviceDontPropagateListReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumClasses uint16 + // padding: 22 bytes + Classes []EventClass // size: xgb.Pad((int(NumClasses) * 4)) +} + +// Waits and reads reply data from request GetDeviceDontPropagateList +func (cook GetDeviceDontPropagateListCookie) Reply() (*GetDeviceDontPropagateListReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDeviceDontPropagateListReply(buf), nil +} + +// Read reply into structure from buffer for GetDeviceDontPropagateList +func getDeviceDontPropagateListReply(buf []byte) *GetDeviceDontPropagateListReply { + v := new(GetDeviceDontPropagateListReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NumClasses = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + v.Classes = make([]EventClass, v.NumClasses) + for i := 0; i < int(v.NumClasses); i++ { + v.Classes[i] = EventClass(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetDeviceDontPropagateList +func getDeviceDontPropagateListRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 9 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + +// Request GetDeviceMotionEvents +// size: 16 +type GetDeviceMotionEventsCookie struct { + *xgb.Cookie +} + +func GetDeviceMotionEvents(c *xgb.Conn, Start xproto.Timestamp, Stop xproto.Timestamp, DeviceId byte) GetDeviceMotionEventsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getDeviceMotionEventsRequest(c, Start, Stop, DeviceId), cookie) + return GetDeviceMotionEventsCookie{cookie} +} + +func GetDeviceMotionEventsUnchecked(c *xgb.Conn, Start xproto.Timestamp, Stop xproto.Timestamp, DeviceId byte) GetDeviceMotionEventsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getDeviceMotionEventsRequest(c, Start, Stop, DeviceId), cookie) + return GetDeviceMotionEventsCookie{cookie} +} + +// Request reply for GetDeviceMotionEvents +// size: 32 +type GetDeviceMotionEventsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumCoords uint32 + NumAxes byte + DeviceMode byte + // padding: 18 bytes +} + +// Waits and reads reply data from request GetDeviceMotionEvents +func (cook GetDeviceMotionEventsCookie) Reply() (*GetDeviceMotionEventsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDeviceMotionEventsReply(buf), nil +} + +// Read reply into structure from buffer for GetDeviceMotionEvents +func getDeviceMotionEventsReply(buf []byte) *GetDeviceMotionEventsReply { + v := new(GetDeviceMotionEventsReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NumCoords = xgb.Get32(buf[b:]) + b += 4 + + v.NumAxes = buf[b] + b += 1 + + v.DeviceMode = buf[b] + b += 1 + + b += 18 // padding + + return v +} + +// Write request to wire for GetDeviceMotionEvents +func getDeviceMotionEventsRequest(c *xgb.Conn, Start xproto.Timestamp, Stop xproto.Timestamp, DeviceId byte) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 10 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Start)) + b += 4 + + xgb.Put32(buf[b:], uint32(Stop)) + b += 4 + + buf[b] = DeviceId + b += 1 + + return buf +} + +// Request ChangeKeyboardDevice +// size: 8 +type ChangeKeyboardDeviceCookie struct { + *xgb.Cookie +} + +func ChangeKeyboardDevice(c *xgb.Conn, DeviceId byte) ChangeKeyboardDeviceCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(changeKeyboardDeviceRequest(c, DeviceId), cookie) + return ChangeKeyboardDeviceCookie{cookie} +} + +func ChangeKeyboardDeviceUnchecked(c *xgb.Conn, DeviceId byte) ChangeKeyboardDeviceCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(changeKeyboardDeviceRequest(c, DeviceId), cookie) + return ChangeKeyboardDeviceCookie{cookie} +} + +// Request reply for ChangeKeyboardDevice +// size: 32 +type ChangeKeyboardDeviceReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Status byte + // padding: 23 bytes +} + +// Waits and reads reply data from request ChangeKeyboardDevice +func (cook ChangeKeyboardDeviceCookie) Reply() (*ChangeKeyboardDeviceReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return changeKeyboardDeviceReply(buf), nil +} + +// Read reply into structure from buffer for ChangeKeyboardDevice +func changeKeyboardDeviceReply(buf []byte) *ChangeKeyboardDeviceReply { + v := new(ChangeKeyboardDeviceReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Status = buf[b] + b += 1 + + b += 23 // padding + + return v +} + +// Write request to wire for ChangeKeyboardDevice +func changeKeyboardDeviceRequest(c *xgb.Conn, DeviceId byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 11 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = DeviceId + b += 1 + + b += 3 // padding + + return buf +} + +// Request ChangePointerDevice +// size: 8 +type ChangePointerDeviceCookie struct { + *xgb.Cookie +} + +func ChangePointerDevice(c *xgb.Conn, XAxis byte, YAxis byte, DeviceId byte) ChangePointerDeviceCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(changePointerDeviceRequest(c, XAxis, YAxis, DeviceId), cookie) + return ChangePointerDeviceCookie{cookie} +} + +func ChangePointerDeviceUnchecked(c *xgb.Conn, XAxis byte, YAxis byte, DeviceId byte) ChangePointerDeviceCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(changePointerDeviceRequest(c, XAxis, YAxis, DeviceId), cookie) + return ChangePointerDeviceCookie{cookie} +} + +// Request reply for ChangePointerDevice +// size: 32 +type ChangePointerDeviceReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Status byte + // padding: 23 bytes +} + +// Waits and reads reply data from request ChangePointerDevice +func (cook ChangePointerDeviceCookie) Reply() (*ChangePointerDeviceReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return changePointerDeviceReply(buf), nil +} + +// Read reply into structure from buffer for ChangePointerDevice +func changePointerDeviceReply(buf []byte) *ChangePointerDeviceReply { + v := new(ChangePointerDeviceReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Status = buf[b] + b += 1 + + b += 23 // padding + + return v +} + +// Write request to wire for ChangePointerDevice +func changePointerDeviceRequest(c *xgb.Conn, XAxis byte, YAxis byte, DeviceId byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 12 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = XAxis + b += 1 + + buf[b] = YAxis + b += 1 + + buf[b] = DeviceId + b += 1 + + b += 1 // padding + + return buf +} + +// Request GrabDevice +// size: xgb.Pad((20 + xgb.Pad((int(NumClasses) * 4)))) +type GrabDeviceCookie struct { + *xgb.Cookie +} + +func GrabDevice(c *xgb.Conn, GrabWindow xproto.Window, Time xproto.Timestamp, NumClasses uint16, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, DeviceId byte, Classes []EventClass) GrabDeviceCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(grabDeviceRequest(c, GrabWindow, Time, NumClasses, ThisDeviceMode, OtherDeviceMode, OwnerEvents, DeviceId, Classes), cookie) + return GrabDeviceCookie{cookie} +} + +func GrabDeviceUnchecked(c *xgb.Conn, GrabWindow xproto.Window, Time xproto.Timestamp, NumClasses uint16, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, DeviceId byte, Classes []EventClass) GrabDeviceCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(grabDeviceRequest(c, GrabWindow, Time, NumClasses, ThisDeviceMode, OtherDeviceMode, OwnerEvents, DeviceId, Classes), cookie) + return GrabDeviceCookie{cookie} +} + +// Request reply for GrabDevice +// size: 32 +type GrabDeviceReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Status byte + // padding: 23 bytes +} + +// Waits and reads reply data from request GrabDevice +func (cook GrabDeviceCookie) Reply() (*GrabDeviceReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return grabDeviceReply(buf), nil +} + +// Read reply into structure from buffer for GrabDevice +func grabDeviceReply(buf []byte) *GrabDeviceReply { + v := new(GrabDeviceReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Status = buf[b] + b += 1 + + b += 23 // padding + + return v +} + +// Write request to wire for GrabDevice +func grabDeviceRequest(c *xgb.Conn, GrabWindow xproto.Window, Time xproto.Timestamp, NumClasses uint16, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, DeviceId byte, Classes []EventClass) []byte { + size := xgb.Pad((20 + xgb.Pad((int(NumClasses) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 13 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(GrabWindow)) + b += 4 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + xgb.Put16(buf[b:], NumClasses) + b += 2 + + buf[b] = ThisDeviceMode + b += 1 + + buf[b] = OtherDeviceMode + b += 1 + + if OwnerEvents { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + buf[b] = DeviceId + b += 1 + + b += 2 // padding + + for i := 0; i < int(NumClasses); i++ { + xgb.Put32(buf[b:], uint32(Classes[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request UngrabDevice +// size: 12 +type UngrabDeviceCookie struct { + *xgb.Cookie +} + +// Write request to wire for UngrabDevice +func UngrabDevice(c *xgb.Conn, Time xproto.Timestamp, DeviceId byte) UngrabDeviceCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(ungrabDeviceRequest(c, Time, DeviceId), cookie) + return UngrabDeviceCookie{cookie} +} + +func UngrabDeviceChecked(c *xgb.Conn, Time xproto.Timestamp, DeviceId byte) UngrabDeviceCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(ungrabDeviceRequest(c, Time, DeviceId), cookie) + return UngrabDeviceCookie{cookie} +} + +func (cook UngrabDeviceCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for UngrabDevice +func ungrabDeviceRequest(c *xgb.Conn, Time xproto.Timestamp, DeviceId byte) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 14 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + buf[b] = DeviceId + b += 1 + + return buf +} + +// Request GrabDeviceKey +// size: xgb.Pad((20 + xgb.Pad((int(NumClasses) * 4)))) +type GrabDeviceKeyCookie struct { + *xgb.Cookie +} + +// Write request to wire for GrabDeviceKey +func GrabDeviceKey(c *xgb.Conn, GrabWindow xproto.Window, NumClasses uint16, Modifiers uint16, ModifierDevice byte, GrabbedDevice byte, Key byte, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, Classes []EventClass) GrabDeviceKeyCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(grabDeviceKeyRequest(c, GrabWindow, NumClasses, Modifiers, ModifierDevice, GrabbedDevice, Key, ThisDeviceMode, OtherDeviceMode, OwnerEvents, Classes), cookie) + return GrabDeviceKeyCookie{cookie} +} + +func GrabDeviceKeyChecked(c *xgb.Conn, GrabWindow xproto.Window, NumClasses uint16, Modifiers uint16, ModifierDevice byte, GrabbedDevice byte, Key byte, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, Classes []EventClass) GrabDeviceKeyCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(grabDeviceKeyRequest(c, GrabWindow, NumClasses, Modifiers, ModifierDevice, GrabbedDevice, Key, ThisDeviceMode, OtherDeviceMode, OwnerEvents, Classes), cookie) + return GrabDeviceKeyCookie{cookie} +} + +func (cook GrabDeviceKeyCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for GrabDeviceKey +func grabDeviceKeyRequest(c *xgb.Conn, GrabWindow xproto.Window, NumClasses uint16, Modifiers uint16, ModifierDevice byte, GrabbedDevice byte, Key byte, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, Classes []EventClass) []byte { + size := xgb.Pad((20 + xgb.Pad((int(NumClasses) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 15 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(GrabWindow)) + b += 4 + + xgb.Put16(buf[b:], NumClasses) + b += 2 + + xgb.Put16(buf[b:], Modifiers) + b += 2 + + buf[b] = ModifierDevice + b += 1 + + buf[b] = GrabbedDevice + b += 1 + + buf[b] = Key + b += 1 + + buf[b] = ThisDeviceMode + b += 1 + + buf[b] = OtherDeviceMode + b += 1 + + if OwnerEvents { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 2 // padding + + for i := 0; i < int(NumClasses); i++ { + xgb.Put32(buf[b:], uint32(Classes[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request UngrabDeviceKey +// size: 16 +type UngrabDeviceKeyCookie struct { + *xgb.Cookie +} + +// Write request to wire for UngrabDeviceKey +func UngrabDeviceKey(c *xgb.Conn, GrabWindow xproto.Window, Modifiers uint16, ModifierDevice byte, Key byte, GrabbedDevice byte) UngrabDeviceKeyCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(ungrabDeviceKeyRequest(c, GrabWindow, Modifiers, ModifierDevice, Key, GrabbedDevice), cookie) + return UngrabDeviceKeyCookie{cookie} +} + +func UngrabDeviceKeyChecked(c *xgb.Conn, GrabWindow xproto.Window, Modifiers uint16, ModifierDevice byte, Key byte, GrabbedDevice byte) UngrabDeviceKeyCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(ungrabDeviceKeyRequest(c, GrabWindow, Modifiers, ModifierDevice, Key, GrabbedDevice), cookie) + return UngrabDeviceKeyCookie{cookie} +} + +func (cook UngrabDeviceKeyCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for UngrabDeviceKey +func ungrabDeviceKeyRequest(c *xgb.Conn, GrabWindow xproto.Window, Modifiers uint16, ModifierDevice byte, Key byte, GrabbedDevice byte) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 16 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(GrabWindow)) + b += 4 + + xgb.Put16(buf[b:], Modifiers) + b += 2 + + buf[b] = ModifierDevice + b += 1 + + buf[b] = Key + b += 1 + + buf[b] = GrabbedDevice + b += 1 + + return buf +} + +// Request GrabDeviceButton +// size: xgb.Pad((20 + xgb.Pad((int(NumClasses) * 4)))) +type GrabDeviceButtonCookie struct { + *xgb.Cookie +} + +// Write request to wire for GrabDeviceButton +func GrabDeviceButton(c *xgb.Conn, GrabWindow xproto.Window, GrabbedDevice byte, ModifierDevice byte, NumClasses uint16, Modifiers uint16, ThisDeviceMode byte, OtherDeviceMode byte, Button byte, OwnerEvents byte, Classes []EventClass) GrabDeviceButtonCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(grabDeviceButtonRequest(c, GrabWindow, GrabbedDevice, ModifierDevice, NumClasses, Modifiers, ThisDeviceMode, OtherDeviceMode, Button, OwnerEvents, Classes), cookie) + return GrabDeviceButtonCookie{cookie} +} + +func GrabDeviceButtonChecked(c *xgb.Conn, GrabWindow xproto.Window, GrabbedDevice byte, ModifierDevice byte, NumClasses uint16, Modifiers uint16, ThisDeviceMode byte, OtherDeviceMode byte, Button byte, OwnerEvents byte, Classes []EventClass) GrabDeviceButtonCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(grabDeviceButtonRequest(c, GrabWindow, GrabbedDevice, ModifierDevice, NumClasses, Modifiers, ThisDeviceMode, OtherDeviceMode, Button, OwnerEvents, Classes), cookie) + return GrabDeviceButtonCookie{cookie} +} + +func (cook GrabDeviceButtonCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for GrabDeviceButton +func grabDeviceButtonRequest(c *xgb.Conn, GrabWindow xproto.Window, GrabbedDevice byte, ModifierDevice byte, NumClasses uint16, Modifiers uint16, ThisDeviceMode byte, OtherDeviceMode byte, Button byte, OwnerEvents byte, Classes []EventClass) []byte { + size := xgb.Pad((20 + xgb.Pad((int(NumClasses) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 17 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(GrabWindow)) + b += 4 + + buf[b] = GrabbedDevice + b += 1 + + buf[b] = ModifierDevice + b += 1 + + xgb.Put16(buf[b:], NumClasses) + b += 2 + + xgb.Put16(buf[b:], Modifiers) + b += 2 + + buf[b] = ThisDeviceMode + b += 1 + + buf[b] = OtherDeviceMode + b += 1 + + buf[b] = Button + b += 1 + + buf[b] = OwnerEvents + b += 1 + + b += 2 // padding + + for i := 0; i < int(NumClasses); i++ { + xgb.Put32(buf[b:], uint32(Classes[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request UngrabDeviceButton +// size: 16 +type UngrabDeviceButtonCookie struct { + *xgb.Cookie +} + +// Write request to wire for UngrabDeviceButton +func UngrabDeviceButton(c *xgb.Conn, GrabWindow xproto.Window, Modifiers uint16, ModifierDevice byte, Button byte, GrabbedDevice byte) UngrabDeviceButtonCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(ungrabDeviceButtonRequest(c, GrabWindow, Modifiers, ModifierDevice, Button, GrabbedDevice), cookie) + return UngrabDeviceButtonCookie{cookie} +} + +func UngrabDeviceButtonChecked(c *xgb.Conn, GrabWindow xproto.Window, Modifiers uint16, ModifierDevice byte, Button byte, GrabbedDevice byte) UngrabDeviceButtonCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(ungrabDeviceButtonRequest(c, GrabWindow, Modifiers, ModifierDevice, Button, GrabbedDevice), cookie) + return UngrabDeviceButtonCookie{cookie} +} + +func (cook UngrabDeviceButtonCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for UngrabDeviceButton +func ungrabDeviceButtonRequest(c *xgb.Conn, GrabWindow xproto.Window, Modifiers uint16, ModifierDevice byte, Button byte, GrabbedDevice byte) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 18 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(GrabWindow)) + b += 4 + + xgb.Put16(buf[b:], Modifiers) + b += 2 + + buf[b] = ModifierDevice + b += 1 + + buf[b] = Button + b += 1 + + buf[b] = GrabbedDevice + b += 1 + + return buf +} + +// Request AllowDeviceEvents +// size: 12 +type AllowDeviceEventsCookie struct { + *xgb.Cookie +} + +// Write request to wire for AllowDeviceEvents +func AllowDeviceEvents(c *xgb.Conn, Time xproto.Timestamp, Mode byte, DeviceId byte) AllowDeviceEventsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(allowDeviceEventsRequest(c, Time, Mode, DeviceId), cookie) + return AllowDeviceEventsCookie{cookie} +} + +func AllowDeviceEventsChecked(c *xgb.Conn, Time xproto.Timestamp, Mode byte, DeviceId byte) AllowDeviceEventsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(allowDeviceEventsRequest(c, Time, Mode, DeviceId), cookie) + return AllowDeviceEventsCookie{cookie} +} + +func (cook AllowDeviceEventsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for AllowDeviceEvents +func allowDeviceEventsRequest(c *xgb.Conn, Time xproto.Timestamp, Mode byte, DeviceId byte) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 19 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + buf[b] = Mode + b += 1 + + buf[b] = DeviceId + b += 1 + + return buf +} + +// Request GetDeviceFocus +// size: 8 +type GetDeviceFocusCookie struct { + *xgb.Cookie +} + +func GetDeviceFocus(c *xgb.Conn, DeviceId byte) GetDeviceFocusCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getDeviceFocusRequest(c, DeviceId), cookie) + return GetDeviceFocusCookie{cookie} +} + +func GetDeviceFocusUnchecked(c *xgb.Conn, DeviceId byte) GetDeviceFocusCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getDeviceFocusRequest(c, DeviceId), cookie) + return GetDeviceFocusCookie{cookie} +} + +// Request reply for GetDeviceFocus +// size: 32 +type GetDeviceFocusReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Focus xproto.Window + Time xproto.Timestamp + RevertTo byte + // padding: 15 bytes +} + +// Waits and reads reply data from request GetDeviceFocus +func (cook GetDeviceFocusCookie) Reply() (*GetDeviceFocusReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDeviceFocusReply(buf), nil +} + +// Read reply into structure from buffer for GetDeviceFocus +func getDeviceFocusReply(buf []byte) *GetDeviceFocusReply { + v := new(GetDeviceFocusReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Focus = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.RevertTo = buf[b] + b += 1 + + b += 15 // padding + + return v +} + +// Write request to wire for GetDeviceFocus +func getDeviceFocusRequest(c *xgb.Conn, DeviceId byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 20 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = DeviceId + b += 1 + + b += 3 // padding + + return buf +} + +// Request SetDeviceFocus +// size: 16 +type SetDeviceFocusCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetDeviceFocus +func SetDeviceFocus(c *xgb.Conn, Focus xproto.Window, Time xproto.Timestamp, RevertTo byte, DeviceId byte) SetDeviceFocusCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setDeviceFocusRequest(c, Focus, Time, RevertTo, DeviceId), cookie) + return SetDeviceFocusCookie{cookie} +} + +func SetDeviceFocusChecked(c *xgb.Conn, Focus xproto.Window, Time xproto.Timestamp, RevertTo byte, DeviceId byte) SetDeviceFocusCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setDeviceFocusRequest(c, Focus, Time, RevertTo, DeviceId), cookie) + return SetDeviceFocusCookie{cookie} +} + +func (cook SetDeviceFocusCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetDeviceFocus +func setDeviceFocusRequest(c *xgb.Conn, Focus xproto.Window, Time xproto.Timestamp, RevertTo byte, DeviceId byte) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 21 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Focus)) + b += 4 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + buf[b] = RevertTo + b += 1 + + buf[b] = DeviceId + b += 1 + + return buf +} + +// Request GetFeedbackControl +// size: 8 +type GetFeedbackControlCookie struct { + *xgb.Cookie +} + +func GetFeedbackControl(c *xgb.Conn, DeviceId byte) GetFeedbackControlCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getFeedbackControlRequest(c, DeviceId), cookie) + return GetFeedbackControlCookie{cookie} +} + +func GetFeedbackControlUnchecked(c *xgb.Conn, DeviceId byte) GetFeedbackControlCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getFeedbackControlRequest(c, DeviceId), cookie) + return GetFeedbackControlCookie{cookie} +} + +// Request reply for GetFeedbackControl +// size: 32 +type GetFeedbackControlReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumFeedback uint16 + // padding: 22 bytes +} + +// Waits and reads reply data from request GetFeedbackControl +func (cook GetFeedbackControlCookie) Reply() (*GetFeedbackControlReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getFeedbackControlReply(buf), nil +} + +// Read reply into structure from buffer for GetFeedbackControl +func getFeedbackControlReply(buf []byte) *GetFeedbackControlReply { + v := new(GetFeedbackControlReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NumFeedback = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + return v +} + +// Write request to wire for GetFeedbackControl +func getFeedbackControlRequest(c *xgb.Conn, DeviceId byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 22 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = DeviceId + b += 1 + + b += 3 // padding + + return buf +} + +// Request GetDeviceKeyMapping +// size: 8 +type GetDeviceKeyMappingCookie struct { + *xgb.Cookie +} + +func GetDeviceKeyMapping(c *xgb.Conn, DeviceId byte, FirstKeycode KeyCode, Count byte) GetDeviceKeyMappingCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getDeviceKeyMappingRequest(c, DeviceId, FirstKeycode, Count), cookie) + return GetDeviceKeyMappingCookie{cookie} +} + +func GetDeviceKeyMappingUnchecked(c *xgb.Conn, DeviceId byte, FirstKeycode KeyCode, Count byte) GetDeviceKeyMappingCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getDeviceKeyMappingRequest(c, DeviceId, FirstKeycode, Count), cookie) + return GetDeviceKeyMappingCookie{cookie} +} + +// Request reply for GetDeviceKeyMapping +// size: (32 + xgb.Pad((int(Length) * 4))) +type GetDeviceKeyMappingReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + KeysymsPerKeycode byte + // padding: 23 bytes + Keysyms []xproto.Keysym // size: xgb.Pad((int(Length) * 4)) +} + +// Waits and reads reply data from request GetDeviceKeyMapping +func (cook GetDeviceKeyMappingCookie) Reply() (*GetDeviceKeyMappingReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDeviceKeyMappingReply(buf), nil +} + +// Read reply into structure from buffer for GetDeviceKeyMapping +func getDeviceKeyMappingReply(buf []byte) *GetDeviceKeyMappingReply { + v := new(GetDeviceKeyMappingReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.KeysymsPerKeycode = buf[b] + b += 1 + + b += 23 // padding + + v.Keysyms = make([]xproto.Keysym, v.Length) + for i := 0; i < int(v.Length); i++ { + v.Keysyms[i] = xproto.Keysym(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetDeviceKeyMapping +func getDeviceKeyMappingRequest(c *xgb.Conn, DeviceId byte, FirstKeycode KeyCode, Count byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 24 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = DeviceId + b += 1 + + buf[b] = byte(FirstKeycode) + b += 1 + + buf[b] = Count + b += 1 + + return buf +} + +// Request ChangeDeviceKeyMapping +// size: xgb.Pad((8 + xgb.Pad(((int(KeycodeCount) * int(KeysymsPerKeycode)) * 4)))) +type ChangeDeviceKeyMappingCookie struct { + *xgb.Cookie +} + +// Write request to wire for ChangeDeviceKeyMapping +func ChangeDeviceKeyMapping(c *xgb.Conn, DeviceId byte, FirstKeycode KeyCode, KeysymsPerKeycode byte, KeycodeCount byte, Keysyms []xproto.Keysym) ChangeDeviceKeyMappingCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeDeviceKeyMappingRequest(c, DeviceId, FirstKeycode, KeysymsPerKeycode, KeycodeCount, Keysyms), cookie) + return ChangeDeviceKeyMappingCookie{cookie} +} + +func ChangeDeviceKeyMappingChecked(c *xgb.Conn, DeviceId byte, FirstKeycode KeyCode, KeysymsPerKeycode byte, KeycodeCount byte, Keysyms []xproto.Keysym) ChangeDeviceKeyMappingCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeDeviceKeyMappingRequest(c, DeviceId, FirstKeycode, KeysymsPerKeycode, KeycodeCount, Keysyms), cookie) + return ChangeDeviceKeyMappingCookie{cookie} +} + +func (cook ChangeDeviceKeyMappingCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangeDeviceKeyMapping +func changeDeviceKeyMappingRequest(c *xgb.Conn, DeviceId byte, FirstKeycode KeyCode, KeysymsPerKeycode byte, KeycodeCount byte, Keysyms []xproto.Keysym) []byte { + size := xgb.Pad((8 + xgb.Pad(((int(KeycodeCount) * int(KeysymsPerKeycode)) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 25 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = DeviceId + b += 1 + + buf[b] = byte(FirstKeycode) + b += 1 + + buf[b] = KeysymsPerKeycode + b += 1 + + buf[b] = KeycodeCount + b += 1 + + for i := 0; i < int((int(KeycodeCount) * int(KeysymsPerKeycode))); i++ { + xgb.Put32(buf[b:], uint32(Keysyms[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request GetDeviceModifierMapping +// size: 8 +type GetDeviceModifierMappingCookie struct { + *xgb.Cookie +} + +func GetDeviceModifierMapping(c *xgb.Conn, DeviceId byte) GetDeviceModifierMappingCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getDeviceModifierMappingRequest(c, DeviceId), cookie) + return GetDeviceModifierMappingCookie{cookie} +} + +func GetDeviceModifierMappingUnchecked(c *xgb.Conn, DeviceId byte) GetDeviceModifierMappingCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getDeviceModifierMappingRequest(c, DeviceId), cookie) + return GetDeviceModifierMappingCookie{cookie} +} + +// Request reply for GetDeviceModifierMapping +// size: (32 + xgb.Pad(((int(KeycodesPerModifier) * 8) * 1))) +type GetDeviceModifierMappingReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + KeycodesPerModifier byte + // padding: 23 bytes + Keymaps []byte // size: xgb.Pad(((int(KeycodesPerModifier) * 8) * 1)) +} + +// Waits and reads reply data from request GetDeviceModifierMapping +func (cook GetDeviceModifierMappingCookie) Reply() (*GetDeviceModifierMappingReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDeviceModifierMappingReply(buf), nil +} + +// Read reply into structure from buffer for GetDeviceModifierMapping +func getDeviceModifierMappingReply(buf []byte) *GetDeviceModifierMappingReply { + v := new(GetDeviceModifierMappingReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.KeycodesPerModifier = buf[b] + b += 1 + + b += 23 // padding + + v.Keymaps = make([]byte, (int(v.KeycodesPerModifier) * 8)) + copy(v.Keymaps[:(int(v.KeycodesPerModifier)*8)], buf[b:]) + b += xgb.Pad(int((int(v.KeycodesPerModifier) * 8))) + + return v +} + +// Write request to wire for GetDeviceModifierMapping +func getDeviceModifierMappingRequest(c *xgb.Conn, DeviceId byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 26 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = DeviceId + b += 1 + + b += 3 // padding + + return buf +} + +// Request SetDeviceModifierMapping +// size: xgb.Pad((7 + xgb.Pad(((int(KeycodesPerModifier) * 8) * 1)))) +type SetDeviceModifierMappingCookie struct { + *xgb.Cookie +} + +func SetDeviceModifierMapping(c *xgb.Conn, DeviceId byte, KeycodesPerModifier byte, Keymaps []byte) SetDeviceModifierMappingCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(setDeviceModifierMappingRequest(c, DeviceId, KeycodesPerModifier, Keymaps), cookie) + return SetDeviceModifierMappingCookie{cookie} +} + +func SetDeviceModifierMappingUnchecked(c *xgb.Conn, DeviceId byte, KeycodesPerModifier byte, Keymaps []byte) SetDeviceModifierMappingCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(setDeviceModifierMappingRequest(c, DeviceId, KeycodesPerModifier, Keymaps), cookie) + return SetDeviceModifierMappingCookie{cookie} +} + +// Request reply for SetDeviceModifierMapping +// size: 32 +type SetDeviceModifierMappingReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Status byte + // padding: 23 bytes +} + +// Waits and reads reply data from request SetDeviceModifierMapping +func (cook SetDeviceModifierMappingCookie) Reply() (*SetDeviceModifierMappingReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return setDeviceModifierMappingReply(buf), nil +} + +// Read reply into structure from buffer for SetDeviceModifierMapping +func setDeviceModifierMappingReply(buf []byte) *SetDeviceModifierMappingReply { + v := new(SetDeviceModifierMappingReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Status = buf[b] + b += 1 + + b += 23 // padding + + return v +} + +// Write request to wire for SetDeviceModifierMapping +func setDeviceModifierMappingRequest(c *xgb.Conn, DeviceId byte, KeycodesPerModifier byte, Keymaps []byte) []byte { + size := xgb.Pad((7 + xgb.Pad(((int(KeycodesPerModifier) * 8) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 27 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = DeviceId + b += 1 + + buf[b] = KeycodesPerModifier + b += 1 + + b += 1 // padding + + copy(buf[b:], Keymaps[:(int(KeycodesPerModifier)*8)]) + b += xgb.Pad(int((int(KeycodesPerModifier) * 8))) + + return buf +} + +// Request GetDeviceButtonMapping +// size: 8 +type GetDeviceButtonMappingCookie struct { + *xgb.Cookie +} + +func GetDeviceButtonMapping(c *xgb.Conn, DeviceId byte) GetDeviceButtonMappingCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getDeviceButtonMappingRequest(c, DeviceId), cookie) + return GetDeviceButtonMappingCookie{cookie} +} + +func GetDeviceButtonMappingUnchecked(c *xgb.Conn, DeviceId byte) GetDeviceButtonMappingCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getDeviceButtonMappingRequest(c, DeviceId), cookie) + return GetDeviceButtonMappingCookie{cookie} +} + +// Request reply for GetDeviceButtonMapping +// size: (32 + xgb.Pad((int(MapSize) * 1))) +type GetDeviceButtonMappingReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + MapSize byte + // padding: 23 bytes + Map []byte // size: xgb.Pad((int(MapSize) * 1)) +} + +// Waits and reads reply data from request GetDeviceButtonMapping +func (cook GetDeviceButtonMappingCookie) Reply() (*GetDeviceButtonMappingReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDeviceButtonMappingReply(buf), nil +} + +// Read reply into structure from buffer for GetDeviceButtonMapping +func getDeviceButtonMappingReply(buf []byte) *GetDeviceButtonMappingReply { + v := new(GetDeviceButtonMappingReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.MapSize = buf[b] + b += 1 + + b += 23 // padding + + v.Map = make([]byte, v.MapSize) + copy(v.Map[:v.MapSize], buf[b:]) + b += xgb.Pad(int(v.MapSize)) + + return v +} + +// Write request to wire for GetDeviceButtonMapping +func getDeviceButtonMappingRequest(c *xgb.Conn, DeviceId byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 28 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = DeviceId + b += 1 + + b += 3 // padding + + return buf +} + +// Request SetDeviceButtonMapping +// size: xgb.Pad((8 + xgb.Pad((int(MapSize) * 1)))) +type SetDeviceButtonMappingCookie struct { + *xgb.Cookie +} + +func SetDeviceButtonMapping(c *xgb.Conn, DeviceId byte, MapSize byte, Map []byte) SetDeviceButtonMappingCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(setDeviceButtonMappingRequest(c, DeviceId, MapSize, Map), cookie) + return SetDeviceButtonMappingCookie{cookie} +} + +func SetDeviceButtonMappingUnchecked(c *xgb.Conn, DeviceId byte, MapSize byte, Map []byte) SetDeviceButtonMappingCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(setDeviceButtonMappingRequest(c, DeviceId, MapSize, Map), cookie) + return SetDeviceButtonMappingCookie{cookie} +} + +// Request reply for SetDeviceButtonMapping +// size: 32 +type SetDeviceButtonMappingReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Status byte + // padding: 23 bytes +} + +// Waits and reads reply data from request SetDeviceButtonMapping +func (cook SetDeviceButtonMappingCookie) Reply() (*SetDeviceButtonMappingReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return setDeviceButtonMappingReply(buf), nil +} + +// Read reply into structure from buffer for SetDeviceButtonMapping +func setDeviceButtonMappingReply(buf []byte) *SetDeviceButtonMappingReply { + v := new(SetDeviceButtonMappingReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Status = buf[b] + b += 1 + + b += 23 // padding + + return v +} + +// Write request to wire for SetDeviceButtonMapping +func setDeviceButtonMappingRequest(c *xgb.Conn, DeviceId byte, MapSize byte, Map []byte) []byte { + size := xgb.Pad((8 + xgb.Pad((int(MapSize) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 29 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = DeviceId + b += 1 + + buf[b] = MapSize + b += 1 + + b += 2 // padding + + copy(buf[b:], Map[:MapSize]) + b += xgb.Pad(int(MapSize)) + + return buf +} + +// Request QueryDeviceState +// size: 8 +type QueryDeviceStateCookie struct { + *xgb.Cookie +} + +func QueryDeviceState(c *xgb.Conn, DeviceId byte) QueryDeviceStateCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryDeviceStateRequest(c, DeviceId), cookie) + return QueryDeviceStateCookie{cookie} +} + +func QueryDeviceStateUnchecked(c *xgb.Conn, DeviceId byte) QueryDeviceStateCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryDeviceStateRequest(c, DeviceId), cookie) + return QueryDeviceStateCookie{cookie} +} + +// Request reply for QueryDeviceState +// size: 32 +type QueryDeviceStateReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumClasses byte + // padding: 23 bytes +} + +// Waits and reads reply data from request QueryDeviceState +func (cook QueryDeviceStateCookie) Reply() (*QueryDeviceStateReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryDeviceStateReply(buf), nil +} + +// Read reply into structure from buffer for QueryDeviceState +func queryDeviceStateReply(buf []byte) *QueryDeviceStateReply { + v := new(QueryDeviceStateReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NumClasses = buf[b] + b += 1 + + b += 23 // padding + + return v +} + +// Write request to wire for QueryDeviceState +func queryDeviceStateRequest(c *xgb.Conn, DeviceId byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 30 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = DeviceId + b += 1 + + b += 3 // padding + + return buf +} + +// Request SendExtensionEvent +// size: xgb.Pad(((16 + xgb.Pad(((int(NumEvents) * 32) * 1))) + xgb.Pad((int(NumClasses) * 4)))) +type SendExtensionEventCookie struct { + *xgb.Cookie +} + +// Write request to wire for SendExtensionEvent +func SendExtensionEvent(c *xgb.Conn, Destination xproto.Window, DeviceId byte, Propagate bool, NumClasses uint16, NumEvents byte, Events string, Classes []EventClass) SendExtensionEventCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(sendExtensionEventRequest(c, Destination, DeviceId, Propagate, NumClasses, NumEvents, Events, Classes), cookie) + return SendExtensionEventCookie{cookie} +} + +func SendExtensionEventChecked(c *xgb.Conn, Destination xproto.Window, DeviceId byte, Propagate bool, NumClasses uint16, NumEvents byte, Events string, Classes []EventClass) SendExtensionEventCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(sendExtensionEventRequest(c, Destination, DeviceId, Propagate, NumClasses, NumEvents, Events, Classes), cookie) + return SendExtensionEventCookie{cookie} +} + +func (cook SendExtensionEventCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SendExtensionEvent +func sendExtensionEventRequest(c *xgb.Conn, Destination xproto.Window, DeviceId byte, Propagate bool, NumClasses uint16, NumEvents byte, Events string, Classes []EventClass) []byte { + size := xgb.Pad(((16 + xgb.Pad(((int(NumEvents) * 32) * 1))) + xgb.Pad((int(NumClasses) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 31 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Destination)) + b += 4 + + buf[b] = DeviceId + b += 1 + + if Propagate { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + xgb.Put16(buf[b:], NumClasses) + b += 2 + + buf[b] = NumEvents + b += 1 + + b += 3 // padding + + copy(buf[b:], Events[:(int(NumEvents)*32)]) + b += xgb.Pad(int((int(NumEvents) * 32))) + + for i := 0; i < int(NumClasses); i++ { + xgb.Put32(buf[b:], uint32(Classes[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request DeviceBell +// size: 8 +type DeviceBellCookie struct { + *xgb.Cookie +} + +// Write request to wire for DeviceBell +func DeviceBell(c *xgb.Conn, DeviceId byte, FeedbackId byte, FeedbackClass byte, Percent int8) DeviceBellCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(deviceBellRequest(c, DeviceId, FeedbackId, FeedbackClass, Percent), cookie) + return DeviceBellCookie{cookie} +} + +func DeviceBellChecked(c *xgb.Conn, DeviceId byte, FeedbackId byte, FeedbackClass byte, Percent int8) DeviceBellCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(deviceBellRequest(c, DeviceId, FeedbackId, FeedbackClass, Percent), cookie) + return DeviceBellCookie{cookie} +} + +func (cook DeviceBellCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DeviceBell +func deviceBellRequest(c *xgb.Conn, DeviceId byte, FeedbackId byte, FeedbackClass byte, Percent int8) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 32 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = DeviceId + b += 1 + + buf[b] = FeedbackId + b += 1 + + buf[b] = FeedbackClass + b += 1 + + buf[b] = byte(Percent) + b += 1 + + return buf +} + +// Request SetDeviceValuators +// size: xgb.Pad((8 + xgb.Pad((int(NumValuators) * 4)))) +type SetDeviceValuatorsCookie struct { + *xgb.Cookie +} + +func SetDeviceValuators(c *xgb.Conn, DeviceId byte, FirstValuator byte, NumValuators byte, Valuators []int32) SetDeviceValuatorsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(setDeviceValuatorsRequest(c, DeviceId, FirstValuator, NumValuators, Valuators), cookie) + return SetDeviceValuatorsCookie{cookie} +} + +func SetDeviceValuatorsUnchecked(c *xgb.Conn, DeviceId byte, FirstValuator byte, NumValuators byte, Valuators []int32) SetDeviceValuatorsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(setDeviceValuatorsRequest(c, DeviceId, FirstValuator, NumValuators, Valuators), cookie) + return SetDeviceValuatorsCookie{cookie} +} + +// Request reply for SetDeviceValuators +// size: 32 +type SetDeviceValuatorsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Status byte + // padding: 23 bytes +} + +// Waits and reads reply data from request SetDeviceValuators +func (cook SetDeviceValuatorsCookie) Reply() (*SetDeviceValuatorsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return setDeviceValuatorsReply(buf), nil +} + +// Read reply into structure from buffer for SetDeviceValuators +func setDeviceValuatorsReply(buf []byte) *SetDeviceValuatorsReply { + v := new(SetDeviceValuatorsReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Status = buf[b] + b += 1 + + b += 23 // padding + + return v +} + +// Write request to wire for SetDeviceValuators +func setDeviceValuatorsRequest(c *xgb.Conn, DeviceId byte, FirstValuator byte, NumValuators byte, Valuators []int32) []byte { + size := xgb.Pad((8 + xgb.Pad((int(NumValuators) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 33 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = DeviceId + b += 1 + + buf[b] = FirstValuator + b += 1 + + buf[b] = NumValuators + b += 1 + + b += 1 // padding + + for i := 0; i < int(NumValuators); i++ { + xgb.Put32(buf[b:], uint32(Valuators[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request GetDeviceControl +// size: 8 +type GetDeviceControlCookie struct { + *xgb.Cookie +} + +func GetDeviceControl(c *xgb.Conn, ControlId uint16, DeviceId byte) GetDeviceControlCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getDeviceControlRequest(c, ControlId, DeviceId), cookie) + return GetDeviceControlCookie{cookie} +} + +func GetDeviceControlUnchecked(c *xgb.Conn, ControlId uint16, DeviceId byte) GetDeviceControlCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getDeviceControlRequest(c, ControlId, DeviceId), cookie) + return GetDeviceControlCookie{cookie} +} + +// Request reply for GetDeviceControl +// size: 32 +type GetDeviceControlReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Status byte + // padding: 23 bytes +} + +// Waits and reads reply data from request GetDeviceControl +func (cook GetDeviceControlCookie) Reply() (*GetDeviceControlReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDeviceControlReply(buf), nil +} + +// Read reply into structure from buffer for GetDeviceControl +func getDeviceControlReply(buf []byte) *GetDeviceControlReply { + v := new(GetDeviceControlReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Status = buf[b] + b += 1 + + b += 23 // padding + + return v +} + +// Write request to wire for GetDeviceControl +func getDeviceControlRequest(c *xgb.Conn, ControlId uint16, DeviceId byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINPUTEXTENSION"] + b += 1 + + buf[b] = 34 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], ControlId) + b += 2 + + buf[b] = DeviceId + b += 1 + + b += 1 // padding + + return buf +} diff --git a/nexgb/xprint/xprint.go b/nexgb/xprint/xprint.go new file mode 100644 index 0000000..2fcf49f --- /dev/null +++ b/nexgb/xprint/xprint.go @@ -0,0 +1,2164 @@ +package xprint + +/* + This file was generated by xprint.xml on May 10 2012 4:20:28pm EDT. + This file is automatically generated. Edit at your peril! +*/ + +import ( + "github.com/BurntSushi/xgb" + + "github.com/BurntSushi/xgb/xproto" +) + +// Init must be called before using the XpExtension extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 11, "XpExtension").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named XpExtension could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["XpExtension"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["XpExtension"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["XpExtension"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["XpExtension"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["XpExtension"] = make(map[int]xgb.NewErrorFun) +} + +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Bool' + +// Skipping definition for base type 'Float' + +const ( + GetDocFinished = 0 + GetDocSecondConsumer = 1 +) + +const ( + EvMaskNoEventMask = 0 + EvMaskPrintMask = 1 + EvMaskAttributeMask = 2 +) + +const ( + DetailStartJobNotify = 1 + DetailEndJobNotify = 2 + DetailStartDocNotify = 3 + DetailEndDocNotify = 4 + DetailStartPageNotify = 5 + DetailEndPageNotify = 6 +) + +const ( + AttrJobAttr = 1 + AttrDocAttr = 2 + AttrPageAttr = 3 + AttrPrinterAttr = 4 + AttrServerAttr = 5 + AttrMediumAttr = 6 + AttrSpoolerAttr = 7 +) + +type Pcontext uint32 + +func NewPcontextId(c *xgb.Conn) (Pcontext, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Pcontext(id), nil +} + +type String8 byte + +// 'Printer' struct definition +// Size: (((4 + xgb.Pad((int(NameLen) * 1))) + 4) + xgb.Pad((int(DescLen) * 1))) +type Printer struct { + NameLen uint32 + Name []String8 // size: xgb.Pad((int(NameLen) * 1)) + DescLen uint32 + Description []String8 // size: xgb.Pad((int(DescLen) * 1)) +} + +// Struct read Printer +func PrinterRead(buf []byte, v *Printer) int { + b := 0 + + v.NameLen = xgb.Get32(buf[b:]) + b += 4 + + v.Name = make([]String8, v.NameLen) + for i := 0; i < int(v.NameLen); i++ { + v.Name[i] = String8(buf[b]) + b += 1 + } + b = xgb.Pad(b) + + v.DescLen = xgb.Get32(buf[b:]) + b += 4 + + v.Description = make([]String8, v.DescLen) + for i := 0; i < int(v.DescLen); i++ { + v.Description[i] = String8(buf[b]) + b += 1 + } + b = xgb.Pad(b) + + return b +} + +// Struct list read Printer +func PrinterReadList(buf []byte, dest []Printer) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Printer{} + b += PrinterRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Printer +func (v Printer) Bytes() []byte { + buf := make([]byte, (((4 + xgb.Pad((int(v.NameLen) * 1))) + 4) + xgb.Pad((int(v.DescLen) * 1)))) + b := 0 + + xgb.Put32(buf[b:], v.NameLen) + b += 4 + + for i := 0; i < int(v.NameLen); i++ { + buf[b] = byte(v.Name[i]) + b += 1 + } + b = xgb.Pad(b) + + xgb.Put32(buf[b:], v.DescLen) + b += 4 + + for i := 0; i < int(v.DescLen); i++ { + buf[b] = byte(v.Description[i]) + b += 1 + } + b = xgb.Pad(b) + + return buf +} + +// Write struct list Printer +func PrinterListBytes(buf []byte, list []Printer) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size Printer +func PrinterListSize(list []Printer) int { + size := 0 + for _, item := range list { + size += (((4 + xgb.Pad((int(item.NameLen) * 1))) + 4) + xgb.Pad((int(item.DescLen) * 1))) + } + return size +} + +// Event definition Notify (0) +// Size: 32 + +const Notify = 0 + +type NotifyEvent struct { + Sequence uint16 + Detail byte + Context Pcontext + Cancel bool +} + +// Event read Notify +func NotifyEventNew(buf []byte) xgb.Event { + v := NotifyEvent{} + b := 1 // don't read event number + + v.Detail = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Context = Pcontext(xgb.Get32(buf[b:])) + b += 4 + + if buf[b] == 1 { + v.Cancel = true + } else { + v.Cancel = false + } + b += 1 + + return v +} + +// Event write Notify +func (v NotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 0 + b += 1 + + buf[b] = v.Detail + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Context)) + b += 4 + + if v.Cancel { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + return buf +} + +func (v NotifyEvent) ImplementsEvent() {} + +func (v NotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v NotifyEvent) String() string { + fieldVals := make([]string, 0, 3) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Context: %d", v.Context)) + fieldVals = append(fieldVals, xgb.Sprintf("Cancel: %t", v.Cancel)) + return "Notify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XpExtension"][0] = NotifyEventNew +} + +// Event definition AttributNotify (1) +// Size: 32 + +const AttributNotify = 1 + +type AttributNotifyEvent struct { + Sequence uint16 + Detail byte + Context Pcontext +} + +// Event read AttributNotify +func AttributNotifyEventNew(buf []byte) xgb.Event { + v := AttributNotifyEvent{} + b := 1 // don't read event number + + v.Detail = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Context = Pcontext(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Event write AttributNotify +func (v AttributNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 1 + b += 1 + + buf[b] = v.Detail + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Context)) + b += 4 + + return buf +} + +func (v AttributNotifyEvent) ImplementsEvent() {} + +func (v AttributNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v AttributNotifyEvent) String() string { + fieldVals := make([]string, 0, 2) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Context: %d", v.Context)) + return "AttributNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XpExtension"][1] = AttributNotifyEventNew +} + +// Error definition BadContext (0) +// Size: 32 + +const BadBadContext = 0 + +type BadContextError struct { + Sequence uint16 + NiceName string +} + +// Error read BadContext +func BadContextErrorNew(buf []byte) xgb.Error { + v := BadContextError{} + v.NiceName = "BadContext" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err BadContextError) ImplementsError() {} + +func (err BadContextError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadContextError) BadId() uint32 { + return 0 +} + +func (err BadContextError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadContext {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XpExtension"][0] = BadContextErrorNew +} + +// Error definition BadSequence (1) +// Size: 32 + +const BadBadSequence = 1 + +type BadSequenceError struct { + Sequence uint16 + NiceName string +} + +// Error read BadSequence +func BadSequenceErrorNew(buf []byte) xgb.Error { + v := BadSequenceError{} + v.NiceName = "BadSequence" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err BadSequenceError) ImplementsError() {} + +func (err BadSequenceError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadSequenceError) BadId() uint32 { + return 0 +} + +func (err BadSequenceError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadSequence {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XpExtension"][1] = BadSequenceErrorNew +} + +// Request PrintQueryVersion +// size: 4 +type PrintQueryVersionCookie struct { + *xgb.Cookie +} + +func PrintQueryVersion(c *xgb.Conn) PrintQueryVersionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(printQueryVersionRequest(c), cookie) + return PrintQueryVersionCookie{cookie} +} + +func PrintQueryVersionUnchecked(c *xgb.Conn) PrintQueryVersionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(printQueryVersionRequest(c), cookie) + return PrintQueryVersionCookie{cookie} +} + +// Request reply for PrintQueryVersion +// size: 12 +type PrintQueryVersionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + MajorVersion uint16 + MinorVersion uint16 +} + +// Waits and reads reply data from request PrintQueryVersion +func (cook PrintQueryVersionCookie) Reply() (*PrintQueryVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return printQueryVersionReply(buf), nil +} + +// Read reply into structure from buffer for PrintQueryVersion +func printQueryVersionReply(buf []byte) *PrintQueryVersionReply { + v := new(PrintQueryVersionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.MajorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.MinorVersion = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Write request to wire for PrintQueryVersion +func printQueryVersionRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 0 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request PrintGetPrinterList +// size: xgb.Pad(((12 + xgb.Pad((int(PrinterNameLen) * 1))) + xgb.Pad((int(LocaleLen) * 1)))) +type PrintGetPrinterListCookie struct { + *xgb.Cookie +} + +func PrintGetPrinterList(c *xgb.Conn, PrinterNameLen uint32, LocaleLen uint32, PrinterName []String8, Locale []String8) PrintGetPrinterListCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(printGetPrinterListRequest(c, PrinterNameLen, LocaleLen, PrinterName, Locale), cookie) + return PrintGetPrinterListCookie{cookie} +} + +func PrintGetPrinterListUnchecked(c *xgb.Conn, PrinterNameLen uint32, LocaleLen uint32, PrinterName []String8, Locale []String8) PrintGetPrinterListCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(printGetPrinterListRequest(c, PrinterNameLen, LocaleLen, PrinterName, Locale), cookie) + return PrintGetPrinterListCookie{cookie} +} + +// Request reply for PrintGetPrinterList +// size: (32 + PrinterListSize(Printers)) +type PrintGetPrinterListReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ListCount uint32 + // padding: 20 bytes + Printers []Printer // size: PrinterListSize(Printers) +} + +// Waits and reads reply data from request PrintGetPrinterList +func (cook PrintGetPrinterListCookie) Reply() (*PrintGetPrinterListReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return printGetPrinterListReply(buf), nil +} + +// Read reply into structure from buffer for PrintGetPrinterList +func printGetPrinterListReply(buf []byte) *PrintGetPrinterListReply { + v := new(PrintGetPrinterListReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ListCount = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Printers = make([]Printer, v.ListCount) + b += PrinterReadList(buf[b:], v.Printers) + + return v +} + +// Write request to wire for PrintGetPrinterList +func printGetPrinterListRequest(c *xgb.Conn, PrinterNameLen uint32, LocaleLen uint32, PrinterName []String8, Locale []String8) []byte { + size := xgb.Pad(((12 + xgb.Pad((int(PrinterNameLen) * 1))) + xgb.Pad((int(LocaleLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 1 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], PrinterNameLen) + b += 4 + + xgb.Put32(buf[b:], LocaleLen) + b += 4 + + for i := 0; i < int(PrinterNameLen); i++ { + buf[b] = byte(PrinterName[i]) + b += 1 + } + b = xgb.Pad(b) + + for i := 0; i < int(LocaleLen); i++ { + buf[b] = byte(Locale[i]) + b += 1 + } + b = xgb.Pad(b) + + return buf +} + +// Request PrintRehashPrinterList +// size: 4 +type PrintRehashPrinterListCookie struct { + *xgb.Cookie +} + +// Write request to wire for PrintRehashPrinterList +func PrintRehashPrinterList(c *xgb.Conn) PrintRehashPrinterListCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(printRehashPrinterListRequest(c), cookie) + return PrintRehashPrinterListCookie{cookie} +} + +func PrintRehashPrinterListChecked(c *xgb.Conn) PrintRehashPrinterListCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(printRehashPrinterListRequest(c), cookie) + return PrintRehashPrinterListCookie{cookie} +} + +func (cook PrintRehashPrinterListCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PrintRehashPrinterList +func printRehashPrinterListRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 20 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request CreateContext +// size: xgb.Pad(((16 + xgb.Pad((int(PrinterNameLen) * 1))) + xgb.Pad((int(LocaleLen) * 1)))) +type CreateContextCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateContext +func CreateContext(c *xgb.Conn, ContextId uint32, PrinterNameLen uint32, LocaleLen uint32, PrinterName []String8, Locale []String8) CreateContextCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createContextRequest(c, ContextId, PrinterNameLen, LocaleLen, PrinterName, Locale), cookie) + return CreateContextCookie{cookie} +} + +func CreateContextChecked(c *xgb.Conn, ContextId uint32, PrinterNameLen uint32, LocaleLen uint32, PrinterName []String8, Locale []String8) CreateContextCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createContextRequest(c, ContextId, PrinterNameLen, LocaleLen, PrinterName, Locale), cookie) + return CreateContextCookie{cookie} +} + +func (cook CreateContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateContext +func createContextRequest(c *xgb.Conn, ContextId uint32, PrinterNameLen uint32, LocaleLen uint32, PrinterName []String8, Locale []String8) []byte { + size := xgb.Pad(((16 + xgb.Pad((int(PrinterNameLen) * 1))) + xgb.Pad((int(LocaleLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 2 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], ContextId) + b += 4 + + xgb.Put32(buf[b:], PrinterNameLen) + b += 4 + + xgb.Put32(buf[b:], LocaleLen) + b += 4 + + for i := 0; i < int(PrinterNameLen); i++ { + buf[b] = byte(PrinterName[i]) + b += 1 + } + b = xgb.Pad(b) + + for i := 0; i < int(LocaleLen); i++ { + buf[b] = byte(Locale[i]) + b += 1 + } + b = xgb.Pad(b) + + return buf +} + +// Request PrintSetContext +// size: 8 +type PrintSetContextCookie struct { + *xgb.Cookie +} + +// Write request to wire for PrintSetContext +func PrintSetContext(c *xgb.Conn, Context uint32) PrintSetContextCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(printSetContextRequest(c, Context), cookie) + return PrintSetContextCookie{cookie} +} + +func PrintSetContextChecked(c *xgb.Conn, Context uint32) PrintSetContextCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(printSetContextRequest(c, Context), cookie) + return PrintSetContextCookie{cookie} +} + +func (cook PrintSetContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PrintSetContext +func printSetContextRequest(c *xgb.Conn, Context uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 3 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Context) + b += 4 + + return buf +} + +// Request PrintGetContext +// size: 4 +type PrintGetContextCookie struct { + *xgb.Cookie +} + +func PrintGetContext(c *xgb.Conn) PrintGetContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(printGetContextRequest(c), cookie) + return PrintGetContextCookie{cookie} +} + +func PrintGetContextUnchecked(c *xgb.Conn) PrintGetContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(printGetContextRequest(c), cookie) + return PrintGetContextCookie{cookie} +} + +// Request reply for PrintGetContext +// size: 12 +type PrintGetContextReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Context uint32 +} + +// Waits and reads reply data from request PrintGetContext +func (cook PrintGetContextCookie) Reply() (*PrintGetContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return printGetContextReply(buf), nil +} + +// Read reply into structure from buffer for PrintGetContext +func printGetContextReply(buf []byte) *PrintGetContextReply { + v := new(PrintGetContextReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Context = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for PrintGetContext +func printGetContextRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 4 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request PrintDestroyContext +// size: 8 +type PrintDestroyContextCookie struct { + *xgb.Cookie +} + +// Write request to wire for PrintDestroyContext +func PrintDestroyContext(c *xgb.Conn, Context uint32) PrintDestroyContextCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(printDestroyContextRequest(c, Context), cookie) + return PrintDestroyContextCookie{cookie} +} + +func PrintDestroyContextChecked(c *xgb.Conn, Context uint32) PrintDestroyContextCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(printDestroyContextRequest(c, Context), cookie) + return PrintDestroyContextCookie{cookie} +} + +func (cook PrintDestroyContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PrintDestroyContext +func printDestroyContextRequest(c *xgb.Conn, Context uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 5 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Context) + b += 4 + + return buf +} + +// Request PrintGetScreenOfContext +// size: 4 +type PrintGetScreenOfContextCookie struct { + *xgb.Cookie +} + +func PrintGetScreenOfContext(c *xgb.Conn) PrintGetScreenOfContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(printGetScreenOfContextRequest(c), cookie) + return PrintGetScreenOfContextCookie{cookie} +} + +func PrintGetScreenOfContextUnchecked(c *xgb.Conn) PrintGetScreenOfContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(printGetScreenOfContextRequest(c), cookie) + return PrintGetScreenOfContextCookie{cookie} +} + +// Request reply for PrintGetScreenOfContext +// size: 12 +type PrintGetScreenOfContextReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Root xproto.Window +} + +// Waits and reads reply data from request PrintGetScreenOfContext +func (cook PrintGetScreenOfContextCookie) Reply() (*PrintGetScreenOfContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return printGetScreenOfContextReply(buf), nil +} + +// Read reply into structure from buffer for PrintGetScreenOfContext +func printGetScreenOfContextReply(buf []byte) *PrintGetScreenOfContextReply { + v := new(PrintGetScreenOfContextReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Root = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Write request to wire for PrintGetScreenOfContext +func printGetScreenOfContextRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 6 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request PrintStartJob +// size: 8 +type PrintStartJobCookie struct { + *xgb.Cookie +} + +// Write request to wire for PrintStartJob +func PrintStartJob(c *xgb.Conn, OutputMode byte) PrintStartJobCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(printStartJobRequest(c, OutputMode), cookie) + return PrintStartJobCookie{cookie} +} + +func PrintStartJobChecked(c *xgb.Conn, OutputMode byte) PrintStartJobCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(printStartJobRequest(c, OutputMode), cookie) + return PrintStartJobCookie{cookie} +} + +func (cook PrintStartJobCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PrintStartJob +func printStartJobRequest(c *xgb.Conn, OutputMode byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 7 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = OutputMode + b += 1 + + return buf +} + +// Request PrintEndJob +// size: 8 +type PrintEndJobCookie struct { + *xgb.Cookie +} + +// Write request to wire for PrintEndJob +func PrintEndJob(c *xgb.Conn, Cancel bool) PrintEndJobCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(printEndJobRequest(c, Cancel), cookie) + return PrintEndJobCookie{cookie} +} + +func PrintEndJobChecked(c *xgb.Conn, Cancel bool) PrintEndJobCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(printEndJobRequest(c, Cancel), cookie) + return PrintEndJobCookie{cookie} +} + +func (cook PrintEndJobCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PrintEndJob +func printEndJobRequest(c *xgb.Conn, Cancel bool) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 8 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + if Cancel { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + return buf +} + +// Request PrintStartDoc +// size: 8 +type PrintStartDocCookie struct { + *xgb.Cookie +} + +// Write request to wire for PrintStartDoc +func PrintStartDoc(c *xgb.Conn, DriverMode byte) PrintStartDocCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(printStartDocRequest(c, DriverMode), cookie) + return PrintStartDocCookie{cookie} +} + +func PrintStartDocChecked(c *xgb.Conn, DriverMode byte) PrintStartDocCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(printStartDocRequest(c, DriverMode), cookie) + return PrintStartDocCookie{cookie} +} + +func (cook PrintStartDocCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PrintStartDoc +func printStartDocRequest(c *xgb.Conn, DriverMode byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 9 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = DriverMode + b += 1 + + return buf +} + +// Request PrintEndDoc +// size: 8 +type PrintEndDocCookie struct { + *xgb.Cookie +} + +// Write request to wire for PrintEndDoc +func PrintEndDoc(c *xgb.Conn, Cancel bool) PrintEndDocCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(printEndDocRequest(c, Cancel), cookie) + return PrintEndDocCookie{cookie} +} + +func PrintEndDocChecked(c *xgb.Conn, Cancel bool) PrintEndDocCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(printEndDocRequest(c, Cancel), cookie) + return PrintEndDocCookie{cookie} +} + +func (cook PrintEndDocCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PrintEndDoc +func printEndDocRequest(c *xgb.Conn, Cancel bool) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 10 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + if Cancel { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + return buf +} + +// Request PrintPutDocumentData +// size: xgb.Pad((((16 + xgb.Pad((int(LenData) * 1))) + xgb.Pad((len(DocFormat) * 1))) + xgb.Pad((len(Options) * 1)))) +type PrintPutDocumentDataCookie struct { + *xgb.Cookie +} + +// Write request to wire for PrintPutDocumentData +func PrintPutDocumentData(c *xgb.Conn, Drawable xproto.Drawable, LenData uint32, LenFmt uint16, LenOptions uint16, Data []byte, DocFormat []String8, Options []String8) PrintPutDocumentDataCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(printPutDocumentDataRequest(c, Drawable, LenData, LenFmt, LenOptions, Data, DocFormat, Options), cookie) + return PrintPutDocumentDataCookie{cookie} +} + +func PrintPutDocumentDataChecked(c *xgb.Conn, Drawable xproto.Drawable, LenData uint32, LenFmt uint16, LenOptions uint16, Data []byte, DocFormat []String8, Options []String8) PrintPutDocumentDataCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(printPutDocumentDataRequest(c, Drawable, LenData, LenFmt, LenOptions, Data, DocFormat, Options), cookie) + return PrintPutDocumentDataCookie{cookie} +} + +func (cook PrintPutDocumentDataCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PrintPutDocumentData +func printPutDocumentDataRequest(c *xgb.Conn, Drawable xproto.Drawable, LenData uint32, LenFmt uint16, LenOptions uint16, Data []byte, DocFormat []String8, Options []String8) []byte { + size := xgb.Pad((((16 + xgb.Pad((int(LenData) * 1))) + xgb.Pad((len(DocFormat) * 1))) + xgb.Pad((len(Options) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 11 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], LenData) + b += 4 + + xgb.Put16(buf[b:], LenFmt) + b += 2 + + xgb.Put16(buf[b:], LenOptions) + b += 2 + + copy(buf[b:], Data[:LenData]) + b += xgb.Pad(int(LenData)) + + for i := 0; i < int(len(DocFormat)); i++ { + buf[b] = byte(DocFormat[i]) + b += 1 + } + b = xgb.Pad(b) + + for i := 0; i < int(len(Options)); i++ { + buf[b] = byte(Options[i]) + b += 1 + } + b = xgb.Pad(b) + + return buf +} + +// Request PrintGetDocumentData +// size: 12 +type PrintGetDocumentDataCookie struct { + *xgb.Cookie +} + +func PrintGetDocumentData(c *xgb.Conn, Context Pcontext, MaxBytes uint32) PrintGetDocumentDataCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(printGetDocumentDataRequest(c, Context, MaxBytes), cookie) + return PrintGetDocumentDataCookie{cookie} +} + +func PrintGetDocumentDataUnchecked(c *xgb.Conn, Context Pcontext, MaxBytes uint32) PrintGetDocumentDataCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(printGetDocumentDataRequest(c, Context, MaxBytes), cookie) + return PrintGetDocumentDataCookie{cookie} +} + +// Request reply for PrintGetDocumentData +// size: (32 + xgb.Pad((int(DataLen) * 1))) +type PrintGetDocumentDataReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + StatusCode uint32 + FinishedFlag uint32 + DataLen uint32 + // padding: 12 bytes + Data []byte // size: xgb.Pad((int(DataLen) * 1)) +} + +// Waits and reads reply data from request PrintGetDocumentData +func (cook PrintGetDocumentDataCookie) Reply() (*PrintGetDocumentDataReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return printGetDocumentDataReply(buf), nil +} + +// Read reply into structure from buffer for PrintGetDocumentData +func printGetDocumentDataReply(buf []byte) *PrintGetDocumentDataReply { + v := new(PrintGetDocumentDataReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.StatusCode = xgb.Get32(buf[b:]) + b += 4 + + v.FinishedFlag = xgb.Get32(buf[b:]) + b += 4 + + v.DataLen = xgb.Get32(buf[b:]) + b += 4 + + b += 12 // padding + + v.Data = make([]byte, v.DataLen) + copy(v.Data[:v.DataLen], buf[b:]) + b += xgb.Pad(int(v.DataLen)) + + return v +} + +// Write request to wire for PrintGetDocumentData +func printGetDocumentDataRequest(c *xgb.Conn, Context Pcontext, MaxBytes uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 12 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + xgb.Put32(buf[b:], MaxBytes) + b += 4 + + return buf +} + +// Request PrintStartPage +// size: 8 +type PrintStartPageCookie struct { + *xgb.Cookie +} + +// Write request to wire for PrintStartPage +func PrintStartPage(c *xgb.Conn, Window xproto.Window) PrintStartPageCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(printStartPageRequest(c, Window), cookie) + return PrintStartPageCookie{cookie} +} + +func PrintStartPageChecked(c *xgb.Conn, Window xproto.Window) PrintStartPageCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(printStartPageRequest(c, Window), cookie) + return PrintStartPageCookie{cookie} +} + +func (cook PrintStartPageCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PrintStartPage +func printStartPageRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 13 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + +// Request PrintEndPage +// size: 8 +type PrintEndPageCookie struct { + *xgb.Cookie +} + +// Write request to wire for PrintEndPage +func PrintEndPage(c *xgb.Conn, Cancel bool) PrintEndPageCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(printEndPageRequest(c, Cancel), cookie) + return PrintEndPageCookie{cookie} +} + +func PrintEndPageChecked(c *xgb.Conn, Cancel bool) PrintEndPageCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(printEndPageRequest(c, Cancel), cookie) + return PrintEndPageCookie{cookie} +} + +func (cook PrintEndPageCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PrintEndPage +func printEndPageRequest(c *xgb.Conn, Cancel bool) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 14 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + if Cancel { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding + + return buf +} + +// Request PrintSelectInput +// size: xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(EventMask))))))) +type PrintSelectInputCookie struct { + *xgb.Cookie +} + +// Write request to wire for PrintSelectInput +func PrintSelectInput(c *xgb.Conn, Context Pcontext, EventMask uint32, EventList []uint32) PrintSelectInputCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(printSelectInputRequest(c, Context, EventMask, EventList), cookie) + return PrintSelectInputCookie{cookie} +} + +func PrintSelectInputChecked(c *xgb.Conn, Context Pcontext, EventMask uint32, EventList []uint32) PrintSelectInputCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(printSelectInputRequest(c, Context, EventMask, EventList), cookie) + return PrintSelectInputCookie{cookie} +} + +func (cook PrintSelectInputCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PrintSelectInput +func printSelectInputRequest(c *xgb.Conn, Context Pcontext, EventMask uint32, EventList []uint32) []byte { + size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(EventMask))))))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 15 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + xgb.Put32(buf[b:], EventMask) + b += 4 + for i := 0; i < xgb.PopCount(int(EventMask)); i++ { + xgb.Put32(buf[b:], EventList[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request PrintInputSelected +// size: 8 +type PrintInputSelectedCookie struct { + *xgb.Cookie +} + +func PrintInputSelected(c *xgb.Conn, Context Pcontext) PrintInputSelectedCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(printInputSelectedRequest(c, Context), cookie) + return PrintInputSelectedCookie{cookie} +} + +func PrintInputSelectedUnchecked(c *xgb.Conn, Context Pcontext) PrintInputSelectedCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(printInputSelectedRequest(c, Context), cookie) + return PrintInputSelectedCookie{cookie} +} + +// Request reply for PrintInputSelected +// size: ((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(EventMask)))))) + (4 + xgb.Pad((4 * xgb.PopCount(int(AllEventsMask)))))) +type PrintInputSelectedReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + EventMask uint32 + EventList []uint32 + AllEventsMask uint32 + AllEventsList []uint32 +} + +// Waits and reads reply data from request PrintInputSelected +func (cook PrintInputSelectedCookie) Reply() (*PrintInputSelectedReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return printInputSelectedReply(buf), nil +} + +// Read reply into structure from buffer for PrintInputSelected +func printInputSelectedReply(buf []byte) *PrintInputSelectedReply { + v := new(PrintInputSelectedReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.EventMask = xgb.Get32(buf[b:]) + b += 4 + + v.EventList = make([]uint32, xgb.PopCount(int(v.EventMask))) + for i := 0; i < xgb.PopCount(int(v.EventMask)); i++ { + v.EventList[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + v.AllEventsMask = xgb.Get32(buf[b:]) + b += 4 + + v.AllEventsList = make([]uint32, xgb.PopCount(int(v.AllEventsMask))) + for i := 0; i < xgb.PopCount(int(v.AllEventsMask)); i++ { + v.AllEventsList[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for PrintInputSelected +func printInputSelectedRequest(c *xgb.Conn, Context Pcontext) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 16 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + return buf +} + +// Request PrintGetAttributes +// size: 12 +type PrintGetAttributesCookie struct { + *xgb.Cookie +} + +func PrintGetAttributes(c *xgb.Conn, Context Pcontext, Pool byte) PrintGetAttributesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(printGetAttributesRequest(c, Context, Pool), cookie) + return PrintGetAttributesCookie{cookie} +} + +func PrintGetAttributesUnchecked(c *xgb.Conn, Context Pcontext, Pool byte) PrintGetAttributesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(printGetAttributesRequest(c, Context, Pool), cookie) + return PrintGetAttributesCookie{cookie} +} + +// Request reply for PrintGetAttributes +// size: 33 +type PrintGetAttributesReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + StringLen uint32 + // padding: 20 bytes + Attributes String8 +} + +// Waits and reads reply data from request PrintGetAttributes +func (cook PrintGetAttributesCookie) Reply() (*PrintGetAttributesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return printGetAttributesReply(buf), nil +} + +// Read reply into structure from buffer for PrintGetAttributes +func printGetAttributesReply(buf []byte) *PrintGetAttributesReply { + v := new(PrintGetAttributesReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.StringLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Attributes = String8(buf[b]) + b += 1 + + return v +} + +// Write request to wire for PrintGetAttributes +func printGetAttributesRequest(c *xgb.Conn, Context Pcontext, Pool byte) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 17 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + buf[b] = Pool + b += 1 + + b += 3 // padding + + return buf +} + +// Request PrintGetOneAttributes +// size: xgb.Pad((16 + xgb.Pad((int(NameLen) * 1)))) +type PrintGetOneAttributesCookie struct { + *xgb.Cookie +} + +func PrintGetOneAttributes(c *xgb.Conn, Context Pcontext, NameLen uint32, Pool byte, Name []String8) PrintGetOneAttributesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(printGetOneAttributesRequest(c, Context, NameLen, Pool, Name), cookie) + return PrintGetOneAttributesCookie{cookie} +} + +func PrintGetOneAttributesUnchecked(c *xgb.Conn, Context Pcontext, NameLen uint32, Pool byte, Name []String8) PrintGetOneAttributesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(printGetOneAttributesRequest(c, Context, NameLen, Pool, Name), cookie) + return PrintGetOneAttributesCookie{cookie} +} + +// Request reply for PrintGetOneAttributes +// size: (32 + xgb.Pad((int(ValueLen) * 1))) +type PrintGetOneAttributesReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ValueLen uint32 + // padding: 20 bytes + Value []String8 // size: xgb.Pad((int(ValueLen) * 1)) +} + +// Waits and reads reply data from request PrintGetOneAttributes +func (cook PrintGetOneAttributesCookie) Reply() (*PrintGetOneAttributesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return printGetOneAttributesReply(buf), nil +} + +// Read reply into structure from buffer for PrintGetOneAttributes +func printGetOneAttributesReply(buf []byte) *PrintGetOneAttributesReply { + v := new(PrintGetOneAttributesReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ValueLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Value = make([]String8, v.ValueLen) + for i := 0; i < int(v.ValueLen); i++ { + v.Value[i] = String8(buf[b]) + b += 1 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for PrintGetOneAttributes +func printGetOneAttributesRequest(c *xgb.Conn, Context Pcontext, NameLen uint32, Pool byte, Name []String8) []byte { + size := xgb.Pad((16 + xgb.Pad((int(NameLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 19 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + xgb.Put32(buf[b:], NameLen) + b += 4 + + buf[b] = Pool + b += 1 + + b += 3 // padding + + for i := 0; i < int(NameLen); i++ { + buf[b] = byte(Name[i]) + b += 1 + } + b = xgb.Pad(b) + + return buf +} + +// Request PrintSetAttributes +// size: xgb.Pad((16 + xgb.Pad((len(Attributes) * 1)))) +type PrintSetAttributesCookie struct { + *xgb.Cookie +} + +// Write request to wire for PrintSetAttributes +func PrintSetAttributes(c *xgb.Conn, Context Pcontext, StringLen uint32, Pool byte, Rule byte, Attributes []String8) PrintSetAttributesCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(printSetAttributesRequest(c, Context, StringLen, Pool, Rule, Attributes), cookie) + return PrintSetAttributesCookie{cookie} +} + +func PrintSetAttributesChecked(c *xgb.Conn, Context Pcontext, StringLen uint32, Pool byte, Rule byte, Attributes []String8) PrintSetAttributesCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(printSetAttributesRequest(c, Context, StringLen, Pool, Rule, Attributes), cookie) + return PrintSetAttributesCookie{cookie} +} + +func (cook PrintSetAttributesCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PrintSetAttributes +func printSetAttributesRequest(c *xgb.Conn, Context Pcontext, StringLen uint32, Pool byte, Rule byte, Attributes []String8) []byte { + size := xgb.Pad((16 + xgb.Pad((len(Attributes) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 18 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + xgb.Put32(buf[b:], StringLen) + b += 4 + + buf[b] = Pool + b += 1 + + buf[b] = Rule + b += 1 + + b += 2 // padding + + for i := 0; i < int(len(Attributes)); i++ { + buf[b] = byte(Attributes[i]) + b += 1 + } + b = xgb.Pad(b) + + return buf +} + +// Request PrintGetPageDimensions +// size: 8 +type PrintGetPageDimensionsCookie struct { + *xgb.Cookie +} + +func PrintGetPageDimensions(c *xgb.Conn, Context Pcontext) PrintGetPageDimensionsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(printGetPageDimensionsRequest(c, Context), cookie) + return PrintGetPageDimensionsCookie{cookie} +} + +func PrintGetPageDimensionsUnchecked(c *xgb.Conn, Context Pcontext) PrintGetPageDimensionsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(printGetPageDimensionsRequest(c, Context), cookie) + return PrintGetPageDimensionsCookie{cookie} +} + +// Request reply for PrintGetPageDimensions +// size: 20 +type PrintGetPageDimensionsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Width uint16 + Height uint16 + OffsetX uint16 + OffsetY uint16 + ReproducibleWidth uint16 + ReproducibleHeight uint16 +} + +// Waits and reads reply data from request PrintGetPageDimensions +func (cook PrintGetPageDimensionsCookie) Reply() (*PrintGetPageDimensionsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return printGetPageDimensionsReply(buf), nil +} + +// Read reply into structure from buffer for PrintGetPageDimensions +func printGetPageDimensionsReply(buf []byte) *PrintGetPageDimensionsReply { + v := new(PrintGetPageDimensionsReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.OffsetX = xgb.Get16(buf[b:]) + b += 2 + + v.OffsetY = xgb.Get16(buf[b:]) + b += 2 + + v.ReproducibleWidth = xgb.Get16(buf[b:]) + b += 2 + + v.ReproducibleHeight = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Write request to wire for PrintGetPageDimensions +func printGetPageDimensionsRequest(c *xgb.Conn, Context Pcontext) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 21 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + return buf +} + +// Request PrintQueryScreens +// size: 4 +type PrintQueryScreensCookie struct { + *xgb.Cookie +} + +func PrintQueryScreens(c *xgb.Conn) PrintQueryScreensCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(printQueryScreensRequest(c), cookie) + return PrintQueryScreensCookie{cookie} +} + +func PrintQueryScreensUnchecked(c *xgb.Conn) PrintQueryScreensCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(printQueryScreensRequest(c), cookie) + return PrintQueryScreensCookie{cookie} +} + +// Request reply for PrintQueryScreens +// size: (32 + xgb.Pad((int(ListCount) * 4))) +type PrintQueryScreensReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ListCount uint32 + // padding: 20 bytes + Roots []xproto.Window // size: xgb.Pad((int(ListCount) * 4)) +} + +// Waits and reads reply data from request PrintQueryScreens +func (cook PrintQueryScreensCookie) Reply() (*PrintQueryScreensReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return printQueryScreensReply(buf), nil +} + +// Read reply into structure from buffer for PrintQueryScreens +func printQueryScreensReply(buf []byte) *PrintQueryScreensReply { + v := new(PrintQueryScreensReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ListCount = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Roots = make([]xproto.Window, v.ListCount) + for i := 0; i < int(v.ListCount); i++ { + v.Roots[i] = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for PrintQueryScreens +func printQueryScreensRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 22 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request PrintSetImageResolution +// size: 12 +type PrintSetImageResolutionCookie struct { + *xgb.Cookie +} + +func PrintSetImageResolution(c *xgb.Conn, Context Pcontext, ImageResolution uint16) PrintSetImageResolutionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(printSetImageResolutionRequest(c, Context, ImageResolution), cookie) + return PrintSetImageResolutionCookie{cookie} +} + +func PrintSetImageResolutionUnchecked(c *xgb.Conn, Context Pcontext, ImageResolution uint16) PrintSetImageResolutionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(printSetImageResolutionRequest(c, Context, ImageResolution), cookie) + return PrintSetImageResolutionCookie{cookie} +} + +// Request reply for PrintSetImageResolution +// size: 10 +type PrintSetImageResolutionReply struct { + Sequence uint16 + Length uint32 + Status bool + PreviousResolutions uint16 +} + +// Waits and reads reply data from request PrintSetImageResolution +func (cook PrintSetImageResolutionCookie) Reply() (*PrintSetImageResolutionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return printSetImageResolutionReply(buf), nil +} + +// Read reply into structure from buffer for PrintSetImageResolution +func printSetImageResolutionReply(buf []byte) *PrintSetImageResolutionReply { + v := new(PrintSetImageResolutionReply) + b := 1 // skip reply determinant + + if buf[b] == 1 { + v.Status = true + } else { + v.Status = false + } + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.PreviousResolutions = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Write request to wire for PrintSetImageResolution +func printSetImageResolutionRequest(c *xgb.Conn, Context Pcontext, ImageResolution uint16) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 23 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + xgb.Put16(buf[b:], ImageResolution) + b += 2 + + return buf +} + +// Request PrintGetImageResolution +// size: 8 +type PrintGetImageResolutionCookie struct { + *xgb.Cookie +} + +func PrintGetImageResolution(c *xgb.Conn, Context Pcontext) PrintGetImageResolutionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(printGetImageResolutionRequest(c, Context), cookie) + return PrintGetImageResolutionCookie{cookie} +} + +func PrintGetImageResolutionUnchecked(c *xgb.Conn, Context Pcontext) PrintGetImageResolutionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(printGetImageResolutionRequest(c, Context), cookie) + return PrintGetImageResolutionCookie{cookie} +} + +// Request reply for PrintGetImageResolution +// size: 10 +type PrintGetImageResolutionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ImageResolution uint16 +} + +// Waits and reads reply data from request PrintGetImageResolution +func (cook PrintGetImageResolutionCookie) Reply() (*PrintGetImageResolutionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return printGetImageResolutionReply(buf), nil +} + +// Read reply into structure from buffer for PrintGetImageResolution +func printGetImageResolutionReply(buf []byte) *PrintGetImageResolutionReply { + v := new(PrintGetImageResolutionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ImageResolution = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Write request to wire for PrintGetImageResolution +func printGetImageResolutionRequest(c *xgb.Conn, Context Pcontext) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XPEXTENSION"] + b += 1 + + buf[b] = 24 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + return buf +} diff --git a/nexgb/xproto/xproto.go b/nexgb/xproto/xproto.go new file mode 100644 index 0000000..2516225 --- /dev/null +++ b/nexgb/xproto/xproto.go @@ -0,0 +1,14347 @@ +package xproto + +/* + This file was generated by xproto.xml on May 10 2012 4:20:28pm EDT. + This file is automatically generated. Edit at your peril! +*/ + +import ( + "github.com/BurntSushi/xgb" +) + +// Setup parses the setup bytes retrieved when +// connecting into a SetupInfo struct. +func Setup(c *xgb.Conn) *SetupInfo { + setup := new(SetupInfo) + SetupInfoRead(c.SetupBytes, setup) + return setup +} + +// DefaultScreen gets the default screen info from SetupInfo. +func (s *SetupInfo) DefaultScreen(c *xgb.Conn) *ScreenInfo { + return &s.Roots[c.DefaultScreen] +} + +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Bool' + +// Skipping definition for base type 'Float' + +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + +const ( + VisualClassStaticGray = 0 + VisualClassGrayScale = 1 + VisualClassStaticColor = 2 + VisualClassPseudoColor = 3 + VisualClassTrueColor = 4 + VisualClassDirectColor = 5 +) + +const ( + EventMaskNoEvent = 0 + EventMaskKeyPress = 1 + EventMaskKeyRelease = 2 + EventMaskButtonPress = 4 + EventMaskButtonRelease = 8 + EventMaskEnterWindow = 16 + EventMaskLeaveWindow = 32 + EventMaskPointerMotion = 64 + EventMaskPointerMotionHint = 128 + EventMaskButton1Motion = 256 + EventMaskButton2Motion = 512 + EventMaskButton3Motion = 1024 + EventMaskButton4Motion = 2048 + EventMaskButton5Motion = 4096 + EventMaskButtonMotion = 8192 + EventMaskKeymapState = 16384 + EventMaskExposure = 32768 + EventMaskVisibilityChange = 65536 + EventMaskStructureNotify = 131072 + EventMaskResizeRedirect = 262144 + EventMaskSubstructureNotify = 524288 + EventMaskSubstructureRedirect = 1048576 + EventMaskFocusChange = 2097152 + EventMaskPropertyChange = 4194304 + EventMaskColorMapChange = 8388608 + EventMaskOwnerGrabButton = 16777216 +) + +const ( + BackingStoreNotUseful = 0 + BackingStoreWhenMapped = 1 + BackingStoreAlways = 2 +) + +const ( + ImageOrderLSBFirst = 0 + ImageOrderMSBFirst = 1 +) + +const ( + ModMaskShift = 1 + ModMaskLock = 2 + ModMaskControl = 4 + ModMask1 = 8 + ModMask2 = 16 + ModMask3 = 32 + ModMask4 = 64 + ModMask5 = 128 + ModMaskAny = 32768 +) + +const ( + KeyButMaskShift = 1 + KeyButMaskLock = 2 + KeyButMaskControl = 4 + KeyButMaskMod1 = 8 + KeyButMaskMod2 = 16 + KeyButMaskMod3 = 32 + KeyButMaskMod4 = 64 + KeyButMaskMod5 = 128 + KeyButMaskButton1 = 256 + KeyButMaskButton2 = 512 + KeyButMaskButton3 = 1024 + KeyButMaskButton4 = 2048 + KeyButMaskButton5 = 4096 +) + +const ( + WindowNone = 0 +) + +const ( + ButtonMask1 = 256 + ButtonMask2 = 512 + ButtonMask3 = 1024 + ButtonMask4 = 2048 + ButtonMask5 = 4096 + ButtonMaskAny = 32768 +) + +const ( + MotionNormal = 0 + MotionHint = 1 +) + +const ( + NotifyDetailAncestor = 0 + NotifyDetailVirtual = 1 + NotifyDetailInferior = 2 + NotifyDetailNonlinear = 3 + NotifyDetailNonlinearVirtual = 4 + NotifyDetailPointer = 5 + NotifyDetailPointerRoot = 6 + NotifyDetailNone = 7 +) + +const ( + NotifyModeNormal = 0 + NotifyModeGrab = 1 + NotifyModeUngrab = 2 + NotifyModeWhileGrabbed = 3 +) + +const ( + VisibilityUnobscured = 0 + VisibilityPartiallyObscured = 1 + VisibilityFullyObscured = 2 +) + +const ( + PlaceOnTop = 0 + PlaceOnBottom = 1 +) + +const ( + PropertyNewValue = 0 + PropertyDelete = 1 +) + +const ( + TimeCurrentTime = 0 +) + +const ( + AtomNone = 0 + AtomAny = 0 + AtomPrimary = 1 + AtomSecondary = 2 + AtomArc = 3 + AtomAtom = 4 + AtomBitmap = 5 + AtomCardinal = 6 + AtomColormap = 7 + AtomCursor = 8 + AtomCutBuffer0 = 9 + AtomCutBuffer1 = 10 + AtomCutBuffer2 = 11 + AtomCutBuffer3 = 12 + AtomCutBuffer4 = 13 + AtomCutBuffer5 = 14 + AtomCutBuffer6 = 15 + AtomCutBuffer7 = 16 + AtomDrawable = 17 + AtomFont = 18 + AtomInteger = 19 + AtomPixmap = 20 + AtomPoint = 21 + AtomRectangle = 22 + AtomResourceManager = 23 + AtomRgbColorMap = 24 + AtomRgbBestMap = 25 + AtomRgbBlueMap = 26 + AtomRgbDefaultMap = 27 + AtomRgbGrayMap = 28 + AtomRgbGreenMap = 29 + AtomRgbRedMap = 30 + AtomString = 31 + AtomVisualid = 32 + AtomWindow = 33 + AtomWmCommand = 34 + AtomWmHints = 35 + AtomWmClientMachine = 36 + AtomWmIconName = 37 + AtomWmIconSize = 38 + AtomWmName = 39 + AtomWmNormalHints = 40 + AtomWmSizeHints = 41 + AtomWmZoomHints = 42 + AtomMinSpace = 43 + AtomNormSpace = 44 + AtomMaxSpace = 45 + AtomEndSpace = 46 + AtomSuperscriptX = 47 + AtomSuperscriptY = 48 + AtomSubscriptX = 49 + AtomSubscriptY = 50 + AtomUnderlinePosition = 51 + AtomUnderlineThickness = 52 + AtomStrikeoutAscent = 53 + AtomStrikeoutDescent = 54 + AtomItalicAngle = 55 + AtomXHeight = 56 + AtomQuadWidth = 57 + AtomWeight = 58 + AtomPointSize = 59 + AtomResolution = 60 + AtomCopyright = 61 + AtomNotice = 62 + AtomFontName = 63 + AtomFamilyName = 64 + AtomFullName = 65 + AtomCapHeight = 66 + AtomWmClass = 67 + AtomWmTransientFor = 68 +) + +const ( + ColormapStateUninstalled = 0 + ColormapStateInstalled = 1 +) + +const ( + ColormapNone = 0 +) + +const ( + MappingModifier = 0 + MappingKeyboard = 1 + MappingPointer = 2 +) + +const ( + WindowClassCopyFromParent = 0 + WindowClassInputOutput = 1 + WindowClassInputOnly = 2 +) + +const ( + CwBackPixmap = 1 + CwBackPixel = 2 + CwBorderPixmap = 4 + CwBorderPixel = 8 + CwBitGravity = 16 + CwWinGravity = 32 + CwBackingStore = 64 + CwBackingPlanes = 128 + CwBackingPixel = 256 + CwOverrideRedirect = 512 + CwSaveUnder = 1024 + CwEventMask = 2048 + CwDontPropagate = 4096 + CwColormap = 8192 + CwCursor = 16384 +) + +const ( + BackPixmapNone = 0 + BackPixmapParentRelative = 1 +) + +const ( + GravityBitForget = 0 + GravityWinUnmap = 0 + GravityNorthWest = 1 + GravityNorth = 2 + GravityNorthEast = 3 + GravityWest = 4 + GravityCenter = 5 + GravityEast = 6 + GravitySouthWest = 7 + GravitySouth = 8 + GravitySouthEast = 9 + GravityStatic = 10 +) + +const ( + MapStateUnmapped = 0 + MapStateUnviewable = 1 + MapStateViewable = 2 +) + +const ( + SetModeInsert = 0 + SetModeDelete = 1 +) + +const ( + ConfigWindowX = 1 + ConfigWindowY = 2 + ConfigWindowWidth = 4 + ConfigWindowHeight = 8 + ConfigWindowBorderWidth = 16 + ConfigWindowSibling = 32 + ConfigWindowStackMode = 64 +) + +const ( + StackModeAbove = 0 + StackModeBelow = 1 + StackModeTopIf = 2 + StackModeBottomIf = 3 + StackModeOpposite = 4 +) + +const ( + CirculateRaiseLowest = 0 + CirculateLowerHighest = 1 +) + +const ( + PropModeReplace = 0 + PropModePrepend = 1 + PropModeAppend = 2 +) + +const ( + GetPropertyTypeAny = 0 +) + +const ( + SendEventDestPointerWindow = 0 + SendEventDestItemFocus = 1 +) + +const ( + GrabModeSync = 0 + GrabModeAsync = 1 +) + +const ( + GrabStatusSuccess = 0 + GrabStatusAlreadyGrabbed = 1 + GrabStatusInvalidTime = 2 + GrabStatusNotViewable = 3 + GrabStatusFrozen = 4 +) + +const ( + CursorNone = 0 +) + +const ( + ButtonIndexAny = 0 + ButtonIndex1 = 1 + ButtonIndex2 = 2 + ButtonIndex3 = 3 + ButtonIndex4 = 4 + ButtonIndex5 = 5 +) + +const ( + GrabAny = 0 +) + +const ( + AllowAsyncPointer = 0 + AllowSyncPointer = 1 + AllowReplayPointer = 2 + AllowAsyncKeyboard = 3 + AllowSyncKeyboard = 4 + AllowReplayKeyboard = 5 + AllowAsyncBoth = 6 + AllowSyncBoth = 7 +) + +const ( + InputFocusNone = 0 + InputFocusPointerRoot = 1 + InputFocusParent = 2 + InputFocusFollowKeyboard = 3 +) + +const ( + FontDrawLeftToRight = 0 + FontDrawRightToLeft = 1 +) + +const ( + GcFunction = 1 + GcPlaneMask = 2 + GcForeground = 4 + GcBackground = 8 + GcLineWidth = 16 + GcLineStyle = 32 + GcCapStyle = 64 + GcJoinStyle = 128 + GcFillStyle = 256 + GcFillRule = 512 + GcTile = 1024 + GcStipple = 2048 + GcTileStippleOriginX = 4096 + GcTileStippleOriginY = 8192 + GcFont = 16384 + GcSubwindowMode = 32768 + GcGraphicsExposures = 65536 + GcClipOriginX = 131072 + GcClipOriginY = 262144 + GcClipMask = 524288 + GcDashOffset = 1048576 + GcDashList = 2097152 + GcArcMode = 4194304 +) + +const ( + GxClear = 0 + GxAnd = 1 + GxAndReverse = 2 + GxCopy = 3 + GxAndInverted = 4 + GxNoop = 5 + GxXor = 6 + GxOr = 7 + GxNor = 8 + GxEquiv = 9 + GxInvert = 10 + GxOrReverse = 11 + GxCopyInverted = 12 + GxOrInverted = 13 + GxNand = 14 + GxSet = 15 +) + +const ( + LineStyleSolid = 0 + LineStyleOnOffDash = 1 + LineStyleDoubleDash = 2 +) + +const ( + CapStyleNotLast = 0 + CapStyleButt = 1 + CapStyleRound = 2 + CapStyleProjecting = 3 +) + +const ( + JoinStyleMiter = 0 + JoinStyleRound = 1 + JoinStyleBevel = 2 +) + +const ( + FillStyleSolid = 0 + FillStyleTiled = 1 + FillStyleStippled = 2 + FillStyleOpaqueStippled = 3 +) + +const ( + FillRuleEvenOdd = 0 + FillRuleWinding = 1 +) + +const ( + SubwindowModeClipByChildren = 0 + SubwindowModeIncludeInferiors = 1 +) + +const ( + ArcModeChord = 0 + ArcModePieSlice = 1 +) + +const ( + ClipOrderingUnsorted = 0 + ClipOrderingYSorted = 1 + ClipOrderingYXSorted = 2 + ClipOrderingYXBanded = 3 +) + +const ( + CoordModeOrigin = 0 + CoordModePrevious = 1 +) + +const ( + PolyShapeComplex = 0 + PolyShapeNonconvex = 1 + PolyShapeConvex = 2 +) + +const ( + ImageFormatXYBitmap = 0 + ImageFormatXYPixmap = 1 + ImageFormatZPixmap = 2 +) + +const ( + ColormapAllocNone = 0 + ColormapAllocAll = 1 +) + +const ( + ColorFlagRed = 1 + ColorFlagGreen = 2 + ColorFlagBlue = 4 +) + +const ( + PixmapNone = 0 +) + +const ( + FontNone = 0 +) + +const ( + QueryShapeOfLargestCursor = 0 + QueryShapeOfFastestTile = 1 + QueryShapeOfFastestStipple = 2 +) + +const ( + KbKeyClickPercent = 1 + KbBellPercent = 2 + KbBellPitch = 4 + KbBellDuration = 8 + KbLed = 16 + KbLedMode = 32 + KbKey = 64 + KbAutoRepeatMode = 128 +) + +const ( + LedModeOff = 0 + LedModeOn = 1 +) + +const ( + AutoRepeatModeOff = 0 + AutoRepeatModeOn = 1 + AutoRepeatModeDefault = 2 +) + +const ( + BlankingNotPreferred = 0 + BlankingPreferred = 1 + BlankingDefault = 2 +) + +const ( + ExposuresNotAllowed = 0 + ExposuresAllowed = 1 + ExposuresDefault = 2 +) + +const ( + HostModeInsert = 0 + HostModeDelete = 1 +) + +const ( + FamilyInternet = 0 + FamilyDECnet = 1 + FamilyChaos = 2 + FamilyServerInterpreted = 5 + FamilyInternet6 = 6 +) + +const ( + AccessControlDisable = 0 + AccessControlEnable = 1 +) + +const ( + CloseDownDestroyAll = 0 + CloseDownRetainPermanent = 1 + CloseDownRetainTemporary = 2 +) + +const ( + KillAllTemporary = 0 +) + +const ( + ScreenSaverReset = 0 + ScreenSaverActive = 1 +) + +const ( + MappingStatusSuccess = 0 + MappingStatusBusy = 1 + MappingStatusFailure = 2 +) + +const ( + MapIndexShift = 0 + MapIndexLock = 1 + MapIndexControl = 2 + MapIndex1 = 3 + MapIndex2 = 4 + MapIndex3 = 5 + MapIndex4 = 6 + MapIndex5 = 7 +) + +type Window uint32 + +func NewWindowId(c *xgb.Conn) (Window, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Window(id), nil +} + +type Pixmap uint32 + +func NewPixmapId(c *xgb.Conn) (Pixmap, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Pixmap(id), nil +} + +type Cursor uint32 + +func NewCursorId(c *xgb.Conn) (Cursor, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Cursor(id), nil +} + +type Font uint32 + +func NewFontId(c *xgb.Conn) (Font, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Font(id), nil +} + +type Gcontext uint32 + +func NewGcontextId(c *xgb.Conn) (Gcontext, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Gcontext(id), nil +} + +type Colormap uint32 + +func NewColormapId(c *xgb.Conn) (Colormap, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Colormap(id), nil +} + +type Atom uint32 + +func NewAtomId(c *xgb.Conn) (Atom, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Atom(id), nil +} + +type Drawable uint32 + +func NewDrawableId(c *xgb.Conn) (Drawable, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Drawable(id), nil +} + +type Fontable uint32 + +func NewFontableId(c *xgb.Conn) (Fontable, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Fontable(id), nil +} + +type Visualid uint32 + +type Timestamp uint32 + +type Keysym uint32 + +type Keycode byte + +type Button byte + +// 'Char2b' struct definition +// Size: 2 +type Char2b struct { + Byte1 byte + Byte2 byte +} + +// Struct read Char2b +func Char2bRead(buf []byte, v *Char2b) int { + b := 0 + + v.Byte1 = buf[b] + b += 1 + + v.Byte2 = buf[b] + b += 1 + + return b +} + +// Struct list read Char2b +func Char2bReadList(buf []byte, dest []Char2b) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Char2b{} + b += Char2bRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Char2b +func (v Char2b) Bytes() []byte { + buf := make([]byte, 2) + b := 0 + + buf[b] = v.Byte1 + b += 1 + + buf[b] = v.Byte2 + b += 1 + + return buf +} + +// Write struct list Char2b +func Char2bListBytes(buf []byte, list []Char2b) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Point' struct definition +// Size: 4 +type Point struct { + X int16 + Y int16 +} + +// Struct read Point +func PointRead(buf []byte, v *Point) int { + b := 0 + + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + + return b +} + +// Struct list read Point +func PointReadList(buf []byte, dest []Point) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Point{} + b += PointRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Point +func (v Point) Bytes() []byte { + buf := make([]byte, 4) + b := 0 + + xgb.Put16(buf[b:], uint16(v.X)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 + + return buf +} + +// Write struct list Point +func PointListBytes(buf []byte, list []Point) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Rectangle' struct definition +// Size: 8 +type Rectangle struct { + X int16 + Y int16 + Width uint16 + Height uint16 +} + +// Struct read Rectangle +func RectangleRead(buf []byte, v *Rectangle) int { + b := 0 + + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + return b +} + +// Struct list read Rectangle +func RectangleReadList(buf []byte, dest []Rectangle) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Rectangle{} + b += RectangleRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Rectangle +func (v Rectangle) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put16(buf[b:], uint16(v.X)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + return buf +} + +// Write struct list Rectangle +func RectangleListBytes(buf []byte, list []Rectangle) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Arc' struct definition +// Size: 12 +type Arc struct { + X int16 + Y int16 + Width uint16 + Height uint16 + Angle1 int16 + Angle2 int16 +} + +// Struct read Arc +func ArcRead(buf []byte, v *Arc) int { + b := 0 + + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.Angle1 = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Angle2 = int16(xgb.Get16(buf[b:])) + b += 2 + + return b +} + +// Struct list read Arc +func ArcReadList(buf []byte, dest []Arc) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Arc{} + b += ArcRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Arc +func (v Arc) Bytes() []byte { + buf := make([]byte, 12) + b := 0 + + xgb.Put16(buf[b:], uint16(v.X)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Angle1)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Angle2)) + b += 2 + + return buf +} + +// Write struct list Arc +func ArcListBytes(buf []byte, list []Arc) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Format' struct definition +// Size: 8 +type Format struct { + Depth byte + BitsPerPixel byte + ScanlinePad byte + // padding: 5 bytes +} + +// Struct read Format +func FormatRead(buf []byte, v *Format) int { + b := 0 + + v.Depth = buf[b] + b += 1 + + v.BitsPerPixel = buf[b] + b += 1 + + v.ScanlinePad = buf[b] + b += 1 + + b += 5 // padding + + return b +} + +// Struct list read Format +func FormatReadList(buf []byte, dest []Format) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Format{} + b += FormatRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Format +func (v Format) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + buf[b] = v.Depth + b += 1 + + buf[b] = v.BitsPerPixel + b += 1 + + buf[b] = v.ScanlinePad + b += 1 + + b += 5 // padding + + return buf +} + +// Write struct list Format +func FormatListBytes(buf []byte, list []Format) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'VisualInfo' struct definition +// Size: 24 +type VisualInfo struct { + VisualId Visualid + Class byte + BitsPerRgbValue byte + ColormapEntries uint16 + RedMask uint32 + GreenMask uint32 + BlueMask uint32 + // padding: 4 bytes +} + +// Struct read VisualInfo +func VisualInfoRead(buf []byte, v *VisualInfo) int { + b := 0 + + v.VisualId = Visualid(xgb.Get32(buf[b:])) + b += 4 + + v.Class = buf[b] + b += 1 + + v.BitsPerRgbValue = buf[b] + b += 1 + + v.ColormapEntries = xgb.Get16(buf[b:]) + b += 2 + + v.RedMask = xgb.Get32(buf[b:]) + b += 4 + + v.GreenMask = xgb.Get32(buf[b:]) + b += 4 + + v.BlueMask = xgb.Get32(buf[b:]) + b += 4 + + b += 4 // padding + + return b +} + +// Struct list read VisualInfo +func VisualInfoReadList(buf []byte, dest []VisualInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = VisualInfo{} + b += VisualInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write VisualInfo +func (v VisualInfo) Bytes() []byte { + buf := make([]byte, 24) + b := 0 + + xgb.Put32(buf[b:], uint32(v.VisualId)) + b += 4 + + buf[b] = v.Class + b += 1 + + buf[b] = v.BitsPerRgbValue + b += 1 + + xgb.Put16(buf[b:], v.ColormapEntries) + b += 2 + + xgb.Put32(buf[b:], v.RedMask) + b += 4 + + xgb.Put32(buf[b:], v.GreenMask) + b += 4 + + xgb.Put32(buf[b:], v.BlueMask) + b += 4 + + b += 4 // padding + + return buf +} + +// Write struct list VisualInfo +func VisualInfoListBytes(buf []byte, list []VisualInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'DepthInfo' struct definition +// Size: (8 + xgb.Pad((int(VisualsLen) * 24))) +type DepthInfo struct { + Depth byte + // padding: 1 bytes + VisualsLen uint16 + // padding: 4 bytes + Visuals []VisualInfo // size: xgb.Pad((int(VisualsLen) * 24)) +} + +// Struct read DepthInfo +func DepthInfoRead(buf []byte, v *DepthInfo) int { + b := 0 + + v.Depth = buf[b] + b += 1 + + b += 1 // padding + + v.VisualsLen = xgb.Get16(buf[b:]) + b += 2 + + b += 4 // padding + + v.Visuals = make([]VisualInfo, v.VisualsLen) + b += VisualInfoReadList(buf[b:], v.Visuals) + + return b +} + +// Struct list read DepthInfo +func DepthInfoReadList(buf []byte, dest []DepthInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DepthInfo{} + b += DepthInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write DepthInfo +func (v DepthInfo) Bytes() []byte { + buf := make([]byte, (8 + xgb.Pad((int(v.VisualsLen) * 24)))) + b := 0 + + buf[b] = v.Depth + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], v.VisualsLen) + b += 2 + + b += 4 // padding + + b += VisualInfoListBytes(buf[b:], v.Visuals) + + return buf +} + +// Write struct list DepthInfo +func DepthInfoListBytes(buf []byte, list []DepthInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size DepthInfo +func DepthInfoListSize(list []DepthInfo) int { + size := 0 + for _, item := range list { + size += (8 + xgb.Pad((int(item.VisualsLen) * 24))) + } + return size +} + +// 'ScreenInfo' struct definition +// Size: (40 + DepthInfoListSize(AllowedDepths)) +type ScreenInfo struct { + Root Window + DefaultColormap Colormap + WhitePixel uint32 + BlackPixel uint32 + CurrentInputMasks uint32 + WidthInPixels uint16 + HeightInPixels uint16 + WidthInMillimeters uint16 + HeightInMillimeters uint16 + MinInstalledMaps uint16 + MaxInstalledMaps uint16 + RootVisual Visualid + BackingStores byte + SaveUnders bool + RootDepth byte + AllowedDepthsLen byte + AllowedDepths []DepthInfo // size: DepthInfoListSize(AllowedDepths) +} + +// Struct read ScreenInfo +func ScreenInfoRead(buf []byte, v *ScreenInfo) int { + b := 0 + + v.Root = Window(xgb.Get32(buf[b:])) + b += 4 + + v.DefaultColormap = Colormap(xgb.Get32(buf[b:])) + b += 4 + + v.WhitePixel = xgb.Get32(buf[b:]) + b += 4 + + v.BlackPixel = xgb.Get32(buf[b:]) + b += 4 + + v.CurrentInputMasks = xgb.Get32(buf[b:]) + b += 4 + + v.WidthInPixels = xgb.Get16(buf[b:]) + b += 2 + + v.HeightInPixels = xgb.Get16(buf[b:]) + b += 2 + + v.WidthInMillimeters = xgb.Get16(buf[b:]) + b += 2 + + v.HeightInMillimeters = xgb.Get16(buf[b:]) + b += 2 + + v.MinInstalledMaps = xgb.Get16(buf[b:]) + b += 2 + + v.MaxInstalledMaps = xgb.Get16(buf[b:]) + b += 2 + + v.RootVisual = Visualid(xgb.Get32(buf[b:])) + b += 4 + + v.BackingStores = buf[b] + b += 1 + + if buf[b] == 1 { + v.SaveUnders = true + } else { + v.SaveUnders = false + } + b += 1 + + v.RootDepth = buf[b] + b += 1 + + v.AllowedDepthsLen = buf[b] + b += 1 + + v.AllowedDepths = make([]DepthInfo, v.AllowedDepthsLen) + b += DepthInfoReadList(buf[b:], v.AllowedDepths) + + return b +} + +// Struct list read ScreenInfo +func ScreenInfoReadList(buf []byte, dest []ScreenInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = ScreenInfo{} + b += ScreenInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write ScreenInfo +func (v ScreenInfo) Bytes() []byte { + buf := make([]byte, (40 + DepthInfoListSize(v.AllowedDepths))) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Root)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.DefaultColormap)) + b += 4 + + xgb.Put32(buf[b:], v.WhitePixel) + b += 4 + + xgb.Put32(buf[b:], v.BlackPixel) + b += 4 + + xgb.Put32(buf[b:], v.CurrentInputMasks) + b += 4 + + xgb.Put16(buf[b:], v.WidthInPixels) + b += 2 + + xgb.Put16(buf[b:], v.HeightInPixels) + b += 2 + + xgb.Put16(buf[b:], v.WidthInMillimeters) + b += 2 + + xgb.Put16(buf[b:], v.HeightInMillimeters) + b += 2 + + xgb.Put16(buf[b:], v.MinInstalledMaps) + b += 2 + + xgb.Put16(buf[b:], v.MaxInstalledMaps) + b += 2 + + xgb.Put32(buf[b:], uint32(v.RootVisual)) + b += 4 + + buf[b] = v.BackingStores + b += 1 + + if v.SaveUnders { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + buf[b] = v.RootDepth + b += 1 + + buf[b] = v.AllowedDepthsLen + b += 1 + + b += DepthInfoListBytes(buf[b:], v.AllowedDepths) + + return buf +} + +// Write struct list ScreenInfo +func ScreenInfoListBytes(buf []byte, list []ScreenInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size ScreenInfo +func ScreenInfoListSize(list []ScreenInfo) int { + size := 0 + for _, item := range list { + size += (40 + DepthInfoListSize(item.AllowedDepths)) + } + return size +} + +// 'SetupRequest' struct definition +// Size: ((12 + xgb.Pad((int(AuthorizationProtocolNameLen) * 1))) + xgb.Pad((int(AuthorizationProtocolDataLen) * 1))) +type SetupRequest struct { + ByteOrder byte + // padding: 1 bytes + ProtocolMajorVersion uint16 + ProtocolMinorVersion uint16 + AuthorizationProtocolNameLen uint16 + AuthorizationProtocolDataLen uint16 + // padding: 2 bytes + AuthorizationProtocolName string // size: xgb.Pad((int(AuthorizationProtocolNameLen) * 1)) + AuthorizationProtocolData string // size: xgb.Pad((int(AuthorizationProtocolDataLen) * 1)) +} + +// Struct read SetupRequest +func SetupRequestRead(buf []byte, v *SetupRequest) int { + b := 0 + + v.ByteOrder = buf[b] + b += 1 + + b += 1 // padding + + v.ProtocolMajorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.ProtocolMinorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.AuthorizationProtocolNameLen = xgb.Get16(buf[b:]) + b += 2 + + v.AuthorizationProtocolDataLen = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + { + byteString := make([]byte, v.AuthorizationProtocolNameLen) + copy(byteString[:v.AuthorizationProtocolNameLen], buf[b:]) + v.AuthorizationProtocolName = string(byteString) + b += xgb.Pad(int(v.AuthorizationProtocolNameLen)) + } + + { + byteString := make([]byte, v.AuthorizationProtocolDataLen) + copy(byteString[:v.AuthorizationProtocolDataLen], buf[b:]) + v.AuthorizationProtocolData = string(byteString) + b += xgb.Pad(int(v.AuthorizationProtocolDataLen)) + } + + return b +} + +// Struct list read SetupRequest +func SetupRequestReadList(buf []byte, dest []SetupRequest) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = SetupRequest{} + b += SetupRequestRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write SetupRequest +func (v SetupRequest) Bytes() []byte { + buf := make([]byte, ((12 + xgb.Pad((int(v.AuthorizationProtocolNameLen) * 1))) + xgb.Pad((int(v.AuthorizationProtocolDataLen) * 1)))) + b := 0 + + buf[b] = v.ByteOrder + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], v.ProtocolMajorVersion) + b += 2 + + xgb.Put16(buf[b:], v.ProtocolMinorVersion) + b += 2 + + xgb.Put16(buf[b:], v.AuthorizationProtocolNameLen) + b += 2 + + xgb.Put16(buf[b:], v.AuthorizationProtocolDataLen) + b += 2 + + b += 2 // padding + + copy(buf[b:], v.AuthorizationProtocolName[:v.AuthorizationProtocolNameLen]) + b += xgb.Pad(int(v.AuthorizationProtocolNameLen)) + + copy(buf[b:], v.AuthorizationProtocolData[:v.AuthorizationProtocolDataLen]) + b += xgb.Pad(int(v.AuthorizationProtocolDataLen)) + + return buf +} + +// Write struct list SetupRequest +func SetupRequestListBytes(buf []byte, list []SetupRequest) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size SetupRequest +func SetupRequestListSize(list []SetupRequest) int { + size := 0 + for _, item := range list { + size += ((12 + xgb.Pad((int(item.AuthorizationProtocolNameLen) * 1))) + xgb.Pad((int(item.AuthorizationProtocolDataLen) * 1))) + } + return size +} + +// 'SetupFailed' struct definition +// Size: (8 + xgb.Pad((int(ReasonLen) * 1))) +type SetupFailed struct { + Status byte + ReasonLen byte + ProtocolMajorVersion uint16 + ProtocolMinorVersion uint16 + Length uint16 + Reason string // size: xgb.Pad((int(ReasonLen) * 1)) +} + +// Struct read SetupFailed +func SetupFailedRead(buf []byte, v *SetupFailed) int { + b := 0 + + v.Status = buf[b] + b += 1 + + v.ReasonLen = buf[b] + b += 1 + + v.ProtocolMajorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.ProtocolMinorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get16(buf[b:]) + b += 2 + + { + byteString := make([]byte, v.ReasonLen) + copy(byteString[:v.ReasonLen], buf[b:]) + v.Reason = string(byteString) + b += xgb.Pad(int(v.ReasonLen)) + } + + return b +} + +// Struct list read SetupFailed +func SetupFailedReadList(buf []byte, dest []SetupFailed) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = SetupFailed{} + b += SetupFailedRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write SetupFailed +func (v SetupFailed) Bytes() []byte { + buf := make([]byte, (8 + xgb.Pad((int(v.ReasonLen) * 1)))) + b := 0 + + buf[b] = v.Status + b += 1 + + buf[b] = v.ReasonLen + b += 1 + + xgb.Put16(buf[b:], v.ProtocolMajorVersion) + b += 2 + + xgb.Put16(buf[b:], v.ProtocolMinorVersion) + b += 2 + + xgb.Put16(buf[b:], v.Length) + b += 2 + + copy(buf[b:], v.Reason[:v.ReasonLen]) + b += xgb.Pad(int(v.ReasonLen)) + + return buf +} + +// Write struct list SetupFailed +func SetupFailedListBytes(buf []byte, list []SetupFailed) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size SetupFailed +func SetupFailedListSize(list []SetupFailed) int { + size := 0 + for _, item := range list { + size += (8 + xgb.Pad((int(item.ReasonLen) * 1))) + } + return size +} + +// 'SetupAuthenticate' struct definition +// Size: (8 + xgb.Pad(((int(Length) * 4) * 1))) +type SetupAuthenticate struct { + Status byte + // padding: 5 bytes + Length uint16 + Reason string // size: xgb.Pad(((int(Length) * 4) * 1)) +} + +// Struct read SetupAuthenticate +func SetupAuthenticateRead(buf []byte, v *SetupAuthenticate) int { + b := 0 + + v.Status = buf[b] + b += 1 + + b += 5 // padding + + v.Length = xgb.Get16(buf[b:]) + b += 2 + + { + byteString := make([]byte, (int(v.Length) * 4)) + copy(byteString[:(int(v.Length)*4)], buf[b:]) + v.Reason = string(byteString) + b += xgb.Pad(int((int(v.Length) * 4))) + } + + return b +} + +// Struct list read SetupAuthenticate +func SetupAuthenticateReadList(buf []byte, dest []SetupAuthenticate) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = SetupAuthenticate{} + b += SetupAuthenticateRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write SetupAuthenticate +func (v SetupAuthenticate) Bytes() []byte { + buf := make([]byte, (8 + xgb.Pad(((int(v.Length) * 4) * 1)))) + b := 0 + + buf[b] = v.Status + b += 1 + + b += 5 // padding + + xgb.Put16(buf[b:], v.Length) + b += 2 + + copy(buf[b:], v.Reason[:(int(v.Length)*4)]) + b += xgb.Pad(int((int(v.Length) * 4))) + + return buf +} + +// Write struct list SetupAuthenticate +func SetupAuthenticateListBytes(buf []byte, list []SetupAuthenticate) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size SetupAuthenticate +func SetupAuthenticateListSize(list []SetupAuthenticate) int { + size := 0 + for _, item := range list { + size += (8 + xgb.Pad(((int(item.Length) * 4) * 1))) + } + return size +} + +// 'SetupInfo' struct definition +// Size: (((40 + xgb.Pad((int(VendorLen) * 1))) + xgb.Pad((int(PixmapFormatsLen) * 8))) + ScreenInfoListSize(Roots)) +type SetupInfo struct { + Status byte + // padding: 1 bytes + ProtocolMajorVersion uint16 + ProtocolMinorVersion uint16 + Length uint16 + ReleaseNumber uint32 + ResourceIdBase uint32 + ResourceIdMask uint32 + MotionBufferSize uint32 + VendorLen uint16 + MaximumRequestLength uint16 + RootsLen byte + PixmapFormatsLen byte + ImageByteOrder byte + BitmapFormatBitOrder byte + BitmapFormatScanlineUnit byte + BitmapFormatScanlinePad byte + MinKeycode Keycode + MaxKeycode Keycode + // padding: 4 bytes + Vendor string // size: xgb.Pad((int(VendorLen) * 1)) + PixmapFormats []Format // size: xgb.Pad((int(PixmapFormatsLen) * 8)) + Roots []ScreenInfo // size: ScreenInfoListSize(Roots) +} + +// Struct read SetupInfo +func SetupInfoRead(buf []byte, v *SetupInfo) int { + b := 0 + + v.Status = buf[b] + b += 1 + + b += 1 // padding + + v.ProtocolMajorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.ProtocolMinorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get16(buf[b:]) + b += 2 + + v.ReleaseNumber = xgb.Get32(buf[b:]) + b += 4 + + v.ResourceIdBase = xgb.Get32(buf[b:]) + b += 4 + + v.ResourceIdMask = xgb.Get32(buf[b:]) + b += 4 + + v.MotionBufferSize = xgb.Get32(buf[b:]) + b += 4 + + v.VendorLen = xgb.Get16(buf[b:]) + b += 2 + + v.MaximumRequestLength = xgb.Get16(buf[b:]) + b += 2 + + v.RootsLen = buf[b] + b += 1 + + v.PixmapFormatsLen = buf[b] + b += 1 + + v.ImageByteOrder = buf[b] + b += 1 + + v.BitmapFormatBitOrder = buf[b] + b += 1 + + v.BitmapFormatScanlineUnit = buf[b] + b += 1 + + v.BitmapFormatScanlinePad = buf[b] + b += 1 + + v.MinKeycode = Keycode(buf[b]) + b += 1 + + v.MaxKeycode = Keycode(buf[b]) + b += 1 + + b += 4 // padding + + { + byteString := make([]byte, v.VendorLen) + copy(byteString[:v.VendorLen], buf[b:]) + v.Vendor = string(byteString) + b += xgb.Pad(int(v.VendorLen)) + } + + v.PixmapFormats = make([]Format, v.PixmapFormatsLen) + b += FormatReadList(buf[b:], v.PixmapFormats) + + v.Roots = make([]ScreenInfo, v.RootsLen) + b += ScreenInfoReadList(buf[b:], v.Roots) + + return b +} + +// Struct list read SetupInfo +func SetupInfoReadList(buf []byte, dest []SetupInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = SetupInfo{} + b += SetupInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write SetupInfo +func (v SetupInfo) Bytes() []byte { + buf := make([]byte, (((40 + xgb.Pad((int(v.VendorLen) * 1))) + xgb.Pad((int(v.PixmapFormatsLen) * 8))) + ScreenInfoListSize(v.Roots))) + b := 0 + + buf[b] = v.Status + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], v.ProtocolMajorVersion) + b += 2 + + xgb.Put16(buf[b:], v.ProtocolMinorVersion) + b += 2 + + xgb.Put16(buf[b:], v.Length) + b += 2 + + xgb.Put32(buf[b:], v.ReleaseNumber) + b += 4 + + xgb.Put32(buf[b:], v.ResourceIdBase) + b += 4 + + xgb.Put32(buf[b:], v.ResourceIdMask) + b += 4 + + xgb.Put32(buf[b:], v.MotionBufferSize) + b += 4 + + xgb.Put16(buf[b:], v.VendorLen) + b += 2 + + xgb.Put16(buf[b:], v.MaximumRequestLength) + b += 2 + + buf[b] = v.RootsLen + b += 1 + + buf[b] = v.PixmapFormatsLen + b += 1 + + buf[b] = v.ImageByteOrder + b += 1 + + buf[b] = v.BitmapFormatBitOrder + b += 1 + + buf[b] = v.BitmapFormatScanlineUnit + b += 1 + + buf[b] = v.BitmapFormatScanlinePad + b += 1 + + buf[b] = byte(v.MinKeycode) + b += 1 + + buf[b] = byte(v.MaxKeycode) + b += 1 + + b += 4 // padding + + copy(buf[b:], v.Vendor[:v.VendorLen]) + b += xgb.Pad(int(v.VendorLen)) + + b += FormatListBytes(buf[b:], v.PixmapFormats) + + b += ScreenInfoListBytes(buf[b:], v.Roots) + + return buf +} + +// Write struct list SetupInfo +func SetupInfoListBytes(buf []byte, list []SetupInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size SetupInfo +func SetupInfoListSize(list []SetupInfo) int { + size := 0 + for _, item := range list { + size += (((40 + xgb.Pad((int(item.VendorLen) * 1))) + xgb.Pad((int(item.PixmapFormatsLen) * 8))) + ScreenInfoListSize(item.Roots)) + } + return size +} + +// 'Timecoord' struct definition +// Size: 8 +type Timecoord struct { + Time Timestamp + X int16 + Y int16 +} + +// Struct read Timecoord +func TimecoordRead(buf []byte, v *Timecoord) int { + b := 0 + + v.Time = Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + + return b +} + +// Struct list read Timecoord +func TimecoordReadList(buf []byte, dest []Timecoord) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Timecoord{} + b += TimecoordRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Timecoord +func (v Timecoord) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + xgb.Put16(buf[b:], uint16(v.X)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 + + return buf +} + +// Write struct list Timecoord +func TimecoordListBytes(buf []byte, list []Timecoord) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Fontprop' struct definition +// Size: 8 +type Fontprop struct { + Name Atom + Value uint32 +} + +// Struct read Fontprop +func FontpropRead(buf []byte, v *Fontprop) int { + b := 0 + + v.Name = Atom(xgb.Get32(buf[b:])) + b += 4 + + v.Value = xgb.Get32(buf[b:]) + b += 4 + + return b +} + +// Struct list read Fontprop +func FontpropReadList(buf []byte, dest []Fontprop) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Fontprop{} + b += FontpropRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Fontprop +func (v Fontprop) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Name)) + b += 4 + + xgb.Put32(buf[b:], v.Value) + b += 4 + + return buf +} + +// Write struct list Fontprop +func FontpropListBytes(buf []byte, list []Fontprop) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Charinfo' struct definition +// Size: 12 +type Charinfo struct { + LeftSideBearing int16 + RightSideBearing int16 + CharacterWidth int16 + Ascent int16 + Descent int16 + Attributes uint16 +} + +// Struct read Charinfo +func CharinfoRead(buf []byte, v *Charinfo) int { + b := 0 + + v.LeftSideBearing = int16(xgb.Get16(buf[b:])) + b += 2 + + v.RightSideBearing = int16(xgb.Get16(buf[b:])) + b += 2 + + v.CharacterWidth = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Ascent = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Descent = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Attributes = xgb.Get16(buf[b:]) + b += 2 + + return b +} + +// Struct list read Charinfo +func CharinfoReadList(buf []byte, dest []Charinfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Charinfo{} + b += CharinfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Charinfo +func (v Charinfo) Bytes() []byte { + buf := make([]byte, 12) + b := 0 + + xgb.Put16(buf[b:], uint16(v.LeftSideBearing)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.RightSideBearing)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.CharacterWidth)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Ascent)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Descent)) + b += 2 + + xgb.Put16(buf[b:], v.Attributes) + b += 2 + + return buf +} + +// Write struct list Charinfo +func CharinfoListBytes(buf []byte, list []Charinfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Str' struct definition +// Size: (1 + xgb.Pad((int(NameLen) * 1))) +type Str struct { + NameLen byte + Name string // size: xgb.Pad((int(NameLen) * 1)) +} + +// Struct read Str +func StrRead(buf []byte, v *Str) int { + b := 0 + + v.NameLen = buf[b] + b += 1 + + { + byteString := make([]byte, v.NameLen) + copy(byteString[:v.NameLen], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.NameLen)) + } + + return b +} + +// Struct list read Str +func StrReadList(buf []byte, dest []Str) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Str{} + b += StrRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Str +func (v Str) Bytes() []byte { + buf := make([]byte, (1 + xgb.Pad((int(v.NameLen) * 1)))) + b := 0 + + buf[b] = v.NameLen + b += 1 + + copy(buf[b:], v.Name[:v.NameLen]) + b += xgb.Pad(int(v.NameLen)) + + return buf +} + +// Write struct list Str +func StrListBytes(buf []byte, list []Str) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size Str +func StrListSize(list []Str) int { + size := 0 + for _, item := range list { + size += (1 + xgb.Pad((int(item.NameLen) * 1))) + } + return size +} + +// 'Segment' struct definition +// Size: 8 +type Segment struct { + X1 int16 + Y1 int16 + X2 int16 + Y2 int16 +} + +// Struct read Segment +func SegmentRead(buf []byte, v *Segment) int { + b := 0 + + v.X1 = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y1 = int16(xgb.Get16(buf[b:])) + b += 2 + + v.X2 = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y2 = int16(xgb.Get16(buf[b:])) + b += 2 + + return b +} + +// Struct list read Segment +func SegmentReadList(buf []byte, dest []Segment) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Segment{} + b += SegmentRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Segment +func (v Segment) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put16(buf[b:], uint16(v.X1)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y1)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.X2)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y2)) + b += 2 + + return buf +} + +// Write struct list Segment +func SegmentListBytes(buf []byte, list []Segment) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Coloritem' struct definition +// Size: 12 +type Coloritem struct { + Pixel uint32 + Red uint16 + Green uint16 + Blue uint16 + Flags byte + // padding: 1 bytes +} + +// Struct read Coloritem +func ColoritemRead(buf []byte, v *Coloritem) int { + b := 0 + + v.Pixel = xgb.Get32(buf[b:]) + b += 4 + + v.Red = xgb.Get16(buf[b:]) + b += 2 + + v.Green = xgb.Get16(buf[b:]) + b += 2 + + v.Blue = xgb.Get16(buf[b:]) + b += 2 + + v.Flags = buf[b] + b += 1 + + b += 1 // padding + + return b +} + +// Struct list read Coloritem +func ColoritemReadList(buf []byte, dest []Coloritem) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Coloritem{} + b += ColoritemRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Coloritem +func (v Coloritem) Bytes() []byte { + buf := make([]byte, 12) + b := 0 + + xgb.Put32(buf[b:], v.Pixel) + b += 4 + + xgb.Put16(buf[b:], v.Red) + b += 2 + + xgb.Put16(buf[b:], v.Green) + b += 2 + + xgb.Put16(buf[b:], v.Blue) + b += 2 + + buf[b] = v.Flags + b += 1 + + b += 1 // padding + + return buf +} + +// Write struct list Coloritem +func ColoritemListBytes(buf []byte, list []Coloritem) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Rgb' struct definition +// Size: 8 +type Rgb struct { + Red uint16 + Green uint16 + Blue uint16 + // padding: 2 bytes +} + +// Struct read Rgb +func RgbRead(buf []byte, v *Rgb) int { + b := 0 + + v.Red = xgb.Get16(buf[b:]) + b += 2 + + v.Green = xgb.Get16(buf[b:]) + b += 2 + + v.Blue = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + return b +} + +// Struct list read Rgb +func RgbReadList(buf []byte, dest []Rgb) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Rgb{} + b += RgbRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Rgb +func (v Rgb) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put16(buf[b:], v.Red) + b += 2 + + xgb.Put16(buf[b:], v.Green) + b += 2 + + xgb.Put16(buf[b:], v.Blue) + b += 2 + + b += 2 // padding + + return buf +} + +// Write struct list Rgb +func RgbListBytes(buf []byte, list []Rgb) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Host' struct definition +// Size: (4 + xgb.Pad((int(AddressLen) * 1))) +type Host struct { + Family byte + // padding: 1 bytes + AddressLen uint16 + Address []byte // size: xgb.Pad((int(AddressLen) * 1)) +} + +// Struct read Host +func HostRead(buf []byte, v *Host) int { + b := 0 + + v.Family = buf[b] + b += 1 + + b += 1 // padding + + v.AddressLen = xgb.Get16(buf[b:]) + b += 2 + + v.Address = make([]byte, v.AddressLen) + copy(v.Address[:v.AddressLen], buf[b:]) + b += xgb.Pad(int(v.AddressLen)) + + return b +} + +// Struct list read Host +func HostReadList(buf []byte, dest []Host) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Host{} + b += HostRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Host +func (v Host) Bytes() []byte { + buf := make([]byte, (4 + xgb.Pad((int(v.AddressLen) * 1)))) + b := 0 + + buf[b] = v.Family + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], v.AddressLen) + b += 2 + + copy(buf[b:], v.Address[:v.AddressLen]) + b += xgb.Pad(int(v.AddressLen)) + + return buf +} + +// Write struct list Host +func HostListBytes(buf []byte, list []Host) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size Host +func HostListSize(list []Host) int { + size := 0 + for _, item := range list { + size += (4 + xgb.Pad((int(item.AddressLen) * 1))) + } + return size +} + +// Union definition ClientMessageDataUnion +// Note that to *create* a Union, you should *never* create +// this struct directly (unless you know what you're doing). +// Instead use one of the following constructors for 'ClientMessageDataUnion': +// ClientMessageDataUnionData8New(Data8 []byte) ClientMessageDataUnion +// ClientMessageDataUnionData16New(Data16 []uint16) ClientMessageDataUnion +// ClientMessageDataUnionData32New(Data32 []uint32) ClientMessageDataUnion +type ClientMessageDataUnion struct { + Data8 []byte // size: 20 + Data16 []uint16 // size: 20 + Data32 []uint32 // size: 20 +} + +// Union constructor for ClientMessageDataUnion for field Data8. +func ClientMessageDataUnionData8New(Data8 []byte) ClientMessageDataUnion { + var b int + buf := make([]byte, 20) + + copy(buf[b:], Data8[:20]) + b += xgb.Pad(int(20)) + + // Create the Union type + v := ClientMessageDataUnion{} + + // Now copy buf into all fields + + b = 0 // always read the same bytes + v.Data8 = make([]byte, 20) + copy(v.Data8[:20], buf[b:]) + b += xgb.Pad(int(20)) + + b = 0 // always read the same bytes + v.Data16 = make([]uint16, 10) + for i := 0; i < int(10); i++ { + v.Data16[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) + + b = 0 // always read the same bytes + v.Data32 = make([]uint32, 5) + for i := 0; i < int(5); i++ { + v.Data32[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Union constructor for ClientMessageDataUnion for field Data16. +func ClientMessageDataUnionData16New(Data16 []uint16) ClientMessageDataUnion { + var b int + buf := make([]byte, 20) + + for i := 0; i < int(10); i++ { + xgb.Put16(buf[b:], Data16[i]) + b += 2 + } + b = xgb.Pad(b) + + // Create the Union type + v := ClientMessageDataUnion{} + + // Now copy buf into all fields + + b = 0 // always read the same bytes + v.Data8 = make([]byte, 20) + copy(v.Data8[:20], buf[b:]) + b += xgb.Pad(int(20)) + + b = 0 // always read the same bytes + v.Data16 = make([]uint16, 10) + for i := 0; i < int(10); i++ { + v.Data16[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) + + b = 0 // always read the same bytes + v.Data32 = make([]uint32, 5) + for i := 0; i < int(5); i++ { + v.Data32[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Union constructor for ClientMessageDataUnion for field Data32. +func ClientMessageDataUnionData32New(Data32 []uint32) ClientMessageDataUnion { + var b int + buf := make([]byte, 20) + + for i := 0; i < int(5); i++ { + xgb.Put32(buf[b:], Data32[i]) + b += 4 + } + b = xgb.Pad(b) + + // Create the Union type + v := ClientMessageDataUnion{} + + // Now copy buf into all fields + + b = 0 // always read the same bytes + v.Data8 = make([]byte, 20) + copy(v.Data8[:20], buf[b:]) + b += xgb.Pad(int(20)) + + b = 0 // always read the same bytes + v.Data16 = make([]uint16, 10) + for i := 0; i < int(10); i++ { + v.Data16[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) + + b = 0 // always read the same bytes + v.Data32 = make([]uint32, 5) + for i := 0; i < int(5); i++ { + v.Data32[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Union read ClientMessageDataUnion +func ClientMessageDataUnionRead(buf []byte, v *ClientMessageDataUnion) int { + var b int + + b = 0 // re-read the same bytes + v.Data8 = make([]byte, 20) + copy(v.Data8[:20], buf[b:]) + b += xgb.Pad(int(20)) + + b = 0 // re-read the same bytes + v.Data16 = make([]uint16, 10) + for i := 0; i < int(10); i++ { + v.Data16[i] = xgb.Get16(buf[b:]) + b += 2 + } + b = xgb.Pad(b) + + b = 0 // re-read the same bytes + v.Data32 = make([]uint32, 5) + for i := 0; i < int(5); i++ { + v.Data32[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return 20 +} + +// Union list read ClientMessageDataUnion +func ClientMessageDataUnionReadList(buf []byte, dest []ClientMessageDataUnion) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = ClientMessageDataUnion{} + b += ClientMessageDataUnionRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Union write ClientMessageDataUnion +// Each field in a union must contain the same data. +// So simply pick the first field and write that to the wire. +func (v ClientMessageDataUnion) Bytes() []byte { + buf := make([]byte, 20) + b := 0 + + copy(buf[b:], v.Data8[:20]) + b += xgb.Pad(int(20)) + return buf +} + +// Union list write ClientMessageDataUnion +func ClientMessageDataUnionListBytes(buf []byte, list []ClientMessageDataUnion) int { + b := 0 + var unionBytes []byte + for _, item := range list { + unionBytes = item.Bytes() + copy(buf[b:], unionBytes) + b += xgb.Pad(len(unionBytes)) + } + return b +} + +// Event definition KeyPress (2) +// Size: 32 + +const KeyPress = 2 + +type KeyPressEvent struct { + Sequence uint16 + Detail Keycode + Time Timestamp + Root Window + Event Window + Child Window + RootX int16 + RootY int16 + EventX int16 + EventY int16 + State uint16 + SameScreen bool + // padding: 1 bytes +} + +// Event read KeyPress +func KeyPressEventNew(buf []byte) xgb.Event { + v := KeyPressEvent{} + b := 1 // don't read event number + + v.Detail = Keycode(buf[b]) + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Time = Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Root = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Event = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Child = Window(xgb.Get32(buf[b:])) + b += 4 + + v.RootX = int16(xgb.Get16(buf[b:])) + b += 2 + + v.RootY = int16(xgb.Get16(buf[b:])) + b += 2 + + v.EventX = int16(xgb.Get16(buf[b:])) + b += 2 + + v.EventY = int16(xgb.Get16(buf[b:])) + b += 2 + + v.State = xgb.Get16(buf[b:]) + b += 2 + + if buf[b] == 1 { + v.SameScreen = true + } else { + v.SameScreen = false + } + b += 1 + + b += 1 // padding + + return v +} + +// Event write KeyPress +func (v KeyPressEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 2 + b += 1 + + buf[b] = byte(v.Detail) + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Root)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Child)) + b += 4 + + xgb.Put16(buf[b:], uint16(v.RootX)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.RootY)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.EventX)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.EventY)) + b += 2 + + xgb.Put16(buf[b:], v.State) + b += 2 + + if v.SameScreen { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 1 // padding + + return buf +} + +func (v KeyPressEvent) ImplementsEvent() {} + +func (v KeyPressEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v KeyPressEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) + return "KeyPress {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[2] = KeyPressEventNew +} + +// Event definition ButtonPress (4) +// Size: 32 + +const ButtonPress = 4 + +type ButtonPressEvent struct { + Sequence uint16 + Detail Button + Time Timestamp + Root Window + Event Window + Child Window + RootX int16 + RootY int16 + EventX int16 + EventY int16 + State uint16 + SameScreen bool + // padding: 1 bytes +} + +// Event read ButtonPress +func ButtonPressEventNew(buf []byte) xgb.Event { + v := ButtonPressEvent{} + b := 1 // don't read event number + + v.Detail = Button(buf[b]) + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Time = Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Root = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Event = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Child = Window(xgb.Get32(buf[b:])) + b += 4 + + v.RootX = int16(xgb.Get16(buf[b:])) + b += 2 + + v.RootY = int16(xgb.Get16(buf[b:])) + b += 2 + + v.EventX = int16(xgb.Get16(buf[b:])) + b += 2 + + v.EventY = int16(xgb.Get16(buf[b:])) + b += 2 + + v.State = xgb.Get16(buf[b:]) + b += 2 + + if buf[b] == 1 { + v.SameScreen = true + } else { + v.SameScreen = false + } + b += 1 + + b += 1 // padding + + return v +} + +// Event write ButtonPress +func (v ButtonPressEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 4 + b += 1 + + buf[b] = byte(v.Detail) + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Root)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Child)) + b += 4 + + xgb.Put16(buf[b:], uint16(v.RootX)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.RootY)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.EventX)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.EventY)) + b += 2 + + xgb.Put16(buf[b:], v.State) + b += 2 + + if v.SameScreen { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 1 // padding + + return buf +} + +func (v ButtonPressEvent) ImplementsEvent() {} + +func (v ButtonPressEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v ButtonPressEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) + return "ButtonPress {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[4] = ButtonPressEventNew +} + +// Event definition MotionNotify (6) +// Size: 32 + +const MotionNotify = 6 + +type MotionNotifyEvent struct { + Sequence uint16 + Detail byte + Time Timestamp + Root Window + Event Window + Child Window + RootX int16 + RootY int16 + EventX int16 + EventY int16 + State uint16 + SameScreen bool + // padding: 1 bytes +} + +// Event read MotionNotify +func MotionNotifyEventNew(buf []byte) xgb.Event { + v := MotionNotifyEvent{} + b := 1 // don't read event number + + v.Detail = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Time = Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Root = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Event = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Child = Window(xgb.Get32(buf[b:])) + b += 4 + + v.RootX = int16(xgb.Get16(buf[b:])) + b += 2 + + v.RootY = int16(xgb.Get16(buf[b:])) + b += 2 + + v.EventX = int16(xgb.Get16(buf[b:])) + b += 2 + + v.EventY = int16(xgb.Get16(buf[b:])) + b += 2 + + v.State = xgb.Get16(buf[b:]) + b += 2 + + if buf[b] == 1 { + v.SameScreen = true + } else { + v.SameScreen = false + } + b += 1 + + b += 1 // padding + + return v +} + +// Event write MotionNotify +func (v MotionNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 6 + b += 1 + + buf[b] = v.Detail + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Root)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Child)) + b += 4 + + xgb.Put16(buf[b:], uint16(v.RootX)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.RootY)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.EventX)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.EventY)) + b += 2 + + xgb.Put16(buf[b:], v.State) + b += 2 + + if v.SameScreen { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 1 // padding + + return buf +} + +func (v MotionNotifyEvent) ImplementsEvent() {} + +func (v MotionNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v MotionNotifyEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) + return "MotionNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[6] = MotionNotifyEventNew +} + +// Event definition EnterNotify (7) +// Size: 32 + +const EnterNotify = 7 + +type EnterNotifyEvent struct { + Sequence uint16 + Detail byte + Time Timestamp + Root Window + Event Window + Child Window + RootX int16 + RootY int16 + EventX int16 + EventY int16 + State uint16 + Mode byte + SameScreenFocus byte +} + +// Event read EnterNotify +func EnterNotifyEventNew(buf []byte) xgb.Event { + v := EnterNotifyEvent{} + b := 1 // don't read event number + + v.Detail = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Time = Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Root = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Event = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Child = Window(xgb.Get32(buf[b:])) + b += 4 + + v.RootX = int16(xgb.Get16(buf[b:])) + b += 2 + + v.RootY = int16(xgb.Get16(buf[b:])) + b += 2 + + v.EventX = int16(xgb.Get16(buf[b:])) + b += 2 + + v.EventY = int16(xgb.Get16(buf[b:])) + b += 2 + + v.State = xgb.Get16(buf[b:]) + b += 2 + + v.Mode = buf[b] + b += 1 + + v.SameScreenFocus = buf[b] + b += 1 + + return v +} + +// Event write EnterNotify +func (v EnterNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 7 + b += 1 + + buf[b] = v.Detail + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Root)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Child)) + b += 4 + + xgb.Put16(buf[b:], uint16(v.RootX)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.RootY)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.EventX)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.EventY)) + b += 2 + + xgb.Put16(buf[b:], v.State) + b += 2 + + buf[b] = v.Mode + b += 1 + + buf[b] = v.SameScreenFocus + b += 1 + + return buf +} + +func (v EnterNotifyEvent) ImplementsEvent() {} + +func (v EnterNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v EnterNotifyEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("Mode: %d", v.Mode)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreenFocus: %d", v.SameScreenFocus)) + return "EnterNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[7] = EnterNotifyEventNew +} + +// Event definition FocusIn (9) +// Size: 32 + +const FocusIn = 9 + +type FocusInEvent struct { + Sequence uint16 + Detail byte + Event Window + Mode byte + // padding: 3 bytes +} + +// Event read FocusIn +func FocusInEventNew(buf []byte) xgb.Event { + v := FocusInEvent{} + b := 1 // don't read event number + + v.Detail = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Event = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Mode = buf[b] + b += 1 + + b += 3 // padding + + return v +} + +// Event write FocusIn +func (v FocusInEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 9 + b += 1 + + buf[b] = v.Detail + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 + + buf[b] = v.Mode + b += 1 + + b += 3 // padding + + return buf +} + +func (v FocusInEvent) ImplementsEvent() {} + +func (v FocusInEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v FocusInEvent) String() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Mode: %d", v.Mode)) + return "FocusIn {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[9] = FocusInEventNew +} + +// Event definition KeymapNotify (11) +// Size: 32 + +const KeymapNotify = 11 + +type KeymapNotifyEvent struct { + Keys []byte // size: 32 +} + +// Event read KeymapNotify +func KeymapNotifyEventNew(buf []byte) xgb.Event { + v := KeymapNotifyEvent{} + b := 1 // don't read event number + + v.Keys = make([]byte, 31) + copy(v.Keys[:31], buf[b:]) + b += xgb.Pad(int(31)) + + return v +} + +// Event write KeymapNotify +func (v KeymapNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 11 + b += 1 + + copy(buf[b:], v.Keys[:31]) + b += xgb.Pad(int(31)) + + return buf +} + +func (v KeymapNotifyEvent) ImplementsEvent() {} + +func (v KeymapNotifyEvent) SequenceId() uint16 { + return uint16(0) +} + +func (v KeymapNotifyEvent) String() string { + fieldVals := make([]string, 0, 1) + return "KeymapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[11] = KeymapNotifyEventNew +} + +// Event definition Expose (12) +// Size: 32 + +const Expose = 12 + +type ExposeEvent struct { + Sequence uint16 + // padding: 1 bytes + Window Window + X uint16 + Y uint16 + Width uint16 + Height uint16 + Count uint16 + // padding: 2 bytes +} + +// Event read Expose +func ExposeEventNew(buf []byte) xgb.Event { + v := ExposeEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + v.X = xgb.Get16(buf[b:]) + b += 2 + + v.Y = xgb.Get16(buf[b:]) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.Count = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + return v +} + +// Event write Expose +func (v ExposeEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 12 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + xgb.Put16(buf[b:], v.X) + b += 2 + + xgb.Put16(buf[b:], v.Y) + b += 2 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + xgb.Put16(buf[b:], v.Count) + b += 2 + + b += 2 // padding + + return buf +} + +func (v ExposeEvent) ImplementsEvent() {} + +func (v ExposeEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v ExposeEvent) String() string { + fieldVals := make([]string, 0, 8) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) + fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) + fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) + fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) + fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) + return "Expose {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[12] = ExposeEventNew +} + +// Event definition GraphicsExposure (13) +// Size: 32 + +const GraphicsExposure = 13 + +type GraphicsExposureEvent struct { + Sequence uint16 + // padding: 1 bytes + Drawable Drawable + X uint16 + Y uint16 + Width uint16 + Height uint16 + MinorOpcode uint16 + Count uint16 + MajorOpcode byte + // padding: 3 bytes +} + +// Event read GraphicsExposure +func GraphicsExposureEventNew(buf []byte) xgb.Event { + v := GraphicsExposureEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Drawable = Drawable(xgb.Get32(buf[b:])) + b += 4 + + v.X = xgb.Get16(buf[b:]) + b += 2 + + v.Y = xgb.Get16(buf[b:]) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.MinorOpcode = xgb.Get16(buf[b:]) + b += 2 + + v.Count = xgb.Get16(buf[b:]) + b += 2 + + v.MajorOpcode = buf[b] + b += 1 + + b += 3 // padding + + return v +} + +// Event write GraphicsExposure +func (v GraphicsExposureEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 13 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Drawable)) + b += 4 + + xgb.Put16(buf[b:], v.X) + b += 2 + + xgb.Put16(buf[b:], v.Y) + b += 2 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + xgb.Put16(buf[b:], v.MinorOpcode) + b += 2 + + xgb.Put16(buf[b:], v.Count) + b += 2 + + buf[b] = v.MajorOpcode + b += 1 + + b += 3 // padding + + return buf +} + +func (v GraphicsExposureEvent) ImplementsEvent() {} + +func (v GraphicsExposureEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v GraphicsExposureEvent) String() string { + fieldVals := make([]string, 0, 10) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Drawable: %d", v.Drawable)) + fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) + fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) + fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) + fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", v.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", v.MajorOpcode)) + return "GraphicsExposure {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[13] = GraphicsExposureEventNew +} + +// Event definition NoExposure (14) +// Size: 32 + +const NoExposure = 14 + +type NoExposureEvent struct { + Sequence uint16 + // padding: 1 bytes + Drawable Drawable + MinorOpcode uint16 + MajorOpcode byte + // padding: 1 bytes +} + +// Event read NoExposure +func NoExposureEventNew(buf []byte) xgb.Event { + v := NoExposureEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Drawable = Drawable(xgb.Get32(buf[b:])) + b += 4 + + v.MinorOpcode = xgb.Get16(buf[b:]) + b += 2 + + v.MajorOpcode = buf[b] + b += 1 + + b += 1 // padding + + return v +} + +// Event write NoExposure +func (v NoExposureEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 14 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Drawable)) + b += 4 + + xgb.Put16(buf[b:], v.MinorOpcode) + b += 2 + + buf[b] = v.MajorOpcode + b += 1 + + b += 1 // padding + + return buf +} + +func (v NoExposureEvent) ImplementsEvent() {} + +func (v NoExposureEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v NoExposureEvent) String() string { + fieldVals := make([]string, 0, 5) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Drawable: %d", v.Drawable)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", v.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", v.MajorOpcode)) + return "NoExposure {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[14] = NoExposureEventNew +} + +// Event definition VisibilityNotify (15) +// Size: 32 + +const VisibilityNotify = 15 + +type VisibilityNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Window Window + State byte + // padding: 3 bytes +} + +// Event read VisibilityNotify +func VisibilityNotifyEventNew(buf []byte) xgb.Event { + v := VisibilityNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + v.State = buf[b] + b += 1 + + b += 3 // padding + + return v +} + +// Event write VisibilityNotify +func (v VisibilityNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 15 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + buf[b] = v.State + b += 1 + + b += 3 // padding + + return buf +} + +func (v VisibilityNotifyEvent) ImplementsEvent() {} + +func (v VisibilityNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v VisibilityNotifyEvent) String() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + return "VisibilityNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[15] = VisibilityNotifyEventNew +} + +// Event definition CreateNotify (16) +// Size: 32 + +const CreateNotify = 16 + +type CreateNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Parent Window + Window Window + X int16 + Y int16 + Width uint16 + Height uint16 + BorderWidth uint16 + OverrideRedirect bool + // padding: 1 bytes +} + +// Event read CreateNotify +func CreateNotifyEventNew(buf []byte) xgb.Event { + v := CreateNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Parent = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.BorderWidth = xgb.Get16(buf[b:]) + b += 2 + + if buf[b] == 1 { + v.OverrideRedirect = true + } else { + v.OverrideRedirect = false + } + b += 1 + + b += 1 // padding + + return v +} + +// Event write CreateNotify +func (v CreateNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 16 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Parent)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + xgb.Put16(buf[b:], uint16(v.X)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + xgb.Put16(buf[b:], v.BorderWidth) + b += 2 + + if v.OverrideRedirect { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 1 // padding + + return buf +} + +func (v CreateNotifyEvent) ImplementsEvent() {} + +func (v CreateNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v CreateNotifyEvent) String() string { + fieldVals := make([]string, 0, 10) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Parent: %d", v.Parent)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) + fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) + fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) + fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) + fieldVals = append(fieldVals, xgb.Sprintf("BorderWidth: %d", v.BorderWidth)) + fieldVals = append(fieldVals, xgb.Sprintf("OverrideRedirect: %t", v.OverrideRedirect)) + return "CreateNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[16] = CreateNotifyEventNew +} + +// Event definition DestroyNotify (17) +// Size: 32 + +const DestroyNotify = 17 + +type DestroyNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Event Window + Window Window +} + +// Event read DestroyNotify +func DestroyNotifyEventNew(buf []byte) xgb.Event { + v := DestroyNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Event = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Event write DestroyNotify +func (v DestroyNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 17 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + return buf +} + +func (v DestroyNotifyEvent) ImplementsEvent() {} + +func (v DestroyNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v DestroyNotifyEvent) String() string { + fieldVals := make([]string, 0, 3) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + return "DestroyNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[17] = DestroyNotifyEventNew +} + +// Event definition UnmapNotify (18) +// Size: 32 + +const UnmapNotify = 18 + +type UnmapNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Event Window + Window Window + FromConfigure bool + // padding: 3 bytes +} + +// Event read UnmapNotify +func UnmapNotifyEventNew(buf []byte) xgb.Event { + v := UnmapNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Event = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + if buf[b] == 1 { + v.FromConfigure = true + } else { + v.FromConfigure = false + } + b += 1 + + b += 3 // padding + + return v +} + +// Event write UnmapNotify +func (v UnmapNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 18 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + if v.FromConfigure { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding + + return buf +} + +func (v UnmapNotifyEvent) ImplementsEvent() {} + +func (v UnmapNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v UnmapNotifyEvent) String() string { + fieldVals := make([]string, 0, 5) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("FromConfigure: %t", v.FromConfigure)) + return "UnmapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[18] = UnmapNotifyEventNew +} + +// Event definition MapNotify (19) +// Size: 32 + +const MapNotify = 19 + +type MapNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Event Window + Window Window + OverrideRedirect bool + // padding: 3 bytes +} + +// Event read MapNotify +func MapNotifyEventNew(buf []byte) xgb.Event { + v := MapNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Event = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + if buf[b] == 1 { + v.OverrideRedirect = true + } else { + v.OverrideRedirect = false + } + b += 1 + + b += 3 // padding + + return v +} + +// Event write MapNotify +func (v MapNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 19 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + if v.OverrideRedirect { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding + + return buf +} + +func (v MapNotifyEvent) ImplementsEvent() {} + +func (v MapNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v MapNotifyEvent) String() string { + fieldVals := make([]string, 0, 5) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("OverrideRedirect: %t", v.OverrideRedirect)) + return "MapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[19] = MapNotifyEventNew +} + +// Event definition MapRequest (20) +// Size: 32 + +const MapRequest = 20 + +type MapRequestEvent struct { + Sequence uint16 + // padding: 1 bytes + Parent Window + Window Window +} + +// Event read MapRequest +func MapRequestEventNew(buf []byte) xgb.Event { + v := MapRequestEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Parent = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Event write MapRequest +func (v MapRequestEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 20 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Parent)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + return buf +} + +func (v MapRequestEvent) ImplementsEvent() {} + +func (v MapRequestEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v MapRequestEvent) String() string { + fieldVals := make([]string, 0, 3) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Parent: %d", v.Parent)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + return "MapRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[20] = MapRequestEventNew +} + +// Event definition ReparentNotify (21) +// Size: 32 + +const ReparentNotify = 21 + +type ReparentNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Event Window + Window Window + Parent Window + X int16 + Y int16 + OverrideRedirect bool + // padding: 3 bytes +} + +// Event read ReparentNotify +func ReparentNotifyEventNew(buf []byte) xgb.Event { + v := ReparentNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Event = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Parent = Window(xgb.Get32(buf[b:])) + b += 4 + + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + + if buf[b] == 1 { + v.OverrideRedirect = true + } else { + v.OverrideRedirect = false + } + b += 1 + + b += 3 // padding + + return v +} + +// Event write ReparentNotify +func (v ReparentNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 21 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Parent)) + b += 4 + + xgb.Put16(buf[b:], uint16(v.X)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 + + if v.OverrideRedirect { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding + + return buf +} + +func (v ReparentNotifyEvent) ImplementsEvent() {} + +func (v ReparentNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v ReparentNotifyEvent) String() string { + fieldVals := make([]string, 0, 8) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("Parent: %d", v.Parent)) + fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) + fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) + fieldVals = append(fieldVals, xgb.Sprintf("OverrideRedirect: %t", v.OverrideRedirect)) + return "ReparentNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[21] = ReparentNotifyEventNew +} + +// Event definition ConfigureNotify (22) +// Size: 32 + +const ConfigureNotify = 22 + +type ConfigureNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Event Window + Window Window + AboveSibling Window + X int16 + Y int16 + Width uint16 + Height uint16 + BorderWidth uint16 + OverrideRedirect bool + // padding: 1 bytes +} + +// Event read ConfigureNotify +func ConfigureNotifyEventNew(buf []byte) xgb.Event { + v := ConfigureNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Event = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + v.AboveSibling = Window(xgb.Get32(buf[b:])) + b += 4 + + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.BorderWidth = xgb.Get16(buf[b:]) + b += 2 + + if buf[b] == 1 { + v.OverrideRedirect = true + } else { + v.OverrideRedirect = false + } + b += 1 + + b += 1 // padding + + return v +} + +// Event write ConfigureNotify +func (v ConfigureNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 22 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.AboveSibling)) + b += 4 + + xgb.Put16(buf[b:], uint16(v.X)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + xgb.Put16(buf[b:], v.BorderWidth) + b += 2 + + if v.OverrideRedirect { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 1 // padding + + return buf +} + +func (v ConfigureNotifyEvent) ImplementsEvent() {} + +func (v ConfigureNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v ConfigureNotifyEvent) String() string { + fieldVals := make([]string, 0, 11) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("AboveSibling: %d", v.AboveSibling)) + fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) + fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) + fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) + fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) + fieldVals = append(fieldVals, xgb.Sprintf("BorderWidth: %d", v.BorderWidth)) + fieldVals = append(fieldVals, xgb.Sprintf("OverrideRedirect: %t", v.OverrideRedirect)) + return "ConfigureNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[22] = ConfigureNotifyEventNew +} + +// Event definition ConfigureRequest (23) +// Size: 32 + +const ConfigureRequest = 23 + +type ConfigureRequestEvent struct { + Sequence uint16 + StackMode byte + Parent Window + Window Window + Sibling Window + X int16 + Y int16 + Width uint16 + Height uint16 + BorderWidth uint16 + ValueMask uint16 +} + +// Event read ConfigureRequest +func ConfigureRequestEventNew(buf []byte) xgb.Event { + v := ConfigureRequestEvent{} + b := 1 // don't read event number + + v.StackMode = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Parent = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Sibling = Window(xgb.Get32(buf[b:])) + b += 4 + + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.BorderWidth = xgb.Get16(buf[b:]) + b += 2 + + v.ValueMask = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Event write ConfigureRequest +func (v ConfigureRequestEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 23 + b += 1 + + buf[b] = v.StackMode + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Parent)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Sibling)) + b += 4 + + xgb.Put16(buf[b:], uint16(v.X)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + xgb.Put16(buf[b:], v.BorderWidth) + b += 2 + + xgb.Put16(buf[b:], v.ValueMask) + b += 2 + + return buf +} + +func (v ConfigureRequestEvent) ImplementsEvent() {} + +func (v ConfigureRequestEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v ConfigureRequestEvent) String() string { + fieldVals := make([]string, 0, 10) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("StackMode: %d", v.StackMode)) + fieldVals = append(fieldVals, xgb.Sprintf("Parent: %d", v.Parent)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("Sibling: %d", v.Sibling)) + fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) + fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) + fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) + fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) + fieldVals = append(fieldVals, xgb.Sprintf("BorderWidth: %d", v.BorderWidth)) + fieldVals = append(fieldVals, xgb.Sprintf("ValueMask: %d", v.ValueMask)) + return "ConfigureRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[23] = ConfigureRequestEventNew +} + +// Event definition GravityNotify (24) +// Size: 32 + +const GravityNotify = 24 + +type GravityNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Event Window + Window Window + X int16 + Y int16 +} + +// Event read GravityNotify +func GravityNotifyEventNew(buf []byte) xgb.Event { + v := GravityNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Event = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + + return v +} + +// Event write GravityNotify +func (v GravityNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 24 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + xgb.Put16(buf[b:], uint16(v.X)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y)) + b += 2 + + return buf +} + +func (v GravityNotifyEvent) ImplementsEvent() {} + +func (v GravityNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v GravityNotifyEvent) String() string { + fieldVals := make([]string, 0, 5) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("X: %d", v.X)) + fieldVals = append(fieldVals, xgb.Sprintf("Y: %d", v.Y)) + return "GravityNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[24] = GravityNotifyEventNew +} + +// Event definition ResizeRequest (25) +// Size: 32 + +const ResizeRequest = 25 + +type ResizeRequestEvent struct { + Sequence uint16 + // padding: 1 bytes + Window Window + Width uint16 + Height uint16 +} + +// Event read ResizeRequest +func ResizeRequestEventNew(buf []byte) xgb.Event { + v := ResizeRequestEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Event write ResizeRequest +func (v ResizeRequestEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 25 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + return buf +} + +func (v ResizeRequestEvent) ImplementsEvent() {} + +func (v ResizeRequestEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v ResizeRequestEvent) String() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width)) + fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height)) + return "ResizeRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[25] = ResizeRequestEventNew +} + +// Event definition CirculateNotify (26) +// Size: 32 + +const CirculateNotify = 26 + +type CirculateNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Event Window + Window Window + // padding: 4 bytes + Place byte + // padding: 3 bytes +} + +// Event read CirculateNotify +func CirculateNotifyEventNew(buf []byte) xgb.Event { + v := CirculateNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Event = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + b += 4 // padding + + v.Place = buf[b] + b += 1 + + b += 3 // padding + + return v +} + +// Event write CirculateNotify +func (v CirculateNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 26 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Event)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + b += 4 // padding + + buf[b] = v.Place + b += 1 + + b += 3 // padding + + return buf +} + +func (v CirculateNotifyEvent) ImplementsEvent() {} + +func (v CirculateNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v CirculateNotifyEvent) String() string { + fieldVals := make([]string, 0, 6) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("Place: %d", v.Place)) + return "CirculateNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[26] = CirculateNotifyEventNew +} + +// Event definition PropertyNotify (28) +// Size: 32 + +const PropertyNotify = 28 + +type PropertyNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Window Window + Atom Atom + Time Timestamp + State byte + // padding: 3 bytes +} + +// Event read PropertyNotify +func PropertyNotifyEventNew(buf []byte) xgb.Event { + v := PropertyNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Atom = Atom(xgb.Get32(buf[b:])) + b += 4 + + v.Time = Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.State = buf[b] + b += 1 + + b += 3 // padding + + return v +} + +// Event write PropertyNotify +func (v PropertyNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 28 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Atom)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + buf[b] = v.State + b += 1 + + b += 3 // padding + + return buf +} + +func (v PropertyNotifyEvent) ImplementsEvent() {} + +func (v PropertyNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v PropertyNotifyEvent) String() string { + fieldVals := make([]string, 0, 6) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("Atom: %d", v.Atom)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + return "PropertyNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[28] = PropertyNotifyEventNew +} + +// Event definition SelectionClear (29) +// Size: 32 + +const SelectionClear = 29 + +type SelectionClearEvent struct { + Sequence uint16 + // padding: 1 bytes + Time Timestamp + Owner Window + Selection Atom +} + +// Event read SelectionClear +func SelectionClearEventNew(buf []byte) xgb.Event { + v := SelectionClearEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Time = Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Owner = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Selection = Atom(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Event write SelectionClear +func (v SelectionClearEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 29 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Owner)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Selection)) + b += 4 + + return buf +} + +func (v SelectionClearEvent) ImplementsEvent() {} + +func (v SelectionClearEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v SelectionClearEvent) String() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Owner: %d", v.Owner)) + fieldVals = append(fieldVals, xgb.Sprintf("Selection: %d", v.Selection)) + return "SelectionClear {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[29] = SelectionClearEventNew +} + +// Event definition SelectionRequest (30) +// Size: 32 + +const SelectionRequest = 30 + +type SelectionRequestEvent struct { + Sequence uint16 + // padding: 1 bytes + Time Timestamp + Owner Window + Requestor Window + Selection Atom + Target Atom + Property Atom +} + +// Event read SelectionRequest +func SelectionRequestEventNew(buf []byte) xgb.Event { + v := SelectionRequestEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Time = Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Owner = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Requestor = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Selection = Atom(xgb.Get32(buf[b:])) + b += 4 + + v.Target = Atom(xgb.Get32(buf[b:])) + b += 4 + + v.Property = Atom(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Event write SelectionRequest +func (v SelectionRequestEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 30 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Owner)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Requestor)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Selection)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Target)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Property)) + b += 4 + + return buf +} + +func (v SelectionRequestEvent) ImplementsEvent() {} + +func (v SelectionRequestEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v SelectionRequestEvent) String() string { + fieldVals := make([]string, 0, 7) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Owner: %d", v.Owner)) + fieldVals = append(fieldVals, xgb.Sprintf("Requestor: %d", v.Requestor)) + fieldVals = append(fieldVals, xgb.Sprintf("Selection: %d", v.Selection)) + fieldVals = append(fieldVals, xgb.Sprintf("Target: %d", v.Target)) + fieldVals = append(fieldVals, xgb.Sprintf("Property: %d", v.Property)) + return "SelectionRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[30] = SelectionRequestEventNew +} + +// Event definition SelectionNotify (31) +// Size: 32 + +const SelectionNotify = 31 + +type SelectionNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Time Timestamp + Requestor Window + Selection Atom + Target Atom + Property Atom +} + +// Event read SelectionNotify +func SelectionNotifyEventNew(buf []byte) xgb.Event { + v := SelectionNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Time = Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Requestor = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Selection = Atom(xgb.Get32(buf[b:])) + b += 4 + + v.Target = Atom(xgb.Get32(buf[b:])) + b += 4 + + v.Property = Atom(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Event write SelectionNotify +func (v SelectionNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 31 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Requestor)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Selection)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Target)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Property)) + b += 4 + + return buf +} + +func (v SelectionNotifyEvent) ImplementsEvent() {} + +func (v SelectionNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v SelectionNotifyEvent) String() string { + fieldVals := make([]string, 0, 6) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Requestor: %d", v.Requestor)) + fieldVals = append(fieldVals, xgb.Sprintf("Selection: %d", v.Selection)) + fieldVals = append(fieldVals, xgb.Sprintf("Target: %d", v.Target)) + fieldVals = append(fieldVals, xgb.Sprintf("Property: %d", v.Property)) + return "SelectionNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[31] = SelectionNotifyEventNew +} + +// Event definition ColormapNotify (32) +// Size: 32 + +const ColormapNotify = 32 + +type ColormapNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Window Window + Colormap Colormap + New bool + State byte + // padding: 2 bytes +} + +// Event read ColormapNotify +func ColormapNotifyEventNew(buf []byte) xgb.Event { + v := ColormapNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Colormap = Colormap(xgb.Get32(buf[b:])) + b += 4 + + if buf[b] == 1 { + v.New = true + } else { + v.New = false + } + b += 1 + + v.State = buf[b] + b += 1 + + b += 2 // padding + + return v +} + +// Event write ColormapNotify +func (v ColormapNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 32 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Colormap)) + b += 4 + + if v.New { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + buf[b] = v.State + b += 1 + + b += 2 // padding + + return buf +} + +func (v ColormapNotifyEvent) ImplementsEvent() {} + +func (v ColormapNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v ColormapNotifyEvent) String() string { + fieldVals := make([]string, 0, 6) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("Colormap: %d", v.Colormap)) + fieldVals = append(fieldVals, xgb.Sprintf("New: %t", v.New)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + return "ColormapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[32] = ColormapNotifyEventNew +} + +// Event definition ClientMessage (33) +// Size: 32 + +const ClientMessage = 33 + +type ClientMessageEvent struct { + Sequence uint16 + Format byte + Window Window + Type Atom + Data ClientMessageDataUnion +} + +// Event read ClientMessage +func ClientMessageEventNew(buf []byte) xgb.Event { + v := ClientMessageEvent{} + b := 1 // don't read event number + + v.Format = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Window = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Type = Atom(xgb.Get32(buf[b:])) + b += 4 + + v.Data = ClientMessageDataUnion{} + b += ClientMessageDataUnionRead(buf[b:], &v.Data) + + return v +} + +// Event write ClientMessage +func (v ClientMessageEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 33 + b += 1 + + buf[b] = v.Format + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Type)) + b += 4 + + { + unionBytes := v.Data.Bytes() + copy(buf[b:], unionBytes) + b += xgb.Pad(len(unionBytes)) + } + + return buf +} + +func (v ClientMessageEvent) ImplementsEvent() {} + +func (v ClientMessageEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v ClientMessageEvent) String() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Format: %d", v.Format)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("Type: %d", v.Type)) + return "ClientMessage {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[33] = ClientMessageEventNew +} + +// Event definition MappingNotify (34) +// Size: 32 + +const MappingNotify = 34 + +type MappingNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Request byte + FirstKeycode Keycode + Count byte + // padding: 1 bytes +} + +// Event read MappingNotify +func MappingNotifyEventNew(buf []byte) xgb.Event { + v := MappingNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Request = buf[b] + b += 1 + + v.FirstKeycode = Keycode(buf[b]) + b += 1 + + v.Count = buf[b] + b += 1 + + b += 1 // padding + + return v +} + +// Event write MappingNotify +func (v MappingNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 34 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + buf[b] = v.Request + b += 1 + + buf[b] = byte(v.FirstKeycode) + b += 1 + + buf[b] = v.Count + b += 1 + + b += 1 // padding + + return buf +} + +func (v MappingNotifyEvent) ImplementsEvent() {} + +func (v MappingNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v MappingNotifyEvent) String() string { + fieldVals := make([]string, 0, 5) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Request: %d", v.Request)) + fieldVals = append(fieldVals, xgb.Sprintf("FirstKeycode: %d", v.FirstKeycode)) + fieldVals = append(fieldVals, xgb.Sprintf("Count: %d", v.Count)) + return "MappingNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[34] = MappingNotifyEventNew +} + +// EventCopy definition KeyRelease (3) + +const KeyRelease = 3 + +type KeyReleaseEvent KeyPressEvent + +func KeyReleaseEventNew(buf []byte) xgb.Event { + return KeyReleaseEvent(KeyPressEventNew(buf).(KeyPressEvent)) +} + +func (v KeyReleaseEvent) Bytes() []byte { + return KeyPressEvent(v).Bytes() +} + +func (v KeyReleaseEvent) ImplementsEvent() {} + +func (v KeyReleaseEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v KeyReleaseEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) + return "KeyRelease {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[3] = KeyReleaseEventNew +} + +// EventCopy definition ButtonRelease (5) + +const ButtonRelease = 5 + +type ButtonReleaseEvent ButtonPressEvent + +func ButtonReleaseEventNew(buf []byte) xgb.Event { + return ButtonReleaseEvent(ButtonPressEventNew(buf).(ButtonPressEvent)) +} + +func (v ButtonReleaseEvent) Bytes() []byte { + return ButtonPressEvent(v).Bytes() +} + +func (v ButtonReleaseEvent) ImplementsEvent() {} + +func (v ButtonReleaseEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v ButtonReleaseEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreen: %t", v.SameScreen)) + return "ButtonRelease {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[5] = ButtonReleaseEventNew +} + +// EventCopy definition LeaveNotify (8) + +const LeaveNotify = 8 + +type LeaveNotifyEvent EnterNotifyEvent + +func LeaveNotifyEventNew(buf []byte) xgb.Event { + return LeaveNotifyEvent(EnterNotifyEventNew(buf).(EnterNotifyEvent)) +} + +func (v LeaveNotifyEvent) Bytes() []byte { + return EnterNotifyEvent(v).Bytes() +} + +func (v LeaveNotifyEvent) ImplementsEvent() {} + +func (v LeaveNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v LeaveNotifyEvent) String() string { + fieldVals := make([]string, 0, 12) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Child: %d", v.Child)) + fieldVals = append(fieldVals, xgb.Sprintf("RootX: %d", v.RootX)) + fieldVals = append(fieldVals, xgb.Sprintf("RootY: %d", v.RootY)) + fieldVals = append(fieldVals, xgb.Sprintf("EventX: %d", v.EventX)) + fieldVals = append(fieldVals, xgb.Sprintf("EventY: %d", v.EventY)) + fieldVals = append(fieldVals, xgb.Sprintf("State: %d", v.State)) + fieldVals = append(fieldVals, xgb.Sprintf("Mode: %d", v.Mode)) + fieldVals = append(fieldVals, xgb.Sprintf("SameScreenFocus: %d", v.SameScreenFocus)) + return "LeaveNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[8] = LeaveNotifyEventNew +} + +// EventCopy definition FocusOut (10) + +const FocusOut = 10 + +type FocusOutEvent FocusInEvent + +func FocusOutEventNew(buf []byte) xgb.Event { + return FocusOutEvent(FocusInEventNew(buf).(FocusInEvent)) +} + +func (v FocusOutEvent) Bytes() []byte { + return FocusInEvent(v).Bytes() +} + +func (v FocusOutEvent) ImplementsEvent() {} + +func (v FocusOutEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v FocusOutEvent) String() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Detail: %d", v.Detail)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Mode: %d", v.Mode)) + return "FocusOut {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[10] = FocusOutEventNew +} + +// EventCopy definition CirculateRequest (27) + +const CirculateRequest = 27 + +type CirculateRequestEvent CirculateNotifyEvent + +func CirculateRequestEventNew(buf []byte) xgb.Event { + return CirculateRequestEvent(CirculateNotifyEventNew(buf).(CirculateNotifyEvent)) +} + +func (v CirculateRequestEvent) Bytes() []byte { + return CirculateNotifyEvent(v).Bytes() +} + +func (v CirculateRequestEvent) ImplementsEvent() {} + +func (v CirculateRequestEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v CirculateRequestEvent) String() string { + fieldVals := make([]string, 0, 6) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Event: %d", v.Event)) + fieldVals = append(fieldVals, xgb.Sprintf("Window: %d", v.Window)) + fieldVals = append(fieldVals, xgb.Sprintf("Place: %d", v.Place)) + return "CirculateRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewEventFuncs[27] = CirculateRequestEventNew +} + +// Error definition Request (1) +// Size: 32 + +const BadRequest = 1 + +type RequestError struct { + Sequence uint16 + NiceName string + BadValue uint32 + MinorOpcode uint16 + MajorOpcode byte + // padding: 1 bytes +} + +// Error read Request +func RequestErrorNew(buf []byte) xgb.Error { + v := RequestError{} + v.NiceName = "Request" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.BadValue = xgb.Get32(buf[b:]) + b += 4 + + v.MinorOpcode = xgb.Get16(buf[b:]) + b += 2 + + v.MajorOpcode = buf[b] + b += 1 + + b += 1 // padding + + return v +} + +func (err RequestError) ImplementsError() {} + +func (err RequestError) SequenceId() uint16 { + return err.Sequence +} + +func (err RequestError) BadId() uint32 { + return err.BadValue +} + +func (err RequestError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadRequest {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[1] = RequestErrorNew +} + +// Error definition Value (2) +// Size: 32 + +const BadValue = 2 + +type ValueError struct { + Sequence uint16 + NiceName string + BadValue uint32 + MinorOpcode uint16 + MajorOpcode byte + // padding: 1 bytes +} + +// Error read Value +func ValueErrorNew(buf []byte) xgb.Error { + v := ValueError{} + v.NiceName = "Value" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.BadValue = xgb.Get32(buf[b:]) + b += 4 + + v.MinorOpcode = xgb.Get16(buf[b:]) + b += 2 + + v.MajorOpcode = buf[b] + b += 1 + + b += 1 // padding + + return v +} + +func (err ValueError) ImplementsError() {} + +func (err ValueError) SequenceId() uint16 { + return err.Sequence +} + +func (err ValueError) BadId() uint32 { + return err.BadValue +} + +func (err ValueError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadValue {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[2] = ValueErrorNew +} + +// ErrorCopy definition Window (3) + +const BadWindow = 3 + +type WindowError ValueError + +func WindowErrorNew(buf []byte) xgb.Error { + v := WindowError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "Window" + return v +} + +func (err WindowError) ImplementsError() {} + +func (err WindowError) SequenceId() uint16 { + return err.Sequence +} + +func (err WindowError) BadId() uint32 { + return err.BadValue +} + +func (err WindowError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadWindow {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[3] = WindowErrorNew +} + +// ErrorCopy definition Pixmap (4) + +const BadPixmap = 4 + +type PixmapError ValueError + +func PixmapErrorNew(buf []byte) xgb.Error { + v := PixmapError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "Pixmap" + return v +} + +func (err PixmapError) ImplementsError() {} + +func (err PixmapError) SequenceId() uint16 { + return err.Sequence +} + +func (err PixmapError) BadId() uint32 { + return err.BadValue +} + +func (err PixmapError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadPixmap {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[4] = PixmapErrorNew +} + +// ErrorCopy definition Atom (5) + +const BadAtom = 5 + +type AtomError ValueError + +func AtomErrorNew(buf []byte) xgb.Error { + v := AtomError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "Atom" + return v +} + +func (err AtomError) ImplementsError() {} + +func (err AtomError) SequenceId() uint16 { + return err.Sequence +} + +func (err AtomError) BadId() uint32 { + return err.BadValue +} + +func (err AtomError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadAtom {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[5] = AtomErrorNew +} + +// ErrorCopy definition Cursor (6) + +const BadCursor = 6 + +type CursorError ValueError + +func CursorErrorNew(buf []byte) xgb.Error { + v := CursorError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "Cursor" + return v +} + +func (err CursorError) ImplementsError() {} + +func (err CursorError) SequenceId() uint16 { + return err.Sequence +} + +func (err CursorError) BadId() uint32 { + return err.BadValue +} + +func (err CursorError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadCursor {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[6] = CursorErrorNew +} + +// ErrorCopy definition Font (7) + +const BadFont = 7 + +type FontError ValueError + +func FontErrorNew(buf []byte) xgb.Error { + v := FontError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "Font" + return v +} + +func (err FontError) ImplementsError() {} + +func (err FontError) SequenceId() uint16 { + return err.Sequence +} + +func (err FontError) BadId() uint32 { + return err.BadValue +} + +func (err FontError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadFont {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[7] = FontErrorNew +} + +// ErrorCopy definition Match (8) + +const BadMatch = 8 + +type MatchError RequestError + +func MatchErrorNew(buf []byte) xgb.Error { + v := MatchError(RequestErrorNew(buf).(RequestError)) + v.NiceName = "Match" + return v +} + +func (err MatchError) ImplementsError() {} + +func (err MatchError) SequenceId() uint16 { + return err.Sequence +} + +func (err MatchError) BadId() uint32 { + return err.BadValue +} + +func (err MatchError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadMatch {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[8] = MatchErrorNew +} + +// ErrorCopy definition Drawable (9) + +const BadDrawable = 9 + +type DrawableError ValueError + +func DrawableErrorNew(buf []byte) xgb.Error { + v := DrawableError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "Drawable" + return v +} + +func (err DrawableError) ImplementsError() {} + +func (err DrawableError) SequenceId() uint16 { + return err.Sequence +} + +func (err DrawableError) BadId() uint32 { + return err.BadValue +} + +func (err DrawableError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadDrawable {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[9] = DrawableErrorNew +} + +// ErrorCopy definition Access (10) + +const BadAccess = 10 + +type AccessError RequestError + +func AccessErrorNew(buf []byte) xgb.Error { + v := AccessError(RequestErrorNew(buf).(RequestError)) + v.NiceName = "Access" + return v +} + +func (err AccessError) ImplementsError() {} + +func (err AccessError) SequenceId() uint16 { + return err.Sequence +} + +func (err AccessError) BadId() uint32 { + return err.BadValue +} + +func (err AccessError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadAccess {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[10] = AccessErrorNew +} + +// ErrorCopy definition Alloc (11) + +const BadAlloc = 11 + +type AllocError RequestError + +func AllocErrorNew(buf []byte) xgb.Error { + v := AllocError(RequestErrorNew(buf).(RequestError)) + v.NiceName = "Alloc" + return v +} + +func (err AllocError) ImplementsError() {} + +func (err AllocError) SequenceId() uint16 { + return err.Sequence +} + +func (err AllocError) BadId() uint32 { + return err.BadValue +} + +func (err AllocError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadAlloc {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[11] = AllocErrorNew +} + +// ErrorCopy definition Colormap (12) + +const BadColormap = 12 + +type ColormapError ValueError + +func ColormapErrorNew(buf []byte) xgb.Error { + v := ColormapError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "Colormap" + return v +} + +func (err ColormapError) ImplementsError() {} + +func (err ColormapError) SequenceId() uint16 { + return err.Sequence +} + +func (err ColormapError) BadId() uint32 { + return err.BadValue +} + +func (err ColormapError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadColormap {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[12] = ColormapErrorNew +} + +// ErrorCopy definition GContext (13) + +const BadGContext = 13 + +type GContextError ValueError + +func GContextErrorNew(buf []byte) xgb.Error { + v := GContextError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "GContext" + return v +} + +func (err GContextError) ImplementsError() {} + +func (err GContextError) SequenceId() uint16 { + return err.Sequence +} + +func (err GContextError) BadId() uint32 { + return err.BadValue +} + +func (err GContextError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadGContext {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[13] = GContextErrorNew +} + +// ErrorCopy definition IDChoice (14) + +const BadIDChoice = 14 + +type IDChoiceError ValueError + +func IDChoiceErrorNew(buf []byte) xgb.Error { + v := IDChoiceError(ValueErrorNew(buf).(ValueError)) + v.NiceName = "IDChoice" + return v +} + +func (err IDChoiceError) ImplementsError() {} + +func (err IDChoiceError) SequenceId() uint16 { + return err.Sequence +} + +func (err IDChoiceError) BadId() uint32 { + return err.BadValue +} + +func (err IDChoiceError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadIDChoice {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[14] = IDChoiceErrorNew +} + +// ErrorCopy definition Name (15) + +const BadName = 15 + +type NameError RequestError + +func NameErrorNew(buf []byte) xgb.Error { + v := NameError(RequestErrorNew(buf).(RequestError)) + v.NiceName = "Name" + return v +} + +func (err NameError) ImplementsError() {} + +func (err NameError) SequenceId() uint16 { + return err.Sequence +} + +func (err NameError) BadId() uint32 { + return err.BadValue +} + +func (err NameError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadName {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[15] = NameErrorNew +} + +// ErrorCopy definition Length (16) + +const BadLength = 16 + +type LengthError RequestError + +func LengthErrorNew(buf []byte) xgb.Error { + v := LengthError(RequestErrorNew(buf).(RequestError)) + v.NiceName = "Length" + return v +} + +func (err LengthError) ImplementsError() {} + +func (err LengthError) SequenceId() uint16 { + return err.Sequence +} + +func (err LengthError) BadId() uint32 { + return err.BadValue +} + +func (err LengthError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadLength {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[16] = LengthErrorNew +} + +// ErrorCopy definition Implementation (17) + +const BadImplementation = 17 + +type ImplementationError RequestError + +func ImplementationErrorNew(buf []byte) xgb.Error { + v := ImplementationError(RequestErrorNew(buf).(RequestError)) + v.NiceName = "Implementation" + return v +} + +func (err ImplementationError) ImplementsError() {} + +func (err ImplementationError) SequenceId() uint16 { + return err.Sequence +} + +func (err ImplementationError) BadId() uint32 { + return err.BadValue +} + +func (err ImplementationError) Error() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("BadValue: %d", err.BadValue)) + fieldVals = append(fieldVals, xgb.Sprintf("MinorOpcode: %d", err.MinorOpcode)) + fieldVals = append(fieldVals, xgb.Sprintf("MajorOpcode: %d", err.MajorOpcode)) + return "BadImplementation {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewErrorFuncs[17] = ImplementationErrorNew +} + +// Request CreateWindow +// size: xgb.Pad((28 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +type CreateWindowCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateWindow +func CreateWindow(c *xgb.Conn, Depth byte, Wid Window, Parent Window, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class uint16, Visual Visualid, ValueMask uint32, ValueList []uint32) CreateWindowCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createWindowRequest(c, Depth, Wid, Parent, X, Y, Width, Height, BorderWidth, Class, Visual, ValueMask, ValueList), cookie) + return CreateWindowCookie{cookie} +} + +func CreateWindowChecked(c *xgb.Conn, Depth byte, Wid Window, Parent Window, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class uint16, Visual Visualid, ValueMask uint32, ValueList []uint32) CreateWindowCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createWindowRequest(c, Depth, Wid, Parent, X, Y, Width, Height, BorderWidth, Class, Visual, ValueMask, ValueList), cookie) + return CreateWindowCookie{cookie} +} + +func (cook CreateWindowCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateWindow +func createWindowRequest(c *xgb.Conn, Depth byte, Wid Window, Parent Window, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class uint16, Visual Visualid, ValueMask uint32, ValueList []uint32) []byte { + size := xgb.Pad((28 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) + b := 0 + buf := make([]byte, size) + + buf[b] = 1 // request opcode + b += 1 + + buf[b] = Depth + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Wid)) + b += 4 + + xgb.Put32(buf[b:], uint32(Parent)) + b += 4 + + xgb.Put16(buf[b:], uint16(X)) + b += 2 + + xgb.Put16(buf[b:], uint16(Y)) + b += 2 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + xgb.Put16(buf[b:], BorderWidth) + b += 2 + + xgb.Put16(buf[b:], Class) + b += 2 + + xgb.Put32(buf[b:], uint32(Visual)) + b += 4 + + xgb.Put32(buf[b:], ValueMask) + b += 4 + for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { + xgb.Put32(buf[b:], ValueList[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request ChangeWindowAttributes +// size: xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +type ChangeWindowAttributesCookie struct { + *xgb.Cookie +} + +// Write request to wire for ChangeWindowAttributes +func ChangeWindowAttributes(c *xgb.Conn, Window Window, ValueMask uint32, ValueList []uint32) ChangeWindowAttributesCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeWindowAttributesRequest(c, Window, ValueMask, ValueList), cookie) + return ChangeWindowAttributesCookie{cookie} +} + +func ChangeWindowAttributesChecked(c *xgb.Conn, Window Window, ValueMask uint32, ValueList []uint32) ChangeWindowAttributesCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeWindowAttributesRequest(c, Window, ValueMask, ValueList), cookie) + return ChangeWindowAttributesCookie{cookie} +} + +func (cook ChangeWindowAttributesCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangeWindowAttributes +func changeWindowAttributesRequest(c *xgb.Conn, Window Window, ValueMask uint32, ValueList []uint32) []byte { + size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) + b := 0 + buf := make([]byte, size) + + buf[b] = 2 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put32(buf[b:], ValueMask) + b += 4 + for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { + xgb.Put32(buf[b:], ValueList[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request GetWindowAttributes +// size: 8 +type GetWindowAttributesCookie struct { + *xgb.Cookie +} + +func GetWindowAttributes(c *xgb.Conn, Window Window) GetWindowAttributesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getWindowAttributesRequest(c, Window), cookie) + return GetWindowAttributesCookie{cookie} +} + +func GetWindowAttributesUnchecked(c *xgb.Conn, Window Window) GetWindowAttributesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getWindowAttributesRequest(c, Window), cookie) + return GetWindowAttributesCookie{cookie} +} + +// Request reply for GetWindowAttributes +// size: 44 +type GetWindowAttributesReply struct { + Sequence uint16 + Length uint32 + BackingStore byte + Visual Visualid + Class uint16 + BitGravity byte + WinGravity byte + BackingPlanes uint32 + BackingPixel uint32 + SaveUnder bool + MapIsInstalled bool + MapState byte + OverrideRedirect bool + Colormap Colormap + AllEventMasks uint32 + YourEventMask uint32 + DoNotPropagateMask uint16 + // padding: 2 bytes +} + +// Waits and reads reply data from request GetWindowAttributes +func (cook GetWindowAttributesCookie) Reply() (*GetWindowAttributesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getWindowAttributesReply(buf), nil +} + +// Read reply into structure from buffer for GetWindowAttributes +func getWindowAttributesReply(buf []byte) *GetWindowAttributesReply { + v := new(GetWindowAttributesReply) + b := 1 // skip reply determinant + + v.BackingStore = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Visual = Visualid(xgb.Get32(buf[b:])) + b += 4 + + v.Class = xgb.Get16(buf[b:]) + b += 2 + + v.BitGravity = buf[b] + b += 1 + + v.WinGravity = buf[b] + b += 1 + + v.BackingPlanes = xgb.Get32(buf[b:]) + b += 4 + + v.BackingPixel = xgb.Get32(buf[b:]) + b += 4 + + if buf[b] == 1 { + v.SaveUnder = true + } else { + v.SaveUnder = false + } + b += 1 + + if buf[b] == 1 { + v.MapIsInstalled = true + } else { + v.MapIsInstalled = false + } + b += 1 + + v.MapState = buf[b] + b += 1 + + if buf[b] == 1 { + v.OverrideRedirect = true + } else { + v.OverrideRedirect = false + } + b += 1 + + v.Colormap = Colormap(xgb.Get32(buf[b:])) + b += 4 + + v.AllEventMasks = xgb.Get32(buf[b:]) + b += 4 + + v.YourEventMask = xgb.Get32(buf[b:]) + b += 4 + + v.DoNotPropagateMask = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + return v +} + +// Write request to wire for GetWindowAttributes +func getWindowAttributesRequest(c *xgb.Conn, Window Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 3 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + +// Request DestroyWindow +// size: 8 +type DestroyWindowCookie struct { + *xgb.Cookie +} + +// Write request to wire for DestroyWindow +func DestroyWindow(c *xgb.Conn, Window Window) DestroyWindowCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroyWindowRequest(c, Window), cookie) + return DestroyWindowCookie{cookie} +} + +func DestroyWindowChecked(c *xgb.Conn, Window Window) DestroyWindowCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(destroyWindowRequest(c, Window), cookie) + return DestroyWindowCookie{cookie} +} + +func (cook DestroyWindowCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DestroyWindow +func destroyWindowRequest(c *xgb.Conn, Window Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 4 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + +// Request DestroySubwindows +// size: 8 +type DestroySubwindowsCookie struct { + *xgb.Cookie +} + +// Write request to wire for DestroySubwindows +func DestroySubwindows(c *xgb.Conn, Window Window) DestroySubwindowsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroySubwindowsRequest(c, Window), cookie) + return DestroySubwindowsCookie{cookie} +} + +func DestroySubwindowsChecked(c *xgb.Conn, Window Window) DestroySubwindowsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(destroySubwindowsRequest(c, Window), cookie) + return DestroySubwindowsCookie{cookie} +} + +func (cook DestroySubwindowsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DestroySubwindows +func destroySubwindowsRequest(c *xgb.Conn, Window Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 5 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + +// Request ChangeSaveSet +// size: 8 +type ChangeSaveSetCookie struct { + *xgb.Cookie +} + +// Write request to wire for ChangeSaveSet +func ChangeSaveSet(c *xgb.Conn, Mode byte, Window Window) ChangeSaveSetCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeSaveSetRequest(c, Mode, Window), cookie) + return ChangeSaveSetCookie{cookie} +} + +func ChangeSaveSetChecked(c *xgb.Conn, Mode byte, Window Window) ChangeSaveSetCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeSaveSetRequest(c, Mode, Window), cookie) + return ChangeSaveSetCookie{cookie} +} + +func (cook ChangeSaveSetCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangeSaveSet +func changeSaveSetRequest(c *xgb.Conn, Mode byte, Window Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 6 // request opcode + b += 1 + + buf[b] = Mode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + +// Request ReparentWindow +// size: 16 +type ReparentWindowCookie struct { + *xgb.Cookie +} + +// Write request to wire for ReparentWindow +func ReparentWindow(c *xgb.Conn, Window Window, Parent Window, X int16, Y int16) ReparentWindowCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(reparentWindowRequest(c, Window, Parent, X, Y), cookie) + return ReparentWindowCookie{cookie} +} + +func ReparentWindowChecked(c *xgb.Conn, Window Window, Parent Window, X int16, Y int16) ReparentWindowCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(reparentWindowRequest(c, Window, Parent, X, Y), cookie) + return ReparentWindowCookie{cookie} +} + +func (cook ReparentWindowCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ReparentWindow +func reparentWindowRequest(c *xgb.Conn, Window Window, Parent Window, X int16, Y int16) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 7 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(Parent)) + b += 4 + + xgb.Put16(buf[b:], uint16(X)) + b += 2 + + xgb.Put16(buf[b:], uint16(Y)) + b += 2 + + return buf +} + +// Request MapWindow +// size: 8 +type MapWindowCookie struct { + *xgb.Cookie +} + +// Write request to wire for MapWindow +func MapWindow(c *xgb.Conn, Window Window) MapWindowCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(mapWindowRequest(c, Window), cookie) + return MapWindowCookie{cookie} +} + +func MapWindowChecked(c *xgb.Conn, Window Window) MapWindowCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(mapWindowRequest(c, Window), cookie) + return MapWindowCookie{cookie} +} + +func (cook MapWindowCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for MapWindow +func mapWindowRequest(c *xgb.Conn, Window Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 8 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + +// Request MapSubwindows +// size: 8 +type MapSubwindowsCookie struct { + *xgb.Cookie +} + +// Write request to wire for MapSubwindows +func MapSubwindows(c *xgb.Conn, Window Window) MapSubwindowsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(mapSubwindowsRequest(c, Window), cookie) + return MapSubwindowsCookie{cookie} +} + +func MapSubwindowsChecked(c *xgb.Conn, Window Window) MapSubwindowsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(mapSubwindowsRequest(c, Window), cookie) + return MapSubwindowsCookie{cookie} +} + +func (cook MapSubwindowsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for MapSubwindows +func mapSubwindowsRequest(c *xgb.Conn, Window Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 9 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + +// Request UnmapWindow +// size: 8 +type UnmapWindowCookie struct { + *xgb.Cookie +} + +// Write request to wire for UnmapWindow +func UnmapWindow(c *xgb.Conn, Window Window) UnmapWindowCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(unmapWindowRequest(c, Window), cookie) + return UnmapWindowCookie{cookie} +} + +func UnmapWindowChecked(c *xgb.Conn, Window Window) UnmapWindowCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(unmapWindowRequest(c, Window), cookie) + return UnmapWindowCookie{cookie} +} + +func (cook UnmapWindowCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for UnmapWindow +func unmapWindowRequest(c *xgb.Conn, Window Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 10 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + +// Request UnmapSubwindows +// size: 8 +type UnmapSubwindowsCookie struct { + *xgb.Cookie +} + +// Write request to wire for UnmapSubwindows +func UnmapSubwindows(c *xgb.Conn, Window Window) UnmapSubwindowsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(unmapSubwindowsRequest(c, Window), cookie) + return UnmapSubwindowsCookie{cookie} +} + +func UnmapSubwindowsChecked(c *xgb.Conn, Window Window) UnmapSubwindowsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(unmapSubwindowsRequest(c, Window), cookie) + return UnmapSubwindowsCookie{cookie} +} + +func (cook UnmapSubwindowsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for UnmapSubwindows +func unmapSubwindowsRequest(c *xgb.Conn, Window Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 11 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + +// Request ConfigureWindow +// size: xgb.Pad((10 + (2 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +type ConfigureWindowCookie struct { + *xgb.Cookie +} + +// Write request to wire for ConfigureWindow +func ConfigureWindow(c *xgb.Conn, Window Window, ValueMask uint16, ValueList []uint32) ConfigureWindowCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(configureWindowRequest(c, Window, ValueMask, ValueList), cookie) + return ConfigureWindowCookie{cookie} +} + +func ConfigureWindowChecked(c *xgb.Conn, Window Window, ValueMask uint16, ValueList []uint32) ConfigureWindowCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(configureWindowRequest(c, Window, ValueMask, ValueList), cookie) + return ConfigureWindowCookie{cookie} +} + +func (cook ConfigureWindowCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ConfigureWindow +func configureWindowRequest(c *xgb.Conn, Window Window, ValueMask uint16, ValueList []uint32) []byte { + size := xgb.Pad((10 + (2 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) + b := 0 + buf := make([]byte, size) + + buf[b] = 12 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put16(buf[b:], ValueMask) + b += 2 + + b += 2 // padding + + for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { + xgb.Put32(buf[b:], ValueList[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request CirculateWindow +// size: 8 +type CirculateWindowCookie struct { + *xgb.Cookie +} + +// Write request to wire for CirculateWindow +func CirculateWindow(c *xgb.Conn, Direction byte, Window Window) CirculateWindowCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(circulateWindowRequest(c, Direction, Window), cookie) + return CirculateWindowCookie{cookie} +} + +func CirculateWindowChecked(c *xgb.Conn, Direction byte, Window Window) CirculateWindowCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(circulateWindowRequest(c, Direction, Window), cookie) + return CirculateWindowCookie{cookie} +} + +func (cook CirculateWindowCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CirculateWindow +func circulateWindowRequest(c *xgb.Conn, Direction byte, Window Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 13 // request opcode + b += 1 + + buf[b] = Direction + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + +// Request GetGeometry +// size: 8 +type GetGeometryCookie struct { + *xgb.Cookie +} + +func GetGeometry(c *xgb.Conn, Drawable Drawable) GetGeometryCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getGeometryRequest(c, Drawable), cookie) + return GetGeometryCookie{cookie} +} + +func GetGeometryUnchecked(c *xgb.Conn, Drawable Drawable) GetGeometryCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getGeometryRequest(c, Drawable), cookie) + return GetGeometryCookie{cookie} +} + +// Request reply for GetGeometry +// size: 24 +type GetGeometryReply struct { + Sequence uint16 + Length uint32 + Depth byte + Root Window + X int16 + Y int16 + Width uint16 + Height uint16 + BorderWidth uint16 + // padding: 2 bytes +} + +// Waits and reads reply data from request GetGeometry +func (cook GetGeometryCookie) Reply() (*GetGeometryReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getGeometryReply(buf), nil +} + +// Read reply into structure from buffer for GetGeometry +func getGeometryReply(buf []byte) *GetGeometryReply { + v := new(GetGeometryReply) + b := 1 // skip reply determinant + + v.Depth = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Root = Window(xgb.Get32(buf[b:])) + b += 4 + + v.X = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.BorderWidth = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + return v +} + +// Write request to wire for GetGeometry +func getGeometryRequest(c *xgb.Conn, Drawable Drawable) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 14 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + return buf +} + +// Request QueryTree +// size: 8 +type QueryTreeCookie struct { + *xgb.Cookie +} + +func QueryTree(c *xgb.Conn, Window Window) QueryTreeCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryTreeRequest(c, Window), cookie) + return QueryTreeCookie{cookie} +} + +func QueryTreeUnchecked(c *xgb.Conn, Window Window) QueryTreeCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryTreeRequest(c, Window), cookie) + return QueryTreeCookie{cookie} +} + +// Request reply for QueryTree +// size: (32 + xgb.Pad((int(ChildrenLen) * 4))) +type QueryTreeReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Root Window + Parent Window + ChildrenLen uint16 + // padding: 14 bytes + Children []Window // size: xgb.Pad((int(ChildrenLen) * 4)) +} + +// Waits and reads reply data from request QueryTree +func (cook QueryTreeCookie) Reply() (*QueryTreeReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryTreeReply(buf), nil +} + +// Read reply into structure from buffer for QueryTree +func queryTreeReply(buf []byte) *QueryTreeReply { + v := new(QueryTreeReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Root = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Parent = Window(xgb.Get32(buf[b:])) + b += 4 + + v.ChildrenLen = xgb.Get16(buf[b:]) + b += 2 + + b += 14 // padding + + v.Children = make([]Window, v.ChildrenLen) + for i := 0; i < int(v.ChildrenLen); i++ { + v.Children[i] = Window(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for QueryTree +func queryTreeRequest(c *xgb.Conn, Window Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 15 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + +// Request InternAtom +// size: xgb.Pad((8 + xgb.Pad((int(NameLen) * 1)))) +type InternAtomCookie struct { + *xgb.Cookie +} + +func InternAtom(c *xgb.Conn, OnlyIfExists bool, NameLen uint16, Name string) InternAtomCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(internAtomRequest(c, OnlyIfExists, NameLen, Name), cookie) + return InternAtomCookie{cookie} +} + +func InternAtomUnchecked(c *xgb.Conn, OnlyIfExists bool, NameLen uint16, Name string) InternAtomCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(internAtomRequest(c, OnlyIfExists, NameLen, Name), cookie) + return InternAtomCookie{cookie} +} + +// Request reply for InternAtom +// size: 12 +type InternAtomReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Atom Atom +} + +// Waits and reads reply data from request InternAtom +func (cook InternAtomCookie) Reply() (*InternAtomReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return internAtomReply(buf), nil +} + +// Read reply into structure from buffer for InternAtom +func internAtomReply(buf []byte) *InternAtomReply { + v := new(InternAtomReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Atom = Atom(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Write request to wire for InternAtom +func internAtomRequest(c *xgb.Conn, OnlyIfExists bool, NameLen uint16, Name string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(NameLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 16 // request opcode + b += 1 + + if OnlyIfExists { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], NameLen) + b += 2 + + b += 2 // padding + + copy(buf[b:], Name[:NameLen]) + b += xgb.Pad(int(NameLen)) + + return buf +} + +// Request GetAtomName +// size: 8 +type GetAtomNameCookie struct { + *xgb.Cookie +} + +func GetAtomName(c *xgb.Conn, Atom Atom) GetAtomNameCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getAtomNameRequest(c, Atom), cookie) + return GetAtomNameCookie{cookie} +} + +func GetAtomNameUnchecked(c *xgb.Conn, Atom Atom) GetAtomNameCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getAtomNameRequest(c, Atom), cookie) + return GetAtomNameCookie{cookie} +} + +// Request reply for GetAtomName +// size: (32 + xgb.Pad((int(NameLen) * 1))) +type GetAtomNameReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NameLen uint16 + // padding: 22 bytes + Name string // size: xgb.Pad((int(NameLen) * 1)) +} + +// Waits and reads reply data from request GetAtomName +func (cook GetAtomNameCookie) Reply() (*GetAtomNameReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getAtomNameReply(buf), nil +} + +// Read reply into structure from buffer for GetAtomName +func getAtomNameReply(buf []byte) *GetAtomNameReply { + v := new(GetAtomNameReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NameLen = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + { + byteString := make([]byte, v.NameLen) + copy(byteString[:v.NameLen], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.NameLen)) + } + + return v +} + +// Write request to wire for GetAtomName +func getAtomNameRequest(c *xgb.Conn, Atom Atom) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 17 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Atom)) + b += 4 + + return buf +} + +// Request ChangeProperty +// size: xgb.Pad((24 + xgb.Pad((((int(DataLen) * int(Format)) / 8) * 1)))) +type ChangePropertyCookie struct { + *xgb.Cookie +} + +// Write request to wire for ChangeProperty +func ChangeProperty(c *xgb.Conn, Mode byte, Window Window, Property Atom, Type Atom, Format byte, DataLen uint32, Data []byte) ChangePropertyCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changePropertyRequest(c, Mode, Window, Property, Type, Format, DataLen, Data), cookie) + return ChangePropertyCookie{cookie} +} + +func ChangePropertyChecked(c *xgb.Conn, Mode byte, Window Window, Property Atom, Type Atom, Format byte, DataLen uint32, Data []byte) ChangePropertyCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changePropertyRequest(c, Mode, Window, Property, Type, Format, DataLen, Data), cookie) + return ChangePropertyCookie{cookie} +} + +func (cook ChangePropertyCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangeProperty +func changePropertyRequest(c *xgb.Conn, Mode byte, Window Window, Property Atom, Type Atom, Format byte, DataLen uint32, Data []byte) []byte { + size := xgb.Pad((24 + xgb.Pad((((int(DataLen) * int(Format)) / 8) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 18 // request opcode + b += 1 + + buf[b] = Mode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(Property)) + b += 4 + + xgb.Put32(buf[b:], uint32(Type)) + b += 4 + + buf[b] = Format + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], DataLen) + b += 4 + + copy(buf[b:], Data[:((int(DataLen)*int(Format))/8)]) + b += xgb.Pad(int(((int(DataLen) * int(Format)) / 8))) + + return buf +} + +// Request DeleteProperty +// size: 12 +type DeletePropertyCookie struct { + *xgb.Cookie +} + +// Write request to wire for DeleteProperty +func DeleteProperty(c *xgb.Conn, Window Window, Property Atom) DeletePropertyCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(deletePropertyRequest(c, Window, Property), cookie) + return DeletePropertyCookie{cookie} +} + +func DeletePropertyChecked(c *xgb.Conn, Window Window, Property Atom) DeletePropertyCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(deletePropertyRequest(c, Window, Property), cookie) + return DeletePropertyCookie{cookie} +} + +func (cook DeletePropertyCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DeleteProperty +func deletePropertyRequest(c *xgb.Conn, Window Window, Property Atom) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = 19 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(Property)) + b += 4 + + return buf +} + +// Request GetProperty +// size: 24 +type GetPropertyCookie struct { + *xgb.Cookie +} + +func GetProperty(c *xgb.Conn, Delete bool, Window Window, Property Atom, Type Atom, LongOffset uint32, LongLength uint32) GetPropertyCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getPropertyRequest(c, Delete, Window, Property, Type, LongOffset, LongLength), cookie) + return GetPropertyCookie{cookie} +} + +func GetPropertyUnchecked(c *xgb.Conn, Delete bool, Window Window, Property Atom, Type Atom, LongOffset uint32, LongLength uint32) GetPropertyCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getPropertyRequest(c, Delete, Window, Property, Type, LongOffset, LongLength), cookie) + return GetPropertyCookie{cookie} +} + +// Request reply for GetProperty +// size: (32 + xgb.Pad(((int(ValueLen) * (int(Format) / 8)) * 1))) +type GetPropertyReply struct { + Sequence uint16 + Length uint32 + Format byte + Type Atom + BytesAfter uint32 + ValueLen uint32 + // padding: 12 bytes + Value []byte // size: xgb.Pad(((int(ValueLen) * (int(Format) / 8)) * 1)) +} + +// Waits and reads reply data from request GetProperty +func (cook GetPropertyCookie) Reply() (*GetPropertyReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPropertyReply(buf), nil +} + +// Read reply into structure from buffer for GetProperty +func getPropertyReply(buf []byte) *GetPropertyReply { + v := new(GetPropertyReply) + b := 1 // skip reply determinant + + v.Format = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Type = Atom(xgb.Get32(buf[b:])) + b += 4 + + v.BytesAfter = xgb.Get32(buf[b:]) + b += 4 + + v.ValueLen = xgb.Get32(buf[b:]) + b += 4 + + b += 12 // padding + + v.Value = make([]byte, (int(v.ValueLen) * (int(v.Format) / 8))) + copy(v.Value[:(int(v.ValueLen)*(int(v.Format)/8))], buf[b:]) + b += xgb.Pad(int((int(v.ValueLen) * (int(v.Format) / 8)))) + + return v +} + +// Write request to wire for GetProperty +func getPropertyRequest(c *xgb.Conn, Delete bool, Window Window, Property Atom, Type Atom, LongOffset uint32, LongLength uint32) []byte { + size := 24 + b := 0 + buf := make([]byte, size) + + buf[b] = 20 // request opcode + b += 1 + + if Delete { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(Property)) + b += 4 + + xgb.Put32(buf[b:], uint32(Type)) + b += 4 + + xgb.Put32(buf[b:], LongOffset) + b += 4 + + xgb.Put32(buf[b:], LongLength) + b += 4 + + return buf +} + +// Request ListProperties +// size: 8 +type ListPropertiesCookie struct { + *xgb.Cookie +} + +func ListProperties(c *xgb.Conn, Window Window) ListPropertiesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(listPropertiesRequest(c, Window), cookie) + return ListPropertiesCookie{cookie} +} + +func ListPropertiesUnchecked(c *xgb.Conn, Window Window) ListPropertiesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(listPropertiesRequest(c, Window), cookie) + return ListPropertiesCookie{cookie} +} + +// Request reply for ListProperties +// size: (32 + xgb.Pad((int(AtomsLen) * 4))) +type ListPropertiesReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + AtomsLen uint16 + // padding: 22 bytes + Atoms []Atom // size: xgb.Pad((int(AtomsLen) * 4)) +} + +// Waits and reads reply data from request ListProperties +func (cook ListPropertiesCookie) Reply() (*ListPropertiesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listPropertiesReply(buf), nil +} + +// Read reply into structure from buffer for ListProperties +func listPropertiesReply(buf []byte) *ListPropertiesReply { + v := new(ListPropertiesReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.AtomsLen = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + v.Atoms = make([]Atom, v.AtomsLen) + for i := 0; i < int(v.AtomsLen); i++ { + v.Atoms[i] = Atom(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for ListProperties +func listPropertiesRequest(c *xgb.Conn, Window Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 21 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + +// Request SetSelectionOwner +// size: 16 +type SetSelectionOwnerCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetSelectionOwner +func SetSelectionOwner(c *xgb.Conn, Owner Window, Selection Atom, Time Timestamp) SetSelectionOwnerCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setSelectionOwnerRequest(c, Owner, Selection, Time), cookie) + return SetSelectionOwnerCookie{cookie} +} + +func SetSelectionOwnerChecked(c *xgb.Conn, Owner Window, Selection Atom, Time Timestamp) SetSelectionOwnerCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setSelectionOwnerRequest(c, Owner, Selection, Time), cookie) + return SetSelectionOwnerCookie{cookie} +} + +func (cook SetSelectionOwnerCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetSelectionOwner +func setSelectionOwnerRequest(c *xgb.Conn, Owner Window, Selection Atom, Time Timestamp) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 22 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Owner)) + b += 4 + + xgb.Put32(buf[b:], uint32(Selection)) + b += 4 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + return buf +} + +// Request GetSelectionOwner +// size: 8 +type GetSelectionOwnerCookie struct { + *xgb.Cookie +} + +func GetSelectionOwner(c *xgb.Conn, Selection Atom) GetSelectionOwnerCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getSelectionOwnerRequest(c, Selection), cookie) + return GetSelectionOwnerCookie{cookie} +} + +func GetSelectionOwnerUnchecked(c *xgb.Conn, Selection Atom) GetSelectionOwnerCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getSelectionOwnerRequest(c, Selection), cookie) + return GetSelectionOwnerCookie{cookie} +} + +// Request reply for GetSelectionOwner +// size: 12 +type GetSelectionOwnerReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Owner Window +} + +// Waits and reads reply data from request GetSelectionOwner +func (cook GetSelectionOwnerCookie) Reply() (*GetSelectionOwnerReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getSelectionOwnerReply(buf), nil +} + +// Read reply into structure from buffer for GetSelectionOwner +func getSelectionOwnerReply(buf []byte) *GetSelectionOwnerReply { + v := new(GetSelectionOwnerReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Owner = Window(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Write request to wire for GetSelectionOwner +func getSelectionOwnerRequest(c *xgb.Conn, Selection Atom) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 23 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Selection)) + b += 4 + + return buf +} + +// Request ConvertSelection +// size: 24 +type ConvertSelectionCookie struct { + *xgb.Cookie +} + +// Write request to wire for ConvertSelection +func ConvertSelection(c *xgb.Conn, Requestor Window, Selection Atom, Target Atom, Property Atom, Time Timestamp) ConvertSelectionCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(convertSelectionRequest(c, Requestor, Selection, Target, Property, Time), cookie) + return ConvertSelectionCookie{cookie} +} + +func ConvertSelectionChecked(c *xgb.Conn, Requestor Window, Selection Atom, Target Atom, Property Atom, Time Timestamp) ConvertSelectionCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(convertSelectionRequest(c, Requestor, Selection, Target, Property, Time), cookie) + return ConvertSelectionCookie{cookie} +} + +func (cook ConvertSelectionCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ConvertSelection +func convertSelectionRequest(c *xgb.Conn, Requestor Window, Selection Atom, Target Atom, Property Atom, Time Timestamp) []byte { + size := 24 + b := 0 + buf := make([]byte, size) + + buf[b] = 24 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Requestor)) + b += 4 + + xgb.Put32(buf[b:], uint32(Selection)) + b += 4 + + xgb.Put32(buf[b:], uint32(Target)) + b += 4 + + xgb.Put32(buf[b:], uint32(Property)) + b += 4 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + return buf +} + +// Request SendEvent +// size: 44 +type SendEventCookie struct { + *xgb.Cookie +} + +// Write request to wire for SendEvent +func SendEvent(c *xgb.Conn, Propagate bool, Destination Window, EventMask uint32, Event string) SendEventCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(sendEventRequest(c, Propagate, Destination, EventMask, Event), cookie) + return SendEventCookie{cookie} +} + +func SendEventChecked(c *xgb.Conn, Propagate bool, Destination Window, EventMask uint32, Event string) SendEventCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(sendEventRequest(c, Propagate, Destination, EventMask, Event), cookie) + return SendEventCookie{cookie} +} + +func (cook SendEventCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SendEvent +func sendEventRequest(c *xgb.Conn, Propagate bool, Destination Window, EventMask uint32, Event string) []byte { + size := 44 + b := 0 + buf := make([]byte, size) + + buf[b] = 25 // request opcode + b += 1 + + if Propagate { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Destination)) + b += 4 + + xgb.Put32(buf[b:], EventMask) + b += 4 + + copy(buf[b:], Event[:32]) + b += xgb.Pad(int(32)) + + return buf +} + +// Request GrabPointer +// size: 24 +type GrabPointerCookie struct { + *xgb.Cookie +} + +func GrabPointer(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Time Timestamp) GrabPointerCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(grabPointerRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Time), cookie) + return GrabPointerCookie{cookie} +} + +func GrabPointerUnchecked(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Time Timestamp) GrabPointerCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(grabPointerRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Time), cookie) + return GrabPointerCookie{cookie} +} + +// Request reply for GrabPointer +// size: 8 +type GrabPointerReply struct { + Sequence uint16 + Length uint32 + Status byte +} + +// Waits and reads reply data from request GrabPointer +func (cook GrabPointerCookie) Reply() (*GrabPointerReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return grabPointerReply(buf), nil +} + +// Read reply into structure from buffer for GrabPointer +func grabPointerReply(buf []byte) *GrabPointerReply { + v := new(GrabPointerReply) + b := 1 // skip reply determinant + + v.Status = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + return v +} + +// Write request to wire for GrabPointer +func grabPointerRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Time Timestamp) []byte { + size := 24 + b := 0 + buf := make([]byte, size) + + buf[b] = 26 // request opcode + b += 1 + + if OwnerEvents { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(GrabWindow)) + b += 4 + + xgb.Put16(buf[b:], EventMask) + b += 2 + + buf[b] = PointerMode + b += 1 + + buf[b] = KeyboardMode + b += 1 + + xgb.Put32(buf[b:], uint32(ConfineTo)) + b += 4 + + xgb.Put32(buf[b:], uint32(Cursor)) + b += 4 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + return buf +} + +// Request UngrabPointer +// size: 8 +type UngrabPointerCookie struct { + *xgb.Cookie +} + +// Write request to wire for UngrabPointer +func UngrabPointer(c *xgb.Conn, Time Timestamp) UngrabPointerCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(ungrabPointerRequest(c, Time), cookie) + return UngrabPointerCookie{cookie} +} + +func UngrabPointerChecked(c *xgb.Conn, Time Timestamp) UngrabPointerCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(ungrabPointerRequest(c, Time), cookie) + return UngrabPointerCookie{cookie} +} + +func (cook UngrabPointerCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for UngrabPointer +func ungrabPointerRequest(c *xgb.Conn, Time Timestamp) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 27 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + return buf +} + +// Request GrabButton +// size: 24 +type GrabButtonCookie struct { + *xgb.Cookie +} + +// Write request to wire for GrabButton +func GrabButton(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Button byte, Modifiers uint16) GrabButtonCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(grabButtonRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Button, Modifiers), cookie) + return GrabButtonCookie{cookie} +} + +func GrabButtonChecked(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Button byte, Modifiers uint16) GrabButtonCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(grabButtonRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Button, Modifiers), cookie) + return GrabButtonCookie{cookie} +} + +func (cook GrabButtonCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for GrabButton +func grabButtonRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Button byte, Modifiers uint16) []byte { + size := 24 + b := 0 + buf := make([]byte, size) + + buf[b] = 28 // request opcode + b += 1 + + if OwnerEvents { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(GrabWindow)) + b += 4 + + xgb.Put16(buf[b:], EventMask) + b += 2 + + buf[b] = PointerMode + b += 1 + + buf[b] = KeyboardMode + b += 1 + + xgb.Put32(buf[b:], uint32(ConfineTo)) + b += 4 + + xgb.Put32(buf[b:], uint32(Cursor)) + b += 4 + + buf[b] = Button + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], Modifiers) + b += 2 + + return buf +} + +// Request UngrabButton +// size: 12 +type UngrabButtonCookie struct { + *xgb.Cookie +} + +// Write request to wire for UngrabButton +func UngrabButton(c *xgb.Conn, Button byte, GrabWindow Window, Modifiers uint16) UngrabButtonCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(ungrabButtonRequest(c, Button, GrabWindow, Modifiers), cookie) + return UngrabButtonCookie{cookie} +} + +func UngrabButtonChecked(c *xgb.Conn, Button byte, GrabWindow Window, Modifiers uint16) UngrabButtonCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(ungrabButtonRequest(c, Button, GrabWindow, Modifiers), cookie) + return UngrabButtonCookie{cookie} +} + +func (cook UngrabButtonCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for UngrabButton +func ungrabButtonRequest(c *xgb.Conn, Button byte, GrabWindow Window, Modifiers uint16) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = 29 // request opcode + b += 1 + + buf[b] = Button + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(GrabWindow)) + b += 4 + + xgb.Put16(buf[b:], Modifiers) + b += 2 + + b += 2 // padding + + return buf +} + +// Request ChangeActivePointerGrab +// size: 16 +type ChangeActivePointerGrabCookie struct { + *xgb.Cookie +} + +// Write request to wire for ChangeActivePointerGrab +func ChangeActivePointerGrab(c *xgb.Conn, Cursor Cursor, Time Timestamp, EventMask uint16) ChangeActivePointerGrabCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeActivePointerGrabRequest(c, Cursor, Time, EventMask), cookie) + return ChangeActivePointerGrabCookie{cookie} +} + +func ChangeActivePointerGrabChecked(c *xgb.Conn, Cursor Cursor, Time Timestamp, EventMask uint16) ChangeActivePointerGrabCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeActivePointerGrabRequest(c, Cursor, Time, EventMask), cookie) + return ChangeActivePointerGrabCookie{cookie} +} + +func (cook ChangeActivePointerGrabCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangeActivePointerGrab +func changeActivePointerGrabRequest(c *xgb.Conn, Cursor Cursor, Time Timestamp, EventMask uint16) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 30 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cursor)) + b += 4 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + xgb.Put16(buf[b:], EventMask) + b += 2 + + b += 2 // padding + + return buf +} + +// Request GrabKeyboard +// size: 16 +type GrabKeyboardCookie struct { + *xgb.Cookie +} + +func GrabKeyboard(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Time Timestamp, PointerMode byte, KeyboardMode byte) GrabKeyboardCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(grabKeyboardRequest(c, OwnerEvents, GrabWindow, Time, PointerMode, KeyboardMode), cookie) + return GrabKeyboardCookie{cookie} +} + +func GrabKeyboardUnchecked(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Time Timestamp, PointerMode byte, KeyboardMode byte) GrabKeyboardCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(grabKeyboardRequest(c, OwnerEvents, GrabWindow, Time, PointerMode, KeyboardMode), cookie) + return GrabKeyboardCookie{cookie} +} + +// Request reply for GrabKeyboard +// size: 8 +type GrabKeyboardReply struct { + Sequence uint16 + Length uint32 + Status byte +} + +// Waits and reads reply data from request GrabKeyboard +func (cook GrabKeyboardCookie) Reply() (*GrabKeyboardReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return grabKeyboardReply(buf), nil +} + +// Read reply into structure from buffer for GrabKeyboard +func grabKeyboardReply(buf []byte) *GrabKeyboardReply { + v := new(GrabKeyboardReply) + b := 1 // skip reply determinant + + v.Status = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + return v +} + +// Write request to wire for GrabKeyboard +func grabKeyboardRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Time Timestamp, PointerMode byte, KeyboardMode byte) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 31 // request opcode + b += 1 + + if OwnerEvents { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(GrabWindow)) + b += 4 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + buf[b] = PointerMode + b += 1 + + buf[b] = KeyboardMode + b += 1 + + b += 2 // padding + + return buf +} + +// Request UngrabKeyboard +// size: 8 +type UngrabKeyboardCookie struct { + *xgb.Cookie +} + +// Write request to wire for UngrabKeyboard +func UngrabKeyboard(c *xgb.Conn, Time Timestamp) UngrabKeyboardCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(ungrabKeyboardRequest(c, Time), cookie) + return UngrabKeyboardCookie{cookie} +} + +func UngrabKeyboardChecked(c *xgb.Conn, Time Timestamp) UngrabKeyboardCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(ungrabKeyboardRequest(c, Time), cookie) + return UngrabKeyboardCookie{cookie} +} + +func (cook UngrabKeyboardCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for UngrabKeyboard +func ungrabKeyboardRequest(c *xgb.Conn, Time Timestamp) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 32 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + return buf +} + +// Request GrabKey +// size: 16 +type GrabKeyCookie struct { + *xgb.Cookie +} + +// Write request to wire for GrabKey +func GrabKey(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Modifiers uint16, Key Keycode, PointerMode byte, KeyboardMode byte) GrabKeyCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(grabKeyRequest(c, OwnerEvents, GrabWindow, Modifiers, Key, PointerMode, KeyboardMode), cookie) + return GrabKeyCookie{cookie} +} + +func GrabKeyChecked(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Modifiers uint16, Key Keycode, PointerMode byte, KeyboardMode byte) GrabKeyCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(grabKeyRequest(c, OwnerEvents, GrabWindow, Modifiers, Key, PointerMode, KeyboardMode), cookie) + return GrabKeyCookie{cookie} +} + +func (cook GrabKeyCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for GrabKey +func grabKeyRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Modifiers uint16, Key Keycode, PointerMode byte, KeyboardMode byte) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 33 // request opcode + b += 1 + + if OwnerEvents { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(GrabWindow)) + b += 4 + + xgb.Put16(buf[b:], Modifiers) + b += 2 + + buf[b] = byte(Key) + b += 1 + + buf[b] = PointerMode + b += 1 + + buf[b] = KeyboardMode + b += 1 + + b += 3 // padding + + return buf +} + +// Request UngrabKey +// size: 12 +type UngrabKeyCookie struct { + *xgb.Cookie +} + +// Write request to wire for UngrabKey +func UngrabKey(c *xgb.Conn, Key Keycode, GrabWindow Window, Modifiers uint16) UngrabKeyCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(ungrabKeyRequest(c, Key, GrabWindow, Modifiers), cookie) + return UngrabKeyCookie{cookie} +} + +func UngrabKeyChecked(c *xgb.Conn, Key Keycode, GrabWindow Window, Modifiers uint16) UngrabKeyCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(ungrabKeyRequest(c, Key, GrabWindow, Modifiers), cookie) + return UngrabKeyCookie{cookie} +} + +func (cook UngrabKeyCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for UngrabKey +func ungrabKeyRequest(c *xgb.Conn, Key Keycode, GrabWindow Window, Modifiers uint16) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = 34 // request opcode + b += 1 + + buf[b] = byte(Key) + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(GrabWindow)) + b += 4 + + xgb.Put16(buf[b:], Modifiers) + b += 2 + + b += 2 // padding + + return buf +} + +// Request AllowEvents +// size: 8 +type AllowEventsCookie struct { + *xgb.Cookie +} + +// Write request to wire for AllowEvents +func AllowEvents(c *xgb.Conn, Mode byte, Time Timestamp) AllowEventsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(allowEventsRequest(c, Mode, Time), cookie) + return AllowEventsCookie{cookie} +} + +func AllowEventsChecked(c *xgb.Conn, Mode byte, Time Timestamp) AllowEventsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(allowEventsRequest(c, Mode, Time), cookie) + return AllowEventsCookie{cookie} +} + +func (cook AllowEventsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for AllowEvents +func allowEventsRequest(c *xgb.Conn, Mode byte, Time Timestamp) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 35 // request opcode + b += 1 + + buf[b] = Mode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + return buf +} + +// Request GrabServer +// size: 4 +type GrabServerCookie struct { + *xgb.Cookie +} + +// Write request to wire for GrabServer +func GrabServer(c *xgb.Conn) GrabServerCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(grabServerRequest(c), cookie) + return GrabServerCookie{cookie} +} + +func GrabServerChecked(c *xgb.Conn) GrabServerCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(grabServerRequest(c), cookie) + return GrabServerCookie{cookie} +} + +func (cook GrabServerCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for GrabServer +func grabServerRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 36 // request opcode + b += 1 + + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request UngrabServer +// size: 4 +type UngrabServerCookie struct { + *xgb.Cookie +} + +// Write request to wire for UngrabServer +func UngrabServer(c *xgb.Conn) UngrabServerCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(ungrabServerRequest(c), cookie) + return UngrabServerCookie{cookie} +} + +func UngrabServerChecked(c *xgb.Conn) UngrabServerCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(ungrabServerRequest(c), cookie) + return UngrabServerCookie{cookie} +} + +func (cook UngrabServerCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for UngrabServer +func ungrabServerRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 37 // request opcode + b += 1 + + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request QueryPointer +// size: 8 +type QueryPointerCookie struct { + *xgb.Cookie +} + +func QueryPointer(c *xgb.Conn, Window Window) QueryPointerCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryPointerRequest(c, Window), cookie) + return QueryPointerCookie{cookie} +} + +func QueryPointerUnchecked(c *xgb.Conn, Window Window) QueryPointerCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryPointerRequest(c, Window), cookie) + return QueryPointerCookie{cookie} +} + +// Request reply for QueryPointer +// size: 28 +type QueryPointerReply struct { + Sequence uint16 + Length uint32 + SameScreen bool + Root Window + Child Window + RootX int16 + RootY int16 + WinX int16 + WinY int16 + Mask uint16 + // padding: 2 bytes +} + +// Waits and reads reply data from request QueryPointer +func (cook QueryPointerCookie) Reply() (*QueryPointerReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryPointerReply(buf), nil +} + +// Read reply into structure from buffer for QueryPointer +func queryPointerReply(buf []byte) *QueryPointerReply { + v := new(QueryPointerReply) + b := 1 // skip reply determinant + + if buf[b] == 1 { + v.SameScreen = true + } else { + v.SameScreen = false + } + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Root = Window(xgb.Get32(buf[b:])) + b += 4 + + v.Child = Window(xgb.Get32(buf[b:])) + b += 4 + + v.RootX = int16(xgb.Get16(buf[b:])) + b += 2 + + v.RootY = int16(xgb.Get16(buf[b:])) + b += 2 + + v.WinX = int16(xgb.Get16(buf[b:])) + b += 2 + + v.WinY = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Mask = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + return v +} + +// Write request to wire for QueryPointer +func queryPointerRequest(c *xgb.Conn, Window Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 38 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + +// Request GetMotionEvents +// size: 16 +type GetMotionEventsCookie struct { + *xgb.Cookie +} + +func GetMotionEvents(c *xgb.Conn, Window Window, Start Timestamp, Stop Timestamp) GetMotionEventsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getMotionEventsRequest(c, Window, Start, Stop), cookie) + return GetMotionEventsCookie{cookie} +} + +func GetMotionEventsUnchecked(c *xgb.Conn, Window Window, Start Timestamp, Stop Timestamp) GetMotionEventsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getMotionEventsRequest(c, Window, Start, Stop), cookie) + return GetMotionEventsCookie{cookie} +} + +// Request reply for GetMotionEvents +// size: (32 + xgb.Pad((int(EventsLen) * 8))) +type GetMotionEventsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + EventsLen uint32 + // padding: 20 bytes + Events []Timecoord // size: xgb.Pad((int(EventsLen) * 8)) +} + +// Waits and reads reply data from request GetMotionEvents +func (cook GetMotionEventsCookie) Reply() (*GetMotionEventsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getMotionEventsReply(buf), nil +} + +// Read reply into structure from buffer for GetMotionEvents +func getMotionEventsReply(buf []byte) *GetMotionEventsReply { + v := new(GetMotionEventsReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.EventsLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Events = make([]Timecoord, v.EventsLen) + b += TimecoordReadList(buf[b:], v.Events) + + return v +} + +// Write request to wire for GetMotionEvents +func getMotionEventsRequest(c *xgb.Conn, Window Window, Start Timestamp, Stop Timestamp) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 39 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(Start)) + b += 4 + + xgb.Put32(buf[b:], uint32(Stop)) + b += 4 + + return buf +} + +// Request TranslateCoordinates +// size: 16 +type TranslateCoordinatesCookie struct { + *xgb.Cookie +} + +func TranslateCoordinates(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16) TranslateCoordinatesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(translateCoordinatesRequest(c, SrcWindow, DstWindow, SrcX, SrcY), cookie) + return TranslateCoordinatesCookie{cookie} +} + +func TranslateCoordinatesUnchecked(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16) TranslateCoordinatesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(translateCoordinatesRequest(c, SrcWindow, DstWindow, SrcX, SrcY), cookie) + return TranslateCoordinatesCookie{cookie} +} + +// Request reply for TranslateCoordinates +// size: 16 +type TranslateCoordinatesReply struct { + Sequence uint16 + Length uint32 + SameScreen bool + Child Window + DstX int16 + DstY int16 +} + +// Waits and reads reply data from request TranslateCoordinates +func (cook TranslateCoordinatesCookie) Reply() (*TranslateCoordinatesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return translateCoordinatesReply(buf), nil +} + +// Read reply into structure from buffer for TranslateCoordinates +func translateCoordinatesReply(buf []byte) *TranslateCoordinatesReply { + v := new(TranslateCoordinatesReply) + b := 1 // skip reply determinant + + if buf[b] == 1 { + v.SameScreen = true + } else { + v.SameScreen = false + } + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Child = Window(xgb.Get32(buf[b:])) + b += 4 + + v.DstX = int16(xgb.Get16(buf[b:])) + b += 2 + + v.DstY = int16(xgb.Get16(buf[b:])) + b += 2 + + return v +} + +// Write request to wire for TranslateCoordinates +func translateCoordinatesRequest(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 40 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(SrcWindow)) + b += 4 + + xgb.Put32(buf[b:], uint32(DstWindow)) + b += 4 + + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 + + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 + + return buf +} + +// Request WarpPointer +// size: 24 +type WarpPointerCookie struct { + *xgb.Cookie +} + +// Write request to wire for WarpPointer +func WarpPointer(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16) WarpPointerCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(warpPointerRequest(c, SrcWindow, DstWindow, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY), cookie) + return WarpPointerCookie{cookie} +} + +func WarpPointerChecked(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16) WarpPointerCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(warpPointerRequest(c, SrcWindow, DstWindow, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY), cookie) + return WarpPointerCookie{cookie} +} + +func (cook WarpPointerCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for WarpPointer +func warpPointerRequest(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16) []byte { + size := 24 + b := 0 + buf := make([]byte, size) + + buf[b] = 41 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(SrcWindow)) + b += 4 + + xgb.Put32(buf[b:], uint32(DstWindow)) + b += 4 + + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 + + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 + + xgb.Put16(buf[b:], SrcWidth) + b += 2 + + xgb.Put16(buf[b:], SrcHeight) + b += 2 + + xgb.Put16(buf[b:], uint16(DstX)) + b += 2 + + xgb.Put16(buf[b:], uint16(DstY)) + b += 2 + + return buf +} + +// Request SetInputFocus +// size: 12 +type SetInputFocusCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetInputFocus +func SetInputFocus(c *xgb.Conn, RevertTo byte, Focus Window, Time Timestamp) SetInputFocusCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setInputFocusRequest(c, RevertTo, Focus, Time), cookie) + return SetInputFocusCookie{cookie} +} + +func SetInputFocusChecked(c *xgb.Conn, RevertTo byte, Focus Window, Time Timestamp) SetInputFocusCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setInputFocusRequest(c, RevertTo, Focus, Time), cookie) + return SetInputFocusCookie{cookie} +} + +func (cook SetInputFocusCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetInputFocus +func setInputFocusRequest(c *xgb.Conn, RevertTo byte, Focus Window, Time Timestamp) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = 42 // request opcode + b += 1 + + buf[b] = RevertTo + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Focus)) + b += 4 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + return buf +} + +// Request GetInputFocus +// size: 4 +type GetInputFocusCookie struct { + *xgb.Cookie +} + +func GetInputFocus(c *xgb.Conn) GetInputFocusCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getInputFocusRequest(c), cookie) + return GetInputFocusCookie{cookie} +} + +func GetInputFocusUnchecked(c *xgb.Conn) GetInputFocusCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getInputFocusRequest(c), cookie) + return GetInputFocusCookie{cookie} +} + +// Request reply for GetInputFocus +// size: 12 +type GetInputFocusReply struct { + Sequence uint16 + Length uint32 + RevertTo byte + Focus Window +} + +// Waits and reads reply data from request GetInputFocus +func (cook GetInputFocusCookie) Reply() (*GetInputFocusReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getInputFocusReply(buf), nil +} + +// Read reply into structure from buffer for GetInputFocus +func getInputFocusReply(buf []byte) *GetInputFocusReply { + v := new(GetInputFocusReply) + b := 1 // skip reply determinant + + v.RevertTo = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Focus = Window(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Write request to wire for GetInputFocus +func getInputFocusRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 43 // request opcode + b += 1 + + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request QueryKeymap +// size: 4 +type QueryKeymapCookie struct { + *xgb.Cookie +} + +func QueryKeymap(c *xgb.Conn) QueryKeymapCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryKeymapRequest(c), cookie) + return QueryKeymapCookie{cookie} +} + +func QueryKeymapUnchecked(c *xgb.Conn) QueryKeymapCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryKeymapRequest(c), cookie) + return QueryKeymapCookie{cookie} +} + +// Request reply for QueryKeymap +// size: 40 +type QueryKeymapReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Keys []byte // size: 32 +} + +// Waits and reads reply data from request QueryKeymap +func (cook QueryKeymapCookie) Reply() (*QueryKeymapReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryKeymapReply(buf), nil +} + +// Read reply into structure from buffer for QueryKeymap +func queryKeymapReply(buf []byte) *QueryKeymapReply { + v := new(QueryKeymapReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Keys = make([]byte, 32) + copy(v.Keys[:32], buf[b:]) + b += xgb.Pad(int(32)) + + return v +} + +// Write request to wire for QueryKeymap +func queryKeymapRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 44 // request opcode + b += 1 + + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request OpenFont +// size: xgb.Pad((12 + xgb.Pad((int(NameLen) * 1)))) +type OpenFontCookie struct { + *xgb.Cookie +} + +// Write request to wire for OpenFont +func OpenFont(c *xgb.Conn, Fid Font, NameLen uint16, Name string) OpenFontCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(openFontRequest(c, Fid, NameLen, Name), cookie) + return OpenFontCookie{cookie} +} + +func OpenFontChecked(c *xgb.Conn, Fid Font, NameLen uint16, Name string) OpenFontCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(openFontRequest(c, Fid, NameLen, Name), cookie) + return OpenFontCookie{cookie} +} + +func (cook OpenFontCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for OpenFont +func openFontRequest(c *xgb.Conn, Fid Font, NameLen uint16, Name string) []byte { + size := xgb.Pad((12 + xgb.Pad((int(NameLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 45 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Fid)) + b += 4 + + xgb.Put16(buf[b:], NameLen) + b += 2 + + b += 2 // padding + + copy(buf[b:], Name[:NameLen]) + b += xgb.Pad(int(NameLen)) + + return buf +} + +// Request CloseFont +// size: 8 +type CloseFontCookie struct { + *xgb.Cookie +} + +// Write request to wire for CloseFont +func CloseFont(c *xgb.Conn, Font Font) CloseFontCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(closeFontRequest(c, Font), cookie) + return CloseFontCookie{cookie} +} + +func CloseFontChecked(c *xgb.Conn, Font Font) CloseFontCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(closeFontRequest(c, Font), cookie) + return CloseFontCookie{cookie} +} + +func (cook CloseFontCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CloseFont +func closeFontRequest(c *xgb.Conn, Font Font) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 46 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Font)) + b += 4 + + return buf +} + +// Request QueryFont +// size: 8 +type QueryFontCookie struct { + *xgb.Cookie +} + +func QueryFont(c *xgb.Conn, Font Fontable) QueryFontCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryFontRequest(c, Font), cookie) + return QueryFontCookie{cookie} +} + +func QueryFontUnchecked(c *xgb.Conn, Font Fontable) QueryFontCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryFontRequest(c, Font), cookie) + return QueryFontCookie{cookie} +} + +// Request reply for QueryFont +// size: ((60 + xgb.Pad((int(PropertiesLen) * 8))) + xgb.Pad((int(CharInfosLen) * 12))) +type QueryFontReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + MinBounds Charinfo + // padding: 4 bytes + MaxBounds Charinfo + // padding: 4 bytes + MinCharOrByte2 uint16 + MaxCharOrByte2 uint16 + DefaultChar uint16 + PropertiesLen uint16 + DrawDirection byte + MinByte1 byte + MaxByte1 byte + AllCharsExist bool + FontAscent int16 + FontDescent int16 + CharInfosLen uint32 + Properties []Fontprop // size: xgb.Pad((int(PropertiesLen) * 8)) + CharInfos []Charinfo // size: xgb.Pad((int(CharInfosLen) * 12)) +} + +// Waits and reads reply data from request QueryFont +func (cook QueryFontCookie) Reply() (*QueryFontReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryFontReply(buf), nil +} + +// Read reply into structure from buffer for QueryFont +func queryFontReply(buf []byte) *QueryFontReply { + v := new(QueryFontReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.MinBounds = Charinfo{} + b += CharinfoRead(buf[b:], &v.MinBounds) + + b += 4 // padding + + v.MaxBounds = Charinfo{} + b += CharinfoRead(buf[b:], &v.MaxBounds) + + b += 4 // padding + + v.MinCharOrByte2 = xgb.Get16(buf[b:]) + b += 2 + + v.MaxCharOrByte2 = xgb.Get16(buf[b:]) + b += 2 + + v.DefaultChar = xgb.Get16(buf[b:]) + b += 2 + + v.PropertiesLen = xgb.Get16(buf[b:]) + b += 2 + + v.DrawDirection = buf[b] + b += 1 + + v.MinByte1 = buf[b] + b += 1 + + v.MaxByte1 = buf[b] + b += 1 + + if buf[b] == 1 { + v.AllCharsExist = true + } else { + v.AllCharsExist = false + } + b += 1 + + v.FontAscent = int16(xgb.Get16(buf[b:])) + b += 2 + + v.FontDescent = int16(xgb.Get16(buf[b:])) + b += 2 + + v.CharInfosLen = xgb.Get32(buf[b:]) + b += 4 + + v.Properties = make([]Fontprop, v.PropertiesLen) + b += FontpropReadList(buf[b:], v.Properties) + + v.CharInfos = make([]Charinfo, v.CharInfosLen) + b += CharinfoReadList(buf[b:], v.CharInfos) + + return v +} + +// Write request to wire for QueryFont +func queryFontRequest(c *xgb.Conn, Font Fontable) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 47 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Font)) + b += 4 + + return buf +} + +// Request QueryTextExtents +// size: xgb.Pad((8 + xgb.Pad((len(String) * 2)))) +type QueryTextExtentsCookie struct { + *xgb.Cookie +} + +func QueryTextExtents(c *xgb.Conn, Font Fontable, String []Char2b, StringLen uint16) QueryTextExtentsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryTextExtentsRequest(c, Font, String, StringLen), cookie) + return QueryTextExtentsCookie{cookie} +} + +func QueryTextExtentsUnchecked(c *xgb.Conn, Font Fontable, String []Char2b, StringLen uint16) QueryTextExtentsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryTextExtentsRequest(c, Font, String, StringLen), cookie) + return QueryTextExtentsCookie{cookie} +} + +// Request reply for QueryTextExtents +// size: 28 +type QueryTextExtentsReply struct { + Sequence uint16 + Length uint32 + DrawDirection byte + FontAscent int16 + FontDescent int16 + OverallAscent int16 + OverallDescent int16 + OverallWidth int32 + OverallLeft int32 + OverallRight int32 +} + +// Waits and reads reply data from request QueryTextExtents +func (cook QueryTextExtentsCookie) Reply() (*QueryTextExtentsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryTextExtentsReply(buf), nil +} + +// Read reply into structure from buffer for QueryTextExtents +func queryTextExtentsReply(buf []byte) *QueryTextExtentsReply { + v := new(QueryTextExtentsReply) + b := 1 // skip reply determinant + + v.DrawDirection = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.FontAscent = int16(xgb.Get16(buf[b:])) + b += 2 + + v.FontDescent = int16(xgb.Get16(buf[b:])) + b += 2 + + v.OverallAscent = int16(xgb.Get16(buf[b:])) + b += 2 + + v.OverallDescent = int16(xgb.Get16(buf[b:])) + b += 2 + + v.OverallWidth = int32(xgb.Get32(buf[b:])) + b += 4 + + v.OverallLeft = int32(xgb.Get32(buf[b:])) + b += 4 + + v.OverallRight = int32(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Write request to wire for QueryTextExtents +func queryTextExtentsRequest(c *xgb.Conn, Font Fontable, String []Char2b, StringLen uint16) []byte { + size := xgb.Pad((8 + xgb.Pad((len(String) * 2)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 48 // request opcode + b += 1 + + buf[b] = byte((int(StringLen) & 1)) + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Font)) + b += 4 + + b += Char2bListBytes(buf[b:], String) + + // skip writing local field: StringLen (2) :: uint16 + + return buf +} + +// Request ListFonts +// size: xgb.Pad((8 + xgb.Pad((int(PatternLen) * 1)))) +type ListFontsCookie struct { + *xgb.Cookie +} + +func ListFonts(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) ListFontsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(listFontsRequest(c, MaxNames, PatternLen, Pattern), cookie) + return ListFontsCookie{cookie} +} + +func ListFontsUnchecked(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) ListFontsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(listFontsRequest(c, MaxNames, PatternLen, Pattern), cookie) + return ListFontsCookie{cookie} +} + +// Request reply for ListFonts +// size: (32 + StrListSize(Names)) +type ListFontsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NamesLen uint16 + // padding: 22 bytes + Names []Str // size: StrListSize(Names) +} + +// Waits and reads reply data from request ListFonts +func (cook ListFontsCookie) Reply() (*ListFontsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listFontsReply(buf), nil +} + +// Read reply into structure from buffer for ListFonts +func listFontsReply(buf []byte) *ListFontsReply { + v := new(ListFontsReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NamesLen = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + v.Names = make([]Str, v.NamesLen) + b += StrReadList(buf[b:], v.Names) + + return v +} + +// Write request to wire for ListFonts +func listFontsRequest(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(PatternLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 49 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], MaxNames) + b += 2 + + xgb.Put16(buf[b:], PatternLen) + b += 2 + + copy(buf[b:], Pattern[:PatternLen]) + b += xgb.Pad(int(PatternLen)) + + return buf +} + +// Request ListFontsWithInfo +// size: xgb.Pad((8 + xgb.Pad((int(PatternLen) * 1)))) +type ListFontsWithInfoCookie struct { + *xgb.Cookie +} + +func ListFontsWithInfo(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) ListFontsWithInfoCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(listFontsWithInfoRequest(c, MaxNames, PatternLen, Pattern), cookie) + return ListFontsWithInfoCookie{cookie} +} + +func ListFontsWithInfoUnchecked(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) ListFontsWithInfoCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(listFontsWithInfoRequest(c, MaxNames, PatternLen, Pattern), cookie) + return ListFontsWithInfoCookie{cookie} +} + +// Request reply for ListFontsWithInfo +// size: ((60 + xgb.Pad((int(PropertiesLen) * 8))) + xgb.Pad((int(NameLen) * 1))) +type ListFontsWithInfoReply struct { + Sequence uint16 + Length uint32 + NameLen byte + MinBounds Charinfo + // padding: 4 bytes + MaxBounds Charinfo + // padding: 4 bytes + MinCharOrByte2 uint16 + MaxCharOrByte2 uint16 + DefaultChar uint16 + PropertiesLen uint16 + DrawDirection byte + MinByte1 byte + MaxByte1 byte + AllCharsExist bool + FontAscent int16 + FontDescent int16 + RepliesHint uint32 + Properties []Fontprop // size: xgb.Pad((int(PropertiesLen) * 8)) + Name string // size: xgb.Pad((int(NameLen) * 1)) +} + +// Waits and reads reply data from request ListFontsWithInfo +func (cook ListFontsWithInfoCookie) Reply() (*ListFontsWithInfoReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listFontsWithInfoReply(buf), nil +} + +// Read reply into structure from buffer for ListFontsWithInfo +func listFontsWithInfoReply(buf []byte) *ListFontsWithInfoReply { + v := new(ListFontsWithInfoReply) + b := 1 // skip reply determinant + + v.NameLen = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.MinBounds = Charinfo{} + b += CharinfoRead(buf[b:], &v.MinBounds) + + b += 4 // padding + + v.MaxBounds = Charinfo{} + b += CharinfoRead(buf[b:], &v.MaxBounds) + + b += 4 // padding + + v.MinCharOrByte2 = xgb.Get16(buf[b:]) + b += 2 + + v.MaxCharOrByte2 = xgb.Get16(buf[b:]) + b += 2 + + v.DefaultChar = xgb.Get16(buf[b:]) + b += 2 + + v.PropertiesLen = xgb.Get16(buf[b:]) + b += 2 + + v.DrawDirection = buf[b] + b += 1 + + v.MinByte1 = buf[b] + b += 1 + + v.MaxByte1 = buf[b] + b += 1 + + if buf[b] == 1 { + v.AllCharsExist = true + } else { + v.AllCharsExist = false + } + b += 1 + + v.FontAscent = int16(xgb.Get16(buf[b:])) + b += 2 + + v.FontDescent = int16(xgb.Get16(buf[b:])) + b += 2 + + v.RepliesHint = xgb.Get32(buf[b:]) + b += 4 + + v.Properties = make([]Fontprop, v.PropertiesLen) + b += FontpropReadList(buf[b:], v.Properties) + + { + byteString := make([]byte, v.NameLen) + copy(byteString[:v.NameLen], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.NameLen)) + } + + return v +} + +// Write request to wire for ListFontsWithInfo +func listFontsWithInfoRequest(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(PatternLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 50 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], MaxNames) + b += 2 + + xgb.Put16(buf[b:], PatternLen) + b += 2 + + copy(buf[b:], Pattern[:PatternLen]) + b += xgb.Pad(int(PatternLen)) + + return buf +} + +// Request SetFontPath +// size: xgb.Pad((8 + StrListSize(Font))) +type SetFontPathCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetFontPath +func SetFontPath(c *xgb.Conn, FontQty uint16, Font []Str) SetFontPathCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setFontPathRequest(c, FontQty, Font), cookie) + return SetFontPathCookie{cookie} +} + +func SetFontPathChecked(c *xgb.Conn, FontQty uint16, Font []Str) SetFontPathCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setFontPathRequest(c, FontQty, Font), cookie) + return SetFontPathCookie{cookie} +} + +func (cook SetFontPathCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetFontPath +func setFontPathRequest(c *xgb.Conn, FontQty uint16, Font []Str) []byte { + size := xgb.Pad((8 + StrListSize(Font))) + b := 0 + buf := make([]byte, size) + + buf[b] = 51 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], FontQty) + b += 2 + + b += 2 // padding + + b += StrListBytes(buf[b:], Font) + + return buf +} + +// Request GetFontPath +// size: 4 +type GetFontPathCookie struct { + *xgb.Cookie +} + +func GetFontPath(c *xgb.Conn) GetFontPathCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getFontPathRequest(c), cookie) + return GetFontPathCookie{cookie} +} + +func GetFontPathUnchecked(c *xgb.Conn) GetFontPathCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getFontPathRequest(c), cookie) + return GetFontPathCookie{cookie} +} + +// Request reply for GetFontPath +// size: (32 + StrListSize(Path)) +type GetFontPathReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + PathLen uint16 + // padding: 22 bytes + Path []Str // size: StrListSize(Path) +} + +// Waits and reads reply data from request GetFontPath +func (cook GetFontPathCookie) Reply() (*GetFontPathReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getFontPathReply(buf), nil +} + +// Read reply into structure from buffer for GetFontPath +func getFontPathReply(buf []byte) *GetFontPathReply { + v := new(GetFontPathReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.PathLen = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + v.Path = make([]Str, v.PathLen) + b += StrReadList(buf[b:], v.Path) + + return v +} + +// Write request to wire for GetFontPath +func getFontPathRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 52 // request opcode + b += 1 + + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request CreatePixmap +// size: 16 +type CreatePixmapCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreatePixmap +func CreatePixmap(c *xgb.Conn, Depth byte, Pid Pixmap, Drawable Drawable, Width uint16, Height uint16) CreatePixmapCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createPixmapRequest(c, Depth, Pid, Drawable, Width, Height), cookie) + return CreatePixmapCookie{cookie} +} + +func CreatePixmapChecked(c *xgb.Conn, Depth byte, Pid Pixmap, Drawable Drawable, Width uint16, Height uint16) CreatePixmapCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createPixmapRequest(c, Depth, Pid, Drawable, Width, Height), cookie) + return CreatePixmapCookie{cookie} +} + +func (cook CreatePixmapCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreatePixmap +func createPixmapRequest(c *xgb.Conn, Depth byte, Pid Pixmap, Drawable Drawable, Width uint16, Height uint16) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 53 // request opcode + b += 1 + + buf[b] = Depth + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Pid)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + return buf +} + +// Request FreePixmap +// size: 8 +type FreePixmapCookie struct { + *xgb.Cookie +} + +// Write request to wire for FreePixmap +func FreePixmap(c *xgb.Conn, Pixmap Pixmap) FreePixmapCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(freePixmapRequest(c, Pixmap), cookie) + return FreePixmapCookie{cookie} +} + +func FreePixmapChecked(c *xgb.Conn, Pixmap Pixmap) FreePixmapCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(freePixmapRequest(c, Pixmap), cookie) + return FreePixmapCookie{cookie} +} + +func (cook FreePixmapCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for FreePixmap +func freePixmapRequest(c *xgb.Conn, Pixmap Pixmap) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 54 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Pixmap)) + b += 4 + + return buf +} + +// Request CreateGC +// size: xgb.Pad((12 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +type CreateGCCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateGC +func CreateGC(c *xgb.Conn, Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) CreateGCCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createGCRequest(c, Cid, Drawable, ValueMask, ValueList), cookie) + return CreateGCCookie{cookie} +} + +func CreateGCChecked(c *xgb.Conn, Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) CreateGCCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createGCRequest(c, Cid, Drawable, ValueMask, ValueList), cookie) + return CreateGCCookie{cookie} +} + +func (cook CreateGCCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateGC +func createGCRequest(c *xgb.Conn, Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) []byte { + size := xgb.Pad((12 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) + b := 0 + buf := make([]byte, size) + + buf[b] = 55 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cid)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], ValueMask) + b += 4 + for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { + xgb.Put32(buf[b:], ValueList[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request ChangeGC +// size: xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +type ChangeGCCookie struct { + *xgb.Cookie +} + +// Write request to wire for ChangeGC +func ChangeGC(c *xgb.Conn, Gc Gcontext, ValueMask uint32, ValueList []uint32) ChangeGCCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeGCRequest(c, Gc, ValueMask, ValueList), cookie) + return ChangeGCCookie{cookie} +} + +func ChangeGCChecked(c *xgb.Conn, Gc Gcontext, ValueMask uint32, ValueList []uint32) ChangeGCCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeGCRequest(c, Gc, ValueMask, ValueList), cookie) + return ChangeGCCookie{cookie} +} + +func (cook ChangeGCCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangeGC +func changeGCRequest(c *xgb.Conn, Gc Gcontext, ValueMask uint32, ValueList []uint32) []byte { + size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) + b := 0 + buf := make([]byte, size) + + buf[b] = 56 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put32(buf[b:], ValueMask) + b += 4 + for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { + xgb.Put32(buf[b:], ValueList[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request CopyGC +// size: 16 +type CopyGCCookie struct { + *xgb.Cookie +} + +// Write request to wire for CopyGC +func CopyGC(c *xgb.Conn, SrcGc Gcontext, DstGc Gcontext, ValueMask uint32) CopyGCCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(copyGCRequest(c, SrcGc, DstGc, ValueMask), cookie) + return CopyGCCookie{cookie} +} + +func CopyGCChecked(c *xgb.Conn, SrcGc Gcontext, DstGc Gcontext, ValueMask uint32) CopyGCCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(copyGCRequest(c, SrcGc, DstGc, ValueMask), cookie) + return CopyGCCookie{cookie} +} + +func (cook CopyGCCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CopyGC +func copyGCRequest(c *xgb.Conn, SrcGc Gcontext, DstGc Gcontext, ValueMask uint32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 57 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(SrcGc)) + b += 4 + + xgb.Put32(buf[b:], uint32(DstGc)) + b += 4 + + xgb.Put32(buf[b:], ValueMask) + b += 4 + + return buf +} + +// Request SetDashes +// size: xgb.Pad((12 + xgb.Pad((int(DashesLen) * 1)))) +type SetDashesCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetDashes +func SetDashes(c *xgb.Conn, Gc Gcontext, DashOffset uint16, DashesLen uint16, Dashes []byte) SetDashesCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setDashesRequest(c, Gc, DashOffset, DashesLen, Dashes), cookie) + return SetDashesCookie{cookie} +} + +func SetDashesChecked(c *xgb.Conn, Gc Gcontext, DashOffset uint16, DashesLen uint16, Dashes []byte) SetDashesCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setDashesRequest(c, Gc, DashOffset, DashesLen, Dashes), cookie) + return SetDashesCookie{cookie} +} + +func (cook SetDashesCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetDashes +func setDashesRequest(c *xgb.Conn, Gc Gcontext, DashOffset uint16, DashesLen uint16, Dashes []byte) []byte { + size := xgb.Pad((12 + xgb.Pad((int(DashesLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 58 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put16(buf[b:], DashOffset) + b += 2 + + xgb.Put16(buf[b:], DashesLen) + b += 2 + + copy(buf[b:], Dashes[:DashesLen]) + b += xgb.Pad(int(DashesLen)) + + return buf +} + +// Request SetClipRectangles +// size: xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) +type SetClipRectanglesCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetClipRectangles +func SetClipRectangles(c *xgb.Conn, Ordering byte, Gc Gcontext, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) SetClipRectanglesCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setClipRectanglesRequest(c, Ordering, Gc, ClipXOrigin, ClipYOrigin, Rectangles), cookie) + return SetClipRectanglesCookie{cookie} +} + +func SetClipRectanglesChecked(c *xgb.Conn, Ordering byte, Gc Gcontext, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) SetClipRectanglesCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setClipRectanglesRequest(c, Ordering, Gc, ClipXOrigin, ClipYOrigin, Rectangles), cookie) + return SetClipRectanglesCookie{cookie} +} + +func (cook SetClipRectanglesCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetClipRectangles +func setClipRectanglesRequest(c *xgb.Conn, Ordering byte, Gc Gcontext, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 59 // request opcode + b += 1 + + buf[b] = Ordering + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put16(buf[b:], uint16(ClipXOrigin)) + b += 2 + + xgb.Put16(buf[b:], uint16(ClipYOrigin)) + b += 2 + + b += RectangleListBytes(buf[b:], Rectangles) + + return buf +} + +// Request FreeGC +// size: 8 +type FreeGCCookie struct { + *xgb.Cookie +} + +// Write request to wire for FreeGC +func FreeGC(c *xgb.Conn, Gc Gcontext) FreeGCCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(freeGCRequest(c, Gc), cookie) + return FreeGCCookie{cookie} +} + +func FreeGCChecked(c *xgb.Conn, Gc Gcontext) FreeGCCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(freeGCRequest(c, Gc), cookie) + return FreeGCCookie{cookie} +} + +func (cook FreeGCCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for FreeGC +func freeGCRequest(c *xgb.Conn, Gc Gcontext) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 60 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + return buf +} + +// Request ClearArea +// size: 16 +type ClearAreaCookie struct { + *xgb.Cookie +} + +// Write request to wire for ClearArea +func ClearArea(c *xgb.Conn, Exposures bool, Window Window, X int16, Y int16, Width uint16, Height uint16) ClearAreaCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(clearAreaRequest(c, Exposures, Window, X, Y, Width, Height), cookie) + return ClearAreaCookie{cookie} +} + +func ClearAreaChecked(c *xgb.Conn, Exposures bool, Window Window, X int16, Y int16, Width uint16, Height uint16) ClearAreaCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(clearAreaRequest(c, Exposures, Window, X, Y, Width, Height), cookie) + return ClearAreaCookie{cookie} +} + +func (cook ClearAreaCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ClearArea +func clearAreaRequest(c *xgb.Conn, Exposures bool, Window Window, X int16, Y int16, Width uint16, Height uint16) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 61 // request opcode + b += 1 + + if Exposures { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put16(buf[b:], uint16(X)) + b += 2 + + xgb.Put16(buf[b:], uint16(Y)) + b += 2 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + return buf +} + +// Request CopyArea +// size: 28 +type CopyAreaCookie struct { + *xgb.Cookie +} + +// Write request to wire for CopyArea +func CopyArea(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16) CopyAreaCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(copyAreaRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height), cookie) + return CopyAreaCookie{cookie} +} + +func CopyAreaChecked(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16) CopyAreaCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(copyAreaRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height), cookie) + return CopyAreaCookie{cookie} +} + +func (cook CopyAreaCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CopyArea +func copyAreaRequest(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16) []byte { + size := 28 + b := 0 + buf := make([]byte, size) + + buf[b] = 62 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(SrcDrawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(DstDrawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 + + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 + + xgb.Put16(buf[b:], uint16(DstX)) + b += 2 + + xgb.Put16(buf[b:], uint16(DstY)) + b += 2 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + return buf +} + +// Request CopyPlane +// size: 32 +type CopyPlaneCookie struct { + *xgb.Cookie +} + +// Write request to wire for CopyPlane +func CopyPlane(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16, BitPlane uint32) CopyPlaneCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(copyPlaneRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height, BitPlane), cookie) + return CopyPlaneCookie{cookie} +} + +func CopyPlaneChecked(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16, BitPlane uint32) CopyPlaneCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(copyPlaneRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height, BitPlane), cookie) + return CopyPlaneCookie{cookie} +} + +func (cook CopyPlaneCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CopyPlane +func copyPlaneRequest(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16, BitPlane uint32) []byte { + size := 32 + b := 0 + buf := make([]byte, size) + + buf[b] = 63 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(SrcDrawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(DstDrawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 + + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 + + xgb.Put16(buf[b:], uint16(DstX)) + b += 2 + + xgb.Put16(buf[b:], uint16(DstY)) + b += 2 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + xgb.Put32(buf[b:], BitPlane) + b += 4 + + return buf +} + +// Request PolyPoint +// size: xgb.Pad((12 + xgb.Pad((len(Points) * 4)))) +type PolyPointCookie struct { + *xgb.Cookie +} + +// Write request to wire for PolyPoint +func PolyPoint(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyPointCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(polyPointRequest(c, CoordinateMode, Drawable, Gc, Points), cookie) + return PolyPointCookie{cookie} +} + +func PolyPointChecked(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyPointCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(polyPointRequest(c, CoordinateMode, Drawable, Gc, Points), cookie) + return PolyPointCookie{cookie} +} + +func (cook PolyPointCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PolyPoint +func polyPointRequest(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Points) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 64 // request opcode + b += 1 + + buf[b] = CoordinateMode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + b += PointListBytes(buf[b:], Points) + + return buf +} + +// Request PolyLine +// size: xgb.Pad((12 + xgb.Pad((len(Points) * 4)))) +type PolyLineCookie struct { + *xgb.Cookie +} + +// Write request to wire for PolyLine +func PolyLine(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyLineCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(polyLineRequest(c, CoordinateMode, Drawable, Gc, Points), cookie) + return PolyLineCookie{cookie} +} + +func PolyLineChecked(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyLineCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(polyLineRequest(c, CoordinateMode, Drawable, Gc, Points), cookie) + return PolyLineCookie{cookie} +} + +func (cook PolyLineCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PolyLine +func polyLineRequest(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Points) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 65 // request opcode + b += 1 + + buf[b] = CoordinateMode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + b += PointListBytes(buf[b:], Points) + + return buf +} + +// Request PolySegment +// size: xgb.Pad((12 + xgb.Pad((len(Segments) * 8)))) +type PolySegmentCookie struct { + *xgb.Cookie +} + +// Write request to wire for PolySegment +func PolySegment(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Segments []Segment) PolySegmentCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(polySegmentRequest(c, Drawable, Gc, Segments), cookie) + return PolySegmentCookie{cookie} +} + +func PolySegmentChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Segments []Segment) PolySegmentCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(polySegmentRequest(c, Drawable, Gc, Segments), cookie) + return PolySegmentCookie{cookie} +} + +func (cook PolySegmentCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PolySegment +func polySegmentRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Segments []Segment) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Segments) * 8)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 66 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + b += SegmentListBytes(buf[b:], Segments) + + return buf +} + +// Request PolyRectangle +// size: xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) +type PolyRectangleCookie struct { + *xgb.Cookie +} + +// Write request to wire for PolyRectangle +func PolyRectangle(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyRectangleCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(polyRectangleRequest(c, Drawable, Gc, Rectangles), cookie) + return PolyRectangleCookie{cookie} +} + +func PolyRectangleChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyRectangleCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(polyRectangleRequest(c, Drawable, Gc, Rectangles), cookie) + return PolyRectangleCookie{cookie} +} + +func (cook PolyRectangleCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PolyRectangle +func polyRectangleRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 67 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + b += RectangleListBytes(buf[b:], Rectangles) + + return buf +} + +// Request PolyArc +// size: xgb.Pad((12 + xgb.Pad((len(Arcs) * 12)))) +type PolyArcCookie struct { + *xgb.Cookie +} + +// Write request to wire for PolyArc +func PolyArc(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyArcCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(polyArcRequest(c, Drawable, Gc, Arcs), cookie) + return PolyArcCookie{cookie} +} + +func PolyArcChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyArcCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(polyArcRequest(c, Drawable, Gc, Arcs), cookie) + return PolyArcCookie{cookie} +} + +func (cook PolyArcCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PolyArc +func polyArcRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Arcs) * 12)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 68 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + b += ArcListBytes(buf[b:], Arcs) + + return buf +} + +// Request FillPoly +// size: xgb.Pad((16 + xgb.Pad((len(Points) * 4)))) +type FillPolyCookie struct { + *xgb.Cookie +} + +// Write request to wire for FillPoly +func FillPoly(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Shape byte, CoordinateMode byte, Points []Point) FillPolyCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(fillPolyRequest(c, Drawable, Gc, Shape, CoordinateMode, Points), cookie) + return FillPolyCookie{cookie} +} + +func FillPolyChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Shape byte, CoordinateMode byte, Points []Point) FillPolyCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(fillPolyRequest(c, Drawable, Gc, Shape, CoordinateMode, Points), cookie) + return FillPolyCookie{cookie} +} + +func (cook FillPolyCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for FillPoly +func fillPolyRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Shape byte, CoordinateMode byte, Points []Point) []byte { + size := xgb.Pad((16 + xgb.Pad((len(Points) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 69 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + buf[b] = Shape + b += 1 + + buf[b] = CoordinateMode + b += 1 + + b += 2 // padding + + b += PointListBytes(buf[b:], Points) + + return buf +} + +// Request PolyFillRectangle +// size: xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) +type PolyFillRectangleCookie struct { + *xgb.Cookie +} + +// Write request to wire for PolyFillRectangle +func PolyFillRectangle(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyFillRectangleCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(polyFillRectangleRequest(c, Drawable, Gc, Rectangles), cookie) + return PolyFillRectangleCookie{cookie} +} + +func PolyFillRectangleChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyFillRectangleCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(polyFillRectangleRequest(c, Drawable, Gc, Rectangles), cookie) + return PolyFillRectangleCookie{cookie} +} + +func (cook PolyFillRectangleCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PolyFillRectangle +func polyFillRectangleRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 70 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + b += RectangleListBytes(buf[b:], Rectangles) + + return buf +} + +// Request PolyFillArc +// size: xgb.Pad((12 + xgb.Pad((len(Arcs) * 12)))) +type PolyFillArcCookie struct { + *xgb.Cookie +} + +// Write request to wire for PolyFillArc +func PolyFillArc(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyFillArcCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(polyFillArcRequest(c, Drawable, Gc, Arcs), cookie) + return PolyFillArcCookie{cookie} +} + +func PolyFillArcChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyFillArcCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(polyFillArcRequest(c, Drawable, Gc, Arcs), cookie) + return PolyFillArcCookie{cookie} +} + +func (cook PolyFillArcCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PolyFillArc +func polyFillArcRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Arcs) * 12)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 71 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + b += ArcListBytes(buf[b:], Arcs) + + return buf +} + +// Request PutImage +// size: xgb.Pad((24 + xgb.Pad((len(Data) * 1)))) +type PutImageCookie struct { + *xgb.Cookie +} + +// Write request to wire for PutImage +func PutImage(c *xgb.Conn, Format byte, Drawable Drawable, Gc Gcontext, Width uint16, Height uint16, DstX int16, DstY int16, LeftPad byte, Depth byte, Data []byte) PutImageCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(putImageRequest(c, Format, Drawable, Gc, Width, Height, DstX, DstY, LeftPad, Depth, Data), cookie) + return PutImageCookie{cookie} +} + +func PutImageChecked(c *xgb.Conn, Format byte, Drawable Drawable, Gc Gcontext, Width uint16, Height uint16, DstX int16, DstY int16, LeftPad byte, Depth byte, Data []byte) PutImageCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(putImageRequest(c, Format, Drawable, Gc, Width, Height, DstX, DstY, LeftPad, Depth, Data), cookie) + return PutImageCookie{cookie} +} + +func (cook PutImageCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PutImage +func putImageRequest(c *xgb.Conn, Format byte, Drawable Drawable, Gc Gcontext, Width uint16, Height uint16, DstX int16, DstY int16, LeftPad byte, Depth byte, Data []byte) []byte { + size := xgb.Pad((24 + xgb.Pad((len(Data) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 72 // request opcode + b += 1 + + buf[b] = Format + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + xgb.Put16(buf[b:], uint16(DstX)) + b += 2 + + xgb.Put16(buf[b:], uint16(DstY)) + b += 2 + + buf[b] = LeftPad + b += 1 + + buf[b] = Depth + b += 1 + + b += 2 // padding + + copy(buf[b:], Data[:len(Data)]) + b += xgb.Pad(int(len(Data))) + + return buf +} + +// Request GetImage +// size: 20 +type GetImageCookie struct { + *xgb.Cookie +} + +func GetImage(c *xgb.Conn, Format byte, Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32) GetImageCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getImageRequest(c, Format, Drawable, X, Y, Width, Height, PlaneMask), cookie) + return GetImageCookie{cookie} +} + +func GetImageUnchecked(c *xgb.Conn, Format byte, Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32) GetImageCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getImageRequest(c, Format, Drawable, X, Y, Width, Height, PlaneMask), cookie) + return GetImageCookie{cookie} +} + +// Request reply for GetImage +// size: (32 + xgb.Pad(((int(Length) * 4) * 1))) +type GetImageReply struct { + Sequence uint16 + Length uint32 + Depth byte + Visual Visualid + // padding: 20 bytes + Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) +} + +// Waits and reads reply data from request GetImage +func (cook GetImageCookie) Reply() (*GetImageReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getImageReply(buf), nil +} + +// Read reply into structure from buffer for GetImage +func getImageReply(buf []byte) *GetImageReply { + v := new(GetImageReply) + b := 1 // skip reply determinant + + v.Depth = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Visual = Visualid(xgb.Get32(buf[b:])) + b += 4 + + b += 20 // padding + + v.Data = make([]byte, (int(v.Length) * 4)) + copy(v.Data[:(int(v.Length)*4)], buf[b:]) + b += xgb.Pad(int((int(v.Length) * 4))) + + return v +} + +// Write request to wire for GetImage +func getImageRequest(c *xgb.Conn, Format byte, Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32) []byte { + size := 20 + b := 0 + buf := make([]byte, size) + + buf[b] = 73 // request opcode + b += 1 + + buf[b] = Format + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put16(buf[b:], uint16(X)) + b += 2 + + xgb.Put16(buf[b:], uint16(Y)) + b += 2 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + xgb.Put32(buf[b:], PlaneMask) + b += 4 + + return buf +} + +// Request PolyText8 +// size: xgb.Pad((16 + xgb.Pad((len(Items) * 1)))) +type PolyText8Cookie struct { + *xgb.Cookie +} + +// Write request to wire for PolyText8 +func PolyText8(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText8Cookie { + cookie := c.NewCookie(false, false) + c.NewRequest(polyText8Request(c, Drawable, Gc, X, Y, Items), cookie) + return PolyText8Cookie{cookie} +} + +func PolyText8Checked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText8Cookie { + cookie := c.NewCookie(true, false) + c.NewRequest(polyText8Request(c, Drawable, Gc, X, Y, Items), cookie) + return PolyText8Cookie{cookie} +} + +func (cook PolyText8Cookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PolyText8 +func polyText8Request(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) []byte { + size := xgb.Pad((16 + xgb.Pad((len(Items) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 74 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put16(buf[b:], uint16(X)) + b += 2 + + xgb.Put16(buf[b:], uint16(Y)) + b += 2 + + copy(buf[b:], Items[:len(Items)]) + b += xgb.Pad(int(len(Items))) + + return buf +} + +// Request PolyText16 +// size: xgb.Pad((16 + xgb.Pad((len(Items) * 1)))) +type PolyText16Cookie struct { + *xgb.Cookie +} + +// Write request to wire for PolyText16 +func PolyText16(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText16Cookie { + cookie := c.NewCookie(false, false) + c.NewRequest(polyText16Request(c, Drawable, Gc, X, Y, Items), cookie) + return PolyText16Cookie{cookie} +} + +func PolyText16Checked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText16Cookie { + cookie := c.NewCookie(true, false) + c.NewRequest(polyText16Request(c, Drawable, Gc, X, Y, Items), cookie) + return PolyText16Cookie{cookie} +} + +func (cook PolyText16Cookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PolyText16 +func polyText16Request(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) []byte { + size := xgb.Pad((16 + xgb.Pad((len(Items) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 75 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put16(buf[b:], uint16(X)) + b += 2 + + xgb.Put16(buf[b:], uint16(Y)) + b += 2 + + copy(buf[b:], Items[:len(Items)]) + b += xgb.Pad(int(len(Items))) + + return buf +} + +// Request ImageText8 +// size: xgb.Pad((16 + xgb.Pad((int(StringLen) * 1)))) +type ImageText8Cookie struct { + *xgb.Cookie +} + +// Write request to wire for ImageText8 +func ImageText8(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String string) ImageText8Cookie { + cookie := c.NewCookie(false, false) + c.NewRequest(imageText8Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) + return ImageText8Cookie{cookie} +} + +func ImageText8Checked(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String string) ImageText8Cookie { + cookie := c.NewCookie(true, false) + c.NewRequest(imageText8Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) + return ImageText8Cookie{cookie} +} + +func (cook ImageText8Cookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ImageText8 +func imageText8Request(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String string) []byte { + size := xgb.Pad((16 + xgb.Pad((int(StringLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 76 // request opcode + b += 1 + + buf[b] = StringLen + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put16(buf[b:], uint16(X)) + b += 2 + + xgb.Put16(buf[b:], uint16(Y)) + b += 2 + + copy(buf[b:], String[:StringLen]) + b += xgb.Pad(int(StringLen)) + + return buf +} + +// Request ImageText16 +// size: xgb.Pad((16 + xgb.Pad((int(StringLen) * 2)))) +type ImageText16Cookie struct { + *xgb.Cookie +} + +// Write request to wire for ImageText16 +func ImageText16(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String []Char2b) ImageText16Cookie { + cookie := c.NewCookie(false, false) + c.NewRequest(imageText16Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) + return ImageText16Cookie{cookie} +} + +func ImageText16Checked(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String []Char2b) ImageText16Cookie { + cookie := c.NewCookie(true, false) + c.NewRequest(imageText16Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) + return ImageText16Cookie{cookie} +} + +func (cook ImageText16Cookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ImageText16 +func imageText16Request(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String []Char2b) []byte { + size := xgb.Pad((16 + xgb.Pad((int(StringLen) * 2)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 77 // request opcode + b += 1 + + buf[b] = StringLen + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put16(buf[b:], uint16(X)) + b += 2 + + xgb.Put16(buf[b:], uint16(Y)) + b += 2 + + b += Char2bListBytes(buf[b:], String) + + return buf +} + +// Request CreateColormap +// size: 16 +type CreateColormapCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateColormap +func CreateColormap(c *xgb.Conn, Alloc byte, Mid Colormap, Window Window, Visual Visualid) CreateColormapCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createColormapRequest(c, Alloc, Mid, Window, Visual), cookie) + return CreateColormapCookie{cookie} +} + +func CreateColormapChecked(c *xgb.Conn, Alloc byte, Mid Colormap, Window Window, Visual Visualid) CreateColormapCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createColormapRequest(c, Alloc, Mid, Window, Visual), cookie) + return CreateColormapCookie{cookie} +} + +func (cook CreateColormapCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateColormap +func createColormapRequest(c *xgb.Conn, Alloc byte, Mid Colormap, Window Window, Visual Visualid) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 78 // request opcode + b += 1 + + buf[b] = Alloc + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Mid)) + b += 4 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(Visual)) + b += 4 + + return buf +} + +// Request FreeColormap +// size: 8 +type FreeColormapCookie struct { + *xgb.Cookie +} + +// Write request to wire for FreeColormap +func FreeColormap(c *xgb.Conn, Cmap Colormap) FreeColormapCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(freeColormapRequest(c, Cmap), cookie) + return FreeColormapCookie{cookie} +} + +func FreeColormapChecked(c *xgb.Conn, Cmap Colormap) FreeColormapCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(freeColormapRequest(c, Cmap), cookie) + return FreeColormapCookie{cookie} +} + +func (cook FreeColormapCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for FreeColormap +func freeColormapRequest(c *xgb.Conn, Cmap Colormap) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 79 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 + + return buf +} + +// Request CopyColormapAndFree +// size: 12 +type CopyColormapAndFreeCookie struct { + *xgb.Cookie +} + +// Write request to wire for CopyColormapAndFree +func CopyColormapAndFree(c *xgb.Conn, Mid Colormap, SrcCmap Colormap) CopyColormapAndFreeCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(copyColormapAndFreeRequest(c, Mid, SrcCmap), cookie) + return CopyColormapAndFreeCookie{cookie} +} + +func CopyColormapAndFreeChecked(c *xgb.Conn, Mid Colormap, SrcCmap Colormap) CopyColormapAndFreeCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(copyColormapAndFreeRequest(c, Mid, SrcCmap), cookie) + return CopyColormapAndFreeCookie{cookie} +} + +func (cook CopyColormapAndFreeCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CopyColormapAndFree +func copyColormapAndFreeRequest(c *xgb.Conn, Mid Colormap, SrcCmap Colormap) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = 80 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Mid)) + b += 4 + + xgb.Put32(buf[b:], uint32(SrcCmap)) + b += 4 + + return buf +} + +// Request InstallColormap +// size: 8 +type InstallColormapCookie struct { + *xgb.Cookie +} + +// Write request to wire for InstallColormap +func InstallColormap(c *xgb.Conn, Cmap Colormap) InstallColormapCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(installColormapRequest(c, Cmap), cookie) + return InstallColormapCookie{cookie} +} + +func InstallColormapChecked(c *xgb.Conn, Cmap Colormap) InstallColormapCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(installColormapRequest(c, Cmap), cookie) + return InstallColormapCookie{cookie} +} + +func (cook InstallColormapCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for InstallColormap +func installColormapRequest(c *xgb.Conn, Cmap Colormap) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 81 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 + + return buf +} + +// Request UninstallColormap +// size: 8 +type UninstallColormapCookie struct { + *xgb.Cookie +} + +// Write request to wire for UninstallColormap +func UninstallColormap(c *xgb.Conn, Cmap Colormap) UninstallColormapCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(uninstallColormapRequest(c, Cmap), cookie) + return UninstallColormapCookie{cookie} +} + +func UninstallColormapChecked(c *xgb.Conn, Cmap Colormap) UninstallColormapCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(uninstallColormapRequest(c, Cmap), cookie) + return UninstallColormapCookie{cookie} +} + +func (cook UninstallColormapCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for UninstallColormap +func uninstallColormapRequest(c *xgb.Conn, Cmap Colormap) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 82 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 + + return buf +} + +// Request ListInstalledColormaps +// size: 8 +type ListInstalledColormapsCookie struct { + *xgb.Cookie +} + +func ListInstalledColormaps(c *xgb.Conn, Window Window) ListInstalledColormapsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(listInstalledColormapsRequest(c, Window), cookie) + return ListInstalledColormapsCookie{cookie} +} + +func ListInstalledColormapsUnchecked(c *xgb.Conn, Window Window) ListInstalledColormapsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(listInstalledColormapsRequest(c, Window), cookie) + return ListInstalledColormapsCookie{cookie} +} + +// Request reply for ListInstalledColormaps +// size: (32 + xgb.Pad((int(CmapsLen) * 4))) +type ListInstalledColormapsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + CmapsLen uint16 + // padding: 22 bytes + Cmaps []Colormap // size: xgb.Pad((int(CmapsLen) * 4)) +} + +// Waits and reads reply data from request ListInstalledColormaps +func (cook ListInstalledColormapsCookie) Reply() (*ListInstalledColormapsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listInstalledColormapsReply(buf), nil +} + +// Read reply into structure from buffer for ListInstalledColormaps +func listInstalledColormapsReply(buf []byte) *ListInstalledColormapsReply { + v := new(ListInstalledColormapsReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.CmapsLen = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + v.Cmaps = make([]Colormap, v.CmapsLen) + for i := 0; i < int(v.CmapsLen); i++ { + v.Cmaps[i] = Colormap(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for ListInstalledColormaps +func listInstalledColormapsRequest(c *xgb.Conn, Window Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 83 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + +// Request AllocColor +// size: 16 +type AllocColorCookie struct { + *xgb.Cookie +} + +func AllocColor(c *xgb.Conn, Cmap Colormap, Red uint16, Green uint16, Blue uint16) AllocColorCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(allocColorRequest(c, Cmap, Red, Green, Blue), cookie) + return AllocColorCookie{cookie} +} + +func AllocColorUnchecked(c *xgb.Conn, Cmap Colormap, Red uint16, Green uint16, Blue uint16) AllocColorCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(allocColorRequest(c, Cmap, Red, Green, Blue), cookie) + return AllocColorCookie{cookie} +} + +// Request reply for AllocColor +// size: 20 +type AllocColorReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Red uint16 + Green uint16 + Blue uint16 + // padding: 2 bytes + Pixel uint32 +} + +// Waits and reads reply data from request AllocColor +func (cook AllocColorCookie) Reply() (*AllocColorReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return allocColorReply(buf), nil +} + +// Read reply into structure from buffer for AllocColor +func allocColorReply(buf []byte) *AllocColorReply { + v := new(AllocColorReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Red = xgb.Get16(buf[b:]) + b += 2 + + v.Green = xgb.Get16(buf[b:]) + b += 2 + + v.Blue = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + v.Pixel = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for AllocColor +func allocColorRequest(c *xgb.Conn, Cmap Colormap, Red uint16, Green uint16, Blue uint16) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 84 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 + + xgb.Put16(buf[b:], Red) + b += 2 + + xgb.Put16(buf[b:], Green) + b += 2 + + xgb.Put16(buf[b:], Blue) + b += 2 + + b += 2 // padding + + return buf +} + +// Request AllocNamedColor +// size: xgb.Pad((12 + xgb.Pad((int(NameLen) * 1)))) +type AllocNamedColorCookie struct { + *xgb.Cookie +} + +func AllocNamedColor(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) AllocNamedColorCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(allocNamedColorRequest(c, Cmap, NameLen, Name), cookie) + return AllocNamedColorCookie{cookie} +} + +func AllocNamedColorUnchecked(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) AllocNamedColorCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(allocNamedColorRequest(c, Cmap, NameLen, Name), cookie) + return AllocNamedColorCookie{cookie} +} + +// Request reply for AllocNamedColor +// size: 24 +type AllocNamedColorReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Pixel uint32 + ExactRed uint16 + ExactGreen uint16 + ExactBlue uint16 + VisualRed uint16 + VisualGreen uint16 + VisualBlue uint16 +} + +// Waits and reads reply data from request AllocNamedColor +func (cook AllocNamedColorCookie) Reply() (*AllocNamedColorReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return allocNamedColorReply(buf), nil +} + +// Read reply into structure from buffer for AllocNamedColor +func allocNamedColorReply(buf []byte) *AllocNamedColorReply { + v := new(AllocNamedColorReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Pixel = xgb.Get32(buf[b:]) + b += 4 + + v.ExactRed = xgb.Get16(buf[b:]) + b += 2 + + v.ExactGreen = xgb.Get16(buf[b:]) + b += 2 + + v.ExactBlue = xgb.Get16(buf[b:]) + b += 2 + + v.VisualRed = xgb.Get16(buf[b:]) + b += 2 + + v.VisualGreen = xgb.Get16(buf[b:]) + b += 2 + + v.VisualBlue = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Write request to wire for AllocNamedColor +func allocNamedColorRequest(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) []byte { + size := xgb.Pad((12 + xgb.Pad((int(NameLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 85 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 + + xgb.Put16(buf[b:], NameLen) + b += 2 + + b += 2 // padding + + copy(buf[b:], Name[:NameLen]) + b += xgb.Pad(int(NameLen)) + + return buf +} + +// Request AllocColorCells +// size: 12 +type AllocColorCellsCookie struct { + *xgb.Cookie +} + +func AllocColorCells(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Planes uint16) AllocColorCellsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(allocColorCellsRequest(c, Contiguous, Cmap, Colors, Planes), cookie) + return AllocColorCellsCookie{cookie} +} + +func AllocColorCellsUnchecked(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Planes uint16) AllocColorCellsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(allocColorCellsRequest(c, Contiguous, Cmap, Colors, Planes), cookie) + return AllocColorCellsCookie{cookie} +} + +// Request reply for AllocColorCells +// size: ((32 + xgb.Pad((int(PixelsLen) * 4))) + xgb.Pad((int(MasksLen) * 4))) +type AllocColorCellsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + PixelsLen uint16 + MasksLen uint16 + // padding: 20 bytes + Pixels []uint32 // size: xgb.Pad((int(PixelsLen) * 4)) + Masks []uint32 // size: xgb.Pad((int(MasksLen) * 4)) +} + +// Waits and reads reply data from request AllocColorCells +func (cook AllocColorCellsCookie) Reply() (*AllocColorCellsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return allocColorCellsReply(buf), nil +} + +// Read reply into structure from buffer for AllocColorCells +func allocColorCellsReply(buf []byte) *AllocColorCellsReply { + v := new(AllocColorCellsReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.PixelsLen = xgb.Get16(buf[b:]) + b += 2 + + v.MasksLen = xgb.Get16(buf[b:]) + b += 2 + + b += 20 // padding + + v.Pixels = make([]uint32, v.PixelsLen) + for i := 0; i < int(v.PixelsLen); i++ { + v.Pixels[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + v.Masks = make([]uint32, v.MasksLen) + for i := 0; i < int(v.MasksLen); i++ { + v.Masks[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for AllocColorCells +func allocColorCellsRequest(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Planes uint16) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = 86 // request opcode + b += 1 + + if Contiguous { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 + + xgb.Put16(buf[b:], Colors) + b += 2 + + xgb.Put16(buf[b:], Planes) + b += 2 + + return buf +} + +// Request AllocColorPlanes +// size: 16 +type AllocColorPlanesCookie struct { + *xgb.Cookie +} + +func AllocColorPlanes(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Reds uint16, Greens uint16, Blues uint16) AllocColorPlanesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(allocColorPlanesRequest(c, Contiguous, Cmap, Colors, Reds, Greens, Blues), cookie) + return AllocColorPlanesCookie{cookie} +} + +func AllocColorPlanesUnchecked(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Reds uint16, Greens uint16, Blues uint16) AllocColorPlanesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(allocColorPlanesRequest(c, Contiguous, Cmap, Colors, Reds, Greens, Blues), cookie) + return AllocColorPlanesCookie{cookie} +} + +// Request reply for AllocColorPlanes +// size: (32 + xgb.Pad((int(PixelsLen) * 4))) +type AllocColorPlanesReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + PixelsLen uint16 + // padding: 2 bytes + RedMask uint32 + GreenMask uint32 + BlueMask uint32 + // padding: 8 bytes + Pixels []uint32 // size: xgb.Pad((int(PixelsLen) * 4)) +} + +// Waits and reads reply data from request AllocColorPlanes +func (cook AllocColorPlanesCookie) Reply() (*AllocColorPlanesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return allocColorPlanesReply(buf), nil +} + +// Read reply into structure from buffer for AllocColorPlanes +func allocColorPlanesReply(buf []byte) *AllocColorPlanesReply { + v := new(AllocColorPlanesReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.PixelsLen = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + v.RedMask = xgb.Get32(buf[b:]) + b += 4 + + v.GreenMask = xgb.Get32(buf[b:]) + b += 4 + + v.BlueMask = xgb.Get32(buf[b:]) + b += 4 + + b += 8 // padding + + v.Pixels = make([]uint32, v.PixelsLen) + for i := 0; i < int(v.PixelsLen); i++ { + v.Pixels[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for AllocColorPlanes +func allocColorPlanesRequest(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Reds uint16, Greens uint16, Blues uint16) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = 87 // request opcode + b += 1 + + if Contiguous { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 + + xgb.Put16(buf[b:], Colors) + b += 2 + + xgb.Put16(buf[b:], Reds) + b += 2 + + xgb.Put16(buf[b:], Greens) + b += 2 + + xgb.Put16(buf[b:], Blues) + b += 2 + + return buf +} + +// Request FreeColors +// size: xgb.Pad((12 + xgb.Pad((len(Pixels) * 4)))) +type FreeColorsCookie struct { + *xgb.Cookie +} + +// Write request to wire for FreeColors +func FreeColors(c *xgb.Conn, Cmap Colormap, PlaneMask uint32, Pixels []uint32) FreeColorsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(freeColorsRequest(c, Cmap, PlaneMask, Pixels), cookie) + return FreeColorsCookie{cookie} +} + +func FreeColorsChecked(c *xgb.Conn, Cmap Colormap, PlaneMask uint32, Pixels []uint32) FreeColorsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(freeColorsRequest(c, Cmap, PlaneMask, Pixels), cookie) + return FreeColorsCookie{cookie} +} + +func (cook FreeColorsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for FreeColors +func freeColorsRequest(c *xgb.Conn, Cmap Colormap, PlaneMask uint32, Pixels []uint32) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Pixels) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 88 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 + + xgb.Put32(buf[b:], PlaneMask) + b += 4 + + for i := 0; i < int(len(Pixels)); i++ { + xgb.Put32(buf[b:], Pixels[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request StoreColors +// size: xgb.Pad((8 + xgb.Pad((len(Items) * 12)))) +type StoreColorsCookie struct { + *xgb.Cookie +} + +// Write request to wire for StoreColors +func StoreColors(c *xgb.Conn, Cmap Colormap, Items []Coloritem) StoreColorsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(storeColorsRequest(c, Cmap, Items), cookie) + return StoreColorsCookie{cookie} +} + +func StoreColorsChecked(c *xgb.Conn, Cmap Colormap, Items []Coloritem) StoreColorsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(storeColorsRequest(c, Cmap, Items), cookie) + return StoreColorsCookie{cookie} +} + +func (cook StoreColorsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for StoreColors +func storeColorsRequest(c *xgb.Conn, Cmap Colormap, Items []Coloritem) []byte { + size := xgb.Pad((8 + xgb.Pad((len(Items) * 12)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 89 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 + + b += ColoritemListBytes(buf[b:], Items) + + return buf +} + +// Request StoreNamedColor +// size: xgb.Pad((16 + xgb.Pad((int(NameLen) * 1)))) +type StoreNamedColorCookie struct { + *xgb.Cookie +} + +// Write request to wire for StoreNamedColor +func StoreNamedColor(c *xgb.Conn, Flags byte, Cmap Colormap, Pixel uint32, NameLen uint16, Name string) StoreNamedColorCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(storeNamedColorRequest(c, Flags, Cmap, Pixel, NameLen, Name), cookie) + return StoreNamedColorCookie{cookie} +} + +func StoreNamedColorChecked(c *xgb.Conn, Flags byte, Cmap Colormap, Pixel uint32, NameLen uint16, Name string) StoreNamedColorCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(storeNamedColorRequest(c, Flags, Cmap, Pixel, NameLen, Name), cookie) + return StoreNamedColorCookie{cookie} +} + +func (cook StoreNamedColorCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for StoreNamedColor +func storeNamedColorRequest(c *xgb.Conn, Flags byte, Cmap Colormap, Pixel uint32, NameLen uint16, Name string) []byte { + size := xgb.Pad((16 + xgb.Pad((int(NameLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 90 // request opcode + b += 1 + + buf[b] = Flags + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 + + xgb.Put32(buf[b:], Pixel) + b += 4 + + xgb.Put16(buf[b:], NameLen) + b += 2 + + b += 2 // padding + + copy(buf[b:], Name[:NameLen]) + b += xgb.Pad(int(NameLen)) + + return buf +} + +// Request QueryColors +// size: xgb.Pad((8 + xgb.Pad((len(Pixels) * 4)))) +type QueryColorsCookie struct { + *xgb.Cookie +} + +func QueryColors(c *xgb.Conn, Cmap Colormap, Pixels []uint32) QueryColorsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryColorsRequest(c, Cmap, Pixels), cookie) + return QueryColorsCookie{cookie} +} + +func QueryColorsUnchecked(c *xgb.Conn, Cmap Colormap, Pixels []uint32) QueryColorsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryColorsRequest(c, Cmap, Pixels), cookie) + return QueryColorsCookie{cookie} +} + +// Request reply for QueryColors +// size: (32 + xgb.Pad((int(ColorsLen) * 8))) +type QueryColorsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ColorsLen uint16 + // padding: 22 bytes + Colors []Rgb // size: xgb.Pad((int(ColorsLen) * 8)) +} + +// Waits and reads reply data from request QueryColors +func (cook QueryColorsCookie) Reply() (*QueryColorsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryColorsReply(buf), nil +} + +// Read reply into structure from buffer for QueryColors +func queryColorsReply(buf []byte) *QueryColorsReply { + v := new(QueryColorsReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ColorsLen = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + v.Colors = make([]Rgb, v.ColorsLen) + b += RgbReadList(buf[b:], v.Colors) + + return v +} + +// Write request to wire for QueryColors +func queryColorsRequest(c *xgb.Conn, Cmap Colormap, Pixels []uint32) []byte { + size := xgb.Pad((8 + xgb.Pad((len(Pixels) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 91 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 + + for i := 0; i < int(len(Pixels)); i++ { + xgb.Put32(buf[b:], Pixels[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request LookupColor +// size: xgb.Pad((12 + xgb.Pad((int(NameLen) * 1)))) +type LookupColorCookie struct { + *xgb.Cookie +} + +func LookupColor(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) LookupColorCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(lookupColorRequest(c, Cmap, NameLen, Name), cookie) + return LookupColorCookie{cookie} +} + +func LookupColorUnchecked(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) LookupColorCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(lookupColorRequest(c, Cmap, NameLen, Name), cookie) + return LookupColorCookie{cookie} +} + +// Request reply for LookupColor +// size: 20 +type LookupColorReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ExactRed uint16 + ExactGreen uint16 + ExactBlue uint16 + VisualRed uint16 + VisualGreen uint16 + VisualBlue uint16 +} + +// Waits and reads reply data from request LookupColor +func (cook LookupColorCookie) Reply() (*LookupColorReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return lookupColorReply(buf), nil +} + +// Read reply into structure from buffer for LookupColor +func lookupColorReply(buf []byte) *LookupColorReply { + v := new(LookupColorReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ExactRed = xgb.Get16(buf[b:]) + b += 2 + + v.ExactGreen = xgb.Get16(buf[b:]) + b += 2 + + v.ExactBlue = xgb.Get16(buf[b:]) + b += 2 + + v.VisualRed = xgb.Get16(buf[b:]) + b += 2 + + v.VisualGreen = xgb.Get16(buf[b:]) + b += 2 + + v.VisualBlue = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Write request to wire for LookupColor +func lookupColorRequest(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) []byte { + size := xgb.Pad((12 + xgb.Pad((int(NameLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 92 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cmap)) + b += 4 + + xgb.Put16(buf[b:], NameLen) + b += 2 + + b += 2 // padding + + copy(buf[b:], Name[:NameLen]) + b += xgb.Pad(int(NameLen)) + + return buf +} + +// Request CreateCursor +// size: 32 +type CreateCursorCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateCursor +func CreateCursor(c *xgb.Conn, Cid Cursor, Source Pixmap, Mask Pixmap, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16, X uint16, Y uint16) CreateCursorCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createCursorRequest(c, Cid, Source, Mask, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue, X, Y), cookie) + return CreateCursorCookie{cookie} +} + +func CreateCursorChecked(c *xgb.Conn, Cid Cursor, Source Pixmap, Mask Pixmap, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16, X uint16, Y uint16) CreateCursorCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createCursorRequest(c, Cid, Source, Mask, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue, X, Y), cookie) + return CreateCursorCookie{cookie} +} + +func (cook CreateCursorCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateCursor +func createCursorRequest(c *xgb.Conn, Cid Cursor, Source Pixmap, Mask Pixmap, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16, X uint16, Y uint16) []byte { + size := 32 + b := 0 + buf := make([]byte, size) + + buf[b] = 93 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cid)) + b += 4 + + xgb.Put32(buf[b:], uint32(Source)) + b += 4 + + xgb.Put32(buf[b:], uint32(Mask)) + b += 4 + + xgb.Put16(buf[b:], ForeRed) + b += 2 + + xgb.Put16(buf[b:], ForeGreen) + b += 2 + + xgb.Put16(buf[b:], ForeBlue) + b += 2 + + xgb.Put16(buf[b:], BackRed) + b += 2 + + xgb.Put16(buf[b:], BackGreen) + b += 2 + + xgb.Put16(buf[b:], BackBlue) + b += 2 + + xgb.Put16(buf[b:], X) + b += 2 + + xgb.Put16(buf[b:], Y) + b += 2 + + return buf +} + +// Request CreateGlyphCursor +// size: 32 +type CreateGlyphCursorCookie struct { + *xgb.Cookie +} + +// Write request to wire for CreateGlyphCursor +func CreateGlyphCursor(c *xgb.Conn, Cid Cursor, SourceFont Font, MaskFont Font, SourceChar uint16, MaskChar uint16, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) CreateGlyphCursorCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(createGlyphCursorRequest(c, Cid, SourceFont, MaskFont, SourceChar, MaskChar, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) + return CreateGlyphCursorCookie{cookie} +} + +func CreateGlyphCursorChecked(c *xgb.Conn, Cid Cursor, SourceFont Font, MaskFont Font, SourceChar uint16, MaskChar uint16, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) CreateGlyphCursorCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(createGlyphCursorRequest(c, Cid, SourceFont, MaskFont, SourceChar, MaskChar, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) + return CreateGlyphCursorCookie{cookie} +} + +func (cook CreateGlyphCursorCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CreateGlyphCursor +func createGlyphCursorRequest(c *xgb.Conn, Cid Cursor, SourceFont Font, MaskFont Font, SourceChar uint16, MaskChar uint16, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) []byte { + size := 32 + b := 0 + buf := make([]byte, size) + + buf[b] = 94 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cid)) + b += 4 + + xgb.Put32(buf[b:], uint32(SourceFont)) + b += 4 + + xgb.Put32(buf[b:], uint32(MaskFont)) + b += 4 + + xgb.Put16(buf[b:], SourceChar) + b += 2 + + xgb.Put16(buf[b:], MaskChar) + b += 2 + + xgb.Put16(buf[b:], ForeRed) + b += 2 + + xgb.Put16(buf[b:], ForeGreen) + b += 2 + + xgb.Put16(buf[b:], ForeBlue) + b += 2 + + xgb.Put16(buf[b:], BackRed) + b += 2 + + xgb.Put16(buf[b:], BackGreen) + b += 2 + + xgb.Put16(buf[b:], BackBlue) + b += 2 + + return buf +} + +// Request FreeCursor +// size: 8 +type FreeCursorCookie struct { + *xgb.Cookie +} + +// Write request to wire for FreeCursor +func FreeCursor(c *xgb.Conn, Cursor Cursor) FreeCursorCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(freeCursorRequest(c, Cursor), cookie) + return FreeCursorCookie{cookie} +} + +func FreeCursorChecked(c *xgb.Conn, Cursor Cursor) FreeCursorCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(freeCursorRequest(c, Cursor), cookie) + return FreeCursorCookie{cookie} +} + +func (cook FreeCursorCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for FreeCursor +func freeCursorRequest(c *xgb.Conn, Cursor Cursor) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 95 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cursor)) + b += 4 + + return buf +} + +// Request RecolorCursor +// size: 20 +type RecolorCursorCookie struct { + *xgb.Cookie +} + +// Write request to wire for RecolorCursor +func RecolorCursor(c *xgb.Conn, Cursor Cursor, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) RecolorCursorCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(recolorCursorRequest(c, Cursor, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) + return RecolorCursorCookie{cookie} +} + +func RecolorCursorChecked(c *xgb.Conn, Cursor Cursor, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) RecolorCursorCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(recolorCursorRequest(c, Cursor, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) + return RecolorCursorCookie{cookie} +} + +func (cook RecolorCursorCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for RecolorCursor +func recolorCursorRequest(c *xgb.Conn, Cursor Cursor, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) []byte { + size := 20 + b := 0 + buf := make([]byte, size) + + buf[b] = 96 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Cursor)) + b += 4 + + xgb.Put16(buf[b:], ForeRed) + b += 2 + + xgb.Put16(buf[b:], ForeGreen) + b += 2 + + xgb.Put16(buf[b:], ForeBlue) + b += 2 + + xgb.Put16(buf[b:], BackRed) + b += 2 + + xgb.Put16(buf[b:], BackGreen) + b += 2 + + xgb.Put16(buf[b:], BackBlue) + b += 2 + + return buf +} + +// Request QueryBestSize +// size: 12 +type QueryBestSizeCookie struct { + *xgb.Cookie +} + +func QueryBestSize(c *xgb.Conn, Class byte, Drawable Drawable, Width uint16, Height uint16) QueryBestSizeCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryBestSizeRequest(c, Class, Drawable, Width, Height), cookie) + return QueryBestSizeCookie{cookie} +} + +func QueryBestSizeUnchecked(c *xgb.Conn, Class byte, Drawable Drawable, Width uint16, Height uint16) QueryBestSizeCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryBestSizeRequest(c, Class, Drawable, Width, Height), cookie) + return QueryBestSizeCookie{cookie} +} + +// Request reply for QueryBestSize +// size: 12 +type QueryBestSizeReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Width uint16 + Height uint16 +} + +// Waits and reads reply data from request QueryBestSize +func (cook QueryBestSizeCookie) Reply() (*QueryBestSizeReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryBestSizeReply(buf), nil +} + +// Read reply into structure from buffer for QueryBestSize +func queryBestSizeReply(buf []byte) *QueryBestSizeReply { + v := new(QueryBestSizeReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Write request to wire for QueryBestSize +func queryBestSizeRequest(c *xgb.Conn, Class byte, Drawable Drawable, Width uint16, Height uint16) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = 97 // request opcode + b += 1 + + buf[b] = Class + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + return buf +} + +// Request QueryExtension +// size: xgb.Pad((8 + xgb.Pad((int(NameLen) * 1)))) +type QueryExtensionCookie struct { + *xgb.Cookie +} + +func QueryExtension(c *xgb.Conn, NameLen uint16, Name string) QueryExtensionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryExtensionRequest(c, NameLen, Name), cookie) + return QueryExtensionCookie{cookie} +} + +func QueryExtensionUnchecked(c *xgb.Conn, NameLen uint16, Name string) QueryExtensionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryExtensionRequest(c, NameLen, Name), cookie) + return QueryExtensionCookie{cookie} +} + +// Request reply for QueryExtension +// size: 12 +type QueryExtensionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Present bool + MajorOpcode byte + FirstEvent byte + FirstError byte +} + +// Waits and reads reply data from request QueryExtension +func (cook QueryExtensionCookie) Reply() (*QueryExtensionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryExtensionReply(buf), nil +} + +// Read reply into structure from buffer for QueryExtension +func queryExtensionReply(buf []byte) *QueryExtensionReply { + v := new(QueryExtensionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + if buf[b] == 1 { + v.Present = true + } else { + v.Present = false + } + b += 1 + + v.MajorOpcode = buf[b] + b += 1 + + v.FirstEvent = buf[b] + b += 1 + + v.FirstError = buf[b] + b += 1 + + return v +} + +// Write request to wire for QueryExtension +func queryExtensionRequest(c *xgb.Conn, NameLen uint16, Name string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(NameLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 98 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], NameLen) + b += 2 + + b += 2 // padding + + copy(buf[b:], Name[:NameLen]) + b += xgb.Pad(int(NameLen)) + + return buf +} + +// Request ListExtensions +// size: 4 +type ListExtensionsCookie struct { + *xgb.Cookie +} + +func ListExtensions(c *xgb.Conn) ListExtensionsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(listExtensionsRequest(c), cookie) + return ListExtensionsCookie{cookie} +} + +func ListExtensionsUnchecked(c *xgb.Conn) ListExtensionsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(listExtensionsRequest(c), cookie) + return ListExtensionsCookie{cookie} +} + +// Request reply for ListExtensions +// size: (32 + StrListSize(Names)) +type ListExtensionsReply struct { + Sequence uint16 + Length uint32 + NamesLen byte + // padding: 24 bytes + Names []Str // size: StrListSize(Names) +} + +// Waits and reads reply data from request ListExtensions +func (cook ListExtensionsCookie) Reply() (*ListExtensionsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listExtensionsReply(buf), nil +} + +// Read reply into structure from buffer for ListExtensions +func listExtensionsReply(buf []byte) *ListExtensionsReply { + v := new(ListExtensionsReply) + b := 1 // skip reply determinant + + v.NamesLen = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 24 // padding + + v.Names = make([]Str, v.NamesLen) + b += StrReadList(buf[b:], v.Names) + + return v +} + +// Write request to wire for ListExtensions +func listExtensionsRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 99 // request opcode + b += 1 + + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request ChangeKeyboardMapping +// size: xgb.Pad((8 + xgb.Pad(((int(KeycodeCount) * int(KeysymsPerKeycode)) * 4)))) +type ChangeKeyboardMappingCookie struct { + *xgb.Cookie +} + +// Write request to wire for ChangeKeyboardMapping +func ChangeKeyboardMapping(c *xgb.Conn, KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) ChangeKeyboardMappingCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeKeyboardMappingRequest(c, KeycodeCount, FirstKeycode, KeysymsPerKeycode, Keysyms), cookie) + return ChangeKeyboardMappingCookie{cookie} +} + +func ChangeKeyboardMappingChecked(c *xgb.Conn, KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) ChangeKeyboardMappingCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeKeyboardMappingRequest(c, KeycodeCount, FirstKeycode, KeysymsPerKeycode, Keysyms), cookie) + return ChangeKeyboardMappingCookie{cookie} +} + +func (cook ChangeKeyboardMappingCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangeKeyboardMapping +func changeKeyboardMappingRequest(c *xgb.Conn, KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) []byte { + size := xgb.Pad((8 + xgb.Pad(((int(KeycodeCount) * int(KeysymsPerKeycode)) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 100 // request opcode + b += 1 + + buf[b] = KeycodeCount + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = byte(FirstKeycode) + b += 1 + + buf[b] = KeysymsPerKeycode + b += 1 + + b += 2 // padding + + for i := 0; i < int((int(KeycodeCount) * int(KeysymsPerKeycode))); i++ { + xgb.Put32(buf[b:], uint32(Keysyms[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request GetKeyboardMapping +// size: 8 +type GetKeyboardMappingCookie struct { + *xgb.Cookie +} + +func GetKeyboardMapping(c *xgb.Conn, FirstKeycode Keycode, Count byte) GetKeyboardMappingCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getKeyboardMappingRequest(c, FirstKeycode, Count), cookie) + return GetKeyboardMappingCookie{cookie} +} + +func GetKeyboardMappingUnchecked(c *xgb.Conn, FirstKeycode Keycode, Count byte) GetKeyboardMappingCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getKeyboardMappingRequest(c, FirstKeycode, Count), cookie) + return GetKeyboardMappingCookie{cookie} +} + +// Request reply for GetKeyboardMapping +// size: (32 + xgb.Pad((int(Length) * 4))) +type GetKeyboardMappingReply struct { + Sequence uint16 + Length uint32 + KeysymsPerKeycode byte + // padding: 24 bytes + Keysyms []Keysym // size: xgb.Pad((int(Length) * 4)) +} + +// Waits and reads reply data from request GetKeyboardMapping +func (cook GetKeyboardMappingCookie) Reply() (*GetKeyboardMappingReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getKeyboardMappingReply(buf), nil +} + +// Read reply into structure from buffer for GetKeyboardMapping +func getKeyboardMappingReply(buf []byte) *GetKeyboardMappingReply { + v := new(GetKeyboardMappingReply) + b := 1 // skip reply determinant + + v.KeysymsPerKeycode = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 24 // padding + + v.Keysyms = make([]Keysym, v.Length) + for i := 0; i < int(v.Length); i++ { + v.Keysyms[i] = Keysym(xgb.Get32(buf[b:])) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetKeyboardMapping +func getKeyboardMappingRequest(c *xgb.Conn, FirstKeycode Keycode, Count byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 101 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = byte(FirstKeycode) + b += 1 + + buf[b] = Count + b += 1 + + return buf +} + +// Request ChangeKeyboardControl +// size: xgb.Pad((4 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +type ChangeKeyboardControlCookie struct { + *xgb.Cookie +} + +// Write request to wire for ChangeKeyboardControl +func ChangeKeyboardControl(c *xgb.Conn, ValueMask uint32, ValueList []uint32) ChangeKeyboardControlCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeKeyboardControlRequest(c, ValueMask, ValueList), cookie) + return ChangeKeyboardControlCookie{cookie} +} + +func ChangeKeyboardControlChecked(c *xgb.Conn, ValueMask uint32, ValueList []uint32) ChangeKeyboardControlCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeKeyboardControlRequest(c, ValueMask, ValueList), cookie) + return ChangeKeyboardControlCookie{cookie} +} + +func (cook ChangeKeyboardControlCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangeKeyboardControl +func changeKeyboardControlRequest(c *xgb.Conn, ValueMask uint32, ValueList []uint32) []byte { + size := xgb.Pad((4 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) + b := 0 + buf := make([]byte, size) + + buf[b] = 102 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], ValueMask) + b += 4 + for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { + xgb.Put32(buf[b:], ValueList[i]) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request GetKeyboardControl +// size: 4 +type GetKeyboardControlCookie struct { + *xgb.Cookie +} + +func GetKeyboardControl(c *xgb.Conn) GetKeyboardControlCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getKeyboardControlRequest(c), cookie) + return GetKeyboardControlCookie{cookie} +} + +func GetKeyboardControlUnchecked(c *xgb.Conn) GetKeyboardControlCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getKeyboardControlRequest(c), cookie) + return GetKeyboardControlCookie{cookie} +} + +// Request reply for GetKeyboardControl +// size: 52 +type GetKeyboardControlReply struct { + Sequence uint16 + Length uint32 + GlobalAutoRepeat byte + LedMask uint32 + KeyClickPercent byte + BellPercent byte + BellPitch uint16 + BellDuration uint16 + // padding: 2 bytes + AutoRepeats []byte // size: 32 +} + +// Waits and reads reply data from request GetKeyboardControl +func (cook GetKeyboardControlCookie) Reply() (*GetKeyboardControlReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getKeyboardControlReply(buf), nil +} + +// Read reply into structure from buffer for GetKeyboardControl +func getKeyboardControlReply(buf []byte) *GetKeyboardControlReply { + v := new(GetKeyboardControlReply) + b := 1 // skip reply determinant + + v.GlobalAutoRepeat = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.LedMask = xgb.Get32(buf[b:]) + b += 4 + + v.KeyClickPercent = buf[b] + b += 1 + + v.BellPercent = buf[b] + b += 1 + + v.BellPitch = xgb.Get16(buf[b:]) + b += 2 + + v.BellDuration = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + v.AutoRepeats = make([]byte, 32) + copy(v.AutoRepeats[:32], buf[b:]) + b += xgb.Pad(int(32)) + + return v +} + +// Write request to wire for GetKeyboardControl +func getKeyboardControlRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 103 // request opcode + b += 1 + + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request Bell +// size: 4 +type BellCookie struct { + *xgb.Cookie +} + +// Write request to wire for Bell +func Bell(c *xgb.Conn, Percent int8) BellCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(bellRequest(c, Percent), cookie) + return BellCookie{cookie} +} + +func BellChecked(c *xgb.Conn, Percent int8) BellCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(bellRequest(c, Percent), cookie) + return BellCookie{cookie} +} + +func (cook BellCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for Bell +func bellRequest(c *xgb.Conn, Percent int8) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 104 // request opcode + b += 1 + + buf[b] = byte(Percent) + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request ChangePointerControl +// size: 12 +type ChangePointerControlCookie struct { + *xgb.Cookie +} + +// Write request to wire for ChangePointerControl +func ChangePointerControl(c *xgb.Conn, AccelerationNumerator int16, AccelerationDenominator int16, Threshold int16, DoAcceleration bool, DoThreshold bool) ChangePointerControlCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changePointerControlRequest(c, AccelerationNumerator, AccelerationDenominator, Threshold, DoAcceleration, DoThreshold), cookie) + return ChangePointerControlCookie{cookie} +} + +func ChangePointerControlChecked(c *xgb.Conn, AccelerationNumerator int16, AccelerationDenominator int16, Threshold int16, DoAcceleration bool, DoThreshold bool) ChangePointerControlCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changePointerControlRequest(c, AccelerationNumerator, AccelerationDenominator, Threshold, DoAcceleration, DoThreshold), cookie) + return ChangePointerControlCookie{cookie} +} + +func (cook ChangePointerControlCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangePointerControl +func changePointerControlRequest(c *xgb.Conn, AccelerationNumerator int16, AccelerationDenominator int16, Threshold int16, DoAcceleration bool, DoThreshold bool) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = 105 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], uint16(AccelerationNumerator)) + b += 2 + + xgb.Put16(buf[b:], uint16(AccelerationDenominator)) + b += 2 + + xgb.Put16(buf[b:], uint16(Threshold)) + b += 2 + + if DoAcceleration { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + if DoThreshold { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + return buf +} + +// Request GetPointerControl +// size: 4 +type GetPointerControlCookie struct { + *xgb.Cookie +} + +func GetPointerControl(c *xgb.Conn) GetPointerControlCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getPointerControlRequest(c), cookie) + return GetPointerControlCookie{cookie} +} + +func GetPointerControlUnchecked(c *xgb.Conn) GetPointerControlCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getPointerControlRequest(c), cookie) + return GetPointerControlCookie{cookie} +} + +// Request reply for GetPointerControl +// size: 32 +type GetPointerControlReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + AccelerationNumerator uint16 + AccelerationDenominator uint16 + Threshold uint16 + // padding: 18 bytes +} + +// Waits and reads reply data from request GetPointerControl +func (cook GetPointerControlCookie) Reply() (*GetPointerControlReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPointerControlReply(buf), nil +} + +// Read reply into structure from buffer for GetPointerControl +func getPointerControlReply(buf []byte) *GetPointerControlReply { + v := new(GetPointerControlReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.AccelerationNumerator = xgb.Get16(buf[b:]) + b += 2 + + v.AccelerationDenominator = xgb.Get16(buf[b:]) + b += 2 + + v.Threshold = xgb.Get16(buf[b:]) + b += 2 + + b += 18 // padding + + return v +} + +// Write request to wire for GetPointerControl +func getPointerControlRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 106 // request opcode + b += 1 + + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request SetScreenSaver +// size: 12 +type SetScreenSaverCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetScreenSaver +func SetScreenSaver(c *xgb.Conn, Timeout int16, Interval int16, PreferBlanking byte, AllowExposures byte) SetScreenSaverCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setScreenSaverRequest(c, Timeout, Interval, PreferBlanking, AllowExposures), cookie) + return SetScreenSaverCookie{cookie} +} + +func SetScreenSaverChecked(c *xgb.Conn, Timeout int16, Interval int16, PreferBlanking byte, AllowExposures byte) SetScreenSaverCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setScreenSaverRequest(c, Timeout, Interval, PreferBlanking, AllowExposures), cookie) + return SetScreenSaverCookie{cookie} +} + +func (cook SetScreenSaverCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetScreenSaver +func setScreenSaverRequest(c *xgb.Conn, Timeout int16, Interval int16, PreferBlanking byte, AllowExposures byte) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = 107 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], uint16(Timeout)) + b += 2 + + xgb.Put16(buf[b:], uint16(Interval)) + b += 2 + + buf[b] = PreferBlanking + b += 1 + + buf[b] = AllowExposures + b += 1 + + return buf +} + +// Request GetScreenSaver +// size: 4 +type GetScreenSaverCookie struct { + *xgb.Cookie +} + +func GetScreenSaver(c *xgb.Conn) GetScreenSaverCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getScreenSaverRequest(c), cookie) + return GetScreenSaverCookie{cookie} +} + +func GetScreenSaverUnchecked(c *xgb.Conn) GetScreenSaverCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getScreenSaverRequest(c), cookie) + return GetScreenSaverCookie{cookie} +} + +// Request reply for GetScreenSaver +// size: 32 +type GetScreenSaverReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Timeout uint16 + Interval uint16 + PreferBlanking byte + AllowExposures byte + // padding: 18 bytes +} + +// Waits and reads reply data from request GetScreenSaver +func (cook GetScreenSaverCookie) Reply() (*GetScreenSaverReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getScreenSaverReply(buf), nil +} + +// Read reply into structure from buffer for GetScreenSaver +func getScreenSaverReply(buf []byte) *GetScreenSaverReply { + v := new(GetScreenSaverReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Timeout = xgb.Get16(buf[b:]) + b += 2 + + v.Interval = xgb.Get16(buf[b:]) + b += 2 + + v.PreferBlanking = buf[b] + b += 1 + + v.AllowExposures = buf[b] + b += 1 + + b += 18 // padding + + return v +} + +// Write request to wire for GetScreenSaver +func getScreenSaverRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 108 // request opcode + b += 1 + + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request ChangeHosts +// size: xgb.Pad((8 + xgb.Pad((int(AddressLen) * 1)))) +type ChangeHostsCookie struct { + *xgb.Cookie +} + +// Write request to wire for ChangeHosts +func ChangeHosts(c *xgb.Conn, Mode byte, Family byte, AddressLen uint16, Address []byte) ChangeHostsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(changeHostsRequest(c, Mode, Family, AddressLen, Address), cookie) + return ChangeHostsCookie{cookie} +} + +func ChangeHostsChecked(c *xgb.Conn, Mode byte, Family byte, AddressLen uint16, Address []byte) ChangeHostsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(changeHostsRequest(c, Mode, Family, AddressLen, Address), cookie) + return ChangeHostsCookie{cookie} +} + +func (cook ChangeHostsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ChangeHosts +func changeHostsRequest(c *xgb.Conn, Mode byte, Family byte, AddressLen uint16, Address []byte) []byte { + size := xgb.Pad((8 + xgb.Pad((int(AddressLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 109 // request opcode + b += 1 + + buf[b] = Mode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = Family + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], AddressLen) + b += 2 + + copy(buf[b:], Address[:AddressLen]) + b += xgb.Pad(int(AddressLen)) + + return buf +} + +// Request ListHosts +// size: 4 +type ListHostsCookie struct { + *xgb.Cookie +} + +func ListHosts(c *xgb.Conn) ListHostsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(listHostsRequest(c), cookie) + return ListHostsCookie{cookie} +} + +func ListHostsUnchecked(c *xgb.Conn) ListHostsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(listHostsRequest(c), cookie) + return ListHostsCookie{cookie} +} + +// Request reply for ListHosts +// size: (32 + HostListSize(Hosts)) +type ListHostsReply struct { + Sequence uint16 + Length uint32 + Mode byte + HostsLen uint16 + // padding: 22 bytes + Hosts []Host // size: HostListSize(Hosts) +} + +// Waits and reads reply data from request ListHosts +func (cook ListHostsCookie) Reply() (*ListHostsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listHostsReply(buf), nil +} + +// Read reply into structure from buffer for ListHosts +func listHostsReply(buf []byte) *ListHostsReply { + v := new(ListHostsReply) + b := 1 // skip reply determinant + + v.Mode = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.HostsLen = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + v.Hosts = make([]Host, v.HostsLen) + b += HostReadList(buf[b:], v.Hosts) + + return v +} + +// Write request to wire for ListHosts +func listHostsRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 110 // request opcode + b += 1 + + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request SetAccessControl +// size: 4 +type SetAccessControlCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetAccessControl +func SetAccessControl(c *xgb.Conn, Mode byte) SetAccessControlCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setAccessControlRequest(c, Mode), cookie) + return SetAccessControlCookie{cookie} +} + +func SetAccessControlChecked(c *xgb.Conn, Mode byte) SetAccessControlCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setAccessControlRequest(c, Mode), cookie) + return SetAccessControlCookie{cookie} +} + +func (cook SetAccessControlCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetAccessControl +func setAccessControlRequest(c *xgb.Conn, Mode byte) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 111 // request opcode + b += 1 + + buf[b] = Mode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request SetCloseDownMode +// size: 4 +type SetCloseDownModeCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetCloseDownMode +func SetCloseDownMode(c *xgb.Conn, Mode byte) SetCloseDownModeCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setCloseDownModeRequest(c, Mode), cookie) + return SetCloseDownModeCookie{cookie} +} + +func SetCloseDownModeChecked(c *xgb.Conn, Mode byte) SetCloseDownModeCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setCloseDownModeRequest(c, Mode), cookie) + return SetCloseDownModeCookie{cookie} +} + +func (cook SetCloseDownModeCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetCloseDownMode +func setCloseDownModeRequest(c *xgb.Conn, Mode byte) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 112 // request opcode + b += 1 + + buf[b] = Mode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request KillClient +// size: 8 +type KillClientCookie struct { + *xgb.Cookie +} + +// Write request to wire for KillClient +func KillClient(c *xgb.Conn, Resource uint32) KillClientCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(killClientRequest(c, Resource), cookie) + return KillClientCookie{cookie} +} + +func KillClientChecked(c *xgb.Conn, Resource uint32) KillClientCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(killClientRequest(c, Resource), cookie) + return KillClientCookie{cookie} +} + +func (cook KillClientCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for KillClient +func killClientRequest(c *xgb.Conn, Resource uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = 113 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Resource) + b += 4 + + return buf +} + +// Request RotateProperties +// size: xgb.Pad((12 + xgb.Pad((int(AtomsLen) * 4)))) +type RotatePropertiesCookie struct { + *xgb.Cookie +} + +// Write request to wire for RotateProperties +func RotateProperties(c *xgb.Conn, Window Window, AtomsLen uint16, Delta int16, Atoms []Atom) RotatePropertiesCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(rotatePropertiesRequest(c, Window, AtomsLen, Delta, Atoms), cookie) + return RotatePropertiesCookie{cookie} +} + +func RotatePropertiesChecked(c *xgb.Conn, Window Window, AtomsLen uint16, Delta int16, Atoms []Atom) RotatePropertiesCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(rotatePropertiesRequest(c, Window, AtomsLen, Delta, Atoms), cookie) + return RotatePropertiesCookie{cookie} +} + +func (cook RotatePropertiesCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for RotateProperties +func rotatePropertiesRequest(c *xgb.Conn, Window Window, AtomsLen uint16, Delta int16, Atoms []Atom) []byte { + size := xgb.Pad((12 + xgb.Pad((int(AtomsLen) * 4)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 114 // request opcode + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put16(buf[b:], AtomsLen) + b += 2 + + xgb.Put16(buf[b:], uint16(Delta)) + b += 2 + + for i := 0; i < int(AtomsLen); i++ { + xgb.Put32(buf[b:], uint32(Atoms[i])) + b += 4 + } + b = xgb.Pad(b) + + return buf +} + +// Request ForceScreenSaver +// size: 4 +type ForceScreenSaverCookie struct { + *xgb.Cookie +} + +// Write request to wire for ForceScreenSaver +func ForceScreenSaver(c *xgb.Conn, Mode byte) ForceScreenSaverCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(forceScreenSaverRequest(c, Mode), cookie) + return ForceScreenSaverCookie{cookie} +} + +func ForceScreenSaverChecked(c *xgb.Conn, Mode byte) ForceScreenSaverCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(forceScreenSaverRequest(c, Mode), cookie) + return ForceScreenSaverCookie{cookie} +} + +func (cook ForceScreenSaverCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ForceScreenSaver +func forceScreenSaverRequest(c *xgb.Conn, Mode byte) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 115 // request opcode + b += 1 + + buf[b] = Mode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request SetPointerMapping +// size: xgb.Pad((4 + xgb.Pad((int(MapLen) * 1)))) +type SetPointerMappingCookie struct { + *xgb.Cookie +} + +func SetPointerMapping(c *xgb.Conn, MapLen byte, Map []byte) SetPointerMappingCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(setPointerMappingRequest(c, MapLen, Map), cookie) + return SetPointerMappingCookie{cookie} +} + +func SetPointerMappingUnchecked(c *xgb.Conn, MapLen byte, Map []byte) SetPointerMappingCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(setPointerMappingRequest(c, MapLen, Map), cookie) + return SetPointerMappingCookie{cookie} +} + +// Request reply for SetPointerMapping +// size: 8 +type SetPointerMappingReply struct { + Sequence uint16 + Length uint32 + Status byte +} + +// Waits and reads reply data from request SetPointerMapping +func (cook SetPointerMappingCookie) Reply() (*SetPointerMappingReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return setPointerMappingReply(buf), nil +} + +// Read reply into structure from buffer for SetPointerMapping +func setPointerMappingReply(buf []byte) *SetPointerMappingReply { + v := new(SetPointerMappingReply) + b := 1 // skip reply determinant + + v.Status = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + return v +} + +// Write request to wire for SetPointerMapping +func setPointerMappingRequest(c *xgb.Conn, MapLen byte, Map []byte) []byte { + size := xgb.Pad((4 + xgb.Pad((int(MapLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 116 // request opcode + b += 1 + + buf[b] = MapLen + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + copy(buf[b:], Map[:MapLen]) + b += xgb.Pad(int(MapLen)) + + return buf +} + +// Request GetPointerMapping +// size: 4 +type GetPointerMappingCookie struct { + *xgb.Cookie +} + +func GetPointerMapping(c *xgb.Conn) GetPointerMappingCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getPointerMappingRequest(c), cookie) + return GetPointerMappingCookie{cookie} +} + +func GetPointerMappingUnchecked(c *xgb.Conn) GetPointerMappingCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getPointerMappingRequest(c), cookie) + return GetPointerMappingCookie{cookie} +} + +// Request reply for GetPointerMapping +// size: (32 + xgb.Pad((int(MapLen) * 1))) +type GetPointerMappingReply struct { + Sequence uint16 + Length uint32 + MapLen byte + // padding: 24 bytes + Map []byte // size: xgb.Pad((int(MapLen) * 1)) +} + +// Waits and reads reply data from request GetPointerMapping +func (cook GetPointerMappingCookie) Reply() (*GetPointerMappingReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPointerMappingReply(buf), nil +} + +// Read reply into structure from buffer for GetPointerMapping +func getPointerMappingReply(buf []byte) *GetPointerMappingReply { + v := new(GetPointerMappingReply) + b := 1 // skip reply determinant + + v.MapLen = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 24 // padding + + v.Map = make([]byte, v.MapLen) + copy(v.Map[:v.MapLen], buf[b:]) + b += xgb.Pad(int(v.MapLen)) + + return v +} + +// Write request to wire for GetPointerMapping +func getPointerMappingRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 117 // request opcode + b += 1 + + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request SetModifierMapping +// size: xgb.Pad((4 + xgb.Pad(((int(KeycodesPerModifier) * 8) * 1)))) +type SetModifierMappingCookie struct { + *xgb.Cookie +} + +func SetModifierMapping(c *xgb.Conn, KeycodesPerModifier byte, Keycodes []Keycode) SetModifierMappingCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(setModifierMappingRequest(c, KeycodesPerModifier, Keycodes), cookie) + return SetModifierMappingCookie{cookie} +} + +func SetModifierMappingUnchecked(c *xgb.Conn, KeycodesPerModifier byte, Keycodes []Keycode) SetModifierMappingCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(setModifierMappingRequest(c, KeycodesPerModifier, Keycodes), cookie) + return SetModifierMappingCookie{cookie} +} + +// Request reply for SetModifierMapping +// size: 8 +type SetModifierMappingReply struct { + Sequence uint16 + Length uint32 + Status byte +} + +// Waits and reads reply data from request SetModifierMapping +func (cook SetModifierMappingCookie) Reply() (*SetModifierMappingReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return setModifierMappingReply(buf), nil +} + +// Read reply into structure from buffer for SetModifierMapping +func setModifierMappingReply(buf []byte) *SetModifierMappingReply { + v := new(SetModifierMappingReply) + b := 1 // skip reply determinant + + v.Status = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + return v +} + +// Write request to wire for SetModifierMapping +func setModifierMappingRequest(c *xgb.Conn, KeycodesPerModifier byte, Keycodes []Keycode) []byte { + size := xgb.Pad((4 + xgb.Pad(((int(KeycodesPerModifier) * 8) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = 118 // request opcode + b += 1 + + buf[b] = KeycodesPerModifier + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + for i := 0; i < int((int(KeycodesPerModifier) * 8)); i++ { + buf[b] = byte(Keycodes[i]) + b += 1 + } + b = xgb.Pad(b) + + return buf +} + +// Request GetModifierMapping +// size: 4 +type GetModifierMappingCookie struct { + *xgb.Cookie +} + +func GetModifierMapping(c *xgb.Conn) GetModifierMappingCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getModifierMappingRequest(c), cookie) + return GetModifierMappingCookie{cookie} +} + +func GetModifierMappingUnchecked(c *xgb.Conn) GetModifierMappingCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getModifierMappingRequest(c), cookie) + return GetModifierMappingCookie{cookie} +} + +// Request reply for GetModifierMapping +// size: (32 + xgb.Pad(((int(KeycodesPerModifier) * 8) * 1))) +type GetModifierMappingReply struct { + Sequence uint16 + Length uint32 + KeycodesPerModifier byte + // padding: 24 bytes + Keycodes []Keycode // size: xgb.Pad(((int(KeycodesPerModifier) * 8) * 1)) +} + +// Waits and reads reply data from request GetModifierMapping +func (cook GetModifierMappingCookie) Reply() (*GetModifierMappingReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getModifierMappingReply(buf), nil +} + +// Read reply into structure from buffer for GetModifierMapping +func getModifierMappingReply(buf []byte) *GetModifierMappingReply { + v := new(GetModifierMappingReply) + b := 1 // skip reply determinant + + v.KeycodesPerModifier = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 24 // padding + + v.Keycodes = make([]Keycode, (int(v.KeycodesPerModifier) * 8)) + for i := 0; i < int((int(v.KeycodesPerModifier) * 8)); i++ { + v.Keycodes[i] = Keycode(buf[b]) + b += 1 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetModifierMapping +func getModifierMappingRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 119 // request opcode + b += 1 + + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request NoOperation +// size: 4 +type NoOperationCookie struct { + *xgb.Cookie +} + +// Write request to wire for NoOperation +func NoOperation(c *xgb.Conn) NoOperationCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(noOperationRequest(c), cookie) + return NoOperationCookie{cookie} +} + +func NoOperationChecked(c *xgb.Conn) NoOperationCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(noOperationRequest(c), cookie) + return NoOperationCookie{cookie} +} + +func (cook NoOperationCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for NoOperation +func noOperationRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = 127 // request opcode + b += 1 + + b += 1 // padding + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} diff --git a/nexgb/xproto/xproto_test.go b/nexgb/xproto/xproto_test.go new file mode 100644 index 0000000..f061198 --- /dev/null +++ b/nexgb/xproto/xproto_test.go @@ -0,0 +1,365 @@ +package xproto + +/* + Tests for XGB. + + These tests only test the core X protocol at the moment. It isn't even + close to complete coverage (and probably never will be), but it does test + a number of different corners: requests with no replies, requests without + replies, checked (i.e., synchronous) errors, unchecked (i.e., asynchronous) + errors, and sequence number wrapping. + + There are also a couple of benchmarks that show the difference between + correctly issuing lots of requests and gathering replies and + incorrectly doing the same. (This particular difference is one of the + claimed advantages of the XCB, and therefore XGB, family. +*/ + +import ( + "fmt" + "log" + "math/rand" + "testing" + "time" + + "github.com/BurntSushi/xgb" +) + +// The X connection used throughout testing. +var X *xgb.Conn + +// init initializes the X connection, seeds the RNG and starts waiting +// for events. +func init() { + var err error + + X, err = xgb.NewConn() + if err != nil { + log.Fatal(err) + } + + rand.Seed(time.Now().UnixNano()) + + go grabEvents() +} + +/******************************************************************************/ +// Tests +/******************************************************************************/ + +// TestSynchronousError purposefully causes a BadWindow error in a +// MapWindow request, and checks it synchronously. +func TestSynchronousError(t *testing.T) { + err := MapWindowChecked(X, 0).Check() // resource 0 is always invalid + if err == nil { + t.Fatalf("MapWindow: A MapWindow request that should return an " + + "error has returned a nil error.") + } + verifyMapWindowError(t, err) +} + +// TestAsynchronousError does the same thing as TestSynchronousError, but +// grabs the error asynchronously instead. +func TestAsynchronousError(t *testing.T) { + MapWindow(X, 0) // resource id 0 is always invalid + + evOrErr := waitForEvent(t, 5) + if evOrErr.ev != nil { + t.Fatalf("After issuing an erroneous MapWindow request, we have "+ + "received an event rather than an error: %s", evOrErr.ev) + } + verifyMapWindowError(t, evOrErr.err) +} + +// TestCookieBuffer issues (2^16) + n requets *without* replies to guarantee +// that the sequence number wraps and that the cookie buffer will have to +// flush itself (since there are no replies coming in to flush it). +// And just like TestSequenceWrap, we issue another request with a reply +// at the end to make sure XGB is still working properly. +func TestCookieBuffer(t *testing.T) { + n := (1 << 16) + 10 + for i := 0; i < n; i++ { + NoOperation(X) + } + TestProperty(t) +} + +// TestSequenceWrap issues (2^16) + n requests w/ replies to guarantee that the +// sequence number (which is a 16 bit integer) will wrap. It then issues one +// final request to ensure things still work properly. +func TestSequenceWrap(t *testing.T) { + n := (1 << 16) + 10 + for i := 0; i < n; i++ { + _, err := InternAtom(X, false, 5, "RANDO").Reply() + if err != nil { + t.Fatalf("InternAtom: %s", err) + } + } + TestProperty(t) +} + +// TestProperty tests whether a random value can be set and read. +func TestProperty(t *testing.T) { + propName := randString(20) // whatevs + writeVal := randString(20) + readVal, err := changeAndGetProp(propName, writeVal) + if err != nil { + t.Error(err) + } + + if readVal != writeVal { + t.Errorf("The value written, '%s', is not the same as the "+ + "value read '%s'.", writeVal, readVal) + } +} + +// TestWindowEvents creates a window, maps it, listens for configure notify +// events, issues a configure request, and checks for the appropriate +// configure notify event. +// This probably violates the notion of "test one thing and test it well," +// but testing X stuff is unique since it involves so much state. +// Each request is checked to make sure there are no errors returned. If there +// is an error, the test is failed. +// You may see a window appear quickly and then disappear. Do not be alarmed :P +// It's possible that this test will yield a false negative because we cannot +// control our environment. That is, the window manager could override the +// placement set. However, we set override redirect on the window, so the +// window manager *shouldn't* touch our window if it is well-behaved. +func TestWindowEvents(t *testing.T) { + // The geometry to set the window. + gx, gy, gw, gh := 200, 400, 1000, 300 + + wid, err := NewWindowId(X) + if err != nil { + t.Fatalf("NewId: %s", err) + } + + screen := Setup(X).DefaultScreen(X) // alias + err = CreateWindowChecked(X, screen.RootDepth, wid, screen.Root, + 0, 0, 500, 500, 0, + WindowClassInputOutput, screen.RootVisual, + CwBackPixel|CwOverrideRedirect, []uint32{0xffffffff, 1}).Check() + if err != nil { + t.Fatalf("CreateWindow: %s", err) + } + + err = MapWindowChecked(X, wid).Check() + if err != nil { + t.Fatalf("MapWindow: %s", err) + } + + // We don't listen in the CreateWindow request so that we don't get + // a MapNotify event. + err = ChangeWindowAttributesChecked(X, wid, + CwEventMask, []uint32{EventMaskStructureNotify}).Check() + if err != nil { + t.Fatalf("ChangeWindowAttributes: %s", err) + } + + err = ConfigureWindowChecked(X, wid, + ConfigWindowX|ConfigWindowY| + ConfigWindowWidth|ConfigWindowHeight, + []uint32{uint32(gx), uint32(gy), uint32(gw), uint32(gh)}).Check() + if err != nil { + t.Fatalf("ConfigureWindow: %s", err) + } + + TestProperty(t) + + evOrErr := waitForEvent(t, 5) + switch event := evOrErr.ev.(type) { + case ConfigureNotifyEvent: + if event.X != int16(gx) { + t.Fatalf("x was set to %d but ConfigureNotify reports %d", + gx, event.X) + } + if event.Y != int16(gy) { + t.Fatalf("y was set to %d but ConfigureNotify reports %d", + gy, event.Y) + } + if event.Width != uint16(gw) { + t.Fatalf("width was set to %d but ConfigureNotify reports %d", + gw, event.Width) + } + if event.Height != uint16(gh) { + t.Fatalf("height was set to %d but ConfigureNotify reports %d", + gh, event.Height) + } + default: + t.Fatalf("Expected a ConfigureNotifyEvent but got %T instead.", event) + } + + // Okay, clean up! + err = ChangeWindowAttributesChecked(X, wid, + CwEventMask, []uint32{0}).Check() + if err != nil { + t.Fatalf("ChangeWindowAttributes: %s", err) + } + + err = DestroyWindowChecked(X, wid).Check() + if err != nil { + t.Fatalf("DestroyWindow: %s", err) + } +} + +/******************************************************************************/ +// Benchmarks +/******************************************************************************/ + +// BenchmarkInternAtomsGood shows how many requests with replies +// *should* be sent and gathered from the server. Namely, send as many +// requests as you can at once, then go back and gather up all the replies. +// More importantly, this approach can exploit parallelism when +// GOMAXPROCS > 1. +// Run with `go test -run 'nomatch' -bench '.*' -cpu 1,2,6` if you have +// multiple cores to see the improvement that parallelism brings. +func BenchmarkInternAtomsGood(b *testing.B) { + b.StopTimer() + names := seqNames(b.N) + + b.StartTimer() + cookies := make([]InternAtomCookie, b.N) + for i := 0; i < b.N; i++ { + cookies[i] = InternAtom(X, false, uint16(len(names[i])), names[i]) + } + for _, cookie := range cookies { + cookie.Reply() + } +} + +// BenchmarkInternAtomsBad shows how *not* to issue a lot of requests with +// replies. Namely, each subsequent request isn't issued *until* the last +// reply is made. This implies a round trip to the X server for every +// iteration. +func BenchmarkInternAtomsPoor(b *testing.B) { + b.StopTimer() + names := seqNames(b.N) + + b.StartTimer() + for i := 0; i < b.N; i++ { + InternAtom(X, false, uint16(len(names[i])), names[i]).Reply() + } +} + +/******************************************************************************/ +// Helper functions +/******************************************************************************/ + +// changeAndGetProp sets property 'prop' with value 'val'. +// It then gets the value of that property and returns it. +// (It's used to check that the 'val' going in is the same 'val' going out.) +// It tests both requests with and without replies (GetProperty and +// ChangeProperty respectively.) +func changeAndGetProp(prop, val string) (string, error) { + setup := Setup(X) + root := setup.DefaultScreen(X).Root + + propAtom, err := InternAtom(X, false, uint16(len(prop)), prop).Reply() + if err != nil { + return "", fmt.Errorf("InternAtom: %s", err) + } + + typName := "UTF8_STRING" + typAtom, err := InternAtom(X, false, uint16(len(typName)), typName).Reply() + if err != nil { + return "", fmt.Errorf("InternAtom: %s", err) + } + + err = ChangePropertyChecked(X, PropModeReplace, root, propAtom.Atom, + typAtom.Atom, 8, uint32(len(val)), []byte(val)).Check() + if err != nil { + return "", fmt.Errorf("ChangeProperty: %s", err) + } + + reply, err := GetProperty(X, false, root, propAtom.Atom, + GetPropertyTypeAny, 0, (1<<32)-1).Reply() + if err != nil { + return "", fmt.Errorf("GetProperty: %s", err) + } + if reply.Format != 8 { + return "", fmt.Errorf("Property reply format is %d but it should be 8.", + reply.Format) + } + + return string(reply.Value), nil +} + +// verifyMapWindowError takes an error that is returned with an invalid +// MapWindow request with a window Id of 0 and makes sure the error is the +// right type and contains the correct values. +func verifyMapWindowError(t *testing.T, err error) { + switch e := err.(type) { + case WindowError: + if e.BadValue != 0 { + t.Fatalf("WindowError should report a bad value of 0 but "+ + "it reports %d instead.", e.BadValue) + } + if e.MajorOpcode != 8 { + t.Fatalf("WindowError should report a major opcode of 8 "+ + "(which is a MapWindow request), but it reports %d instead.", + e.MajorOpcode) + } + default: + t.Fatalf("Expected a WindowError but got %T instead.", e) + } +} + +// randString generates a random string of length n. +func randString(n int) string { + byts := make([]byte, n) + for i := 0; i < n; i++ { + rando := rand.Intn(53) + switch { + case rando <= 25: + byts[i] = byte(65 + rando) + case rando <= 51: + byts[i] = byte(97 + rando - 26) + default: + byts[i] = ' ' + } + } + return string(byts) +} + +// seqNames creates a slice of NAME0, NAME1, ..., NAMEN. +func seqNames(n int) []string { + names := make([]string, n) + for i := range names { + names[i] = fmt.Sprintf("NAME%d", i) + } + return names +} + +// evErr represents a value that is either an event or an error. +type evErr struct { + ev xgb.Event + err xgb.Error +} + +// channel used to pass evErrs. +var evOrErrChan = make(chan evErr, 0) + +// grabEvents is a goroutine that reads events off the wire. +// We used this instead of WaitForEvent directly in our tests so that +// we can timeout and fail a test. +func grabEvents() { + for { + ev, err := X.WaitForEvent() + evOrErrChan <- evErr{ev, err} + } +} + +// waitForEvent asks the evOrErrChan channel for an event. +// If it doesn't get an event in 'n' seconds, the current test is failed. +func waitForEvent(t *testing.T, n int) evErr { + var evOrErr evErr + + select { + case evOrErr = <-evOrErrChan: + case <-time.After(time.Second * 5): + t.Fatalf("After waiting 5 seconds for an event or an error, " + + "we have timed out.") + } + + return evOrErr +} diff --git a/nexgb/xselinux/xselinux.go b/nexgb/xselinux/xselinux.go new file mode 100644 index 0000000..4675e90 --- /dev/null +++ b/nexgb/xselinux/xselinux.go @@ -0,0 +1,1903 @@ +package xselinux + +/* + This file was generated by xselinux.xml on May 10 2012 4:20:29pm EDT. + This file is automatically generated. Edit at your peril! +*/ + +import ( + "github.com/BurntSushi/xgb" + + "github.com/BurntSushi/xgb/xproto" +) + +// Init must be called before using the SELinux extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 7, "SELinux").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named SELinux could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["SELinux"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["SELinux"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["SELinux"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["SELinux"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["SELinux"] = make(map[int]xgb.NewErrorFun) +} + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Bool' + +// Skipping definition for base type 'Float' + +// Skipping definition for base type 'Card8' + +// 'ListItem' struct definition +// Size: ((12 + xgb.Pad((int(ObjectContextLen) * 1))) + xgb.Pad((int(DataContextLen) * 1))) +type ListItem struct { + Name xproto.Atom + ObjectContextLen uint32 + DataContextLen uint32 + ObjectContext string // size: xgb.Pad((int(ObjectContextLen) * 1)) + DataContext string // size: xgb.Pad((int(DataContextLen) * 1)) +} + +// Struct read ListItem +func ListItemRead(buf []byte, v *ListItem) int { + b := 0 + + v.Name = xproto.Atom(xgb.Get32(buf[b:])) + b += 4 + + v.ObjectContextLen = xgb.Get32(buf[b:]) + b += 4 + + v.DataContextLen = xgb.Get32(buf[b:]) + b += 4 + + { + byteString := make([]byte, v.ObjectContextLen) + copy(byteString[:v.ObjectContextLen], buf[b:]) + v.ObjectContext = string(byteString) + b += xgb.Pad(int(v.ObjectContextLen)) + } + + { + byteString := make([]byte, v.DataContextLen) + copy(byteString[:v.DataContextLen], buf[b:]) + v.DataContext = string(byteString) + b += xgb.Pad(int(v.DataContextLen)) + } + + return b +} + +// Struct list read ListItem +func ListItemReadList(buf []byte, dest []ListItem) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = ListItem{} + b += ListItemRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write ListItem +func (v ListItem) Bytes() []byte { + buf := make([]byte, ((12 + xgb.Pad((int(v.ObjectContextLen) * 1))) + xgb.Pad((int(v.DataContextLen) * 1)))) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Name)) + b += 4 + + xgb.Put32(buf[b:], v.ObjectContextLen) + b += 4 + + xgb.Put32(buf[b:], v.DataContextLen) + b += 4 + + copy(buf[b:], v.ObjectContext[:v.ObjectContextLen]) + b += xgb.Pad(int(v.ObjectContextLen)) + + copy(buf[b:], v.DataContext[:v.DataContextLen]) + b += xgb.Pad(int(v.DataContextLen)) + + return buf +} + +// Write struct list ListItem +func ListItemListBytes(buf []byte, list []ListItem) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size ListItem +func ListItemListSize(list []ListItem) int { + size := 0 + for _, item := range list { + size += ((12 + xgb.Pad((int(item.ObjectContextLen) * 1))) + xgb.Pad((int(item.DataContextLen) * 1))) + } + return size +} + +// Request QueryVersion +// size: 8 +type QueryVersionCookie struct { + *xgb.Cookie +} + +func QueryVersion(c *xgb.Conn, ClientMajor byte, ClientMinor byte) QueryVersionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c, ClientMajor, ClientMinor), cookie) + return QueryVersionCookie{cookie} +} + +func QueryVersionUnchecked(c *xgb.Conn, ClientMajor byte, ClientMinor byte) QueryVersionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c, ClientMajor, ClientMinor), cookie) + return QueryVersionCookie{cookie} +} + +// Request reply for QueryVersion +// size: 12 +type QueryVersionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ServerMajor uint16 + ServerMinor uint16 +} + +// Waits and reads reply data from request QueryVersion +func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryVersionReply(buf), nil +} + +// Read reply into structure from buffer for QueryVersion +func queryVersionReply(buf []byte) *QueryVersionReply { + v := new(QueryVersionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ServerMajor = xgb.Get16(buf[b:]) + b += 2 + + v.ServerMinor = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Write request to wire for QueryVersion +func queryVersionRequest(c *xgb.Conn, ClientMajor byte, ClientMinor byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 0 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = ClientMajor + b += 1 + + buf[b] = ClientMinor + b += 1 + + return buf +} + +// Request SetDeviceCreateContext +// size: xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) +type SetDeviceCreateContextCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetDeviceCreateContext +func SetDeviceCreateContext(c *xgb.Conn, ContextLen uint32, Context string) SetDeviceCreateContextCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setDeviceCreateContextRequest(c, ContextLen, Context), cookie) + return SetDeviceCreateContextCookie{cookie} +} + +func SetDeviceCreateContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetDeviceCreateContextCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setDeviceCreateContextRequest(c, ContextLen, Context), cookie) + return SetDeviceCreateContextCookie{cookie} +} + +func (cook SetDeviceCreateContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetDeviceCreateContext +func setDeviceCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 1 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], ContextLen) + b += 4 + + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) + + return buf +} + +// Request GetDeviceCreateContext +// size: 4 +type GetDeviceCreateContextCookie struct { + *xgb.Cookie +} + +func GetDeviceCreateContext(c *xgb.Conn) GetDeviceCreateContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getDeviceCreateContextRequest(c), cookie) + return GetDeviceCreateContextCookie{cookie} +} + +func GetDeviceCreateContextUnchecked(c *xgb.Conn) GetDeviceCreateContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getDeviceCreateContextRequest(c), cookie) + return GetDeviceCreateContextCookie{cookie} +} + +// Request reply for GetDeviceCreateContext +// size: (32 + xgb.Pad((int(ContextLen) * 1))) +type GetDeviceCreateContextReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ContextLen uint32 + // padding: 20 bytes + Context string // size: xgb.Pad((int(ContextLen) * 1)) +} + +// Waits and reads reply data from request GetDeviceCreateContext +func (cook GetDeviceCreateContextCookie) Reply() (*GetDeviceCreateContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDeviceCreateContextReply(buf), nil +} + +// Read reply into structure from buffer for GetDeviceCreateContext +func getDeviceCreateContextReply(buf []byte) *GetDeviceCreateContextReply { + v := new(GetDeviceCreateContextReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ContextLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + { + byteString := make([]byte, v.ContextLen) + copy(byteString[:v.ContextLen], buf[b:]) + v.Context = string(byteString) + b += xgb.Pad(int(v.ContextLen)) + } + + return v +} + +// Write request to wire for GetDeviceCreateContext +func getDeviceCreateContextRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 2 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request SetDeviceContext +// size: xgb.Pad((12 + xgb.Pad((int(ContextLen) * 1)))) +type SetDeviceContextCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetDeviceContext +func SetDeviceContext(c *xgb.Conn, Device uint32, ContextLen uint32, Context string) SetDeviceContextCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setDeviceContextRequest(c, Device, ContextLen, Context), cookie) + return SetDeviceContextCookie{cookie} +} + +func SetDeviceContextChecked(c *xgb.Conn, Device uint32, ContextLen uint32, Context string) SetDeviceContextCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setDeviceContextRequest(c, Device, ContextLen, Context), cookie) + return SetDeviceContextCookie{cookie} +} + +func (cook SetDeviceContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetDeviceContext +func setDeviceContextRequest(c *xgb.Conn, Device uint32, ContextLen uint32, Context string) []byte { + size := xgb.Pad((12 + xgb.Pad((int(ContextLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 3 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Device) + b += 4 + + xgb.Put32(buf[b:], ContextLen) + b += 4 + + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) + + return buf +} + +// Request GetDeviceContext +// size: 8 +type GetDeviceContextCookie struct { + *xgb.Cookie +} + +func GetDeviceContext(c *xgb.Conn, Device uint32) GetDeviceContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getDeviceContextRequest(c, Device), cookie) + return GetDeviceContextCookie{cookie} +} + +func GetDeviceContextUnchecked(c *xgb.Conn, Device uint32) GetDeviceContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getDeviceContextRequest(c, Device), cookie) + return GetDeviceContextCookie{cookie} +} + +// Request reply for GetDeviceContext +// size: (32 + xgb.Pad((int(ContextLen) * 1))) +type GetDeviceContextReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ContextLen uint32 + // padding: 20 bytes + Context string // size: xgb.Pad((int(ContextLen) * 1)) +} + +// Waits and reads reply data from request GetDeviceContext +func (cook GetDeviceContextCookie) Reply() (*GetDeviceContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDeviceContextReply(buf), nil +} + +// Read reply into structure from buffer for GetDeviceContext +func getDeviceContextReply(buf []byte) *GetDeviceContextReply { + v := new(GetDeviceContextReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ContextLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + { + byteString := make([]byte, v.ContextLen) + copy(byteString[:v.ContextLen], buf[b:]) + v.Context = string(byteString) + b += xgb.Pad(int(v.ContextLen)) + } + + return v +} + +// Write request to wire for GetDeviceContext +func getDeviceContextRequest(c *xgb.Conn, Device uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 4 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Device) + b += 4 + + return buf +} + +// Request SetWindowCreateContext +// size: xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) +type SetWindowCreateContextCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetWindowCreateContext +func SetWindowCreateContext(c *xgb.Conn, ContextLen uint32, Context string) SetWindowCreateContextCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setWindowCreateContextRequest(c, ContextLen, Context), cookie) + return SetWindowCreateContextCookie{cookie} +} + +func SetWindowCreateContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetWindowCreateContextCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setWindowCreateContextRequest(c, ContextLen, Context), cookie) + return SetWindowCreateContextCookie{cookie} +} + +func (cook SetWindowCreateContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetWindowCreateContext +func setWindowCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 5 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], ContextLen) + b += 4 + + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) + + return buf +} + +// Request GetWindowCreateContext +// size: 4 +type GetWindowCreateContextCookie struct { + *xgb.Cookie +} + +func GetWindowCreateContext(c *xgb.Conn) GetWindowCreateContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getWindowCreateContextRequest(c), cookie) + return GetWindowCreateContextCookie{cookie} +} + +func GetWindowCreateContextUnchecked(c *xgb.Conn) GetWindowCreateContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getWindowCreateContextRequest(c), cookie) + return GetWindowCreateContextCookie{cookie} +} + +// Request reply for GetWindowCreateContext +// size: (32 + xgb.Pad((int(ContextLen) * 1))) +type GetWindowCreateContextReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ContextLen uint32 + // padding: 20 bytes + Context string // size: xgb.Pad((int(ContextLen) * 1)) +} + +// Waits and reads reply data from request GetWindowCreateContext +func (cook GetWindowCreateContextCookie) Reply() (*GetWindowCreateContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getWindowCreateContextReply(buf), nil +} + +// Read reply into structure from buffer for GetWindowCreateContext +func getWindowCreateContextReply(buf []byte) *GetWindowCreateContextReply { + v := new(GetWindowCreateContextReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ContextLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + { + byteString := make([]byte, v.ContextLen) + copy(byteString[:v.ContextLen], buf[b:]) + v.Context = string(byteString) + b += xgb.Pad(int(v.ContextLen)) + } + + return v +} + +// Write request to wire for GetWindowCreateContext +func getWindowCreateContextRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 6 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request GetWindowContext +// size: 8 +type GetWindowContextCookie struct { + *xgb.Cookie +} + +func GetWindowContext(c *xgb.Conn, Window xproto.Window) GetWindowContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getWindowContextRequest(c, Window), cookie) + return GetWindowContextCookie{cookie} +} + +func GetWindowContextUnchecked(c *xgb.Conn, Window xproto.Window) GetWindowContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getWindowContextRequest(c, Window), cookie) + return GetWindowContextCookie{cookie} +} + +// Request reply for GetWindowContext +// size: (32 + xgb.Pad((int(ContextLen) * 1))) +type GetWindowContextReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ContextLen uint32 + // padding: 20 bytes + Context string // size: xgb.Pad((int(ContextLen) * 1)) +} + +// Waits and reads reply data from request GetWindowContext +func (cook GetWindowContextCookie) Reply() (*GetWindowContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getWindowContextReply(buf), nil +} + +// Read reply into structure from buffer for GetWindowContext +func getWindowContextReply(buf []byte) *GetWindowContextReply { + v := new(GetWindowContextReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ContextLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + { + byteString := make([]byte, v.ContextLen) + copy(byteString[:v.ContextLen], buf[b:]) + v.Context = string(byteString) + b += xgb.Pad(int(v.ContextLen)) + } + + return v +} + +// Write request to wire for GetWindowContext +func getWindowContextRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 7 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + +// Request SetPropertyCreateContext +// size: xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) +type SetPropertyCreateContextCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetPropertyCreateContext +func SetPropertyCreateContext(c *xgb.Conn, ContextLen uint32, Context string) SetPropertyCreateContextCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setPropertyCreateContextRequest(c, ContextLen, Context), cookie) + return SetPropertyCreateContextCookie{cookie} +} + +func SetPropertyCreateContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetPropertyCreateContextCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setPropertyCreateContextRequest(c, ContextLen, Context), cookie) + return SetPropertyCreateContextCookie{cookie} +} + +func (cook SetPropertyCreateContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetPropertyCreateContext +func setPropertyCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 8 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], ContextLen) + b += 4 + + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) + + return buf +} + +// Request GetPropertyCreateContext +// size: 4 +type GetPropertyCreateContextCookie struct { + *xgb.Cookie +} + +func GetPropertyCreateContext(c *xgb.Conn) GetPropertyCreateContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getPropertyCreateContextRequest(c), cookie) + return GetPropertyCreateContextCookie{cookie} +} + +func GetPropertyCreateContextUnchecked(c *xgb.Conn) GetPropertyCreateContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getPropertyCreateContextRequest(c), cookie) + return GetPropertyCreateContextCookie{cookie} +} + +// Request reply for GetPropertyCreateContext +// size: (32 + xgb.Pad((int(ContextLen) * 1))) +type GetPropertyCreateContextReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ContextLen uint32 + // padding: 20 bytes + Context string // size: xgb.Pad((int(ContextLen) * 1)) +} + +// Waits and reads reply data from request GetPropertyCreateContext +func (cook GetPropertyCreateContextCookie) Reply() (*GetPropertyCreateContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPropertyCreateContextReply(buf), nil +} + +// Read reply into structure from buffer for GetPropertyCreateContext +func getPropertyCreateContextReply(buf []byte) *GetPropertyCreateContextReply { + v := new(GetPropertyCreateContextReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ContextLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + { + byteString := make([]byte, v.ContextLen) + copy(byteString[:v.ContextLen], buf[b:]) + v.Context = string(byteString) + b += xgb.Pad(int(v.ContextLen)) + } + + return v +} + +// Write request to wire for GetPropertyCreateContext +func getPropertyCreateContextRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 9 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request SetPropertyUseContext +// size: xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) +type SetPropertyUseContextCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetPropertyUseContext +func SetPropertyUseContext(c *xgb.Conn, ContextLen uint32, Context string) SetPropertyUseContextCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setPropertyUseContextRequest(c, ContextLen, Context), cookie) + return SetPropertyUseContextCookie{cookie} +} + +func SetPropertyUseContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetPropertyUseContextCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setPropertyUseContextRequest(c, ContextLen, Context), cookie) + return SetPropertyUseContextCookie{cookie} +} + +func (cook SetPropertyUseContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetPropertyUseContext +func setPropertyUseContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 10 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], ContextLen) + b += 4 + + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) + + return buf +} + +// Request GetPropertyUseContext +// size: 4 +type GetPropertyUseContextCookie struct { + *xgb.Cookie +} + +func GetPropertyUseContext(c *xgb.Conn) GetPropertyUseContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getPropertyUseContextRequest(c), cookie) + return GetPropertyUseContextCookie{cookie} +} + +func GetPropertyUseContextUnchecked(c *xgb.Conn) GetPropertyUseContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getPropertyUseContextRequest(c), cookie) + return GetPropertyUseContextCookie{cookie} +} + +// Request reply for GetPropertyUseContext +// size: (32 + xgb.Pad((int(ContextLen) * 1))) +type GetPropertyUseContextReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ContextLen uint32 + // padding: 20 bytes + Context string // size: xgb.Pad((int(ContextLen) * 1)) +} + +// Waits and reads reply data from request GetPropertyUseContext +func (cook GetPropertyUseContextCookie) Reply() (*GetPropertyUseContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPropertyUseContextReply(buf), nil +} + +// Read reply into structure from buffer for GetPropertyUseContext +func getPropertyUseContextReply(buf []byte) *GetPropertyUseContextReply { + v := new(GetPropertyUseContextReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ContextLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + { + byteString := make([]byte, v.ContextLen) + copy(byteString[:v.ContextLen], buf[b:]) + v.Context = string(byteString) + b += xgb.Pad(int(v.ContextLen)) + } + + return v +} + +// Write request to wire for GetPropertyUseContext +func getPropertyUseContextRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 11 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request GetPropertyContext +// size: 12 +type GetPropertyContextCookie struct { + *xgb.Cookie +} + +func GetPropertyContext(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) GetPropertyContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getPropertyContextRequest(c, Window, Property), cookie) + return GetPropertyContextCookie{cookie} +} + +func GetPropertyContextUnchecked(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) GetPropertyContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getPropertyContextRequest(c, Window, Property), cookie) + return GetPropertyContextCookie{cookie} +} + +// Request reply for GetPropertyContext +// size: (32 + xgb.Pad((int(ContextLen) * 1))) +type GetPropertyContextReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ContextLen uint32 + // padding: 20 bytes + Context string // size: xgb.Pad((int(ContextLen) * 1)) +} + +// Waits and reads reply data from request GetPropertyContext +func (cook GetPropertyContextCookie) Reply() (*GetPropertyContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPropertyContextReply(buf), nil +} + +// Read reply into structure from buffer for GetPropertyContext +func getPropertyContextReply(buf []byte) *GetPropertyContextReply { + v := new(GetPropertyContextReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ContextLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + { + byteString := make([]byte, v.ContextLen) + copy(byteString[:v.ContextLen], buf[b:]) + v.Context = string(byteString) + b += xgb.Pad(int(v.ContextLen)) + } + + return v +} + +// Write request to wire for GetPropertyContext +func getPropertyContextRequest(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 12 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(Property)) + b += 4 + + return buf +} + +// Request GetPropertyDataContext +// size: 12 +type GetPropertyDataContextCookie struct { + *xgb.Cookie +} + +func GetPropertyDataContext(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) GetPropertyDataContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getPropertyDataContextRequest(c, Window, Property), cookie) + return GetPropertyDataContextCookie{cookie} +} + +func GetPropertyDataContextUnchecked(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) GetPropertyDataContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getPropertyDataContextRequest(c, Window, Property), cookie) + return GetPropertyDataContextCookie{cookie} +} + +// Request reply for GetPropertyDataContext +// size: (32 + xgb.Pad((int(ContextLen) * 1))) +type GetPropertyDataContextReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ContextLen uint32 + // padding: 20 bytes + Context string // size: xgb.Pad((int(ContextLen) * 1)) +} + +// Waits and reads reply data from request GetPropertyDataContext +func (cook GetPropertyDataContextCookie) Reply() (*GetPropertyDataContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPropertyDataContextReply(buf), nil +} + +// Read reply into structure from buffer for GetPropertyDataContext +func getPropertyDataContextReply(buf []byte) *GetPropertyDataContextReply { + v := new(GetPropertyDataContextReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ContextLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + { + byteString := make([]byte, v.ContextLen) + copy(byteString[:v.ContextLen], buf[b:]) + v.Context = string(byteString) + b += xgb.Pad(int(v.ContextLen)) + } + + return v +} + +// Write request to wire for GetPropertyDataContext +func getPropertyDataContextRequest(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 13 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(Property)) + b += 4 + + return buf +} + +// Request ListProperties +// size: 8 +type ListPropertiesCookie struct { + *xgb.Cookie +} + +func ListProperties(c *xgb.Conn, Window xproto.Window) ListPropertiesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(listPropertiesRequest(c, Window), cookie) + return ListPropertiesCookie{cookie} +} + +func ListPropertiesUnchecked(c *xgb.Conn, Window xproto.Window) ListPropertiesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(listPropertiesRequest(c, Window), cookie) + return ListPropertiesCookie{cookie} +} + +// Request reply for ListProperties +// size: (32 + ListItemListSize(Properties)) +type ListPropertiesReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + PropertiesLen uint32 + // padding: 20 bytes + Properties []ListItem // size: ListItemListSize(Properties) +} + +// Waits and reads reply data from request ListProperties +func (cook ListPropertiesCookie) Reply() (*ListPropertiesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listPropertiesReply(buf), nil +} + +// Read reply into structure from buffer for ListProperties +func listPropertiesReply(buf []byte) *ListPropertiesReply { + v := new(ListPropertiesReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.PropertiesLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Properties = make([]ListItem, v.PropertiesLen) + b += ListItemReadList(buf[b:], v.Properties) + + return v +} + +// Write request to wire for ListProperties +func listPropertiesRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 14 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + +// Request SetSelectionCreateContext +// size: xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) +type SetSelectionCreateContextCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetSelectionCreateContext +func SetSelectionCreateContext(c *xgb.Conn, ContextLen uint32, Context string) SetSelectionCreateContextCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setSelectionCreateContextRequest(c, ContextLen, Context), cookie) + return SetSelectionCreateContextCookie{cookie} +} + +func SetSelectionCreateContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetSelectionCreateContextCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setSelectionCreateContextRequest(c, ContextLen, Context), cookie) + return SetSelectionCreateContextCookie{cookie} +} + +func (cook SetSelectionCreateContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetSelectionCreateContext +func setSelectionCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 15 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], ContextLen) + b += 4 + + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) + + return buf +} + +// Request GetSelectionCreateContext +// size: 4 +type GetSelectionCreateContextCookie struct { + *xgb.Cookie +} + +func GetSelectionCreateContext(c *xgb.Conn) GetSelectionCreateContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getSelectionCreateContextRequest(c), cookie) + return GetSelectionCreateContextCookie{cookie} +} + +func GetSelectionCreateContextUnchecked(c *xgb.Conn) GetSelectionCreateContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getSelectionCreateContextRequest(c), cookie) + return GetSelectionCreateContextCookie{cookie} +} + +// Request reply for GetSelectionCreateContext +// size: (32 + xgb.Pad((int(ContextLen) * 1))) +type GetSelectionCreateContextReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ContextLen uint32 + // padding: 20 bytes + Context string // size: xgb.Pad((int(ContextLen) * 1)) +} + +// Waits and reads reply data from request GetSelectionCreateContext +func (cook GetSelectionCreateContextCookie) Reply() (*GetSelectionCreateContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getSelectionCreateContextReply(buf), nil +} + +// Read reply into structure from buffer for GetSelectionCreateContext +func getSelectionCreateContextReply(buf []byte) *GetSelectionCreateContextReply { + v := new(GetSelectionCreateContextReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ContextLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + { + byteString := make([]byte, v.ContextLen) + copy(byteString[:v.ContextLen], buf[b:]) + v.Context = string(byteString) + b += xgb.Pad(int(v.ContextLen)) + } + + return v +} + +// Write request to wire for GetSelectionCreateContext +func getSelectionCreateContextRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 16 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request SetSelectionUseContext +// size: xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) +type SetSelectionUseContextCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetSelectionUseContext +func SetSelectionUseContext(c *xgb.Conn, ContextLen uint32, Context string) SetSelectionUseContextCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setSelectionUseContextRequest(c, ContextLen, Context), cookie) + return SetSelectionUseContextCookie{cookie} +} + +func SetSelectionUseContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetSelectionUseContextCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setSelectionUseContextRequest(c, ContextLen, Context), cookie) + return SetSelectionUseContextCookie{cookie} +} + +func (cook SetSelectionUseContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetSelectionUseContext +func setSelectionUseContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { + size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 17 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], ContextLen) + b += 4 + + copy(buf[b:], Context[:ContextLen]) + b += xgb.Pad(int(ContextLen)) + + return buf +} + +// Request GetSelectionUseContext +// size: 4 +type GetSelectionUseContextCookie struct { + *xgb.Cookie +} + +func GetSelectionUseContext(c *xgb.Conn) GetSelectionUseContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getSelectionUseContextRequest(c), cookie) + return GetSelectionUseContextCookie{cookie} +} + +func GetSelectionUseContextUnchecked(c *xgb.Conn) GetSelectionUseContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getSelectionUseContextRequest(c), cookie) + return GetSelectionUseContextCookie{cookie} +} + +// Request reply for GetSelectionUseContext +// size: (32 + xgb.Pad((int(ContextLen) * 1))) +type GetSelectionUseContextReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ContextLen uint32 + // padding: 20 bytes + Context string // size: xgb.Pad((int(ContextLen) * 1)) +} + +// Waits and reads reply data from request GetSelectionUseContext +func (cook GetSelectionUseContextCookie) Reply() (*GetSelectionUseContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getSelectionUseContextReply(buf), nil +} + +// Read reply into structure from buffer for GetSelectionUseContext +func getSelectionUseContextReply(buf []byte) *GetSelectionUseContextReply { + v := new(GetSelectionUseContextReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ContextLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + { + byteString := make([]byte, v.ContextLen) + copy(byteString[:v.ContextLen], buf[b:]) + v.Context = string(byteString) + b += xgb.Pad(int(v.ContextLen)) + } + + return v +} + +// Write request to wire for GetSelectionUseContext +func getSelectionUseContextRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 18 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request GetSelectionContext +// size: 8 +type GetSelectionContextCookie struct { + *xgb.Cookie +} + +func GetSelectionContext(c *xgb.Conn, Selection xproto.Atom) GetSelectionContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getSelectionContextRequest(c, Selection), cookie) + return GetSelectionContextCookie{cookie} +} + +func GetSelectionContextUnchecked(c *xgb.Conn, Selection xproto.Atom) GetSelectionContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getSelectionContextRequest(c, Selection), cookie) + return GetSelectionContextCookie{cookie} +} + +// Request reply for GetSelectionContext +// size: (32 + xgb.Pad((int(ContextLen) * 1))) +type GetSelectionContextReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ContextLen uint32 + // padding: 20 bytes + Context string // size: xgb.Pad((int(ContextLen) * 1)) +} + +// Waits and reads reply data from request GetSelectionContext +func (cook GetSelectionContextCookie) Reply() (*GetSelectionContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getSelectionContextReply(buf), nil +} + +// Read reply into structure from buffer for GetSelectionContext +func getSelectionContextReply(buf []byte) *GetSelectionContextReply { + v := new(GetSelectionContextReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ContextLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + { + byteString := make([]byte, v.ContextLen) + copy(byteString[:v.ContextLen], buf[b:]) + v.Context = string(byteString) + b += xgb.Pad(int(v.ContextLen)) + } + + return v +} + +// Write request to wire for GetSelectionContext +func getSelectionContextRequest(c *xgb.Conn, Selection xproto.Atom) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 19 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Selection)) + b += 4 + + return buf +} + +// Request GetSelectionDataContext +// size: 8 +type GetSelectionDataContextCookie struct { + *xgb.Cookie +} + +func GetSelectionDataContext(c *xgb.Conn, Selection xproto.Atom) GetSelectionDataContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getSelectionDataContextRequest(c, Selection), cookie) + return GetSelectionDataContextCookie{cookie} +} + +func GetSelectionDataContextUnchecked(c *xgb.Conn, Selection xproto.Atom) GetSelectionDataContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getSelectionDataContextRequest(c, Selection), cookie) + return GetSelectionDataContextCookie{cookie} +} + +// Request reply for GetSelectionDataContext +// size: (32 + xgb.Pad((int(ContextLen) * 1))) +type GetSelectionDataContextReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ContextLen uint32 + // padding: 20 bytes + Context string // size: xgb.Pad((int(ContextLen) * 1)) +} + +// Waits and reads reply data from request GetSelectionDataContext +func (cook GetSelectionDataContextCookie) Reply() (*GetSelectionDataContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getSelectionDataContextReply(buf), nil +} + +// Read reply into structure from buffer for GetSelectionDataContext +func getSelectionDataContextReply(buf []byte) *GetSelectionDataContextReply { + v := new(GetSelectionDataContextReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ContextLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + { + byteString := make([]byte, v.ContextLen) + copy(byteString[:v.ContextLen], buf[b:]) + v.Context = string(byteString) + b += xgb.Pad(int(v.ContextLen)) + } + + return v +} + +// Write request to wire for GetSelectionDataContext +func getSelectionDataContextRequest(c *xgb.Conn, Selection xproto.Atom) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 20 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Selection)) + b += 4 + + return buf +} + +// Request ListSelections +// size: 4 +type ListSelectionsCookie struct { + *xgb.Cookie +} + +func ListSelections(c *xgb.Conn) ListSelectionsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(listSelectionsRequest(c), cookie) + return ListSelectionsCookie{cookie} +} + +func ListSelectionsUnchecked(c *xgb.Conn) ListSelectionsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(listSelectionsRequest(c), cookie) + return ListSelectionsCookie{cookie} +} + +// Request reply for ListSelections +// size: (32 + ListItemListSize(Selections)) +type ListSelectionsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + SelectionsLen uint32 + // padding: 20 bytes + Selections []ListItem // size: ListItemListSize(Selections) +} + +// Waits and reads reply data from request ListSelections +func (cook ListSelectionsCookie) Reply() (*ListSelectionsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listSelectionsReply(buf), nil +} + +// Read reply into structure from buffer for ListSelections +func listSelectionsReply(buf []byte) *ListSelectionsReply { + v := new(ListSelectionsReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.SelectionsLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Selections = make([]ListItem, v.SelectionsLen) + b += ListItemReadList(buf[b:], v.Selections) + + return v +} + +// Write request to wire for ListSelections +func listSelectionsRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 21 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request GetClientContext +// size: 8 +type GetClientContextCookie struct { + *xgb.Cookie +} + +func GetClientContext(c *xgb.Conn, Resource uint32) GetClientContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getClientContextRequest(c, Resource), cookie) + return GetClientContextCookie{cookie} +} + +func GetClientContextUnchecked(c *xgb.Conn, Resource uint32) GetClientContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getClientContextRequest(c, Resource), cookie) + return GetClientContextCookie{cookie} +} + +// Request reply for GetClientContext +// size: (32 + xgb.Pad((int(ContextLen) * 1))) +type GetClientContextReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ContextLen uint32 + // padding: 20 bytes + Context string // size: xgb.Pad((int(ContextLen) * 1)) +} + +// Waits and reads reply data from request GetClientContext +func (cook GetClientContextCookie) Reply() (*GetClientContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getClientContextReply(buf), nil +} + +// Read reply into structure from buffer for GetClientContext +func getClientContextReply(buf []byte) *GetClientContextReply { + v := new(GetClientContextReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ContextLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + { + byteString := make([]byte, v.ContextLen) + copy(byteString[:v.ContextLen], buf[b:]) + v.Context = string(byteString) + b += xgb.Pad(int(v.ContextLen)) + } + + return v +} + +// Write request to wire for GetClientContext +func getClientContextRequest(c *xgb.Conn, Resource uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["SELINUX"] + b += 1 + + buf[b] = 22 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Resource) + b += 4 + + return buf +} diff --git a/nexgb/xtest/xtest.go b/nexgb/xtest/xtest.go new file mode 100644 index 0000000..e035fe5 --- /dev/null +++ b/nexgb/xtest/xtest.go @@ -0,0 +1,355 @@ +package xtest + +/* + This file was generated by xtest.xml on May 10 2012 4:20:29pm EDT. + This file is automatically generated. Edit at your peril! +*/ + +import ( + "github.com/BurntSushi/xgb" + + "github.com/BurntSushi/xgb/xproto" +) + +// Init must be called before using the XTEST extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 5, "XTEST").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named XTEST could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["XTEST"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["XTEST"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["XTEST"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["XTEST"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["XTEST"] = make(map[int]xgb.NewErrorFun) +} + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Bool' + +// Skipping definition for base type 'Float' + +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +const ( + CursorNone = 0 + CursorCurrent = 1 +) + +// Request GetVersion +// size: 8 +type GetVersionCookie struct { + *xgb.Cookie +} + +func GetVersion(c *xgb.Conn, MajorVersion byte, MinorVersion uint16) GetVersionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getVersionRequest(c, MajorVersion, MinorVersion), cookie) + return GetVersionCookie{cookie} +} + +func GetVersionUnchecked(c *xgb.Conn, MajorVersion byte, MinorVersion uint16) GetVersionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getVersionRequest(c, MajorVersion, MinorVersion), cookie) + return GetVersionCookie{cookie} +} + +// Request reply for GetVersion +// size: 10 +type GetVersionReply struct { + Sequence uint16 + Length uint32 + MajorVersion byte + MinorVersion uint16 +} + +// Waits and reads reply data from request GetVersion +func (cook GetVersionCookie) Reply() (*GetVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getVersionReply(buf), nil +} + +// Read reply into structure from buffer for GetVersion +func getVersionReply(buf []byte) *GetVersionReply { + v := new(GetVersionReply) + b := 1 // skip reply determinant + + v.MajorVersion = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.MinorVersion = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Write request to wire for GetVersion +func getVersionRequest(c *xgb.Conn, MajorVersion byte, MinorVersion uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XTEST"] + b += 1 + + buf[b] = 0 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = MajorVersion + b += 1 + + b += 1 // padding + + xgb.Put16(buf[b:], MinorVersion) + b += 2 + + return buf +} + +// Request CompareCursor +// size: 12 +type CompareCursorCookie struct { + *xgb.Cookie +} + +func CompareCursor(c *xgb.Conn, Window xproto.Window, Cursor xproto.Cursor) CompareCursorCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(compareCursorRequest(c, Window, Cursor), cookie) + return CompareCursorCookie{cookie} +} + +func CompareCursorUnchecked(c *xgb.Conn, Window xproto.Window, Cursor xproto.Cursor) CompareCursorCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(compareCursorRequest(c, Window, Cursor), cookie) + return CompareCursorCookie{cookie} +} + +// Request reply for CompareCursor +// size: 8 +type CompareCursorReply struct { + Sequence uint16 + Length uint32 + Same bool +} + +// Waits and reads reply data from request CompareCursor +func (cook CompareCursorCookie) Reply() (*CompareCursorReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return compareCursorReply(buf), nil +} + +// Read reply into structure from buffer for CompareCursor +func compareCursorReply(buf []byte) *CompareCursorReply { + v := new(CompareCursorReply) + b := 1 // skip reply determinant + + if buf[b] == 1 { + v.Same = true + } else { + v.Same = false + } + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + return v +} + +// Write request to wire for CompareCursor +func compareCursorRequest(c *xgb.Conn, Window xproto.Window, Cursor xproto.Cursor) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XTEST"] + b += 1 + + buf[b] = 1 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(Cursor)) + b += 4 + + return buf +} + +// Request FakeInput +// size: 36 +type FakeInputCookie struct { + *xgb.Cookie +} + +// Write request to wire for FakeInput +func FakeInput(c *xgb.Conn, Type byte, Detail byte, Time uint32, Root xproto.Window, RootX int16, RootY int16, Deviceid byte) FakeInputCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(fakeInputRequest(c, Type, Detail, Time, Root, RootX, RootY, Deviceid), cookie) + return FakeInputCookie{cookie} +} + +func FakeInputChecked(c *xgb.Conn, Type byte, Detail byte, Time uint32, Root xproto.Window, RootX int16, RootY int16, Deviceid byte) FakeInputCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(fakeInputRequest(c, Type, Detail, Time, Root, RootX, RootY, Deviceid), cookie) + return FakeInputCookie{cookie} +} + +func (cook FakeInputCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for FakeInput +func fakeInputRequest(c *xgb.Conn, Type byte, Detail byte, Time uint32, Root xproto.Window, RootX int16, RootY int16, Deviceid byte) []byte { + size := 36 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XTEST"] + b += 1 + + buf[b] = 2 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = Type + b += 1 + + buf[b] = Detail + b += 1 + + b += 2 // padding + + xgb.Put32(buf[b:], Time) + b += 4 + + xgb.Put32(buf[b:], uint32(Root)) + b += 4 + + b += 8 // padding + + xgb.Put16(buf[b:], uint16(RootX)) + b += 2 + + xgb.Put16(buf[b:], uint16(RootY)) + b += 2 + + b += 7 // padding + + buf[b] = Deviceid + b += 1 + + return buf +} + +// Request GrabControl +// size: 8 +type GrabControlCookie struct { + *xgb.Cookie +} + +// Write request to wire for GrabControl +func GrabControl(c *xgb.Conn, Impervious bool) GrabControlCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(grabControlRequest(c, Impervious), cookie) + return GrabControlCookie{cookie} +} + +func GrabControlChecked(c *xgb.Conn, Impervious bool) GrabControlCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(grabControlRequest(c, Impervious), cookie) + return GrabControlCookie{cookie} +} + +func (cook GrabControlCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for GrabControl +func grabControlRequest(c *xgb.Conn, Impervious bool) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XTEST"] + b += 1 + + buf[b] = 3 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + if Impervious { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding + + return buf +} diff --git a/nexgb/xv/xv.go b/nexgb/xv/xv.go new file mode 100644 index 0000000..8faaf83 --- /dev/null +++ b/nexgb/xv/xv.go @@ -0,0 +1,2746 @@ +package xv + +/* + This file was generated by xv.xml on May 10 2012 4:20:29pm EDT. + This file is automatically generated. Edit at your peril! +*/ + +import ( + "github.com/BurntSushi/xgb" + + "github.com/BurntSushi/xgb/shm" + "github.com/BurntSushi/xgb/xproto" +) + +// Init must be called before using the XVideo extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 6, "XVideo").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named XVideo could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["XVideo"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["XVideo"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["XVideo"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["XVideo"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["XVideo"] = make(map[int]xgb.NewErrorFun) +} + +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Bool' + +// Skipping definition for base type 'Float' + +const ( + TypeInputMask = 1 + TypeOutputMask = 2 + TypeVideoMask = 4 + TypeStillMask = 8 + TypeImageMask = 16 +) + +const ( + ImageFormatInfoTypeRgb = 0 + ImageFormatInfoTypeYuv = 1 +) + +const ( + ImageFormatInfoFormatPacked = 0 + ImageFormatInfoFormatPlanar = 1 +) + +const ( + AttributeFlagGettable = 1 + AttributeFlagSettable = 2 +) + +const ( + VideoNotifyReasonStarted = 0 + VideoNotifyReasonStopped = 1 + VideoNotifyReasonBusy = 2 + VideoNotifyReasonPreempted = 3 + VideoNotifyReasonHardError = 4 +) + +const ( + ScanlineOrderTopToBottom = 0 + ScanlineOrderBottomToTop = 1 +) + +const ( + GrabPortStatusSuccess = 0 + GrabPortStatusBadExtension = 1 + GrabPortStatusAlreadyGrabbed = 2 + GrabPortStatusInvalidTime = 3 + GrabPortStatusBadReply = 4 + GrabPortStatusBadAlloc = 5 +) + +type Port uint32 + +func NewPortId(c *xgb.Conn) (Port, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Port(id), nil +} + +type Encoding uint32 + +func NewEncodingId(c *xgb.Conn) (Encoding, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Encoding(id), nil +} + +// 'Rational' struct definition +// Size: 8 +type Rational struct { + Numerator int32 + Denominator int32 +} + +// Struct read Rational +func RationalRead(buf []byte, v *Rational) int { + b := 0 + + v.Numerator = int32(xgb.Get32(buf[b:])) + b += 4 + + v.Denominator = int32(xgb.Get32(buf[b:])) + b += 4 + + return b +} + +// Struct list read Rational +func RationalReadList(buf []byte, dest []Rational) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Rational{} + b += RationalRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Rational +func (v Rational) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Numerator)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Denominator)) + b += 4 + + return buf +} + +// Write struct list Rational +func RationalListBytes(buf []byte, list []Rational) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Format' struct definition +// Size: 8 +type Format struct { + Visual xproto.Visualid + Depth byte + // padding: 3 bytes +} + +// Struct read Format +func FormatRead(buf []byte, v *Format) int { + b := 0 + + v.Visual = xproto.Visualid(xgb.Get32(buf[b:])) + b += 4 + + v.Depth = buf[b] + b += 1 + + b += 3 // padding + + return b +} + +// Struct list read Format +func FormatReadList(buf []byte, dest []Format) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Format{} + b += FormatRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Format +func (v Format) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Visual)) + b += 4 + + buf[b] = v.Depth + b += 1 + + b += 3 // padding + + return buf +} + +// Write struct list Format +func FormatListBytes(buf []byte, list []Format) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'AdaptorInfo' struct definition +// Size: ((12 + xgb.Pad((int(NameSize) * 1))) + xgb.Pad((int(NumFormats) * 8))) +type AdaptorInfo struct { + BaseId Port + NameSize uint16 + NumPorts uint16 + NumFormats uint16 + Type byte + // padding: 1 bytes + Name string // size: xgb.Pad((int(NameSize) * 1)) + Formats []Format // size: xgb.Pad((int(NumFormats) * 8)) +} + +// Struct read AdaptorInfo +func AdaptorInfoRead(buf []byte, v *AdaptorInfo) int { + b := 0 + + v.BaseId = Port(xgb.Get32(buf[b:])) + b += 4 + + v.NameSize = xgb.Get16(buf[b:]) + b += 2 + + v.NumPorts = xgb.Get16(buf[b:]) + b += 2 + + v.NumFormats = xgb.Get16(buf[b:]) + b += 2 + + v.Type = buf[b] + b += 1 + + b += 1 // padding + + { + byteString := make([]byte, v.NameSize) + copy(byteString[:v.NameSize], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.NameSize)) + } + + v.Formats = make([]Format, v.NumFormats) + b += FormatReadList(buf[b:], v.Formats) + + return b +} + +// Struct list read AdaptorInfo +func AdaptorInfoReadList(buf []byte, dest []AdaptorInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = AdaptorInfo{} + b += AdaptorInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write AdaptorInfo +func (v AdaptorInfo) Bytes() []byte { + buf := make([]byte, ((12 + xgb.Pad((int(v.NameSize) * 1))) + xgb.Pad((int(v.NumFormats) * 8)))) + b := 0 + + xgb.Put32(buf[b:], uint32(v.BaseId)) + b += 4 + + xgb.Put16(buf[b:], v.NameSize) + b += 2 + + xgb.Put16(buf[b:], v.NumPorts) + b += 2 + + xgb.Put16(buf[b:], v.NumFormats) + b += 2 + + buf[b] = v.Type + b += 1 + + b += 1 // padding + + copy(buf[b:], v.Name[:v.NameSize]) + b += xgb.Pad(int(v.NameSize)) + + b += FormatListBytes(buf[b:], v.Formats) + + return buf +} + +// Write struct list AdaptorInfo +func AdaptorInfoListBytes(buf []byte, list []AdaptorInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size AdaptorInfo +func AdaptorInfoListSize(list []AdaptorInfo) int { + size := 0 + for _, item := range list { + size += ((12 + xgb.Pad((int(item.NameSize) * 1))) + xgb.Pad((int(item.NumFormats) * 8))) + } + return size +} + +// 'EncodingInfo' struct definition +// Size: (20 + xgb.Pad((int(NameSize) * 1))) +type EncodingInfo struct { + Encoding Encoding + NameSize uint16 + Width uint16 + Height uint16 + // padding: 2 bytes + Rate Rational + Name string // size: xgb.Pad((int(NameSize) * 1)) +} + +// Struct read EncodingInfo +func EncodingInfoRead(buf []byte, v *EncodingInfo) int { + b := 0 + + v.Encoding = Encoding(xgb.Get32(buf[b:])) + b += 4 + + v.NameSize = xgb.Get16(buf[b:]) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + v.Rate = Rational{} + b += RationalRead(buf[b:], &v.Rate) + + { + byteString := make([]byte, v.NameSize) + copy(byteString[:v.NameSize], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.NameSize)) + } + + return b +} + +// Struct list read EncodingInfo +func EncodingInfoReadList(buf []byte, dest []EncodingInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = EncodingInfo{} + b += EncodingInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write EncodingInfo +func (v EncodingInfo) Bytes() []byte { + buf := make([]byte, (20 + xgb.Pad((int(v.NameSize) * 1)))) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Encoding)) + b += 4 + + xgb.Put16(buf[b:], v.NameSize) + b += 2 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + b += 2 // padding + + { + structBytes := v.Rate.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + copy(buf[b:], v.Name[:v.NameSize]) + b += xgb.Pad(int(v.NameSize)) + + return buf +} + +// Write struct list EncodingInfo +func EncodingInfoListBytes(buf []byte, list []EncodingInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size EncodingInfo +func EncodingInfoListSize(list []EncodingInfo) int { + size := 0 + for _, item := range list { + size += (20 + xgb.Pad((int(item.NameSize) * 1))) + } + return size +} + +// 'Image' struct definition +// Size: (((16 + xgb.Pad((int(NumPlanes) * 4))) + xgb.Pad((int(NumPlanes) * 4))) + xgb.Pad((int(DataSize) * 1))) +type Image struct { + Id uint32 + Width uint16 + Height uint16 + DataSize uint32 + NumPlanes uint32 + Pitches []uint32 // size: xgb.Pad((int(NumPlanes) * 4)) + Offsets []uint32 // size: xgb.Pad((int(NumPlanes) * 4)) + Data []byte // size: xgb.Pad((int(DataSize) * 1)) +} + +// Struct read Image +func ImageRead(buf []byte, v *Image) int { + b := 0 + + v.Id = xgb.Get32(buf[b:]) + b += 4 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.DataSize = xgb.Get32(buf[b:]) + b += 4 + + v.NumPlanes = xgb.Get32(buf[b:]) + b += 4 + + v.Pitches = make([]uint32, v.NumPlanes) + for i := 0; i < int(v.NumPlanes); i++ { + v.Pitches[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + v.Offsets = make([]uint32, v.NumPlanes) + for i := 0; i < int(v.NumPlanes); i++ { + v.Offsets[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + v.Data = make([]byte, v.DataSize) + copy(v.Data[:v.DataSize], buf[b:]) + b += xgb.Pad(int(v.DataSize)) + + return b +} + +// Struct list read Image +func ImageReadList(buf []byte, dest []Image) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Image{} + b += ImageRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Image +func (v Image) Bytes() []byte { + buf := make([]byte, (((16 + xgb.Pad((int(v.NumPlanes) * 4))) + xgb.Pad((int(v.NumPlanes) * 4))) + xgb.Pad((int(v.DataSize) * 1)))) + b := 0 + + xgb.Put32(buf[b:], v.Id) + b += 4 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + xgb.Put32(buf[b:], v.DataSize) + b += 4 + + xgb.Put32(buf[b:], v.NumPlanes) + b += 4 + + for i := 0; i < int(v.NumPlanes); i++ { + xgb.Put32(buf[b:], v.Pitches[i]) + b += 4 + } + b = xgb.Pad(b) + + for i := 0; i < int(v.NumPlanes); i++ { + xgb.Put32(buf[b:], v.Offsets[i]) + b += 4 + } + b = xgb.Pad(b) + + copy(buf[b:], v.Data[:v.DataSize]) + b += xgb.Pad(int(v.DataSize)) + + return buf +} + +// Write struct list Image +func ImageListBytes(buf []byte, list []Image) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size Image +func ImageListSize(list []Image) int { + size := 0 + for _, item := range list { + size += (((16 + xgb.Pad((int(item.NumPlanes) * 4))) + xgb.Pad((int(item.NumPlanes) * 4))) + xgb.Pad((int(item.DataSize) * 1))) + } + return size +} + +// 'AttributeInfo' struct definition +// Size: (16 + xgb.Pad((int(Size) * 1))) +type AttributeInfo struct { + Flags uint32 + Min int32 + Max int32 + Size uint32 + Name string // size: xgb.Pad((int(Size) * 1)) +} + +// Struct read AttributeInfo +func AttributeInfoRead(buf []byte, v *AttributeInfo) int { + b := 0 + + v.Flags = xgb.Get32(buf[b:]) + b += 4 + + v.Min = int32(xgb.Get32(buf[b:])) + b += 4 + + v.Max = int32(xgb.Get32(buf[b:])) + b += 4 + + v.Size = xgb.Get32(buf[b:]) + b += 4 + + { + byteString := make([]byte, v.Size) + copy(byteString[:v.Size], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.Size)) + } + + return b +} + +// Struct list read AttributeInfo +func AttributeInfoReadList(buf []byte, dest []AttributeInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = AttributeInfo{} + b += AttributeInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write AttributeInfo +func (v AttributeInfo) Bytes() []byte { + buf := make([]byte, (16 + xgb.Pad((int(v.Size) * 1)))) + b := 0 + + xgb.Put32(buf[b:], v.Flags) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Min)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Max)) + b += 4 + + xgb.Put32(buf[b:], v.Size) + b += 4 + + copy(buf[b:], v.Name[:v.Size]) + b += xgb.Pad(int(v.Size)) + + return buf +} + +// Write struct list AttributeInfo +func AttributeInfoListBytes(buf []byte, list []AttributeInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size AttributeInfo +func AttributeInfoListSize(list []AttributeInfo) int { + size := 0 + for _, item := range list { + size += (16 + xgb.Pad((int(item.Size) * 1))) + } + return size +} + +// 'ImageFormatInfo' struct definition +// Size: 128 +type ImageFormatInfo struct { + Id uint32 + Type byte + ByteOrder byte + // padding: 2 bytes + Guid []byte // size: 16 + Bpp byte + NumPlanes byte + // padding: 2 bytes + Depth byte + // padding: 3 bytes + RedMask uint32 + GreenMask uint32 + BlueMask uint32 + Format byte + // padding: 3 bytes + YSampleBits uint32 + USampleBits uint32 + VSampleBits uint32 + VhorzYPeriod uint32 + VhorzUPeriod uint32 + VhorzVPeriod uint32 + VvertYPeriod uint32 + VvertUPeriod uint32 + VvertVPeriod uint32 + VcompOrder []byte // size: 32 + VscanlineOrder byte + // padding: 11 bytes +} + +// Struct read ImageFormatInfo +func ImageFormatInfoRead(buf []byte, v *ImageFormatInfo) int { + b := 0 + + v.Id = xgb.Get32(buf[b:]) + b += 4 + + v.Type = buf[b] + b += 1 + + v.ByteOrder = buf[b] + b += 1 + + b += 2 // padding + + v.Guid = make([]byte, 16) + copy(v.Guid[:16], buf[b:]) + b += xgb.Pad(int(16)) + + v.Bpp = buf[b] + b += 1 + + v.NumPlanes = buf[b] + b += 1 + + b += 2 // padding + + v.Depth = buf[b] + b += 1 + + b += 3 // padding + + v.RedMask = xgb.Get32(buf[b:]) + b += 4 + + v.GreenMask = xgb.Get32(buf[b:]) + b += 4 + + v.BlueMask = xgb.Get32(buf[b:]) + b += 4 + + v.Format = buf[b] + b += 1 + + b += 3 // padding + + v.YSampleBits = xgb.Get32(buf[b:]) + b += 4 + + v.USampleBits = xgb.Get32(buf[b:]) + b += 4 + + v.VSampleBits = xgb.Get32(buf[b:]) + b += 4 + + v.VhorzYPeriod = xgb.Get32(buf[b:]) + b += 4 + + v.VhorzUPeriod = xgb.Get32(buf[b:]) + b += 4 + + v.VhorzVPeriod = xgb.Get32(buf[b:]) + b += 4 + + v.VvertYPeriod = xgb.Get32(buf[b:]) + b += 4 + + v.VvertUPeriod = xgb.Get32(buf[b:]) + b += 4 + + v.VvertVPeriod = xgb.Get32(buf[b:]) + b += 4 + + v.VcompOrder = make([]byte, 32) + copy(v.VcompOrder[:32], buf[b:]) + b += xgb.Pad(int(32)) + + v.VscanlineOrder = buf[b] + b += 1 + + b += 11 // padding + + return b +} + +// Struct list read ImageFormatInfo +func ImageFormatInfoReadList(buf []byte, dest []ImageFormatInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = ImageFormatInfo{} + b += ImageFormatInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write ImageFormatInfo +func (v ImageFormatInfo) Bytes() []byte { + buf := make([]byte, 128) + b := 0 + + xgb.Put32(buf[b:], v.Id) + b += 4 + + buf[b] = v.Type + b += 1 + + buf[b] = v.ByteOrder + b += 1 + + b += 2 // padding + + copy(buf[b:], v.Guid[:16]) + b += xgb.Pad(int(16)) + + buf[b] = v.Bpp + b += 1 + + buf[b] = v.NumPlanes + b += 1 + + b += 2 // padding + + buf[b] = v.Depth + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], v.RedMask) + b += 4 + + xgb.Put32(buf[b:], v.GreenMask) + b += 4 + + xgb.Put32(buf[b:], v.BlueMask) + b += 4 + + buf[b] = v.Format + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], v.YSampleBits) + b += 4 + + xgb.Put32(buf[b:], v.USampleBits) + b += 4 + + xgb.Put32(buf[b:], v.VSampleBits) + b += 4 + + xgb.Put32(buf[b:], v.VhorzYPeriod) + b += 4 + + xgb.Put32(buf[b:], v.VhorzUPeriod) + b += 4 + + xgb.Put32(buf[b:], v.VhorzVPeriod) + b += 4 + + xgb.Put32(buf[b:], v.VvertYPeriod) + b += 4 + + xgb.Put32(buf[b:], v.VvertUPeriod) + b += 4 + + xgb.Put32(buf[b:], v.VvertVPeriod) + b += 4 + + copy(buf[b:], v.VcompOrder[:32]) + b += xgb.Pad(int(32)) + + buf[b] = v.VscanlineOrder + b += 1 + + b += 11 // padding + + return buf +} + +// Write struct list ImageFormatInfo +func ImageFormatInfoListBytes(buf []byte, list []ImageFormatInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size ImageFormatInfo +func ImageFormatInfoListSize(list []ImageFormatInfo) int { + size := 0 + for _ = range list { + size += 128 + } + return size +} + +// Event definition VideoNotify (0) +// Size: 32 + +const VideoNotify = 0 + +type VideoNotifyEvent struct { + Sequence uint16 + Reason byte + Time xproto.Timestamp + Drawable xproto.Drawable + Port Port +} + +// Event read VideoNotify +func VideoNotifyEventNew(buf []byte) xgb.Event { + v := VideoNotifyEvent{} + b := 1 // don't read event number + + v.Reason = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Drawable = xproto.Drawable(xgb.Get32(buf[b:])) + b += 4 + + v.Port = Port(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Event write VideoNotify +func (v VideoNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 0 + b += 1 + + buf[b] = v.Reason + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Port)) + b += 4 + + return buf +} + +func (v VideoNotifyEvent) ImplementsEvent() {} + +func (v VideoNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v VideoNotifyEvent) String() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Reason: %d", v.Reason)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Drawable: %d", v.Drawable)) + fieldVals = append(fieldVals, xgb.Sprintf("Port: %d", v.Port)) + return "VideoNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XVideo"][0] = VideoNotifyEventNew +} + +// Event definition PortNotify (1) +// Size: 32 + +const PortNotify = 1 + +type PortNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Time xproto.Timestamp + Port Port + Attribute xproto.Atom + Value int32 +} + +// Event read PortNotify +func PortNotifyEventNew(buf []byte) xgb.Event { + v := PortNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Port = Port(xgb.Get32(buf[b:])) + b += 4 + + v.Attribute = xproto.Atom(xgb.Get32(buf[b:])) + b += 4 + + v.Value = int32(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Event write PortNotify +func (v PortNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 1 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Attribute)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Value)) + b += 4 + + return buf +} + +func (v PortNotifyEvent) ImplementsEvent() {} + +func (v PortNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v PortNotifyEvent) String() string { + fieldVals := make([]string, 0, 5) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Port: %d", v.Port)) + fieldVals = append(fieldVals, xgb.Sprintf("Attribute: %d", v.Attribute)) + fieldVals = append(fieldVals, xgb.Sprintf("Value: %d", v.Value)) + return "PortNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XVideo"][1] = PortNotifyEventNew +} + +// Error definition BadPort (0) +// Size: 32 + +const BadBadPort = 0 + +type BadPortError struct { + Sequence uint16 + NiceName string +} + +// Error read BadPort +func BadPortErrorNew(buf []byte) xgb.Error { + v := BadPortError{} + v.NiceName = "BadPort" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err BadPortError) ImplementsError() {} + +func (err BadPortError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadPortError) BadId() uint32 { + return 0 +} + +func (err BadPortError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadPort {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XVideo"][0] = BadPortErrorNew +} + +// Error definition BadEncoding (1) +// Size: 32 + +const BadBadEncoding = 1 + +type BadEncodingError struct { + Sequence uint16 + NiceName string +} + +// Error read BadEncoding +func BadEncodingErrorNew(buf []byte) xgb.Error { + v := BadEncodingError{} + v.NiceName = "BadEncoding" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err BadEncodingError) ImplementsError() {} + +func (err BadEncodingError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadEncodingError) BadId() uint32 { + return 0 +} + +func (err BadEncodingError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadEncoding {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XVideo"][1] = BadEncodingErrorNew +} + +// Error definition BadControl (2) +// Size: 32 + +const BadBadControl = 2 + +type BadControlError struct { + Sequence uint16 + NiceName string +} + +// Error read BadControl +func BadControlErrorNew(buf []byte) xgb.Error { + v := BadControlError{} + v.NiceName = "BadControl" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err BadControlError) ImplementsError() {} + +func (err BadControlError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadControlError) BadId() uint32 { + return 0 +} + +func (err BadControlError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadControl {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XVideo"][2] = BadControlErrorNew +} + +// Request QueryExtension +// size: 4 +type QueryExtensionCookie struct { + *xgb.Cookie +} + +func QueryExtension(c *xgb.Conn) QueryExtensionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryExtensionRequest(c), cookie) + return QueryExtensionCookie{cookie} +} + +func QueryExtensionUnchecked(c *xgb.Conn) QueryExtensionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryExtensionRequest(c), cookie) + return QueryExtensionCookie{cookie} +} + +// Request reply for QueryExtension +// size: 12 +type QueryExtensionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Major uint16 + Minor uint16 +} + +// Waits and reads reply data from request QueryExtension +func (cook QueryExtensionCookie) Reply() (*QueryExtensionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryExtensionReply(buf), nil +} + +// Read reply into structure from buffer for QueryExtension +func queryExtensionReply(buf []byte) *QueryExtensionReply { + v := new(QueryExtensionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Major = xgb.Get16(buf[b:]) + b += 2 + + v.Minor = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Write request to wire for QueryExtension +func queryExtensionRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 0 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request QueryAdaptors +// size: 8 +type QueryAdaptorsCookie struct { + *xgb.Cookie +} + +func QueryAdaptors(c *xgb.Conn, Window xproto.Window) QueryAdaptorsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryAdaptorsRequest(c, Window), cookie) + return QueryAdaptorsCookie{cookie} +} + +func QueryAdaptorsUnchecked(c *xgb.Conn, Window xproto.Window) QueryAdaptorsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryAdaptorsRequest(c, Window), cookie) + return QueryAdaptorsCookie{cookie} +} + +// Request reply for QueryAdaptors +// size: (32 + AdaptorInfoListSize(Info)) +type QueryAdaptorsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumAdaptors uint16 + // padding: 22 bytes + Info []AdaptorInfo // size: AdaptorInfoListSize(Info) +} + +// Waits and reads reply data from request QueryAdaptors +func (cook QueryAdaptorsCookie) Reply() (*QueryAdaptorsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryAdaptorsReply(buf), nil +} + +// Read reply into structure from buffer for QueryAdaptors +func queryAdaptorsReply(buf []byte) *QueryAdaptorsReply { + v := new(QueryAdaptorsReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NumAdaptors = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + v.Info = make([]AdaptorInfo, v.NumAdaptors) + b += AdaptorInfoReadList(buf[b:], v.Info) + + return v +} + +// Write request to wire for QueryAdaptors +func queryAdaptorsRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 1 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + +// Request QueryEncodings +// size: 8 +type QueryEncodingsCookie struct { + *xgb.Cookie +} + +func QueryEncodings(c *xgb.Conn, Port Port) QueryEncodingsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryEncodingsRequest(c, Port), cookie) + return QueryEncodingsCookie{cookie} +} + +func QueryEncodingsUnchecked(c *xgb.Conn, Port Port) QueryEncodingsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryEncodingsRequest(c, Port), cookie) + return QueryEncodingsCookie{cookie} +} + +// Request reply for QueryEncodings +// size: (32 + EncodingInfoListSize(Info)) +type QueryEncodingsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumEncodings uint16 + // padding: 22 bytes + Info []EncodingInfo // size: EncodingInfoListSize(Info) +} + +// Waits and reads reply data from request QueryEncodings +func (cook QueryEncodingsCookie) Reply() (*QueryEncodingsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryEncodingsReply(buf), nil +} + +// Read reply into structure from buffer for QueryEncodings +func queryEncodingsReply(buf []byte) *QueryEncodingsReply { + v := new(QueryEncodingsReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NumEncodings = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + v.Info = make([]EncodingInfo, v.NumEncodings) + b += EncodingInfoReadList(buf[b:], v.Info) + + return v +} + +// Write request to wire for QueryEncodings +func queryEncodingsRequest(c *xgb.Conn, Port Port) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 2 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + return buf +} + +// Request GrabPort +// size: 12 +type GrabPortCookie struct { + *xgb.Cookie +} + +func GrabPort(c *xgb.Conn, Port Port, Time xproto.Timestamp) GrabPortCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(grabPortRequest(c, Port, Time), cookie) + return GrabPortCookie{cookie} +} + +func GrabPortUnchecked(c *xgb.Conn, Port Port, Time xproto.Timestamp) GrabPortCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(grabPortRequest(c, Port, Time), cookie) + return GrabPortCookie{cookie} +} + +// Request reply for GrabPort +// size: 8 +type GrabPortReply struct { + Sequence uint16 + Length uint32 + Result byte +} + +// Waits and reads reply data from request GrabPort +func (cook GrabPortCookie) Reply() (*GrabPortReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return grabPortReply(buf), nil +} + +// Read reply into structure from buffer for GrabPort +func grabPortReply(buf []byte) *GrabPortReply { + v := new(GrabPortReply) + b := 1 // skip reply determinant + + v.Result = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + return v +} + +// Write request to wire for GrabPort +func grabPortRequest(c *xgb.Conn, Port Port, Time xproto.Timestamp) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 3 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + return buf +} + +// Request UngrabPort +// size: 12 +type UngrabPortCookie struct { + *xgb.Cookie +} + +// Write request to wire for UngrabPort +func UngrabPort(c *xgb.Conn, Port Port, Time xproto.Timestamp) UngrabPortCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(ungrabPortRequest(c, Port, Time), cookie) + return UngrabPortCookie{cookie} +} + +func UngrabPortChecked(c *xgb.Conn, Port Port, Time xproto.Timestamp) UngrabPortCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(ungrabPortRequest(c, Port, Time), cookie) + return UngrabPortCookie{cookie} +} + +func (cook UngrabPortCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for UngrabPort +func ungrabPortRequest(c *xgb.Conn, Port Port, Time xproto.Timestamp) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 4 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + return buf +} + +// Request PutVideo +// size: 32 +type PutVideoCookie struct { + *xgb.Cookie +} + +// Write request to wire for PutVideo +func PutVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutVideoCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(putVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return PutVideoCookie{cookie} +} + +func PutVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutVideoCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(putVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return PutVideoCookie{cookie} +} + +func (cook PutVideoCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PutVideo +func putVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { + size := 32 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 5 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put16(buf[b:], uint16(VidX)) + b += 2 + + xgb.Put16(buf[b:], uint16(VidY)) + b += 2 + + xgb.Put16(buf[b:], VidW) + b += 2 + + xgb.Put16(buf[b:], VidH) + b += 2 + + xgb.Put16(buf[b:], uint16(DrwX)) + b += 2 + + xgb.Put16(buf[b:], uint16(DrwY)) + b += 2 + + xgb.Put16(buf[b:], DrwW) + b += 2 + + xgb.Put16(buf[b:], DrwH) + b += 2 + + return buf +} + +// Request PutStill +// size: 32 +type PutStillCookie struct { + *xgb.Cookie +} + +// Write request to wire for PutStill +func PutStill(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutStillCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(putStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return PutStillCookie{cookie} +} + +func PutStillChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutStillCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(putStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return PutStillCookie{cookie} +} + +func (cook PutStillCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PutStill +func putStillRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { + size := 32 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 6 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put16(buf[b:], uint16(VidX)) + b += 2 + + xgb.Put16(buf[b:], uint16(VidY)) + b += 2 + + xgb.Put16(buf[b:], VidW) + b += 2 + + xgb.Put16(buf[b:], VidH) + b += 2 + + xgb.Put16(buf[b:], uint16(DrwX)) + b += 2 + + xgb.Put16(buf[b:], uint16(DrwY)) + b += 2 + + xgb.Put16(buf[b:], DrwW) + b += 2 + + xgb.Put16(buf[b:], DrwH) + b += 2 + + return buf +} + +// Request GetVideo +// size: 32 +type GetVideoCookie struct { + *xgb.Cookie +} + +// Write request to wire for GetVideo +func GetVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetVideoCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(getVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return GetVideoCookie{cookie} +} + +func GetVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetVideoCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(getVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return GetVideoCookie{cookie} +} + +func (cook GetVideoCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for GetVideo +func getVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { + size := 32 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 7 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put16(buf[b:], uint16(VidX)) + b += 2 + + xgb.Put16(buf[b:], uint16(VidY)) + b += 2 + + xgb.Put16(buf[b:], VidW) + b += 2 + + xgb.Put16(buf[b:], VidH) + b += 2 + + xgb.Put16(buf[b:], uint16(DrwX)) + b += 2 + + xgb.Put16(buf[b:], uint16(DrwY)) + b += 2 + + xgb.Put16(buf[b:], DrwW) + b += 2 + + xgb.Put16(buf[b:], DrwH) + b += 2 + + return buf +} + +// Request GetStill +// size: 32 +type GetStillCookie struct { + *xgb.Cookie +} + +// Write request to wire for GetStill +func GetStill(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetStillCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(getStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return GetStillCookie{cookie} +} + +func GetStillChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetStillCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(getStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return GetStillCookie{cookie} +} + +func (cook GetStillCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for GetStill +func getStillRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { + size := 32 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 8 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put16(buf[b:], uint16(VidX)) + b += 2 + + xgb.Put16(buf[b:], uint16(VidY)) + b += 2 + + xgb.Put16(buf[b:], VidW) + b += 2 + + xgb.Put16(buf[b:], VidH) + b += 2 + + xgb.Put16(buf[b:], uint16(DrwX)) + b += 2 + + xgb.Put16(buf[b:], uint16(DrwY)) + b += 2 + + xgb.Put16(buf[b:], DrwW) + b += 2 + + xgb.Put16(buf[b:], DrwH) + b += 2 + + return buf +} + +// Request StopVideo +// size: 12 +type StopVideoCookie struct { + *xgb.Cookie +} + +// Write request to wire for StopVideo +func StopVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable) StopVideoCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(stopVideoRequest(c, Port, Drawable), cookie) + return StopVideoCookie{cookie} +} + +func StopVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable) StopVideoCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(stopVideoRequest(c, Port, Drawable), cookie) + return StopVideoCookie{cookie} +} + +func (cook StopVideoCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for StopVideo +func stopVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 9 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + return buf +} + +// Request SelectVideoNotify +// size: 12 +type SelectVideoNotifyCookie struct { + *xgb.Cookie +} + +// Write request to wire for SelectVideoNotify +func SelectVideoNotify(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) SelectVideoNotifyCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(selectVideoNotifyRequest(c, Drawable, Onoff), cookie) + return SelectVideoNotifyCookie{cookie} +} + +func SelectVideoNotifyChecked(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) SelectVideoNotifyCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(selectVideoNotifyRequest(c, Drawable, Onoff), cookie) + return SelectVideoNotifyCookie{cookie} +} + +func (cook SelectVideoNotifyCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SelectVideoNotify +func selectVideoNotifyRequest(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 10 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + if Onoff { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding + + return buf +} + +// Request SelectPortNotify +// size: 12 +type SelectPortNotifyCookie struct { + *xgb.Cookie +} + +// Write request to wire for SelectPortNotify +func SelectPortNotify(c *xgb.Conn, Port Port, Onoff bool) SelectPortNotifyCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(selectPortNotifyRequest(c, Port, Onoff), cookie) + return SelectPortNotifyCookie{cookie} +} + +func SelectPortNotifyChecked(c *xgb.Conn, Port Port, Onoff bool) SelectPortNotifyCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(selectPortNotifyRequest(c, Port, Onoff), cookie) + return SelectPortNotifyCookie{cookie} +} + +func (cook SelectPortNotifyCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SelectPortNotify +func selectPortNotifyRequest(c *xgb.Conn, Port Port, Onoff bool) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 11 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + if Onoff { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding + + return buf +} + +// Request QueryBestSize +// size: 20 +type QueryBestSizeCookie struct { + *xgb.Cookie +} + +func QueryBestSize(c *xgb.Conn, Port Port, VidW uint16, VidH uint16, DrwW uint16, DrwH uint16, Motion bool) QueryBestSizeCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryBestSizeRequest(c, Port, VidW, VidH, DrwW, DrwH, Motion), cookie) + return QueryBestSizeCookie{cookie} +} + +func QueryBestSizeUnchecked(c *xgb.Conn, Port Port, VidW uint16, VidH uint16, DrwW uint16, DrwH uint16, Motion bool) QueryBestSizeCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryBestSizeRequest(c, Port, VidW, VidH, DrwW, DrwH, Motion), cookie) + return QueryBestSizeCookie{cookie} +} + +// Request reply for QueryBestSize +// size: 12 +type QueryBestSizeReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ActualWidth uint16 + ActualHeight uint16 +} + +// Waits and reads reply data from request QueryBestSize +func (cook QueryBestSizeCookie) Reply() (*QueryBestSizeReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryBestSizeReply(buf), nil +} + +// Read reply into structure from buffer for QueryBestSize +func queryBestSizeReply(buf []byte) *QueryBestSizeReply { + v := new(QueryBestSizeReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ActualWidth = xgb.Get16(buf[b:]) + b += 2 + + v.ActualHeight = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Write request to wire for QueryBestSize +func queryBestSizeRequest(c *xgb.Conn, Port Port, VidW uint16, VidH uint16, DrwW uint16, DrwH uint16, Motion bool) []byte { + size := 20 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 12 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + xgb.Put16(buf[b:], VidW) + b += 2 + + xgb.Put16(buf[b:], VidH) + b += 2 + + xgb.Put16(buf[b:], DrwW) + b += 2 + + xgb.Put16(buf[b:], DrwH) + b += 2 + + if Motion { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding + + return buf +} + +// Request SetPortAttribute +// size: 16 +type SetPortAttributeCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetPortAttribute +func SetPortAttribute(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32) SetPortAttributeCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setPortAttributeRequest(c, Port, Attribute, Value), cookie) + return SetPortAttributeCookie{cookie} +} + +func SetPortAttributeChecked(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32) SetPortAttributeCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setPortAttributeRequest(c, Port, Attribute, Value), cookie) + return SetPortAttributeCookie{cookie} +} + +func (cook SetPortAttributeCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetPortAttribute +func setPortAttributeRequest(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 13 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Attribute)) + b += 4 + + xgb.Put32(buf[b:], uint32(Value)) + b += 4 + + return buf +} + +// Request GetPortAttribute +// size: 12 +type GetPortAttributeCookie struct { + *xgb.Cookie +} + +func GetPortAttribute(c *xgb.Conn, Port Port, Attribute xproto.Atom) GetPortAttributeCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getPortAttributeRequest(c, Port, Attribute), cookie) + return GetPortAttributeCookie{cookie} +} + +func GetPortAttributeUnchecked(c *xgb.Conn, Port Port, Attribute xproto.Atom) GetPortAttributeCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getPortAttributeRequest(c, Port, Attribute), cookie) + return GetPortAttributeCookie{cookie} +} + +// Request reply for GetPortAttribute +// size: 12 +type GetPortAttributeReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Value int32 +} + +// Waits and reads reply data from request GetPortAttribute +func (cook GetPortAttributeCookie) Reply() (*GetPortAttributeReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPortAttributeReply(buf), nil +} + +// Read reply into structure from buffer for GetPortAttribute +func getPortAttributeReply(buf []byte) *GetPortAttributeReply { + v := new(GetPortAttributeReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Value = int32(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Write request to wire for GetPortAttribute +func getPortAttributeRequest(c *xgb.Conn, Port Port, Attribute xproto.Atom) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 14 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Attribute)) + b += 4 + + return buf +} + +// Request QueryPortAttributes +// size: 8 +type QueryPortAttributesCookie struct { + *xgb.Cookie +} + +func QueryPortAttributes(c *xgb.Conn, Port Port) QueryPortAttributesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryPortAttributesRequest(c, Port), cookie) + return QueryPortAttributesCookie{cookie} +} + +func QueryPortAttributesUnchecked(c *xgb.Conn, Port Port) QueryPortAttributesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryPortAttributesRequest(c, Port), cookie) + return QueryPortAttributesCookie{cookie} +} + +// Request reply for QueryPortAttributes +// size: (32 + AttributeInfoListSize(Attributes)) +type QueryPortAttributesReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumAttributes uint32 + TextSize uint32 + // padding: 16 bytes + Attributes []AttributeInfo // size: AttributeInfoListSize(Attributes) +} + +// Waits and reads reply data from request QueryPortAttributes +func (cook QueryPortAttributesCookie) Reply() (*QueryPortAttributesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryPortAttributesReply(buf), nil +} + +// Read reply into structure from buffer for QueryPortAttributes +func queryPortAttributesReply(buf []byte) *QueryPortAttributesReply { + v := new(QueryPortAttributesReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NumAttributes = xgb.Get32(buf[b:]) + b += 4 + + v.TextSize = xgb.Get32(buf[b:]) + b += 4 + + b += 16 // padding + + v.Attributes = make([]AttributeInfo, v.NumAttributes) + b += AttributeInfoReadList(buf[b:], v.Attributes) + + return v +} + +// Write request to wire for QueryPortAttributes +func queryPortAttributesRequest(c *xgb.Conn, Port Port) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 15 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + return buf +} + +// Request ListImageFormats +// size: 8 +type ListImageFormatsCookie struct { + *xgb.Cookie +} + +func ListImageFormats(c *xgb.Conn, Port Port) ListImageFormatsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(listImageFormatsRequest(c, Port), cookie) + return ListImageFormatsCookie{cookie} +} + +func ListImageFormatsUnchecked(c *xgb.Conn, Port Port) ListImageFormatsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(listImageFormatsRequest(c, Port), cookie) + return ListImageFormatsCookie{cookie} +} + +// Request reply for ListImageFormats +// size: (32 + ImageFormatInfoListSize(Format)) +type ListImageFormatsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumFormats uint32 + // padding: 20 bytes + Format []ImageFormatInfo // size: ImageFormatInfoListSize(Format) +} + +// Waits and reads reply data from request ListImageFormats +func (cook ListImageFormatsCookie) Reply() (*ListImageFormatsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listImageFormatsReply(buf), nil +} + +// Read reply into structure from buffer for ListImageFormats +func listImageFormatsReply(buf []byte) *ListImageFormatsReply { + v := new(ListImageFormatsReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NumFormats = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Format = make([]ImageFormatInfo, v.NumFormats) + b += ImageFormatInfoReadList(buf[b:], v.Format) + + return v +} + +// Write request to wire for ListImageFormats +func listImageFormatsRequest(c *xgb.Conn, Port Port) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 16 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + return buf +} + +// Request QueryImageAttributes +// size: 16 +type QueryImageAttributesCookie struct { + *xgb.Cookie +} + +func QueryImageAttributes(c *xgb.Conn, Port Port, Id uint32, Width uint16, Height uint16) QueryImageAttributesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryImageAttributesRequest(c, Port, Id, Width, Height), cookie) + return QueryImageAttributesCookie{cookie} +} + +func QueryImageAttributesUnchecked(c *xgb.Conn, Port Port, Id uint32, Width uint16, Height uint16) QueryImageAttributesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryImageAttributesRequest(c, Port, Id, Width, Height), cookie) + return QueryImageAttributesCookie{cookie} +} + +// Request reply for QueryImageAttributes +// size: ((32 + xgb.Pad((int(NumPlanes) * 4))) + xgb.Pad((int(NumPlanes) * 4))) +type QueryImageAttributesReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumPlanes uint32 + DataSize uint32 + Width uint16 + Height uint16 + // padding: 12 bytes + Pitches []uint32 // size: xgb.Pad((int(NumPlanes) * 4)) + Offsets []uint32 // size: xgb.Pad((int(NumPlanes) * 4)) +} + +// Waits and reads reply data from request QueryImageAttributes +func (cook QueryImageAttributesCookie) Reply() (*QueryImageAttributesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryImageAttributesReply(buf), nil +} + +// Read reply into structure from buffer for QueryImageAttributes +func queryImageAttributesReply(buf []byte) *QueryImageAttributesReply { + v := new(QueryImageAttributesReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NumPlanes = xgb.Get32(buf[b:]) + b += 4 + + v.DataSize = xgb.Get32(buf[b:]) + b += 4 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + b += 12 // padding + + v.Pitches = make([]uint32, v.NumPlanes) + for i := 0; i < int(v.NumPlanes); i++ { + v.Pitches[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + v.Offsets = make([]uint32, v.NumPlanes) + for i := 0; i < int(v.NumPlanes); i++ { + v.Offsets[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for QueryImageAttributes +func queryImageAttributesRequest(c *xgb.Conn, Port Port, Id uint32, Width uint16, Height uint16) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 17 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + xgb.Put32(buf[b:], Id) + b += 4 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + return buf +} + +// Request PutImage +// size: xgb.Pad((40 + xgb.Pad((len(Data) * 1)))) +type PutImageCookie struct { + *xgb.Cookie +} + +// Write request to wire for PutImage +func PutImage(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) PutImageCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(putImageRequest(c, Port, Drawable, Gc, Id, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, Data), cookie) + return PutImageCookie{cookie} +} + +func PutImageChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) PutImageCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(putImageRequest(c, Port, Drawable, Gc, Id, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, Data), cookie) + return PutImageCookie{cookie} +} + +func (cook PutImageCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PutImage +func putImageRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) []byte { + size := xgb.Pad((40 + xgb.Pad((len(Data) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 18 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put32(buf[b:], Id) + b += 4 + + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 + + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 + + xgb.Put16(buf[b:], SrcW) + b += 2 + + xgb.Put16(buf[b:], SrcH) + b += 2 + + xgb.Put16(buf[b:], uint16(DrwX)) + b += 2 + + xgb.Put16(buf[b:], uint16(DrwY)) + b += 2 + + xgb.Put16(buf[b:], DrwW) + b += 2 + + xgb.Put16(buf[b:], DrwH) + b += 2 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + copy(buf[b:], Data[:len(Data)]) + b += xgb.Pad(int(len(Data))) + + return buf +} + +// Request ShmPutImage +// size: 52 +type ShmPutImageCookie struct { + *xgb.Cookie +} + +// Write request to wire for ShmPutImage +func ShmPutImage(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Shmseg shm.Seg, Id uint32, Offset uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, SendEvent byte) ShmPutImageCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(shmPutImageRequest(c, Port, Drawable, Gc, Shmseg, Id, Offset, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, SendEvent), cookie) + return ShmPutImageCookie{cookie} +} + +func ShmPutImageChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Shmseg shm.Seg, Id uint32, Offset uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, SendEvent byte) ShmPutImageCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(shmPutImageRequest(c, Port, Drawable, Gc, Shmseg, Id, Offset, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, SendEvent), cookie) + return ShmPutImageCookie{cookie} +} + +func (cook ShmPutImageCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ShmPutImage +func shmPutImageRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Shmseg shm.Seg, Id uint32, Offset uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, SendEvent byte) []byte { + size := 52 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 19 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put32(buf[b:], uint32(Shmseg)) + b += 4 + + xgb.Put32(buf[b:], Id) + b += 4 + + xgb.Put32(buf[b:], Offset) + b += 4 + + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 + + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 + + xgb.Put16(buf[b:], SrcW) + b += 2 + + xgb.Put16(buf[b:], SrcH) + b += 2 + + xgb.Put16(buf[b:], uint16(DrwX)) + b += 2 + + xgb.Put16(buf[b:], uint16(DrwY)) + b += 2 + + xgb.Put16(buf[b:], DrwW) + b += 2 + + xgb.Put16(buf[b:], DrwH) + b += 2 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + buf[b] = SendEvent + b += 1 + + b += 3 // padding + + return buf +} diff --git a/nexgb/xvmc/xvmc.go b/nexgb/xvmc/xvmc.go new file mode 100644 index 0000000..8878acf --- /dev/null +++ b/nexgb/xvmc/xvmc.go @@ -0,0 +1,908 @@ +package xvmc + +/* + This file was generated by xvmc.xml on May 10 2012 4:20:29pm EDT. + This file is automatically generated. Edit at your peril! +*/ + +import ( + "github.com/BurntSushi/xgb" + + "github.com/BurntSushi/xgb/xproto" + "github.com/BurntSushi/xgb/xv" +) + +// Init must be called before using the XVideo-MotionCompensation extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 25, "XVideo-MotionCompensation").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named XVideo-MotionCompensation could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["XVideo-MotionCompensation"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["XVideo-MotionCompensation"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["XVideo-MotionCompensation"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["XVideo-MotionCompensation"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["XVideo-MotionCompensation"] = make(map[int]xgb.NewErrorFun) +} + +// Skipping definition for base type 'Bool' + +// Skipping definition for base type 'Float' + +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + +type Context uint32 + +func NewContextId(c *xgb.Conn) (Context, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Context(id), nil +} + +type Surface uint32 + +func NewSurfaceId(c *xgb.Conn) (Surface, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Surface(id), nil +} + +type Subpicture uint32 + +func NewSubpictureId(c *xgb.Conn) (Subpicture, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Subpicture(id), nil +} + +// 'SurfaceInfo' struct definition +// Size: 24 +type SurfaceInfo struct { + Id Surface + ChromaFormat uint16 + Pad0 uint16 + MaxWidth uint16 + MaxHeight uint16 + SubpictureMaxWidth uint16 + SubpictureMaxHeight uint16 + McType uint32 + Flags uint32 +} + +// Struct read SurfaceInfo +func SurfaceInfoRead(buf []byte, v *SurfaceInfo) int { + b := 0 + + v.Id = Surface(xgb.Get32(buf[b:])) + b += 4 + + v.ChromaFormat = xgb.Get16(buf[b:]) + b += 2 + + v.Pad0 = xgb.Get16(buf[b:]) + b += 2 + + v.MaxWidth = xgb.Get16(buf[b:]) + b += 2 + + v.MaxHeight = xgb.Get16(buf[b:]) + b += 2 + + v.SubpictureMaxWidth = xgb.Get16(buf[b:]) + b += 2 + + v.SubpictureMaxHeight = xgb.Get16(buf[b:]) + b += 2 + + v.McType = xgb.Get32(buf[b:]) + b += 4 + + v.Flags = xgb.Get32(buf[b:]) + b += 4 + + return b +} + +// Struct list read SurfaceInfo +func SurfaceInfoReadList(buf []byte, dest []SurfaceInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = SurfaceInfo{} + b += SurfaceInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write SurfaceInfo +func (v SurfaceInfo) Bytes() []byte { + buf := make([]byte, 24) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Id)) + b += 4 + + xgb.Put16(buf[b:], v.ChromaFormat) + b += 2 + + xgb.Put16(buf[b:], v.Pad0) + b += 2 + + xgb.Put16(buf[b:], v.MaxWidth) + b += 2 + + xgb.Put16(buf[b:], v.MaxHeight) + b += 2 + + xgb.Put16(buf[b:], v.SubpictureMaxWidth) + b += 2 + + xgb.Put16(buf[b:], v.SubpictureMaxHeight) + b += 2 + + xgb.Put32(buf[b:], v.McType) + b += 4 + + xgb.Put32(buf[b:], v.Flags) + b += 4 + + return buf +} + +// Write struct list SurfaceInfo +func SurfaceInfoListBytes(buf []byte, list []SurfaceInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Request QueryVersion +// size: 4 +type QueryVersionCookie struct { + *xgb.Cookie +} + +func QueryVersion(c *xgb.Conn) QueryVersionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c), cookie) + return QueryVersionCookie{cookie} +} + +func QueryVersionUnchecked(c *xgb.Conn) QueryVersionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c), cookie) + return QueryVersionCookie{cookie} +} + +// Request reply for QueryVersion +// size: 16 +type QueryVersionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Major uint32 + Minor uint32 +} + +// Waits and reads reply data from request QueryVersion +func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryVersionReply(buf), nil +} + +// Read reply into structure from buffer for QueryVersion +func queryVersionReply(buf []byte) *QueryVersionReply { + v := new(QueryVersionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Major = xgb.Get32(buf[b:]) + b += 4 + + v.Minor = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for QueryVersion +func queryVersionRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO-MOTIONCOMPENSATION"] + b += 1 + + buf[b] = 0 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request ListSurfaceTypes +// size: 8 +type ListSurfaceTypesCookie struct { + *xgb.Cookie +} + +func ListSurfaceTypes(c *xgb.Conn, PortId xv.Port) ListSurfaceTypesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(listSurfaceTypesRequest(c, PortId), cookie) + return ListSurfaceTypesCookie{cookie} +} + +func ListSurfaceTypesUnchecked(c *xgb.Conn, PortId xv.Port) ListSurfaceTypesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(listSurfaceTypesRequest(c, PortId), cookie) + return ListSurfaceTypesCookie{cookie} +} + +// Request reply for ListSurfaceTypes +// size: (32 + xgb.Pad((int(Num) * 24))) +type ListSurfaceTypesReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Num uint32 + // padding: 20 bytes + Surfaces []SurfaceInfo // size: xgb.Pad((int(Num) * 24)) +} + +// Waits and reads reply data from request ListSurfaceTypes +func (cook ListSurfaceTypesCookie) Reply() (*ListSurfaceTypesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listSurfaceTypesReply(buf), nil +} + +// Read reply into structure from buffer for ListSurfaceTypes +func listSurfaceTypesReply(buf []byte) *ListSurfaceTypesReply { + v := new(ListSurfaceTypesReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Num = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Surfaces = make([]SurfaceInfo, v.Num) + b += SurfaceInfoReadList(buf[b:], v.Surfaces) + + return v +} + +// Write request to wire for ListSurfaceTypes +func listSurfaceTypesRequest(c *xgb.Conn, PortId xv.Port) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO-MOTIONCOMPENSATION"] + b += 1 + + buf[b] = 1 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(PortId)) + b += 4 + + return buf +} + +// Request CreateContext +// size: 24 +type CreateContextCookie struct { + *xgb.Cookie +} + +func CreateContext(c *xgb.Conn, ContextId Context, PortId xv.Port, SurfaceId Surface, Width uint16, Height uint16, Flags uint32) CreateContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(createContextRequest(c, ContextId, PortId, SurfaceId, Width, Height, Flags), cookie) + return CreateContextCookie{cookie} +} + +func CreateContextUnchecked(c *xgb.Conn, ContextId Context, PortId xv.Port, SurfaceId Surface, Width uint16, Height uint16, Flags uint32) CreateContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(createContextRequest(c, ContextId, PortId, SurfaceId, Width, Height, Flags), cookie) + return CreateContextCookie{cookie} +} + +// Request reply for CreateContext +// size: (36 + xgb.Pad((int(Length) * 4))) +type CreateContextReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + WidthActual uint16 + HeightActual uint16 + FlagsReturn uint32 + // padding: 20 bytes + PrivData []uint32 // size: xgb.Pad((int(Length) * 4)) +} + +// Waits and reads reply data from request CreateContext +func (cook CreateContextCookie) Reply() (*CreateContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return createContextReply(buf), nil +} + +// Read reply into structure from buffer for CreateContext +func createContextReply(buf []byte) *CreateContextReply { + v := new(CreateContextReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.WidthActual = xgb.Get16(buf[b:]) + b += 2 + + v.HeightActual = xgb.Get16(buf[b:]) + b += 2 + + v.FlagsReturn = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.PrivData = make([]uint32, v.Length) + for i := 0; i < int(v.Length); i++ { + v.PrivData[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for CreateContext +func createContextRequest(c *xgb.Conn, ContextId Context, PortId xv.Port, SurfaceId Surface, Width uint16, Height uint16, Flags uint32) []byte { + size := 24 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO-MOTIONCOMPENSATION"] + b += 1 + + buf[b] = 2 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextId)) + b += 4 + + xgb.Put32(buf[b:], uint32(PortId)) + b += 4 + + xgb.Put32(buf[b:], uint32(SurfaceId)) + b += 4 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + xgb.Put32(buf[b:], Flags) + b += 4 + + return buf +} + +// Request DestroyContext +// size: 8 +type DestroyContextCookie struct { + *xgb.Cookie +} + +// Write request to wire for DestroyContext +func DestroyContext(c *xgb.Conn, ContextId Context) DestroyContextCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroyContextRequest(c, ContextId), cookie) + return DestroyContextCookie{cookie} +} + +func DestroyContextChecked(c *xgb.Conn, ContextId Context) DestroyContextCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(destroyContextRequest(c, ContextId), cookie) + return DestroyContextCookie{cookie} +} + +func (cook DestroyContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DestroyContext +func destroyContextRequest(c *xgb.Conn, ContextId Context) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO-MOTIONCOMPENSATION"] + b += 1 + + buf[b] = 3 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(ContextId)) + b += 4 + + return buf +} + +// Request CreateSurface +// size: 12 +type CreateSurfaceCookie struct { + *xgb.Cookie +} + +func CreateSurface(c *xgb.Conn, SurfaceId Surface, ContextId Context) CreateSurfaceCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(createSurfaceRequest(c, SurfaceId, ContextId), cookie) + return CreateSurfaceCookie{cookie} +} + +func CreateSurfaceUnchecked(c *xgb.Conn, SurfaceId Surface, ContextId Context) CreateSurfaceCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(createSurfaceRequest(c, SurfaceId, ContextId), cookie) + return CreateSurfaceCookie{cookie} +} + +// Request reply for CreateSurface +// size: (32 + xgb.Pad((int(Length) * 4))) +type CreateSurfaceReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + // padding: 24 bytes + PrivData []uint32 // size: xgb.Pad((int(Length) * 4)) +} + +// Waits and reads reply data from request CreateSurface +func (cook CreateSurfaceCookie) Reply() (*CreateSurfaceReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return createSurfaceReply(buf), nil +} + +// Read reply into structure from buffer for CreateSurface +func createSurfaceReply(buf []byte) *CreateSurfaceReply { + v := new(CreateSurfaceReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + b += 24 // padding + + v.PrivData = make([]uint32, v.Length) + for i := 0; i < int(v.Length); i++ { + v.PrivData[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for CreateSurface +func createSurfaceRequest(c *xgb.Conn, SurfaceId Surface, ContextId Context) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO-MOTIONCOMPENSATION"] + b += 1 + + buf[b] = 4 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(SurfaceId)) + b += 4 + + xgb.Put32(buf[b:], uint32(ContextId)) + b += 4 + + return buf +} + +// Request DestroySurface +// size: 8 +type DestroySurfaceCookie struct { + *xgb.Cookie +} + +// Write request to wire for DestroySurface +func DestroySurface(c *xgb.Conn, SurfaceId Surface) DestroySurfaceCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroySurfaceRequest(c, SurfaceId), cookie) + return DestroySurfaceCookie{cookie} +} + +func DestroySurfaceChecked(c *xgb.Conn, SurfaceId Surface) DestroySurfaceCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(destroySurfaceRequest(c, SurfaceId), cookie) + return DestroySurfaceCookie{cookie} +} + +func (cook DestroySurfaceCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DestroySurface +func destroySurfaceRequest(c *xgb.Conn, SurfaceId Surface) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO-MOTIONCOMPENSATION"] + b += 1 + + buf[b] = 5 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(SurfaceId)) + b += 4 + + return buf +} + +// Request CreateSubpicture +// size: 20 +type CreateSubpictureCookie struct { + *xgb.Cookie +} + +func CreateSubpicture(c *xgb.Conn, SubpictureId Subpicture, Context Context, XvimageId uint32, Width uint16, Height uint16) CreateSubpictureCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(createSubpictureRequest(c, SubpictureId, Context, XvimageId, Width, Height), cookie) + return CreateSubpictureCookie{cookie} +} + +func CreateSubpictureUnchecked(c *xgb.Conn, SubpictureId Subpicture, Context Context, XvimageId uint32, Width uint16, Height uint16) CreateSubpictureCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(createSubpictureRequest(c, SubpictureId, Context, XvimageId, Width, Height), cookie) + return CreateSubpictureCookie{cookie} +} + +// Request reply for CreateSubpicture +// size: (32 + xgb.Pad((int(Length) * 4))) +type CreateSubpictureReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + WidthActual uint16 + HeightActual uint16 + NumPaletteEntries uint16 + EntryBytes uint16 + ComponentOrder []byte // size: 4 + // padding: 12 bytes + PrivData []uint32 // size: xgb.Pad((int(Length) * 4)) +} + +// Waits and reads reply data from request CreateSubpicture +func (cook CreateSubpictureCookie) Reply() (*CreateSubpictureReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return createSubpictureReply(buf), nil +} + +// Read reply into structure from buffer for CreateSubpicture +func createSubpictureReply(buf []byte) *CreateSubpictureReply { + v := new(CreateSubpictureReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.WidthActual = xgb.Get16(buf[b:]) + b += 2 + + v.HeightActual = xgb.Get16(buf[b:]) + b += 2 + + v.NumPaletteEntries = xgb.Get16(buf[b:]) + b += 2 + + v.EntryBytes = xgb.Get16(buf[b:]) + b += 2 + + v.ComponentOrder = make([]byte, 4) + copy(v.ComponentOrder[:4], buf[b:]) + b += xgb.Pad(int(4)) + + b += 12 // padding + + v.PrivData = make([]uint32, v.Length) + for i := 0; i < int(v.Length); i++ { + v.PrivData[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for CreateSubpicture +func createSubpictureRequest(c *xgb.Conn, SubpictureId Subpicture, Context Context, XvimageId uint32, Width uint16, Height uint16) []byte { + size := 20 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO-MOTIONCOMPENSATION"] + b += 1 + + buf[b] = 6 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(SubpictureId)) + b += 4 + + xgb.Put32(buf[b:], uint32(Context)) + b += 4 + + xgb.Put32(buf[b:], XvimageId) + b += 4 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + return buf +} + +// Request DestroySubpicture +// size: 8 +type DestroySubpictureCookie struct { + *xgb.Cookie +} + +// Write request to wire for DestroySubpicture +func DestroySubpicture(c *xgb.Conn, SubpictureId Subpicture) DestroySubpictureCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroySubpictureRequest(c, SubpictureId), cookie) + return DestroySubpictureCookie{cookie} +} + +func DestroySubpictureChecked(c *xgb.Conn, SubpictureId Subpicture) DestroySubpictureCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(destroySubpictureRequest(c, SubpictureId), cookie) + return DestroySubpictureCookie{cookie} +} + +func (cook DestroySubpictureCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DestroySubpicture +func destroySubpictureRequest(c *xgb.Conn, SubpictureId Subpicture) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO-MOTIONCOMPENSATION"] + b += 1 + + buf[b] = 7 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(SubpictureId)) + b += 4 + + return buf +} + +// Request ListSubpictureTypes +// size: 12 +type ListSubpictureTypesCookie struct { + *xgb.Cookie +} + +func ListSubpictureTypes(c *xgb.Conn, PortId xv.Port, SurfaceId Surface) ListSubpictureTypesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(listSubpictureTypesRequest(c, PortId, SurfaceId), cookie) + return ListSubpictureTypesCookie{cookie} +} + +func ListSubpictureTypesUnchecked(c *xgb.Conn, PortId xv.Port, SurfaceId Surface) ListSubpictureTypesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(listSubpictureTypesRequest(c, PortId, SurfaceId), cookie) + return ListSubpictureTypesCookie{cookie} +} + +// Request reply for ListSubpictureTypes +// size: (32 + xv.ImageFormatInfoListSize(Types)) +type ListSubpictureTypesReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Num uint32 + // padding: 20 bytes + Types []xv.ImageFormatInfo // size: xv.ImageFormatInfoListSize(Types) +} + +// Waits and reads reply data from request ListSubpictureTypes +func (cook ListSubpictureTypesCookie) Reply() (*ListSubpictureTypesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listSubpictureTypesReply(buf), nil +} + +// Read reply into structure from buffer for ListSubpictureTypes +func listSubpictureTypesReply(buf []byte) *ListSubpictureTypesReply { + v := new(ListSubpictureTypesReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Num = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Types = make([]xv.ImageFormatInfo, v.Num) + b += xv.ImageFormatInfoReadList(buf[b:], v.Types) + + return v +} + +// Write request to wire for ListSubpictureTypes +func listSubpictureTypesRequest(c *xgb.Conn, PortId xv.Port, SurfaceId Surface) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO-MOTIONCOMPENSATION"] + b += 1 + + buf[b] = 8 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(PortId)) + b += 4 + + xgb.Put32(buf[b:], uint32(SurfaceId)) + b += 4 + + return buf +} -- cgit v1.2.3-70-g09d2 From c00652934e4ec68016a152b9bea10273b0be8726 Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Thu, 10 May 2012 23:57:34 -0400 Subject: better docs --- nexgb/bigreq/bigreq.go | 25 +- nexgb/composite/composite.go | 137 ++- nexgb/damage/damage.go | 89 +- nexgb/dpms/dpms.go | 138 ++- nexgb/dri2/dri2.go | 289 +++-- nexgb/ge/ge.go | 29 +- nexgb/glx/glx.go | 1778 ++++++++++++++++----------- nexgb/randr/randr.go | 632 +++++----- nexgb/record/record.go | 176 +-- nexgb/render/render.go | 597 +++++---- nexgb/res/res.go | 98 +- nexgb/screensaver/screensaver.go | 106 +- nexgb/shape/shape.go | 147 ++- nexgb/shm/shm.go | 110 +- nexgb/sync/sync.go | 368 +++--- nexgb/xcmisc/xcmisc.go | 59 +- nexgb/xevie/xevie.go | 127 +- nexgb/xf86dri/xf86dri.go | 240 ++-- nexgb/xf86vidmode/xf86vidmode.go | 425 ++++--- nexgb/xfixes/xfixes.go | 441 ++++--- nexgb/xgb.go | 2 - nexgb/xgbgen/go_error.go | 22 +- nexgb/xgbgen/go_event.go | 29 +- nexgb/xgbgen/go_request_reply.go | 37 +- nexgb/xgbgen/go_struct.go | 17 +- nexgb/xgbgen/go_union.go | 20 +- nexgb/xinerama/xinerama.go | 126 +- nexgb/xinput/xinput.go | 1169 +++++++++--------- nexgb/xprint/xprint.go | 437 ++++--- nexgb/xproto/xproto.go | 2476 +++++++++++++++++++++++--------------- nexgb/xselinux/xselinux.go | 395 +++--- nexgb/xtest/xtest.go | 62 +- nexgb/xv/xv.go | 440 ++++--- nexgb/xvmc/xvmc.go | 179 +-- 34 files changed, 6734 insertions(+), 4688 deletions(-) (limited to 'nexgb/xgbgen/go_event.go') diff --git a/nexgb/bigreq/bigreq.go b/nexgb/bigreq/bigreq.go index c2263a0..3913c5f 100644 --- a/nexgb/bigreq/bigreq.go +++ b/nexgb/bigreq/bigreq.go @@ -2,7 +2,7 @@ package bigreq /* - This file was generated by bigreq.xml on May 10 2012 8:04:31pm EDT. + This file was generated by bigreq.xml on May 10 2012 11:56:18pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,6 +40,8 @@ func init() { xgb.NewExtErrorFuncs["BIG-REQUESTS"] = make(map[int]xgb.NewErrorFun) } +// Skipping definition for base type 'Float' + // Skipping definition for base type 'Card8' // Skipping definition for base type 'Int16' @@ -62,36 +64,36 @@ func init() { // Skipping definition for base type 'Bool' -// Skipping definition for base type 'Float' - -// Request Enable -// size: 4 +// EnableCookie is a cookie used only for Enable requests. type EnableCookie struct { *xgb.Cookie } +// Enable sends a checked request. +// If an error occurs, it will be returned with the reply by calling EnableCookie.Reply() func Enable(c *xgb.Conn) EnableCookie { cookie := c.NewCookie(true, true) c.NewRequest(enableRequest(c), cookie) return EnableCookie{cookie} } +// EnableUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func EnableUnchecked(c *xgb.Conn) EnableCookie { cookie := c.NewCookie(false, true) c.NewRequest(enableRequest(c), cookie) return EnableCookie{cookie} } -// Request reply for Enable -// size: 12 +// EnableReply represents the data returned from a Enable request. type EnableReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes MaximumRequestLength uint32 } -// Waits and reads reply data from request Enable +// Reply blocks and returns the reply data for a Enable request. func (cook EnableCookie) Reply() (*EnableReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -103,7 +105,7 @@ func (cook EnableCookie) Reply() (*EnableReply, error) { return enableReply(buf), nil } -// Read reply into structure from buffer for Enable +// enableReply reads a byte slice into a EnableReply value. func enableReply(buf []byte) *EnableReply { v := new(EnableReply) b := 1 // skip reply determinant @@ -123,6 +125,7 @@ func enableReply(buf []byte) *EnableReply { } // Write request to wire for Enable +// enableRequest writes a Enable request to a byte slice. func enableRequest(c *xgb.Conn) []byte { size := 4 b := 0 diff --git a/nexgb/composite/composite.go b/nexgb/composite/composite.go index 5a3d7c4..be56807 100644 --- a/nexgb/composite/composite.go +++ b/nexgb/composite/composite.go @@ -2,7 +2,7 @@ package composite /* - This file was generated by composite.xml on May 10 2012 8:04:31pm EDT. + This file was generated by composite.xml on May 10 2012 11:56:18pm EDT. This file is automatically generated. Edit at your peril! */ @@ -41,16 +41,6 @@ func init() { xgb.NewExtErrorFuncs["Composite"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - // Skipping definition for base type 'Int8' // Skipping definition for base type 'Card16' @@ -65,41 +55,53 @@ func init() { // Skipping definition for base type 'Float' +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + const ( RedirectAutomatic = 0 RedirectManual = 1 ) -// Request QueryVersion -// size: 12 +// QueryVersionCookie is a cookie used only for QueryVersion requests. type QueryVersionCookie struct { *xgb.Cookie } +// QueryVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() func QueryVersion(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) return QueryVersionCookie{cookie} } +// QueryVersionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) return QueryVersionCookie{cookie} } -// Request reply for QueryVersion -// size: 32 +// QueryVersionReply represents the data returned from a QueryVersion request. type QueryVersionReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes MajorVersion uint32 MinorVersion uint32 // padding: 16 bytes } -// Waits and reads reply data from request QueryVersion +// Reply blocks and returns the reply data for a QueryVersion request. func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -111,7 +113,7 @@ func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { return queryVersionReply(buf), nil } -// Read reply into structure from buffer for QueryVersion +// queryVersionReply reads a byte slice into a QueryVersionReply value. func queryVersionReply(buf []byte) *QueryVersionReply { v := new(QueryVersionReply) b := 1 // skip reply determinant @@ -136,6 +138,7 @@ func queryVersionReply(buf []byte) *QueryVersionReply { } // Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) []byte { size := 12 b := 0 @@ -159,30 +162,35 @@ func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVers return buf } -// Request RedirectWindow -// size: 12 +// RedirectWindowCookie is a cookie used only for RedirectWindow requests. type RedirectWindowCookie struct { *xgb.Cookie } -// Write request to wire for RedirectWindow +// RedirectWindow sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func RedirectWindow(c *xgb.Conn, Window xproto.Window, Update byte) RedirectWindowCookie { cookie := c.NewCookie(false, false) c.NewRequest(redirectWindowRequest(c, Window, Update), cookie) return RedirectWindowCookie{cookie} } +// RedirectWindowChecked sends a checked request. +// If an error occurs, it can be retrieved using RedirectWindowCookie.Check() func RedirectWindowChecked(c *xgb.Conn, Window xproto.Window, Update byte) RedirectWindowCookie { cookie := c.NewCookie(true, false) c.NewRequest(redirectWindowRequest(c, Window, Update), cookie) return RedirectWindowCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook RedirectWindowCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for RedirectWindow +// redirectWindowRequest writes a RedirectWindow request to a byte slice. func redirectWindowRequest(c *xgb.Conn, Window xproto.Window, Update byte) []byte { size := 12 b := 0 @@ -208,30 +216,35 @@ func redirectWindowRequest(c *xgb.Conn, Window xproto.Window, Update byte) []byt return buf } -// Request RedirectSubwindows -// size: 12 +// RedirectSubwindowsCookie is a cookie used only for RedirectSubwindows requests. type RedirectSubwindowsCookie struct { *xgb.Cookie } -// Write request to wire for RedirectSubwindows +// RedirectSubwindows sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func RedirectSubwindows(c *xgb.Conn, Window xproto.Window, Update byte) RedirectSubwindowsCookie { cookie := c.NewCookie(false, false) c.NewRequest(redirectSubwindowsRequest(c, Window, Update), cookie) return RedirectSubwindowsCookie{cookie} } +// RedirectSubwindowsChecked sends a checked request. +// If an error occurs, it can be retrieved using RedirectSubwindowsCookie.Check() func RedirectSubwindowsChecked(c *xgb.Conn, Window xproto.Window, Update byte) RedirectSubwindowsCookie { cookie := c.NewCookie(true, false) c.NewRequest(redirectSubwindowsRequest(c, Window, Update), cookie) return RedirectSubwindowsCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook RedirectSubwindowsCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for RedirectSubwindows +// redirectSubwindowsRequest writes a RedirectSubwindows request to a byte slice. func redirectSubwindowsRequest(c *xgb.Conn, Window xproto.Window, Update byte) []byte { size := 12 b := 0 @@ -257,30 +270,35 @@ func redirectSubwindowsRequest(c *xgb.Conn, Window xproto.Window, Update byte) [ return buf } -// Request UnredirectWindow -// size: 12 +// UnredirectWindowCookie is a cookie used only for UnredirectWindow requests. type UnredirectWindowCookie struct { *xgb.Cookie } -// Write request to wire for UnredirectWindow +// UnredirectWindow sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func UnredirectWindow(c *xgb.Conn, Window xproto.Window, Update byte) UnredirectWindowCookie { cookie := c.NewCookie(false, false) c.NewRequest(unredirectWindowRequest(c, Window, Update), cookie) return UnredirectWindowCookie{cookie} } +// UnredirectWindowChecked sends a checked request. +// If an error occurs, it can be retrieved using UnredirectWindowCookie.Check() func UnredirectWindowChecked(c *xgb.Conn, Window xproto.Window, Update byte) UnredirectWindowCookie { cookie := c.NewCookie(true, false) c.NewRequest(unredirectWindowRequest(c, Window, Update), cookie) return UnredirectWindowCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook UnredirectWindowCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for UnredirectWindow +// unredirectWindowRequest writes a UnredirectWindow request to a byte slice. func unredirectWindowRequest(c *xgb.Conn, Window xproto.Window, Update byte) []byte { size := 12 b := 0 @@ -306,30 +324,35 @@ func unredirectWindowRequest(c *xgb.Conn, Window xproto.Window, Update byte) []b return buf } -// Request UnredirectSubwindows -// size: 12 +// UnredirectSubwindowsCookie is a cookie used only for UnredirectSubwindows requests. type UnredirectSubwindowsCookie struct { *xgb.Cookie } -// Write request to wire for UnredirectSubwindows +// UnredirectSubwindows sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func UnredirectSubwindows(c *xgb.Conn, Window xproto.Window, Update byte) UnredirectSubwindowsCookie { cookie := c.NewCookie(false, false) c.NewRequest(unredirectSubwindowsRequest(c, Window, Update), cookie) return UnredirectSubwindowsCookie{cookie} } +// UnredirectSubwindowsChecked sends a checked request. +// If an error occurs, it can be retrieved using UnredirectSubwindowsCookie.Check() func UnredirectSubwindowsChecked(c *xgb.Conn, Window xproto.Window, Update byte) UnredirectSubwindowsCookie { cookie := c.NewCookie(true, false) c.NewRequest(unredirectSubwindowsRequest(c, Window, Update), cookie) return UnredirectSubwindowsCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook UnredirectSubwindowsCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for UnredirectSubwindows +// unredirectSubwindowsRequest writes a UnredirectSubwindows request to a byte slice. func unredirectSubwindowsRequest(c *xgb.Conn, Window xproto.Window, Update byte) []byte { size := 12 b := 0 @@ -355,30 +378,35 @@ func unredirectSubwindowsRequest(c *xgb.Conn, Window xproto.Window, Update byte) return buf } -// Request CreateRegionFromBorderClip -// size: 12 +// CreateRegionFromBorderClipCookie is a cookie used only for CreateRegionFromBorderClip requests. type CreateRegionFromBorderClipCookie struct { *xgb.Cookie } -// Write request to wire for CreateRegionFromBorderClip +// CreateRegionFromBorderClip sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreateRegionFromBorderClip(c *xgb.Conn, Region xfixes.Region, Window xproto.Window) CreateRegionFromBorderClipCookie { cookie := c.NewCookie(false, false) c.NewRequest(createRegionFromBorderClipRequest(c, Region, Window), cookie) return CreateRegionFromBorderClipCookie{cookie} } +// CreateRegionFromBorderClipChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateRegionFromBorderClipCookie.Check() func CreateRegionFromBorderClipChecked(c *xgb.Conn, Region xfixes.Region, Window xproto.Window) CreateRegionFromBorderClipCookie { cookie := c.NewCookie(true, false) c.NewRequest(createRegionFromBorderClipRequest(c, Region, Window), cookie) return CreateRegionFromBorderClipCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CreateRegionFromBorderClipCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreateRegionFromBorderClip +// createRegionFromBorderClipRequest writes a CreateRegionFromBorderClip request to a byte slice. func createRegionFromBorderClipRequest(c *xgb.Conn, Region xfixes.Region, Window xproto.Window) []byte { size := 12 b := 0 @@ -402,30 +430,35 @@ func createRegionFromBorderClipRequest(c *xgb.Conn, Region xfixes.Region, Window return buf } -// Request NameWindowPixmap -// size: 12 +// NameWindowPixmapCookie is a cookie used only for NameWindowPixmap requests. type NameWindowPixmapCookie struct { *xgb.Cookie } -// Write request to wire for NameWindowPixmap +// NameWindowPixmap sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func NameWindowPixmap(c *xgb.Conn, Window xproto.Window, Pixmap xproto.Pixmap) NameWindowPixmapCookie { cookie := c.NewCookie(false, false) c.NewRequest(nameWindowPixmapRequest(c, Window, Pixmap), cookie) return NameWindowPixmapCookie{cookie} } +// NameWindowPixmapChecked sends a checked request. +// If an error occurs, it can be retrieved using NameWindowPixmapCookie.Check() func NameWindowPixmapChecked(c *xgb.Conn, Window xproto.Window, Pixmap xproto.Pixmap) NameWindowPixmapCookie { cookie := c.NewCookie(true, false) c.NewRequest(nameWindowPixmapRequest(c, Window, Pixmap), cookie) return NameWindowPixmapCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook NameWindowPixmapCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for NameWindowPixmap +// nameWindowPixmapRequest writes a NameWindowPixmap request to a byte slice. func nameWindowPixmapRequest(c *xgb.Conn, Window xproto.Window, Pixmap xproto.Pixmap) []byte { size := 12 b := 0 @@ -449,35 +482,37 @@ func nameWindowPixmapRequest(c *xgb.Conn, Window xproto.Window, Pixmap xproto.Pi return buf } -// Request GetOverlayWindow -// size: 8 +// GetOverlayWindowCookie is a cookie used only for GetOverlayWindow requests. type GetOverlayWindowCookie struct { *xgb.Cookie } +// GetOverlayWindow sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetOverlayWindowCookie.Reply() func GetOverlayWindow(c *xgb.Conn, Window xproto.Window) GetOverlayWindowCookie { cookie := c.NewCookie(true, true) c.NewRequest(getOverlayWindowRequest(c, Window), cookie) return GetOverlayWindowCookie{cookie} } +// GetOverlayWindowUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetOverlayWindowUnchecked(c *xgb.Conn, Window xproto.Window) GetOverlayWindowCookie { cookie := c.NewCookie(false, true) c.NewRequest(getOverlayWindowRequest(c, Window), cookie) return GetOverlayWindowCookie{cookie} } -// Request reply for GetOverlayWindow -// size: 32 +// GetOverlayWindowReply represents the data returned from a GetOverlayWindow request. type GetOverlayWindowReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes OverlayWin xproto.Window // padding: 20 bytes } -// Waits and reads reply data from request GetOverlayWindow +// Reply blocks and returns the reply data for a GetOverlayWindow request. func (cook GetOverlayWindowCookie) Reply() (*GetOverlayWindowReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -489,7 +524,7 @@ func (cook GetOverlayWindowCookie) Reply() (*GetOverlayWindowReply, error) { return getOverlayWindowReply(buf), nil } -// Read reply into structure from buffer for GetOverlayWindow +// getOverlayWindowReply reads a byte slice into a GetOverlayWindowReply value. func getOverlayWindowReply(buf []byte) *GetOverlayWindowReply { v := new(GetOverlayWindowReply) b := 1 // skip reply determinant @@ -511,6 +546,7 @@ func getOverlayWindowReply(buf []byte) *GetOverlayWindowReply { } // Write request to wire for GetOverlayWindow +// getOverlayWindowRequest writes a GetOverlayWindow request to a byte slice. func getOverlayWindowRequest(c *xgb.Conn, Window xproto.Window) []byte { size := 8 b := 0 @@ -531,30 +567,35 @@ func getOverlayWindowRequest(c *xgb.Conn, Window xproto.Window) []byte { return buf } -// Request ReleaseOverlayWindow -// size: 8 +// ReleaseOverlayWindowCookie is a cookie used only for ReleaseOverlayWindow requests. type ReleaseOverlayWindowCookie struct { *xgb.Cookie } -// Write request to wire for ReleaseOverlayWindow +// ReleaseOverlayWindow sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ReleaseOverlayWindow(c *xgb.Conn, Window xproto.Window) ReleaseOverlayWindowCookie { cookie := c.NewCookie(false, false) c.NewRequest(releaseOverlayWindowRequest(c, Window), cookie) return ReleaseOverlayWindowCookie{cookie} } +// ReleaseOverlayWindowChecked sends a checked request. +// If an error occurs, it can be retrieved using ReleaseOverlayWindowCookie.Check() func ReleaseOverlayWindowChecked(c *xgb.Conn, Window xproto.Window) ReleaseOverlayWindowCookie { cookie := c.NewCookie(true, false) c.NewRequest(releaseOverlayWindowRequest(c, Window), cookie) return ReleaseOverlayWindowCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook ReleaseOverlayWindowCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ReleaseOverlayWindow +// releaseOverlayWindowRequest writes a ReleaseOverlayWindow request to a byte slice. func releaseOverlayWindowRequest(c *xgb.Conn, Window xproto.Window) []byte { size := 8 b := 0 diff --git a/nexgb/damage/damage.go b/nexgb/damage/damage.go index 8c59f55..1c17501 100644 --- a/nexgb/damage/damage.go +++ b/nexgb/damage/damage.go @@ -2,7 +2,7 @@ package damage /* - This file was generated by damage.xml on May 10 2012 8:04:31pm EDT. + This file was generated by damage.xml on May 10 2012 11:56:18pm EDT. This file is automatically generated. Edit at your peril! */ @@ -82,9 +82,7 @@ func NewDamageId(c *xgb.Conn) (Damage, error) { return Damage(id), nil } -// Event definition Notify (0) -// Size: 32 - +// Notify is the event number for a NotifyEvent. const Notify = 0 type NotifyEvent struct { @@ -97,7 +95,7 @@ type NotifyEvent struct { Geometry xproto.Rectangle } -// Event read Notify +// NotifyEventNew constructs a NotifyEvent value that implements xgb.Event from a byte slice. func NotifyEventNew(buf []byte) xgb.Event { v := NotifyEvent{} b := 1 // don't read event number @@ -126,7 +124,7 @@ func NotifyEventNew(buf []byte) xgb.Event { return v } -// Event write Notify +// Bytes writes a NotifyEvent value to a byte slice. func (v NotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -164,12 +162,14 @@ func (v NotifyEvent) Bytes() []byte { return buf } -func (v NotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the Notify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v NotifyEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of NotifyEvent. func (v NotifyEvent) String() string { fieldVals := make([]string, 0, 6) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -184,9 +184,7 @@ func init() { xgb.NewExtEventFuncs["DAMAGE"][0] = NotifyEventNew } -// Error definition BadDamage (0) -// Size: 32 - +// BadBadDamage is the error number for a BadBadDamage. const BadBadDamage = 0 type BadDamageError struct { @@ -194,7 +192,7 @@ type BadDamageError struct { NiceName string } -// Error read BadDamage +// BadDamageErrorNew constructs a BadDamageError value that implements xgb.Error from a byte slice. func BadDamageErrorNew(buf []byte) xgb.Error { v := BadDamageError{} v.NiceName = "BadDamage" @@ -208,8 +206,8 @@ func BadDamageErrorNew(buf []byte) xgb.Error { return v } -func (err BadDamageError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadBadDamage error. +// This is mostly used internally. func (err BadDamageError) SequenceId() uint16 { return err.Sequence } @@ -229,36 +227,38 @@ func init() { xgb.NewExtErrorFuncs["DAMAGE"][0] = BadDamageErrorNew } -// Request QueryVersion -// size: 12 +// QueryVersionCookie is a cookie used only for QueryVersion requests. type QueryVersionCookie struct { *xgb.Cookie } +// QueryVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() func QueryVersion(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) return QueryVersionCookie{cookie} } +// QueryVersionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) return QueryVersionCookie{cookie} } -// Request reply for QueryVersion -// size: 32 +// QueryVersionReply represents the data returned from a QueryVersion request. type QueryVersionReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes MajorVersion uint32 MinorVersion uint32 // padding: 16 bytes } -// Waits and reads reply data from request QueryVersion +// Reply blocks and returns the reply data for a QueryVersion request. func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -270,7 +270,7 @@ func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { return queryVersionReply(buf), nil } -// Read reply into structure from buffer for QueryVersion +// queryVersionReply reads a byte slice into a QueryVersionReply value. func queryVersionReply(buf []byte) *QueryVersionReply { v := new(QueryVersionReply) b := 1 // skip reply determinant @@ -295,6 +295,7 @@ func queryVersionReply(buf []byte) *QueryVersionReply { } // Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) []byte { size := 12 b := 0 @@ -318,30 +319,35 @@ func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVers return buf } -// Request Create -// size: 16 +// CreateCookie is a cookie used only for Create requests. type CreateCookie struct { *xgb.Cookie } -// Write request to wire for Create +// Create sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func Create(c *xgb.Conn, Damage Damage, Drawable xproto.Drawable, Level byte) CreateCookie { cookie := c.NewCookie(false, false) c.NewRequest(createRequest(c, Damage, Drawable, Level), cookie) return CreateCookie{cookie} } +// CreateChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateCookie.Check() func CreateChecked(c *xgb.Conn, Damage Damage, Drawable xproto.Drawable, Level byte) CreateCookie { cookie := c.NewCookie(true, false) c.NewRequest(createRequest(c, Damage, Drawable, Level), cookie) return CreateCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CreateCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for Create +// createRequest writes a Create request to a byte slice. func createRequest(c *xgb.Conn, Damage Damage, Drawable xproto.Drawable, Level byte) []byte { size := 16 b := 0 @@ -370,30 +376,35 @@ func createRequest(c *xgb.Conn, Damage Damage, Drawable xproto.Drawable, Level b return buf } -// Request Destroy -// size: 8 +// DestroyCookie is a cookie used only for Destroy requests. type DestroyCookie struct { *xgb.Cookie } -// Write request to wire for Destroy +// Destroy sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func Destroy(c *xgb.Conn, Damage Damage) DestroyCookie { cookie := c.NewCookie(false, false) c.NewRequest(destroyRequest(c, Damage), cookie) return DestroyCookie{cookie} } +// DestroyChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroyCookie.Check() func DestroyChecked(c *xgb.Conn, Damage Damage) DestroyCookie { cookie := c.NewCookie(true, false) c.NewRequest(destroyRequest(c, Damage), cookie) return DestroyCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook DestroyCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for Destroy +// destroyRequest writes a Destroy request to a byte slice. func destroyRequest(c *xgb.Conn, Damage Damage) []byte { size := 8 b := 0 @@ -414,30 +425,35 @@ func destroyRequest(c *xgb.Conn, Damage Damage) []byte { return buf } -// Request Subtract -// size: 16 +// SubtractCookie is a cookie used only for Subtract requests. type SubtractCookie struct { *xgb.Cookie } -// Write request to wire for Subtract +// Subtract sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func Subtract(c *xgb.Conn, Damage Damage, Repair xfixes.Region, Parts xfixes.Region) SubtractCookie { cookie := c.NewCookie(false, false) c.NewRequest(subtractRequest(c, Damage, Repair, Parts), cookie) return SubtractCookie{cookie} } +// SubtractChecked sends a checked request. +// If an error occurs, it can be retrieved using SubtractCookie.Check() func SubtractChecked(c *xgb.Conn, Damage Damage, Repair xfixes.Region, Parts xfixes.Region) SubtractCookie { cookie := c.NewCookie(true, false) c.NewRequest(subtractRequest(c, Damage, Repair, Parts), cookie) return SubtractCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SubtractCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for Subtract +// subtractRequest writes a Subtract request to a byte slice. func subtractRequest(c *xgb.Conn, Damage Damage, Repair xfixes.Region, Parts xfixes.Region) []byte { size := 16 b := 0 @@ -464,30 +480,35 @@ func subtractRequest(c *xgb.Conn, Damage Damage, Repair xfixes.Region, Parts xfi return buf } -// Request Add -// size: 12 +// AddCookie is a cookie used only for Add requests. type AddCookie struct { *xgb.Cookie } -// Write request to wire for Add +// Add sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func Add(c *xgb.Conn, Drawable xproto.Drawable, Region xfixes.Region) AddCookie { cookie := c.NewCookie(false, false) c.NewRequest(addRequest(c, Drawable, Region), cookie) return AddCookie{cookie} } +// AddChecked sends a checked request. +// If an error occurs, it can be retrieved using AddCookie.Check() func AddChecked(c *xgb.Conn, Drawable xproto.Drawable, Region xfixes.Region) AddCookie { cookie := c.NewCookie(true, false) c.NewRequest(addRequest(c, Drawable, Region), cookie) return AddCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook AddCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for Add +// addRequest writes a Add request to a byte slice. func addRequest(c *xgb.Conn, Drawable xproto.Drawable, Region xfixes.Region) []byte { size := 12 b := 0 diff --git a/nexgb/dpms/dpms.go b/nexgb/dpms/dpms.go index de748e4..e3e095a 100644 --- a/nexgb/dpms/dpms.go +++ b/nexgb/dpms/dpms.go @@ -2,7 +2,7 @@ package dpms /* - This file was generated by dpms.xml on May 10 2012 8:04:31pm EDT. + This file was generated by dpms.xml on May 10 2012 11:56:18pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,6 +40,14 @@ func init() { xgb.NewExtErrorFuncs["DPMS"] = make(map[int]xgb.NewErrorFun) } +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Void' + // Skipping definition for base type 'Byte' // Skipping definition for base type 'Int8' @@ -56,14 +64,6 @@ func init() { // Skipping definition for base type 'Float' -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - const ( DPMSModeOn = 0 DPMSModeStandby = 1 @@ -71,35 +71,37 @@ const ( DPMSModeOff = 3 ) -// Request GetVersion -// size: 8 +// GetVersionCookie is a cookie used only for GetVersion requests. type GetVersionCookie struct { *xgb.Cookie } +// GetVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetVersionCookie.Reply() func GetVersion(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) GetVersionCookie { cookie := c.NewCookie(true, true) c.NewRequest(getVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) return GetVersionCookie{cookie} } +// GetVersionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) GetVersionCookie { cookie := c.NewCookie(false, true) c.NewRequest(getVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) return GetVersionCookie{cookie} } -// Request reply for GetVersion -// size: 12 +// GetVersionReply represents the data returned from a GetVersion request. type GetVersionReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes ServerMajorVersion uint16 ServerMinorVersion uint16 } -// Waits and reads reply data from request GetVersion +// Reply blocks and returns the reply data for a GetVersion request. func (cook GetVersionCookie) Reply() (*GetVersionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -111,7 +113,7 @@ func (cook GetVersionCookie) Reply() (*GetVersionReply, error) { return getVersionReply(buf), nil } -// Read reply into structure from buffer for GetVersion +// getVersionReply reads a byte slice into a GetVersionReply value. func getVersionReply(buf []byte) *GetVersionReply { v := new(GetVersionReply) b := 1 // skip reply determinant @@ -134,6 +136,7 @@ func getVersionReply(buf []byte) *GetVersionReply { } // Write request to wire for GetVersion +// getVersionRequest writes a GetVersion request to a byte slice. func getVersionRequest(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) []byte { size := 8 b := 0 @@ -157,35 +160,37 @@ func getVersionRequest(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersio return buf } -// Request Capable -// size: 4 +// CapableCookie is a cookie used only for Capable requests. type CapableCookie struct { *xgb.Cookie } +// Capable sends a checked request. +// If an error occurs, it will be returned with the reply by calling CapableCookie.Reply() func Capable(c *xgb.Conn) CapableCookie { cookie := c.NewCookie(true, true) c.NewRequest(capableRequest(c), cookie) return CapableCookie{cookie} } +// CapableUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CapableUnchecked(c *xgb.Conn) CapableCookie { cookie := c.NewCookie(false, true) c.NewRequest(capableRequest(c), cookie) return CapableCookie{cookie} } -// Request reply for Capable -// size: 32 +// CapableReply represents the data returned from a Capable request. type CapableReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Capable bool // padding: 23 bytes } -// Waits and reads reply data from request Capable +// Reply blocks and returns the reply data for a Capable request. func (cook CapableCookie) Reply() (*CapableReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -197,7 +202,7 @@ func (cook CapableCookie) Reply() (*CapableReply, error) { return capableReply(buf), nil } -// Read reply into structure from buffer for Capable +// capableReply reads a byte slice into a CapableReply value. func capableReply(buf []byte) *CapableReply { v := new(CapableReply) b := 1 // skip reply determinant @@ -223,6 +228,7 @@ func capableReply(buf []byte) *CapableReply { } // Write request to wire for Capable +// capableRequest writes a Capable request to a byte slice. func capableRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -240,29 +246,31 @@ func capableRequest(c *xgb.Conn) []byte { return buf } -// Request GetTimeouts -// size: 4 +// GetTimeoutsCookie is a cookie used only for GetTimeouts requests. type GetTimeoutsCookie struct { *xgb.Cookie } +// GetTimeouts sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetTimeoutsCookie.Reply() func GetTimeouts(c *xgb.Conn) GetTimeoutsCookie { cookie := c.NewCookie(true, true) c.NewRequest(getTimeoutsRequest(c), cookie) return GetTimeoutsCookie{cookie} } +// GetTimeoutsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetTimeoutsUnchecked(c *xgb.Conn) GetTimeoutsCookie { cookie := c.NewCookie(false, true) c.NewRequest(getTimeoutsRequest(c), cookie) return GetTimeoutsCookie{cookie} } -// Request reply for GetTimeouts -// size: 32 +// GetTimeoutsReply represents the data returned from a GetTimeouts request. type GetTimeoutsReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes StandbyTimeout uint16 SuspendTimeout uint16 @@ -270,7 +278,7 @@ type GetTimeoutsReply struct { // padding: 18 bytes } -// Waits and reads reply data from request GetTimeouts +// Reply blocks and returns the reply data for a GetTimeouts request. func (cook GetTimeoutsCookie) Reply() (*GetTimeoutsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -282,7 +290,7 @@ func (cook GetTimeoutsCookie) Reply() (*GetTimeoutsReply, error) { return getTimeoutsReply(buf), nil } -// Read reply into structure from buffer for GetTimeouts +// getTimeoutsReply reads a byte slice into a GetTimeoutsReply value. func getTimeoutsReply(buf []byte) *GetTimeoutsReply { v := new(GetTimeoutsReply) b := 1 // skip reply determinant @@ -310,6 +318,7 @@ func getTimeoutsReply(buf []byte) *GetTimeoutsReply { } // Write request to wire for GetTimeouts +// getTimeoutsRequest writes a GetTimeouts request to a byte slice. func getTimeoutsRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -327,30 +336,35 @@ func getTimeoutsRequest(c *xgb.Conn) []byte { return buf } -// Request SetTimeouts -// size: 12 +// SetTimeoutsCookie is a cookie used only for SetTimeouts requests. type SetTimeoutsCookie struct { *xgb.Cookie } -// Write request to wire for SetTimeouts +// SetTimeouts sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetTimeouts(c *xgb.Conn, StandbyTimeout uint16, SuspendTimeout uint16, OffTimeout uint16) SetTimeoutsCookie { cookie := c.NewCookie(false, false) c.NewRequest(setTimeoutsRequest(c, StandbyTimeout, SuspendTimeout, OffTimeout), cookie) return SetTimeoutsCookie{cookie} } +// SetTimeoutsChecked sends a checked request. +// If an error occurs, it can be retrieved using SetTimeoutsCookie.Check() func SetTimeoutsChecked(c *xgb.Conn, StandbyTimeout uint16, SuspendTimeout uint16, OffTimeout uint16) SetTimeoutsCookie { cookie := c.NewCookie(true, false) c.NewRequest(setTimeoutsRequest(c, StandbyTimeout, SuspendTimeout, OffTimeout), cookie) return SetTimeoutsCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetTimeoutsCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetTimeouts +// setTimeoutsRequest writes a SetTimeouts request to a byte slice. func setTimeoutsRequest(c *xgb.Conn, StandbyTimeout uint16, SuspendTimeout uint16, OffTimeout uint16) []byte { size := 12 b := 0 @@ -377,30 +391,35 @@ func setTimeoutsRequest(c *xgb.Conn, StandbyTimeout uint16, SuspendTimeout uint1 return buf } -// Request Enable -// size: 4 +// EnableCookie is a cookie used only for Enable requests. type EnableCookie struct { *xgb.Cookie } -// Write request to wire for Enable +// Enable sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func Enable(c *xgb.Conn) EnableCookie { cookie := c.NewCookie(false, false) c.NewRequest(enableRequest(c), cookie) return EnableCookie{cookie} } +// EnableChecked sends a checked request. +// If an error occurs, it can be retrieved using EnableCookie.Check() func EnableChecked(c *xgb.Conn) EnableCookie { cookie := c.NewCookie(true, false) c.NewRequest(enableRequest(c), cookie) return EnableCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook EnableCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for Enable +// enableRequest writes a Enable request to a byte slice. func enableRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -418,30 +437,35 @@ func enableRequest(c *xgb.Conn) []byte { return buf } -// Request Disable -// size: 4 +// DisableCookie is a cookie used only for Disable requests. type DisableCookie struct { *xgb.Cookie } -// Write request to wire for Disable +// Disable sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func Disable(c *xgb.Conn) DisableCookie { cookie := c.NewCookie(false, false) c.NewRequest(disableRequest(c), cookie) return DisableCookie{cookie} } +// DisableChecked sends a checked request. +// If an error occurs, it can be retrieved using DisableCookie.Check() func DisableChecked(c *xgb.Conn) DisableCookie { cookie := c.NewCookie(true, false) c.NewRequest(disableRequest(c), cookie) return DisableCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook DisableCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for Disable +// disableRequest writes a Disable request to a byte slice. func disableRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -459,30 +483,35 @@ func disableRequest(c *xgb.Conn) []byte { return buf } -// Request ForceLevel -// size: 8 +// ForceLevelCookie is a cookie used only for ForceLevel requests. type ForceLevelCookie struct { *xgb.Cookie } -// Write request to wire for ForceLevel +// ForceLevel sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ForceLevel(c *xgb.Conn, PowerLevel uint16) ForceLevelCookie { cookie := c.NewCookie(false, false) c.NewRequest(forceLevelRequest(c, PowerLevel), cookie) return ForceLevelCookie{cookie} } +// ForceLevelChecked sends a checked request. +// If an error occurs, it can be retrieved using ForceLevelCookie.Check() func ForceLevelChecked(c *xgb.Conn, PowerLevel uint16) ForceLevelCookie { cookie := c.NewCookie(true, false) c.NewRequest(forceLevelRequest(c, PowerLevel), cookie) return ForceLevelCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook ForceLevelCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ForceLevel +// forceLevelRequest writes a ForceLevel request to a byte slice. func forceLevelRequest(c *xgb.Conn, PowerLevel uint16) []byte { size := 8 b := 0 @@ -503,36 +532,38 @@ func forceLevelRequest(c *xgb.Conn, PowerLevel uint16) []byte { return buf } -// Request Info -// size: 4 +// InfoCookie is a cookie used only for Info requests. type InfoCookie struct { *xgb.Cookie } +// Info sends a checked request. +// If an error occurs, it will be returned with the reply by calling InfoCookie.Reply() func Info(c *xgb.Conn) InfoCookie { cookie := c.NewCookie(true, true) c.NewRequest(infoRequest(c), cookie) return InfoCookie{cookie} } +// InfoUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func InfoUnchecked(c *xgb.Conn) InfoCookie { cookie := c.NewCookie(false, true) c.NewRequest(infoRequest(c), cookie) return InfoCookie{cookie} } -// Request reply for Info -// size: 32 +// InfoReply represents the data returned from a Info request. type InfoReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes PowerLevel uint16 State bool // padding: 21 bytes } -// Waits and reads reply data from request Info +// Reply blocks and returns the reply data for a Info request. func (cook InfoCookie) Reply() (*InfoReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -544,7 +575,7 @@ func (cook InfoCookie) Reply() (*InfoReply, error) { return infoReply(buf), nil } -// Read reply into structure from buffer for Info +// infoReply reads a byte slice into a InfoReply value. func infoReply(buf []byte) *InfoReply { v := new(InfoReply) b := 1 // skip reply determinant @@ -573,6 +604,7 @@ func infoReply(buf []byte) *InfoReply { } // Write request to wire for Info +// infoRequest writes a Info request to a byte slice. func infoRequest(c *xgb.Conn) []byte { size := 4 b := 0 diff --git a/nexgb/dri2/dri2.go b/nexgb/dri2/dri2.go index c875111..b6398e1 100644 --- a/nexgb/dri2/dri2.go +++ b/nexgb/dri2/dri2.go @@ -2,7 +2,7 @@ package dri2 /* - This file was generated by dri2.xml on May 10 2012 8:04:31pm EDT. + This file was generated by dri2.xml on May 10 2012 11:56:18pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,14 +40,6 @@ func init() { xgb.NewExtErrorFuncs["DRI2"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - // Skipping definition for base type 'Float' // Skipping definition for base type 'Card8' @@ -64,6 +56,14 @@ func init() { // Skipping definition for base type 'Card16' +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Bool' + const ( AttachmentBufferFrontLeft = 0 AttachmentBufferBackLeft = 1 @@ -89,8 +89,6 @@ const ( EventTypeFlipComplete = 3 ) -// 'DRI2Buffer' struct definition -// Size: 20 type DRI2Buffer struct { Attachment uint32 Name uint32 @@ -99,7 +97,7 @@ type DRI2Buffer struct { Flags uint32 } -// Struct read DRI2Buffer +// DRI2BufferRead reads a byte slice into a DRI2Buffer value. func DRI2BufferRead(buf []byte, v *DRI2Buffer) int { b := 0 @@ -121,7 +119,7 @@ func DRI2BufferRead(buf []byte, v *DRI2Buffer) int { return b } -// Struct list read DRI2Buffer +// DRI2BufferReadList reads a byte slice into a list of DRI2Buffer values. func DRI2BufferReadList(buf []byte, dest []DRI2Buffer) int { b := 0 for i := 0; i < len(dest); i++ { @@ -131,7 +129,7 @@ func DRI2BufferReadList(buf []byte, dest []DRI2Buffer) int { return xgb.Pad(b) } -// Struct write DRI2Buffer +// Bytes writes a DRI2Buffer value to a byte slice. func (v DRI2Buffer) Bytes() []byte { buf := make([]byte, 20) b := 0 @@ -154,7 +152,7 @@ func (v DRI2Buffer) Bytes() []byte { return buf } -// Write struct list DRI2Buffer +// DRI2BufferListBytes writes a list of %s(MISSING) values to a byte slice. func DRI2BufferListBytes(buf []byte, list []DRI2Buffer) int { b := 0 var structBytes []byte @@ -166,14 +164,12 @@ func DRI2BufferListBytes(buf []byte, list []DRI2Buffer) int { return b } -// 'AttachFormat' struct definition -// Size: 8 type AttachFormat struct { Attachment uint32 Format uint32 } -// Struct read AttachFormat +// AttachFormatRead reads a byte slice into a AttachFormat value. func AttachFormatRead(buf []byte, v *AttachFormat) int { b := 0 @@ -186,7 +182,7 @@ func AttachFormatRead(buf []byte, v *AttachFormat) int { return b } -// Struct list read AttachFormat +// AttachFormatReadList reads a byte slice into a list of AttachFormat values. func AttachFormatReadList(buf []byte, dest []AttachFormat) int { b := 0 for i := 0; i < len(dest); i++ { @@ -196,7 +192,7 @@ func AttachFormatReadList(buf []byte, dest []AttachFormat) int { return xgb.Pad(b) } -// Struct write AttachFormat +// Bytes writes a AttachFormat value to a byte slice. func (v AttachFormat) Bytes() []byte { buf := make([]byte, 8) b := 0 @@ -210,7 +206,7 @@ func (v AttachFormat) Bytes() []byte { return buf } -// Write struct list AttachFormat +// AttachFormatListBytes writes a list of %s(MISSING) values to a byte slice. func AttachFormatListBytes(buf []byte, list []AttachFormat) int { b := 0 var structBytes []byte @@ -222,9 +218,7 @@ func AttachFormatListBytes(buf []byte, list []AttachFormat) int { return b } -// Event definition BufferSwapComplete (0) -// Size: 32 - +// BufferSwapComplete is the event number for a BufferSwapCompleteEvent. const BufferSwapComplete = 0 type BufferSwapCompleteEvent struct { @@ -240,7 +234,7 @@ type BufferSwapCompleteEvent struct { Sbc uint32 } -// Event read BufferSwapComplete +// BufferSwapCompleteEventNew constructs a BufferSwapCompleteEvent value that implements xgb.Event from a byte slice. func BufferSwapCompleteEventNew(buf []byte) xgb.Event { v := BufferSwapCompleteEvent{} b := 1 // don't read event number @@ -276,7 +270,7 @@ func BufferSwapCompleteEventNew(buf []byte) xgb.Event { return v } -// Event write BufferSwapComplete +// Bytes writes a BufferSwapCompleteEvent value to a byte slice. func (v BufferSwapCompleteEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -315,12 +309,14 @@ func (v BufferSwapCompleteEvent) Bytes() []byte { return buf } -func (v BufferSwapCompleteEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the BufferSwapComplete event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v BufferSwapCompleteEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of BufferSwapCompleteEvent. func (v BufferSwapCompleteEvent) String() string { fieldVals := make([]string, 0, 9) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -338,9 +334,7 @@ func init() { xgb.NewExtEventFuncs["DRI2"][0] = BufferSwapCompleteEventNew } -// Event definition InvalidateBuffers (1) -// Size: 32 - +// InvalidateBuffers is the event number for a InvalidateBuffersEvent. const InvalidateBuffers = 1 type InvalidateBuffersEvent struct { @@ -349,7 +343,7 @@ type InvalidateBuffersEvent struct { Drawable xproto.Drawable } -// Event read InvalidateBuffers +// InvalidateBuffersEventNew constructs a InvalidateBuffersEvent value that implements xgb.Event from a byte slice. func InvalidateBuffersEventNew(buf []byte) xgb.Event { v := InvalidateBuffersEvent{} b := 1 // don't read event number @@ -365,7 +359,7 @@ func InvalidateBuffersEventNew(buf []byte) xgb.Event { return v } -// Event write InvalidateBuffers +// Bytes writes a InvalidateBuffersEvent value to a byte slice. func (v InvalidateBuffersEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -384,12 +378,14 @@ func (v InvalidateBuffersEvent) Bytes() []byte { return buf } -func (v InvalidateBuffersEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the InvalidateBuffers event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v InvalidateBuffersEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of InvalidateBuffersEvent. func (v InvalidateBuffersEvent) String() string { fieldVals := make([]string, 0, 2) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -401,35 +397,37 @@ func init() { xgb.NewExtEventFuncs["DRI2"][1] = InvalidateBuffersEventNew } -// Request QueryVersion -// size: 12 +// QueryVersionCookie is a cookie used only for QueryVersion requests. type QueryVersionCookie struct { *xgb.Cookie } +// QueryVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() func QueryVersion(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) return QueryVersionCookie{cookie} } +// QueryVersionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryVersionUnchecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) return QueryVersionCookie{cookie} } -// Request reply for QueryVersion -// size: 16 +// QueryVersionReply represents the data returned from a QueryVersion request. type QueryVersionReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes MajorVersion uint32 MinorVersion uint32 } -// Waits and reads reply data from request QueryVersion +// Reply blocks and returns the reply data for a QueryVersion request. func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -441,7 +439,7 @@ func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { return queryVersionReply(buf), nil } -// Read reply into structure from buffer for QueryVersion +// queryVersionReply reads a byte slice into a QueryVersionReply value. func queryVersionReply(buf []byte) *QueryVersionReply { v := new(QueryVersionReply) b := 1 // skip reply determinant @@ -464,6 +462,7 @@ func queryVersionReply(buf []byte) *QueryVersionReply { } // Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. func queryVersionRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) []byte { size := 12 b := 0 @@ -487,29 +486,31 @@ func queryVersionRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) return buf } -// Request Connect -// size: 12 +// ConnectCookie is a cookie used only for Connect requests. type ConnectCookie struct { *xgb.Cookie } +// Connect sends a checked request. +// If an error occurs, it will be returned with the reply by calling ConnectCookie.Reply() func Connect(c *xgb.Conn, Window xproto.Window, DriverType uint32) ConnectCookie { cookie := c.NewCookie(true, true) c.NewRequest(connectRequest(c, Window, DriverType), cookie) return ConnectCookie{cookie} } +// ConnectUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ConnectUnchecked(c *xgb.Conn, Window xproto.Window, DriverType uint32) ConnectCookie { cookie := c.NewCookie(false, true) c.NewRequest(connectRequest(c, Window, DriverType), cookie) return ConnectCookie{cookie} } -// Request reply for Connect -// size: (((32 + xgb.Pad((int(DriverNameLength) * 1))) + xgb.Pad(((((int(DriverNameLength) + 3) & -4) - int(DriverNameLength)) * 1))) + xgb.Pad((int(DeviceNameLength) * 1))) +// ConnectReply represents the data returned from a Connect request. type ConnectReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes DriverNameLength uint32 DeviceNameLength uint32 @@ -519,7 +520,7 @@ type ConnectReply struct { DeviceName string // size: xgb.Pad((int(DeviceNameLength) * 1)) } -// Waits and reads reply data from request Connect +// Reply blocks and returns the reply data for a Connect request. func (cook ConnectCookie) Reply() (*ConnectReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -531,7 +532,7 @@ func (cook ConnectCookie) Reply() (*ConnectReply, error) { return connectReply(buf), nil } -// Read reply into structure from buffer for Connect +// connectReply reads a byte slice into a ConnectReply value. func connectReply(buf []byte) *ConnectReply { v := new(ConnectReply) b := 1 // skip reply determinant @@ -574,6 +575,7 @@ func connectReply(buf []byte) *ConnectReply { } // Write request to wire for Connect +// connectRequest writes a Connect request to a byte slice. func connectRequest(c *xgb.Conn, Window xproto.Window, DriverType uint32) []byte { size := 12 b := 0 @@ -597,34 +599,36 @@ func connectRequest(c *xgb.Conn, Window xproto.Window, DriverType uint32) []byte return buf } -// Request Authenticate -// size: 12 +// AuthenticateCookie is a cookie used only for Authenticate requests. type AuthenticateCookie struct { *xgb.Cookie } +// Authenticate sends a checked request. +// If an error occurs, it will be returned with the reply by calling AuthenticateCookie.Reply() func Authenticate(c *xgb.Conn, Window xproto.Window, Magic uint32) AuthenticateCookie { cookie := c.NewCookie(true, true) c.NewRequest(authenticateRequest(c, Window, Magic), cookie) return AuthenticateCookie{cookie} } +// AuthenticateUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func AuthenticateUnchecked(c *xgb.Conn, Window xproto.Window, Magic uint32) AuthenticateCookie { cookie := c.NewCookie(false, true) c.NewRequest(authenticateRequest(c, Window, Magic), cookie) return AuthenticateCookie{cookie} } -// Request reply for Authenticate -// size: 12 +// AuthenticateReply represents the data returned from a Authenticate request. type AuthenticateReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Authenticated uint32 } -// Waits and reads reply data from request Authenticate +// Reply blocks and returns the reply data for a Authenticate request. func (cook AuthenticateCookie) Reply() (*AuthenticateReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -636,7 +640,7 @@ func (cook AuthenticateCookie) Reply() (*AuthenticateReply, error) { return authenticateReply(buf), nil } -// Read reply into structure from buffer for Authenticate +// authenticateReply reads a byte slice into a AuthenticateReply value. func authenticateReply(buf []byte) *AuthenticateReply { v := new(AuthenticateReply) b := 1 // skip reply determinant @@ -656,6 +660,7 @@ func authenticateReply(buf []byte) *AuthenticateReply { } // Write request to wire for Authenticate +// authenticateRequest writes a Authenticate request to a byte slice. func authenticateRequest(c *xgb.Conn, Window xproto.Window, Magic uint32) []byte { size := 12 b := 0 @@ -679,30 +684,35 @@ func authenticateRequest(c *xgb.Conn, Window xproto.Window, Magic uint32) []byte return buf } -// Request CreateDrawable -// size: 8 +// CreateDrawableCookie is a cookie used only for CreateDrawable requests. type CreateDrawableCookie struct { *xgb.Cookie } -// Write request to wire for CreateDrawable +// CreateDrawable sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreateDrawable(c *xgb.Conn, Drawable xproto.Drawable) CreateDrawableCookie { cookie := c.NewCookie(false, false) c.NewRequest(createDrawableRequest(c, Drawable), cookie) return CreateDrawableCookie{cookie} } +// CreateDrawableChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateDrawableCookie.Check() func CreateDrawableChecked(c *xgb.Conn, Drawable xproto.Drawable) CreateDrawableCookie { cookie := c.NewCookie(true, false) c.NewRequest(createDrawableRequest(c, Drawable), cookie) return CreateDrawableCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CreateDrawableCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreateDrawable +// createDrawableRequest writes a CreateDrawable request to a byte slice. func createDrawableRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte { size := 8 b := 0 @@ -723,30 +733,35 @@ func createDrawableRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte { return buf } -// Request DestroyDrawable -// size: 8 +// DestroyDrawableCookie is a cookie used only for DestroyDrawable requests. type DestroyDrawableCookie struct { *xgb.Cookie } -// Write request to wire for DestroyDrawable +// DestroyDrawable sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func DestroyDrawable(c *xgb.Conn, Drawable xproto.Drawable) DestroyDrawableCookie { cookie := c.NewCookie(false, false) c.NewRequest(destroyDrawableRequest(c, Drawable), cookie) return DestroyDrawableCookie{cookie} } +// DestroyDrawableChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroyDrawableCookie.Check() func DestroyDrawableChecked(c *xgb.Conn, Drawable xproto.Drawable) DestroyDrawableCookie { cookie := c.NewCookie(true, false) c.NewRequest(destroyDrawableRequest(c, Drawable), cookie) return DestroyDrawableCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook DestroyDrawableCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for DestroyDrawable +// destroyDrawableRequest writes a DestroyDrawable request to a byte slice. func destroyDrawableRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte { size := 8 b := 0 @@ -767,29 +782,31 @@ func destroyDrawableRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte { return buf } -// Request GetBuffers -// size: xgb.Pad((12 + xgb.Pad((len(Attachments) * 4)))) +// GetBuffersCookie is a cookie used only for GetBuffers requests. type GetBuffersCookie struct { *xgb.Cookie } +// GetBuffers sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetBuffersCookie.Reply() func GetBuffers(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Attachments []uint32) GetBuffersCookie { cookie := c.NewCookie(true, true) c.NewRequest(getBuffersRequest(c, Drawable, Count, Attachments), cookie) return GetBuffersCookie{cookie} } +// GetBuffersUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetBuffersUnchecked(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Attachments []uint32) GetBuffersCookie { cookie := c.NewCookie(false, true) c.NewRequest(getBuffersRequest(c, Drawable, Count, Attachments), cookie) return GetBuffersCookie{cookie} } -// Request reply for GetBuffers -// size: (32 + xgb.Pad((int(Count) * 20))) +// GetBuffersReply represents the data returned from a GetBuffers request. type GetBuffersReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Width uint32 Height uint32 @@ -798,7 +815,7 @@ type GetBuffersReply struct { Buffers []DRI2Buffer // size: xgb.Pad((int(Count) * 20)) } -// Waits and reads reply data from request GetBuffers +// Reply blocks and returns the reply data for a GetBuffers request. func (cook GetBuffersCookie) Reply() (*GetBuffersReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -810,7 +827,7 @@ func (cook GetBuffersCookie) Reply() (*GetBuffersReply, error) { return getBuffersReply(buf), nil } -// Read reply into structure from buffer for GetBuffers +// getBuffersReply reads a byte slice into a GetBuffersReply value. func getBuffersReply(buf []byte) *GetBuffersReply { v := new(GetBuffersReply) b := 1 // skip reply determinant @@ -841,6 +858,7 @@ func getBuffersReply(buf []byte) *GetBuffersReply { } // Write request to wire for GetBuffers +// getBuffersRequest writes a GetBuffers request to a byte slice. func getBuffersRequest(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Attachments []uint32) []byte { size := xgb.Pad((12 + xgb.Pad((len(Attachments) * 4)))) b := 0 @@ -870,33 +888,35 @@ func getBuffersRequest(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Atta return buf } -// Request CopyRegion -// size: 20 +// CopyRegionCookie is a cookie used only for CopyRegion requests. type CopyRegionCookie struct { *xgb.Cookie } +// CopyRegion sends a checked request. +// If an error occurs, it will be returned with the reply by calling CopyRegionCookie.Reply() func CopyRegion(c *xgb.Conn, Drawable xproto.Drawable, Region uint32, Dest uint32, Src uint32) CopyRegionCookie { cookie := c.NewCookie(true, true) c.NewRequest(copyRegionRequest(c, Drawable, Region, Dest, Src), cookie) return CopyRegionCookie{cookie} } +// CopyRegionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CopyRegionUnchecked(c *xgb.Conn, Drawable xproto.Drawable, Region uint32, Dest uint32, Src uint32) CopyRegionCookie { cookie := c.NewCookie(false, true) c.NewRequest(copyRegionRequest(c, Drawable, Region, Dest, Src), cookie) return CopyRegionCookie{cookie} } -// Request reply for CopyRegion -// size: 8 +// CopyRegionReply represents the data returned from a CopyRegion request. type CopyRegionReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes } -// Waits and reads reply data from request CopyRegion +// Reply blocks and returns the reply data for a CopyRegion request. func (cook CopyRegionCookie) Reply() (*CopyRegionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -908,7 +928,7 @@ func (cook CopyRegionCookie) Reply() (*CopyRegionReply, error) { return copyRegionReply(buf), nil } -// Read reply into structure from buffer for CopyRegion +// copyRegionReply reads a byte slice into a CopyRegionReply value. func copyRegionReply(buf []byte) *CopyRegionReply { v := new(CopyRegionReply) b := 1 // skip reply determinant @@ -925,6 +945,7 @@ func copyRegionReply(buf []byte) *CopyRegionReply { } // Write request to wire for CopyRegion +// copyRegionRequest writes a CopyRegion request to a byte slice. func copyRegionRequest(c *xgb.Conn, Drawable xproto.Drawable, Region uint32, Dest uint32, Src uint32) []byte { size := 20 b := 0 @@ -954,29 +975,31 @@ func copyRegionRequest(c *xgb.Conn, Drawable xproto.Drawable, Region uint32, Des return buf } -// Request GetBuffersWithFormat -// size: xgb.Pad((12 + xgb.Pad((len(Attachments) * 8)))) +// GetBuffersWithFormatCookie is a cookie used only for GetBuffersWithFormat requests. type GetBuffersWithFormatCookie struct { *xgb.Cookie } +// GetBuffersWithFormat sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetBuffersWithFormatCookie.Reply() func GetBuffersWithFormat(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Attachments []AttachFormat) GetBuffersWithFormatCookie { cookie := c.NewCookie(true, true) c.NewRequest(getBuffersWithFormatRequest(c, Drawable, Count, Attachments), cookie) return GetBuffersWithFormatCookie{cookie} } +// GetBuffersWithFormatUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetBuffersWithFormatUnchecked(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Attachments []AttachFormat) GetBuffersWithFormatCookie { cookie := c.NewCookie(false, true) c.NewRequest(getBuffersWithFormatRequest(c, Drawable, Count, Attachments), cookie) return GetBuffersWithFormatCookie{cookie} } -// Request reply for GetBuffersWithFormat -// size: (32 + xgb.Pad((int(Count) * 20))) +// GetBuffersWithFormatReply represents the data returned from a GetBuffersWithFormat request. type GetBuffersWithFormatReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Width uint32 Height uint32 @@ -985,7 +1008,7 @@ type GetBuffersWithFormatReply struct { Buffers []DRI2Buffer // size: xgb.Pad((int(Count) * 20)) } -// Waits and reads reply data from request GetBuffersWithFormat +// Reply blocks and returns the reply data for a GetBuffersWithFormat request. func (cook GetBuffersWithFormatCookie) Reply() (*GetBuffersWithFormatReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -997,7 +1020,7 @@ func (cook GetBuffersWithFormatCookie) Reply() (*GetBuffersWithFormatReply, erro return getBuffersWithFormatReply(buf), nil } -// Read reply into structure from buffer for GetBuffersWithFormat +// getBuffersWithFormatReply reads a byte slice into a GetBuffersWithFormatReply value. func getBuffersWithFormatReply(buf []byte) *GetBuffersWithFormatReply { v := new(GetBuffersWithFormatReply) b := 1 // skip reply determinant @@ -1028,6 +1051,7 @@ func getBuffersWithFormatReply(buf []byte) *GetBuffersWithFormatReply { } // Write request to wire for GetBuffersWithFormat +// getBuffersWithFormatRequest writes a GetBuffersWithFormat request to a byte slice. func getBuffersWithFormatRequest(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Attachments []AttachFormat) []byte { size := xgb.Pad((12 + xgb.Pad((len(Attachments) * 8)))) b := 0 @@ -1053,35 +1077,37 @@ func getBuffersWithFormatRequest(c *xgb.Conn, Drawable xproto.Drawable, Count ui return buf } -// Request SwapBuffers -// size: 32 +// SwapBuffersCookie is a cookie used only for SwapBuffers requests. type SwapBuffersCookie struct { *xgb.Cookie } +// SwapBuffers sends a checked request. +// If an error occurs, it will be returned with the reply by calling SwapBuffersCookie.Reply() func SwapBuffers(c *xgb.Conn, Drawable xproto.Drawable, TargetMscHi uint32, TargetMscLo uint32, DivisorHi uint32, DivisorLo uint32, RemainderHi uint32, RemainderLo uint32) SwapBuffersCookie { cookie := c.NewCookie(true, true) c.NewRequest(swapBuffersRequest(c, Drawable, TargetMscHi, TargetMscLo, DivisorHi, DivisorLo, RemainderHi, RemainderLo), cookie) return SwapBuffersCookie{cookie} } +// SwapBuffersUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SwapBuffersUnchecked(c *xgb.Conn, Drawable xproto.Drawable, TargetMscHi uint32, TargetMscLo uint32, DivisorHi uint32, DivisorLo uint32, RemainderHi uint32, RemainderLo uint32) SwapBuffersCookie { cookie := c.NewCookie(false, true) c.NewRequest(swapBuffersRequest(c, Drawable, TargetMscHi, TargetMscLo, DivisorHi, DivisorLo, RemainderHi, RemainderLo), cookie) return SwapBuffersCookie{cookie} } -// Request reply for SwapBuffers -// size: 16 +// SwapBuffersReply represents the data returned from a SwapBuffers request. type SwapBuffersReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes SwapHi uint32 SwapLo uint32 } -// Waits and reads reply data from request SwapBuffers +// Reply blocks and returns the reply data for a SwapBuffers request. func (cook SwapBuffersCookie) Reply() (*SwapBuffersReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1093,7 +1119,7 @@ func (cook SwapBuffersCookie) Reply() (*SwapBuffersReply, error) { return swapBuffersReply(buf), nil } -// Read reply into structure from buffer for SwapBuffers +// swapBuffersReply reads a byte slice into a SwapBuffersReply value. func swapBuffersReply(buf []byte) *SwapBuffersReply { v := new(SwapBuffersReply) b := 1 // skip reply determinant @@ -1116,6 +1142,7 @@ func swapBuffersReply(buf []byte) *SwapBuffersReply { } // Write request to wire for SwapBuffers +// swapBuffersRequest writes a SwapBuffers request to a byte slice. func swapBuffersRequest(c *xgb.Conn, Drawable xproto.Drawable, TargetMscHi uint32, TargetMscLo uint32, DivisorHi uint32, DivisorLo uint32, RemainderHi uint32, RemainderLo uint32) []byte { size := 32 b := 0 @@ -1154,29 +1181,31 @@ func swapBuffersRequest(c *xgb.Conn, Drawable xproto.Drawable, TargetMscHi uint3 return buf } -// Request GetMSC -// size: 8 +// GetMSCCookie is a cookie used only for GetMSC requests. type GetMSCCookie struct { *xgb.Cookie } +// GetMSC sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetMSCCookie.Reply() func GetMSC(c *xgb.Conn, Drawable xproto.Drawable) GetMSCCookie { cookie := c.NewCookie(true, true) c.NewRequest(getMSCRequest(c, Drawable), cookie) return GetMSCCookie{cookie} } +// GetMSCUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetMSCUnchecked(c *xgb.Conn, Drawable xproto.Drawable) GetMSCCookie { cookie := c.NewCookie(false, true) c.NewRequest(getMSCRequest(c, Drawable), cookie) return GetMSCCookie{cookie} } -// Request reply for GetMSC -// size: 32 +// GetMSCReply represents the data returned from a GetMSC request. type GetMSCReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes UstHi uint32 UstLo uint32 @@ -1186,7 +1215,7 @@ type GetMSCReply struct { SbcLo uint32 } -// Waits and reads reply data from request GetMSC +// Reply blocks and returns the reply data for a GetMSC request. func (cook GetMSCCookie) Reply() (*GetMSCReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1198,7 +1227,7 @@ func (cook GetMSCCookie) Reply() (*GetMSCReply, error) { return getMSCReply(buf), nil } -// Read reply into structure from buffer for GetMSC +// getMSCReply reads a byte slice into a GetMSCReply value. func getMSCReply(buf []byte) *GetMSCReply { v := new(GetMSCReply) b := 1 // skip reply determinant @@ -1233,6 +1262,7 @@ func getMSCReply(buf []byte) *GetMSCReply { } // Write request to wire for GetMSC +// getMSCRequest writes a GetMSC request to a byte slice. func getMSCRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte { size := 8 b := 0 @@ -1253,29 +1283,31 @@ func getMSCRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte { return buf } -// Request WaitMSC -// size: 32 +// WaitMSCCookie is a cookie used only for WaitMSC requests. type WaitMSCCookie struct { *xgb.Cookie } +// WaitMSC sends a checked request. +// If an error occurs, it will be returned with the reply by calling WaitMSCCookie.Reply() func WaitMSC(c *xgb.Conn, Drawable xproto.Drawable, TargetMscHi uint32, TargetMscLo uint32, DivisorHi uint32, DivisorLo uint32, RemainderHi uint32, RemainderLo uint32) WaitMSCCookie { cookie := c.NewCookie(true, true) c.NewRequest(waitMSCRequest(c, Drawable, TargetMscHi, TargetMscLo, DivisorHi, DivisorLo, RemainderHi, RemainderLo), cookie) return WaitMSCCookie{cookie} } +// WaitMSCUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func WaitMSCUnchecked(c *xgb.Conn, Drawable xproto.Drawable, TargetMscHi uint32, TargetMscLo uint32, DivisorHi uint32, DivisorLo uint32, RemainderHi uint32, RemainderLo uint32) WaitMSCCookie { cookie := c.NewCookie(false, true) c.NewRequest(waitMSCRequest(c, Drawable, TargetMscHi, TargetMscLo, DivisorHi, DivisorLo, RemainderHi, RemainderLo), cookie) return WaitMSCCookie{cookie} } -// Request reply for WaitMSC -// size: 32 +// WaitMSCReply represents the data returned from a WaitMSC request. type WaitMSCReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes UstHi uint32 UstLo uint32 @@ -1285,7 +1317,7 @@ type WaitMSCReply struct { SbcLo uint32 } -// Waits and reads reply data from request WaitMSC +// Reply blocks and returns the reply data for a WaitMSC request. func (cook WaitMSCCookie) Reply() (*WaitMSCReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1297,7 +1329,7 @@ func (cook WaitMSCCookie) Reply() (*WaitMSCReply, error) { return waitMSCReply(buf), nil } -// Read reply into structure from buffer for WaitMSC +// waitMSCReply reads a byte slice into a WaitMSCReply value. func waitMSCReply(buf []byte) *WaitMSCReply { v := new(WaitMSCReply) b := 1 // skip reply determinant @@ -1332,6 +1364,7 @@ func waitMSCReply(buf []byte) *WaitMSCReply { } // Write request to wire for WaitMSC +// waitMSCRequest writes a WaitMSC request to a byte slice. func waitMSCRequest(c *xgb.Conn, Drawable xproto.Drawable, TargetMscHi uint32, TargetMscLo uint32, DivisorHi uint32, DivisorLo uint32, RemainderHi uint32, RemainderLo uint32) []byte { size := 32 b := 0 @@ -1370,29 +1403,31 @@ func waitMSCRequest(c *xgb.Conn, Drawable xproto.Drawable, TargetMscHi uint32, T return buf } -// Request WaitSBC -// size: 16 +// WaitSBCCookie is a cookie used only for WaitSBC requests. type WaitSBCCookie struct { *xgb.Cookie } +// WaitSBC sends a checked request. +// If an error occurs, it will be returned with the reply by calling WaitSBCCookie.Reply() func WaitSBC(c *xgb.Conn, Drawable xproto.Drawable, TargetSbcHi uint32, TargetSbcLo uint32) WaitSBCCookie { cookie := c.NewCookie(true, true) c.NewRequest(waitSBCRequest(c, Drawable, TargetSbcHi, TargetSbcLo), cookie) return WaitSBCCookie{cookie} } +// WaitSBCUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func WaitSBCUnchecked(c *xgb.Conn, Drawable xproto.Drawable, TargetSbcHi uint32, TargetSbcLo uint32) WaitSBCCookie { cookie := c.NewCookie(false, true) c.NewRequest(waitSBCRequest(c, Drawable, TargetSbcHi, TargetSbcLo), cookie) return WaitSBCCookie{cookie} } -// Request reply for WaitSBC -// size: 32 +// WaitSBCReply represents the data returned from a WaitSBC request. type WaitSBCReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes UstHi uint32 UstLo uint32 @@ -1402,7 +1437,7 @@ type WaitSBCReply struct { SbcLo uint32 } -// Waits and reads reply data from request WaitSBC +// Reply blocks and returns the reply data for a WaitSBC request. func (cook WaitSBCCookie) Reply() (*WaitSBCReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1414,7 +1449,7 @@ func (cook WaitSBCCookie) Reply() (*WaitSBCReply, error) { return waitSBCReply(buf), nil } -// Read reply into structure from buffer for WaitSBC +// waitSBCReply reads a byte slice into a WaitSBCReply value. func waitSBCReply(buf []byte) *WaitSBCReply { v := new(WaitSBCReply) b := 1 // skip reply determinant @@ -1449,6 +1484,7 @@ func waitSBCReply(buf []byte) *WaitSBCReply { } // Write request to wire for WaitSBC +// waitSBCRequest writes a WaitSBC request to a byte slice. func waitSBCRequest(c *xgb.Conn, Drawable xproto.Drawable, TargetSbcHi uint32, TargetSbcLo uint32) []byte { size := 16 b := 0 @@ -1475,30 +1511,35 @@ func waitSBCRequest(c *xgb.Conn, Drawable xproto.Drawable, TargetSbcHi uint32, T return buf } -// Request SwapInterval -// size: 12 +// SwapIntervalCookie is a cookie used only for SwapInterval requests. type SwapIntervalCookie struct { *xgb.Cookie } -// Write request to wire for SwapInterval +// SwapInterval sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SwapInterval(c *xgb.Conn, Drawable xproto.Drawable, Interval uint32) SwapIntervalCookie { cookie := c.NewCookie(false, false) c.NewRequest(swapIntervalRequest(c, Drawable, Interval), cookie) return SwapIntervalCookie{cookie} } +// SwapIntervalChecked sends a checked request. +// If an error occurs, it can be retrieved using SwapIntervalCookie.Check() func SwapIntervalChecked(c *xgb.Conn, Drawable xproto.Drawable, Interval uint32) SwapIntervalCookie { cookie := c.NewCookie(true, false) c.NewRequest(swapIntervalRequest(c, Drawable, Interval), cookie) return SwapIntervalCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SwapIntervalCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SwapInterval +// swapIntervalRequest writes a SwapInterval request to a byte slice. func swapIntervalRequest(c *xgb.Conn, Drawable xproto.Drawable, Interval uint32) []byte { size := 12 b := 0 diff --git a/nexgb/ge/ge.go b/nexgb/ge/ge.go index 5bb11fa..21fdb4b 100644 --- a/nexgb/ge/ge.go +++ b/nexgb/ge/ge.go @@ -2,7 +2,7 @@ package ge /* - This file was generated by ge.xml on May 10 2012 8:04:31pm EDT. + This file was generated by ge.xml on May 10 2012 11:56:18pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,10 +40,6 @@ func init() { xgb.NewExtErrorFuncs["Generic Event Extension"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - // Skipping definition for base type 'Int32' // Skipping definition for base type 'Void' @@ -64,36 +60,42 @@ func init() { // Skipping definition for base type 'Float' -// Request QueryVersion -// size: 8 +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +// QueryVersionCookie is a cookie used only for QueryVersion requests. type QueryVersionCookie struct { *xgb.Cookie } +// QueryVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() func QueryVersion(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) QueryVersionCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) return QueryVersionCookie{cookie} } +// QueryVersionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) QueryVersionCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) return QueryVersionCookie{cookie} } -// Request reply for QueryVersion -// size: 32 +// QueryVersionReply represents the data returned from a QueryVersion request. type QueryVersionReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes MajorVersion uint16 MinorVersion uint16 // padding: 20 bytes } -// Waits and reads reply data from request QueryVersion +// Reply blocks and returns the reply data for a QueryVersion request. func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -105,7 +107,7 @@ func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { return queryVersionReply(buf), nil } -// Read reply into structure from buffer for QueryVersion +// queryVersionReply reads a byte slice into a QueryVersionReply value. func queryVersionReply(buf []byte) *QueryVersionReply { v := new(QueryVersionReply) b := 1 // skip reply determinant @@ -130,6 +132,7 @@ func queryVersionReply(buf []byte) *QueryVersionReply { } // Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) []byte { size := 8 b := 0 diff --git a/nexgb/glx/glx.go b/nexgb/glx/glx.go index 887d96b..d351137 100644 --- a/nexgb/glx/glx.go +++ b/nexgb/glx/glx.go @@ -2,7 +2,7 @@ package glx /* - This file was generated by glx.xml on May 10 2012 8:04:31pm EDT. + This file was generated by glx.xml on May 10 2012 11:56:18pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,6 +40,12 @@ func init() { xgb.NewExtErrorFuncs["GLX"] = make(map[int]xgb.NewErrorFun) } +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Bool' + // Skipping definition for base type 'Float' // Skipping definition for base type 'Card8' @@ -58,12 +64,6 @@ func init() { // Skipping definition for base type 'Char' -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - const ( PbcetDamaged = 32791 PbcetSaved = 32792 @@ -172,9 +172,7 @@ type Bool32 uint32 type ContextTag uint32 -// Event definition PbufferClobber (0) -// Size: 32 - +// PbufferClobber is the event number for a PbufferClobberEvent. const PbufferClobber = 0 type PbufferClobberEvent struct { @@ -193,7 +191,7 @@ type PbufferClobberEvent struct { // padding: 4 bytes } -// Event read PbufferClobber +// PbufferClobberEventNew constructs a PbufferClobberEvent value that implements xgb.Event from a byte slice. func PbufferClobberEventNew(buf []byte) xgb.Event { v := PbufferClobberEvent{} b := 1 // don't read event number @@ -238,7 +236,7 @@ func PbufferClobberEventNew(buf []byte) xgb.Event { return v } -// Event write PbufferClobber +// Bytes writes a PbufferClobberEvent value to a byte slice. func (v PbufferClobberEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -286,12 +284,14 @@ func (v PbufferClobberEvent) Bytes() []byte { return buf } -func (v PbufferClobberEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the PbufferClobber event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v PbufferClobberEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of PbufferClobberEvent. func (v PbufferClobberEvent) String() string { fieldVals := make([]string, 0, 12) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -312,9 +312,7 @@ func init() { xgb.NewExtEventFuncs["GLX"][0] = PbufferClobberEventNew } -// Error definition Generic (-1) -// Size: 32 - +// BadGeneric is the error number for a BadGeneric. const BadGeneric = -1 type GenericError struct { @@ -326,7 +324,7 @@ type GenericError struct { // padding: 21 bytes } -// Error read Generic +// GenericErrorNew constructs a GenericError value that implements xgb.Error from a byte slice. func GenericErrorNew(buf []byte) xgb.Error { v := GenericError{} v.NiceName = "Generic" @@ -351,8 +349,8 @@ func GenericErrorNew(buf []byte) xgb.Error { return v } -func (err GenericError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadGeneric error. +// This is mostly used internally. func (err GenericError) SequenceId() uint16 { return err.Sequence } @@ -375,20 +373,20 @@ func init() { xgb.NewExtErrorFuncs["GLX"][-1] = GenericErrorNew } -// ErrorCopy definition BadContext (0) - +// BadBadContext is the error number for a BadBadContext. const BadBadContext = 0 type BadContextError GenericError +// BadContextErrorNew constructs a BadContextError value that implements xgb.Error from a byte slice. func BadContextErrorNew(buf []byte) xgb.Error { v := BadContextError(GenericErrorNew(buf).(GenericError)) v.NiceName = "BadContext" return v } -func (err BadContextError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadBadContext error. +// This is mostly used internally. func (err BadContextError) SequenceId() uint16 { return err.Sequence } @@ -411,20 +409,20 @@ func init() { xgb.NewExtErrorFuncs["GLX"][0] = BadContextErrorNew } -// ErrorCopy definition BadContextState (1) - +// BadBadContextState is the error number for a BadBadContextState. const BadBadContextState = 1 type BadContextStateError GenericError +// BadContextStateErrorNew constructs a BadContextStateError value that implements xgb.Error from a byte slice. func BadContextStateErrorNew(buf []byte) xgb.Error { v := BadContextStateError(GenericErrorNew(buf).(GenericError)) v.NiceName = "BadContextState" return v } -func (err BadContextStateError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadBadContextState error. +// This is mostly used internally. func (err BadContextStateError) SequenceId() uint16 { return err.Sequence } @@ -447,20 +445,20 @@ func init() { xgb.NewExtErrorFuncs["GLX"][1] = BadContextStateErrorNew } -// ErrorCopy definition BadDrawable (2) - +// BadBadDrawable is the error number for a BadBadDrawable. const BadBadDrawable = 2 type BadDrawableError GenericError +// BadDrawableErrorNew constructs a BadDrawableError value that implements xgb.Error from a byte slice. func BadDrawableErrorNew(buf []byte) xgb.Error { v := BadDrawableError(GenericErrorNew(buf).(GenericError)) v.NiceName = "BadDrawable" return v } -func (err BadDrawableError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadBadDrawable error. +// This is mostly used internally. func (err BadDrawableError) SequenceId() uint16 { return err.Sequence } @@ -483,20 +481,20 @@ func init() { xgb.NewExtErrorFuncs["GLX"][2] = BadDrawableErrorNew } -// ErrorCopy definition BadPixmap (3) - +// BadBadPixmap is the error number for a BadBadPixmap. const BadBadPixmap = 3 type BadPixmapError GenericError +// BadPixmapErrorNew constructs a BadPixmapError value that implements xgb.Error from a byte slice. func BadPixmapErrorNew(buf []byte) xgb.Error { v := BadPixmapError(GenericErrorNew(buf).(GenericError)) v.NiceName = "BadPixmap" return v } -func (err BadPixmapError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadBadPixmap error. +// This is mostly used internally. func (err BadPixmapError) SequenceId() uint16 { return err.Sequence } @@ -519,20 +517,20 @@ func init() { xgb.NewExtErrorFuncs["GLX"][3] = BadPixmapErrorNew } -// ErrorCopy definition BadContextTag (4) - +// BadBadContextTag is the error number for a BadBadContextTag. const BadBadContextTag = 4 type BadContextTagError GenericError +// BadContextTagErrorNew constructs a BadContextTagError value that implements xgb.Error from a byte slice. func BadContextTagErrorNew(buf []byte) xgb.Error { v := BadContextTagError(GenericErrorNew(buf).(GenericError)) v.NiceName = "BadContextTag" return v } -func (err BadContextTagError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadBadContextTag error. +// This is mostly used internally. func (err BadContextTagError) SequenceId() uint16 { return err.Sequence } @@ -555,20 +553,20 @@ func init() { xgb.NewExtErrorFuncs["GLX"][4] = BadContextTagErrorNew } -// ErrorCopy definition BadCurrentWindow (5) - +// BadBadCurrentWindow is the error number for a BadBadCurrentWindow. const BadBadCurrentWindow = 5 type BadCurrentWindowError GenericError +// BadCurrentWindowErrorNew constructs a BadCurrentWindowError value that implements xgb.Error from a byte slice. func BadCurrentWindowErrorNew(buf []byte) xgb.Error { v := BadCurrentWindowError(GenericErrorNew(buf).(GenericError)) v.NiceName = "BadCurrentWindow" return v } -func (err BadCurrentWindowError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadBadCurrentWindow error. +// This is mostly used internally. func (err BadCurrentWindowError) SequenceId() uint16 { return err.Sequence } @@ -591,20 +589,20 @@ func init() { xgb.NewExtErrorFuncs["GLX"][5] = BadCurrentWindowErrorNew } -// ErrorCopy definition BadRenderRequest (6) - +// BadBadRenderRequest is the error number for a BadBadRenderRequest. const BadBadRenderRequest = 6 type BadRenderRequestError GenericError +// BadRenderRequestErrorNew constructs a BadRenderRequestError value that implements xgb.Error from a byte slice. func BadRenderRequestErrorNew(buf []byte) xgb.Error { v := BadRenderRequestError(GenericErrorNew(buf).(GenericError)) v.NiceName = "BadRenderRequest" return v } -func (err BadRenderRequestError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadBadRenderRequest error. +// This is mostly used internally. func (err BadRenderRequestError) SequenceId() uint16 { return err.Sequence } @@ -627,20 +625,20 @@ func init() { xgb.NewExtErrorFuncs["GLX"][6] = BadRenderRequestErrorNew } -// ErrorCopy definition BadLargeRequest (7) - +// BadBadLargeRequest is the error number for a BadBadLargeRequest. const BadBadLargeRequest = 7 type BadLargeRequestError GenericError +// BadLargeRequestErrorNew constructs a BadLargeRequestError value that implements xgb.Error from a byte slice. func BadLargeRequestErrorNew(buf []byte) xgb.Error { v := BadLargeRequestError(GenericErrorNew(buf).(GenericError)) v.NiceName = "BadLargeRequest" return v } -func (err BadLargeRequestError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadBadLargeRequest error. +// This is mostly used internally. func (err BadLargeRequestError) SequenceId() uint16 { return err.Sequence } @@ -663,20 +661,20 @@ func init() { xgb.NewExtErrorFuncs["GLX"][7] = BadLargeRequestErrorNew } -// ErrorCopy definition UnsupportedPrivateRequest (8) - +// BadUnsupportedPrivateRequest is the error number for a BadUnsupportedPrivateRequest. const BadUnsupportedPrivateRequest = 8 type UnsupportedPrivateRequestError GenericError +// UnsupportedPrivateRequestErrorNew constructs a UnsupportedPrivateRequestError value that implements xgb.Error from a byte slice. func UnsupportedPrivateRequestErrorNew(buf []byte) xgb.Error { v := UnsupportedPrivateRequestError(GenericErrorNew(buf).(GenericError)) v.NiceName = "UnsupportedPrivateRequest" return v } -func (err UnsupportedPrivateRequestError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadUnsupportedPrivateRequest error. +// This is mostly used internally. func (err UnsupportedPrivateRequestError) SequenceId() uint16 { return err.Sequence } @@ -699,20 +697,20 @@ func init() { xgb.NewExtErrorFuncs["GLX"][8] = UnsupportedPrivateRequestErrorNew } -// ErrorCopy definition BadFBConfig (9) - +// BadBadFBConfig is the error number for a BadBadFBConfig. const BadBadFBConfig = 9 type BadFBConfigError GenericError +// BadFBConfigErrorNew constructs a BadFBConfigError value that implements xgb.Error from a byte slice. func BadFBConfigErrorNew(buf []byte) xgb.Error { v := BadFBConfigError(GenericErrorNew(buf).(GenericError)) v.NiceName = "BadFBConfig" return v } -func (err BadFBConfigError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadBadFBConfig error. +// This is mostly used internally. func (err BadFBConfigError) SequenceId() uint16 { return err.Sequence } @@ -735,20 +733,20 @@ func init() { xgb.NewExtErrorFuncs["GLX"][9] = BadFBConfigErrorNew } -// ErrorCopy definition BadPbuffer (10) - +// BadBadPbuffer is the error number for a BadBadPbuffer. const BadBadPbuffer = 10 type BadPbufferError GenericError +// BadPbufferErrorNew constructs a BadPbufferError value that implements xgb.Error from a byte slice. func BadPbufferErrorNew(buf []byte) xgb.Error { v := BadPbufferError(GenericErrorNew(buf).(GenericError)) v.NiceName = "BadPbuffer" return v } -func (err BadPbufferError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadBadPbuffer error. +// This is mostly used internally. func (err BadPbufferError) SequenceId() uint16 { return err.Sequence } @@ -771,20 +769,20 @@ func init() { xgb.NewExtErrorFuncs["GLX"][10] = BadPbufferErrorNew } -// ErrorCopy definition BadCurrentDrawable (11) - +// BadBadCurrentDrawable is the error number for a BadBadCurrentDrawable. const BadBadCurrentDrawable = 11 type BadCurrentDrawableError GenericError +// BadCurrentDrawableErrorNew constructs a BadCurrentDrawableError value that implements xgb.Error from a byte slice. func BadCurrentDrawableErrorNew(buf []byte) xgb.Error { v := BadCurrentDrawableError(GenericErrorNew(buf).(GenericError)) v.NiceName = "BadCurrentDrawable" return v } -func (err BadCurrentDrawableError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadBadCurrentDrawable error. +// This is mostly used internally. func (err BadCurrentDrawableError) SequenceId() uint16 { return err.Sequence } @@ -807,20 +805,20 @@ func init() { xgb.NewExtErrorFuncs["GLX"][11] = BadCurrentDrawableErrorNew } -// ErrorCopy definition BadWindow (12) - +// BadBadWindow is the error number for a BadBadWindow. const BadBadWindow = 12 type BadWindowError GenericError +// BadWindowErrorNew constructs a BadWindowError value that implements xgb.Error from a byte slice. func BadWindowErrorNew(buf []byte) xgb.Error { v := BadWindowError(GenericErrorNew(buf).(GenericError)) v.NiceName = "BadWindow" return v } -func (err BadWindowError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadBadWindow error. +// This is mostly used internally. func (err BadWindowError) SequenceId() uint16 { return err.Sequence } @@ -843,20 +841,20 @@ func init() { xgb.NewExtErrorFuncs["GLX"][12] = BadWindowErrorNew } -// ErrorCopy definition GLXBadProfileARB (13) - +// BadGLXBadProfileARB is the error number for a BadGLXBadProfileARB. const BadGLXBadProfileARB = 13 type GLXBadProfileARBError GenericError +// GLXBadProfileARBErrorNew constructs a GLXBadProfileARBError value that implements xgb.Error from a byte slice. func GLXBadProfileARBErrorNew(buf []byte) xgb.Error { v := GLXBadProfileARBError(GenericErrorNew(buf).(GenericError)) v.NiceName = "GLXBadProfileARB" return v } -func (err GLXBadProfileARBError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadGLXBadProfileARB error. +// This is mostly used internally. func (err GLXBadProfileARBError) SequenceId() uint16 { return err.Sequence } @@ -879,30 +877,35 @@ func init() { xgb.NewExtErrorFuncs["GLX"][13] = GLXBadProfileARBErrorNew } -// Request Render -// size: xgb.Pad((8 + xgb.Pad((len(Data) * 1)))) +// RenderCookie is a cookie used only for Render requests. type RenderCookie struct { *xgb.Cookie } -// Write request to wire for Render +// Render sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func Render(c *xgb.Conn, ContextTag ContextTag, Data []byte) RenderCookie { cookie := c.NewCookie(false, false) c.NewRequest(renderRequest(c, ContextTag, Data), cookie) return RenderCookie{cookie} } +// RenderChecked sends a checked request. +// If an error occurs, it can be retrieved using RenderCookie.Check() func RenderChecked(c *xgb.Conn, ContextTag ContextTag, Data []byte) RenderCookie { cookie := c.NewCookie(true, false) c.NewRequest(renderRequest(c, ContextTag, Data), cookie) return RenderCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook RenderCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for Render +// renderRequest writes a Render request to a byte slice. func renderRequest(c *xgb.Conn, ContextTag ContextTag, Data []byte) []byte { size := xgb.Pad((8 + xgb.Pad((len(Data) * 1)))) b := 0 @@ -926,30 +929,35 @@ func renderRequest(c *xgb.Conn, ContextTag ContextTag, Data []byte) []byte { return buf } -// Request RenderLarge -// size: xgb.Pad((16 + xgb.Pad((int(DataLen) * 1)))) +// RenderLargeCookie is a cookie used only for RenderLarge requests. type RenderLargeCookie struct { *xgb.Cookie } -// Write request to wire for RenderLarge +// RenderLarge sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func RenderLarge(c *xgb.Conn, ContextTag ContextTag, RequestNum uint16, RequestTotal uint16, DataLen uint32, Data []byte) RenderLargeCookie { cookie := c.NewCookie(false, false) c.NewRequest(renderLargeRequest(c, ContextTag, RequestNum, RequestTotal, DataLen, Data), cookie) return RenderLargeCookie{cookie} } +// RenderLargeChecked sends a checked request. +// If an error occurs, it can be retrieved using RenderLargeCookie.Check() func RenderLargeChecked(c *xgb.Conn, ContextTag ContextTag, RequestNum uint16, RequestTotal uint16, DataLen uint32, Data []byte) RenderLargeCookie { cookie := c.NewCookie(true, false) c.NewRequest(renderLargeRequest(c, ContextTag, RequestNum, RequestTotal, DataLen, Data), cookie) return RenderLargeCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook RenderLargeCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for RenderLarge +// renderLargeRequest writes a RenderLarge request to a byte slice. func renderLargeRequest(c *xgb.Conn, ContextTag ContextTag, RequestNum uint16, RequestTotal uint16, DataLen uint32, Data []byte) []byte { size := xgb.Pad((16 + xgb.Pad((int(DataLen) * 1)))) b := 0 @@ -982,30 +990,35 @@ func renderLargeRequest(c *xgb.Conn, ContextTag ContextTag, RequestNum uint16, R return buf } -// Request CreateContext -// size: 24 +// CreateContextCookie is a cookie used only for CreateContext requests. type CreateContextCookie struct { *xgb.Cookie } -// Write request to wire for CreateContext +// CreateContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreateContext(c *xgb.Conn, Context Context, Visual xproto.Visualid, Screen uint32, ShareList Context, IsDirect bool) CreateContextCookie { cookie := c.NewCookie(false, false) c.NewRequest(createContextRequest(c, Context, Visual, Screen, ShareList, IsDirect), cookie) return CreateContextCookie{cookie} } +// CreateContextChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateContextCookie.Check() func CreateContextChecked(c *xgb.Conn, Context Context, Visual xproto.Visualid, Screen uint32, ShareList Context, IsDirect bool) CreateContextCookie { cookie := c.NewCookie(true, false) c.NewRequest(createContextRequest(c, Context, Visual, Screen, ShareList, IsDirect), cookie) return CreateContextCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CreateContextCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreateContext +// createContextRequest writes a CreateContext request to a byte slice. func createContextRequest(c *xgb.Conn, Context Context, Visual xproto.Visualid, Screen uint32, ShareList Context, IsDirect bool) []byte { size := 24 b := 0 @@ -1044,30 +1057,35 @@ func createContextRequest(c *xgb.Conn, Context Context, Visual xproto.Visualid, return buf } -// Request DestroyContext -// size: 8 +// DestroyContextCookie is a cookie used only for DestroyContext requests. type DestroyContextCookie struct { *xgb.Cookie } -// Write request to wire for DestroyContext +// DestroyContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func DestroyContext(c *xgb.Conn, Context Context) DestroyContextCookie { cookie := c.NewCookie(false, false) c.NewRequest(destroyContextRequest(c, Context), cookie) return DestroyContextCookie{cookie} } +// DestroyContextChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroyContextCookie.Check() func DestroyContextChecked(c *xgb.Conn, Context Context) DestroyContextCookie { cookie := c.NewCookie(true, false) c.NewRequest(destroyContextRequest(c, Context), cookie) return DestroyContextCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook DestroyContextCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for DestroyContext +// destroyContextRequest writes a DestroyContext request to a byte slice. func destroyContextRequest(c *xgb.Conn, Context Context) []byte { size := 8 b := 0 @@ -1088,35 +1106,37 @@ func destroyContextRequest(c *xgb.Conn, Context Context) []byte { return buf } -// Request MakeCurrent -// size: 16 +// MakeCurrentCookie is a cookie used only for MakeCurrent requests. type MakeCurrentCookie struct { *xgb.Cookie } +// MakeCurrent sends a checked request. +// If an error occurs, it will be returned with the reply by calling MakeCurrentCookie.Reply() func MakeCurrent(c *xgb.Conn, Drawable Drawable, Context Context, OldContextTag ContextTag) MakeCurrentCookie { cookie := c.NewCookie(true, true) c.NewRequest(makeCurrentRequest(c, Drawable, Context, OldContextTag), cookie) return MakeCurrentCookie{cookie} } +// MakeCurrentUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func MakeCurrentUnchecked(c *xgb.Conn, Drawable Drawable, Context Context, OldContextTag ContextTag) MakeCurrentCookie { cookie := c.NewCookie(false, true) c.NewRequest(makeCurrentRequest(c, Drawable, Context, OldContextTag), cookie) return MakeCurrentCookie{cookie} } -// Request reply for MakeCurrent -// size: 32 +// MakeCurrentReply represents the data returned from a MakeCurrent request. type MakeCurrentReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes ContextTag ContextTag // padding: 20 bytes } -// Waits and reads reply data from request MakeCurrent +// Reply blocks and returns the reply data for a MakeCurrent request. func (cook MakeCurrentCookie) Reply() (*MakeCurrentReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1128,7 +1148,7 @@ func (cook MakeCurrentCookie) Reply() (*MakeCurrentReply, error) { return makeCurrentReply(buf), nil } -// Read reply into structure from buffer for MakeCurrent +// makeCurrentReply reads a byte slice into a MakeCurrentReply value. func makeCurrentReply(buf []byte) *MakeCurrentReply { v := new(MakeCurrentReply) b := 1 // skip reply determinant @@ -1150,6 +1170,7 @@ func makeCurrentReply(buf []byte) *MakeCurrentReply { } // Write request to wire for MakeCurrent +// makeCurrentRequest writes a MakeCurrent request to a byte slice. func makeCurrentRequest(c *xgb.Conn, Drawable Drawable, Context Context, OldContextTag ContextTag) []byte { size := 16 b := 0 @@ -1176,35 +1197,37 @@ func makeCurrentRequest(c *xgb.Conn, Drawable Drawable, Context Context, OldCont return buf } -// Request IsDirect -// size: 8 +// IsDirectCookie is a cookie used only for IsDirect requests. type IsDirectCookie struct { *xgb.Cookie } +// IsDirect sends a checked request. +// If an error occurs, it will be returned with the reply by calling IsDirectCookie.Reply() func IsDirect(c *xgb.Conn, Context Context) IsDirectCookie { cookie := c.NewCookie(true, true) c.NewRequest(isDirectRequest(c, Context), cookie) return IsDirectCookie{cookie} } +// IsDirectUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func IsDirectUnchecked(c *xgb.Conn, Context Context) IsDirectCookie { cookie := c.NewCookie(false, true) c.NewRequest(isDirectRequest(c, Context), cookie) return IsDirectCookie{cookie} } -// Request reply for IsDirect -// size: 32 +// IsDirectReply represents the data returned from a IsDirect request. type IsDirectReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes IsDirect bool // padding: 23 bytes } -// Waits and reads reply data from request IsDirect +// Reply blocks and returns the reply data for a IsDirect request. func (cook IsDirectCookie) Reply() (*IsDirectReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1216,7 +1239,7 @@ func (cook IsDirectCookie) Reply() (*IsDirectReply, error) { return isDirectReply(buf), nil } -// Read reply into structure from buffer for IsDirect +// isDirectReply reads a byte slice into a IsDirectReply value. func isDirectReply(buf []byte) *IsDirectReply { v := new(IsDirectReply) b := 1 // skip reply determinant @@ -1242,6 +1265,7 @@ func isDirectReply(buf []byte) *IsDirectReply { } // Write request to wire for IsDirect +// isDirectRequest writes a IsDirect request to a byte slice. func isDirectRequest(c *xgb.Conn, Context Context) []byte { size := 8 b := 0 @@ -1262,36 +1286,38 @@ func isDirectRequest(c *xgb.Conn, Context Context) []byte { return buf } -// Request QueryVersion -// size: 12 +// QueryVersionCookie is a cookie used only for QueryVersion requests. type QueryVersionCookie struct { *xgb.Cookie } +// QueryVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() func QueryVersion(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) return QueryVersionCookie{cookie} } +// QueryVersionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryVersionUnchecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) return QueryVersionCookie{cookie} } -// Request reply for QueryVersion -// size: 32 +// QueryVersionReply represents the data returned from a QueryVersion request. type QueryVersionReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes MajorVersion uint32 MinorVersion uint32 // padding: 16 bytes } -// Waits and reads reply data from request QueryVersion +// Reply blocks and returns the reply data for a QueryVersion request. func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1303,7 +1329,7 @@ func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { return queryVersionReply(buf), nil } -// Read reply into structure from buffer for QueryVersion +// queryVersionReply reads a byte slice into a QueryVersionReply value. func queryVersionReply(buf []byte) *QueryVersionReply { v := new(QueryVersionReply) b := 1 // skip reply determinant @@ -1328,6 +1354,7 @@ func queryVersionReply(buf []byte) *QueryVersionReply { } // Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. func queryVersionRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) []byte { size := 12 b := 0 @@ -1351,30 +1378,35 @@ func queryVersionRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) return buf } -// Request WaitGL -// size: 8 +// WaitGLCookie is a cookie used only for WaitGL requests. type WaitGLCookie struct { *xgb.Cookie } -// Write request to wire for WaitGL +// WaitGL sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func WaitGL(c *xgb.Conn, ContextTag ContextTag) WaitGLCookie { cookie := c.NewCookie(false, false) c.NewRequest(waitGLRequest(c, ContextTag), cookie) return WaitGLCookie{cookie} } +// WaitGLChecked sends a checked request. +// If an error occurs, it can be retrieved using WaitGLCookie.Check() func WaitGLChecked(c *xgb.Conn, ContextTag ContextTag) WaitGLCookie { cookie := c.NewCookie(true, false) c.NewRequest(waitGLRequest(c, ContextTag), cookie) return WaitGLCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook WaitGLCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for WaitGL +// waitGLRequest writes a WaitGL request to a byte slice. func waitGLRequest(c *xgb.Conn, ContextTag ContextTag) []byte { size := 8 b := 0 @@ -1395,30 +1427,35 @@ func waitGLRequest(c *xgb.Conn, ContextTag ContextTag) []byte { return buf } -// Request WaitX -// size: 8 +// WaitXCookie is a cookie used only for WaitX requests. type WaitXCookie struct { *xgb.Cookie } -// Write request to wire for WaitX +// WaitX sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func WaitX(c *xgb.Conn, ContextTag ContextTag) WaitXCookie { cookie := c.NewCookie(false, false) c.NewRequest(waitXRequest(c, ContextTag), cookie) return WaitXCookie{cookie} } +// WaitXChecked sends a checked request. +// If an error occurs, it can be retrieved using WaitXCookie.Check() func WaitXChecked(c *xgb.Conn, ContextTag ContextTag) WaitXCookie { cookie := c.NewCookie(true, false) c.NewRequest(waitXRequest(c, ContextTag), cookie) return WaitXCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook WaitXCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for WaitX +// waitXRequest writes a WaitX request to a byte slice. func waitXRequest(c *xgb.Conn, ContextTag ContextTag) []byte { size := 8 b := 0 @@ -1439,30 +1476,35 @@ func waitXRequest(c *xgb.Conn, ContextTag ContextTag) []byte { return buf } -// Request CopyContext -// size: 20 +// CopyContextCookie is a cookie used only for CopyContext requests. type CopyContextCookie struct { *xgb.Cookie } -// Write request to wire for CopyContext +// CopyContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CopyContext(c *xgb.Conn, Src Context, Dest Context, Mask uint32, SrcContextTag ContextTag) CopyContextCookie { cookie := c.NewCookie(false, false) c.NewRequest(copyContextRequest(c, Src, Dest, Mask, SrcContextTag), cookie) return CopyContextCookie{cookie} } +// CopyContextChecked sends a checked request. +// If an error occurs, it can be retrieved using CopyContextCookie.Check() func CopyContextChecked(c *xgb.Conn, Src Context, Dest Context, Mask uint32, SrcContextTag ContextTag) CopyContextCookie { cookie := c.NewCookie(true, false) c.NewRequest(copyContextRequest(c, Src, Dest, Mask, SrcContextTag), cookie) return CopyContextCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CopyContextCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CopyContext +// copyContextRequest writes a CopyContext request to a byte slice. func copyContextRequest(c *xgb.Conn, Src Context, Dest Context, Mask uint32, SrcContextTag ContextTag) []byte { size := 20 b := 0 @@ -1492,30 +1534,35 @@ func copyContextRequest(c *xgb.Conn, Src Context, Dest Context, Mask uint32, Src return buf } -// Request SwapBuffers -// size: 12 +// SwapBuffersCookie is a cookie used only for SwapBuffers requests. type SwapBuffersCookie struct { *xgb.Cookie } -// Write request to wire for SwapBuffers +// SwapBuffers sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SwapBuffers(c *xgb.Conn, ContextTag ContextTag, Drawable Drawable) SwapBuffersCookie { cookie := c.NewCookie(false, false) c.NewRequest(swapBuffersRequest(c, ContextTag, Drawable), cookie) return SwapBuffersCookie{cookie} } +// SwapBuffersChecked sends a checked request. +// If an error occurs, it can be retrieved using SwapBuffersCookie.Check() func SwapBuffersChecked(c *xgb.Conn, ContextTag ContextTag, Drawable Drawable) SwapBuffersCookie { cookie := c.NewCookie(true, false) c.NewRequest(swapBuffersRequest(c, ContextTag, Drawable), cookie) return SwapBuffersCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SwapBuffersCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SwapBuffers +// swapBuffersRequest writes a SwapBuffers request to a byte slice. func swapBuffersRequest(c *xgb.Conn, ContextTag ContextTag, Drawable Drawable) []byte { size := 12 b := 0 @@ -1539,30 +1586,35 @@ func swapBuffersRequest(c *xgb.Conn, ContextTag ContextTag, Drawable Drawable) [ return buf } -// Request UseXFont -// size: 24 +// UseXFontCookie is a cookie used only for UseXFont requests. type UseXFontCookie struct { *xgb.Cookie } -// Write request to wire for UseXFont +// UseXFont sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func UseXFont(c *xgb.Conn, ContextTag ContextTag, Font xproto.Font, First uint32, Count uint32, ListBase uint32) UseXFontCookie { cookie := c.NewCookie(false, false) c.NewRequest(useXFontRequest(c, ContextTag, Font, First, Count, ListBase), cookie) return UseXFontCookie{cookie} } +// UseXFontChecked sends a checked request. +// If an error occurs, it can be retrieved using UseXFontCookie.Check() func UseXFontChecked(c *xgb.Conn, ContextTag ContextTag, Font xproto.Font, First uint32, Count uint32, ListBase uint32) UseXFontCookie { cookie := c.NewCookie(true, false) c.NewRequest(useXFontRequest(c, ContextTag, Font, First, Count, ListBase), cookie) return UseXFontCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook UseXFontCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for UseXFont +// useXFontRequest writes a UseXFont request to a byte slice. func useXFontRequest(c *xgb.Conn, ContextTag ContextTag, Font xproto.Font, First uint32, Count uint32, ListBase uint32) []byte { size := 24 b := 0 @@ -1595,30 +1647,35 @@ func useXFontRequest(c *xgb.Conn, ContextTag ContextTag, Font xproto.Font, First return buf } -// Request CreateGLXPixmap -// size: 20 +// CreateGLXPixmapCookie is a cookie used only for CreateGLXPixmap requests. type CreateGLXPixmapCookie struct { *xgb.Cookie } -// Write request to wire for CreateGLXPixmap +// CreateGLXPixmap sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreateGLXPixmap(c *xgb.Conn, Screen uint32, Visual xproto.Visualid, Pixmap xproto.Pixmap, GlxPixmap Pixmap) CreateGLXPixmapCookie { cookie := c.NewCookie(false, false) c.NewRequest(createGLXPixmapRequest(c, Screen, Visual, Pixmap, GlxPixmap), cookie) return CreateGLXPixmapCookie{cookie} } +// CreateGLXPixmapChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateGLXPixmapCookie.Check() func CreateGLXPixmapChecked(c *xgb.Conn, Screen uint32, Visual xproto.Visualid, Pixmap xproto.Pixmap, GlxPixmap Pixmap) CreateGLXPixmapCookie { cookie := c.NewCookie(true, false) c.NewRequest(createGLXPixmapRequest(c, Screen, Visual, Pixmap, GlxPixmap), cookie) return CreateGLXPixmapCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CreateGLXPixmapCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreateGLXPixmap +// createGLXPixmapRequest writes a CreateGLXPixmap request to a byte slice. func createGLXPixmapRequest(c *xgb.Conn, Screen uint32, Visual xproto.Visualid, Pixmap xproto.Pixmap, GlxPixmap Pixmap) []byte { size := 20 b := 0 @@ -1648,29 +1705,31 @@ func createGLXPixmapRequest(c *xgb.Conn, Screen uint32, Visual xproto.Visualid, return buf } -// Request GetVisualConfigs -// size: 8 +// GetVisualConfigsCookie is a cookie used only for GetVisualConfigs requests. type GetVisualConfigsCookie struct { *xgb.Cookie } +// GetVisualConfigs sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetVisualConfigsCookie.Reply() func GetVisualConfigs(c *xgb.Conn, Screen uint32) GetVisualConfigsCookie { cookie := c.NewCookie(true, true) c.NewRequest(getVisualConfigsRequest(c, Screen), cookie) return GetVisualConfigsCookie{cookie} } +// GetVisualConfigsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetVisualConfigsUnchecked(c *xgb.Conn, Screen uint32) GetVisualConfigsCookie { cookie := c.NewCookie(false, true) c.NewRequest(getVisualConfigsRequest(c, Screen), cookie) return GetVisualConfigsCookie{cookie} } -// Request reply for GetVisualConfigs -// size: (32 + xgb.Pad((int(Length) * 4))) +// GetVisualConfigsReply represents the data returned from a GetVisualConfigs request. type GetVisualConfigsReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes NumVisuals uint32 NumProperties uint32 @@ -1678,7 +1737,7 @@ type GetVisualConfigsReply struct { PropertyList []uint32 // size: xgb.Pad((int(Length) * 4)) } -// Waits and reads reply data from request GetVisualConfigs +// Reply blocks and returns the reply data for a GetVisualConfigs request. func (cook GetVisualConfigsCookie) Reply() (*GetVisualConfigsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1690,7 +1749,7 @@ func (cook GetVisualConfigsCookie) Reply() (*GetVisualConfigsReply, error) { return getVisualConfigsReply(buf), nil } -// Read reply into structure from buffer for GetVisualConfigs +// getVisualConfigsReply reads a byte slice into a GetVisualConfigsReply value. func getVisualConfigsReply(buf []byte) *GetVisualConfigsReply { v := new(GetVisualConfigsReply) b := 1 // skip reply determinant @@ -1722,6 +1781,7 @@ func getVisualConfigsReply(buf []byte) *GetVisualConfigsReply { } // Write request to wire for GetVisualConfigs +// getVisualConfigsRequest writes a GetVisualConfigs request to a byte slice. func getVisualConfigsRequest(c *xgb.Conn, Screen uint32) []byte { size := 8 b := 0 @@ -1742,30 +1802,35 @@ func getVisualConfigsRequest(c *xgb.Conn, Screen uint32) []byte { return buf } -// Request DestroyGLXPixmap -// size: 8 +// DestroyGLXPixmapCookie is a cookie used only for DestroyGLXPixmap requests. type DestroyGLXPixmapCookie struct { *xgb.Cookie } -// Write request to wire for DestroyGLXPixmap +// DestroyGLXPixmap sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func DestroyGLXPixmap(c *xgb.Conn, GlxPixmap Pixmap) DestroyGLXPixmapCookie { cookie := c.NewCookie(false, false) c.NewRequest(destroyGLXPixmapRequest(c, GlxPixmap), cookie) return DestroyGLXPixmapCookie{cookie} } +// DestroyGLXPixmapChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroyGLXPixmapCookie.Check() func DestroyGLXPixmapChecked(c *xgb.Conn, GlxPixmap Pixmap) DestroyGLXPixmapCookie { cookie := c.NewCookie(true, false) c.NewRequest(destroyGLXPixmapRequest(c, GlxPixmap), cookie) return DestroyGLXPixmapCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook DestroyGLXPixmapCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for DestroyGLXPixmap +// destroyGLXPixmapRequest writes a DestroyGLXPixmap request to a byte slice. func destroyGLXPixmapRequest(c *xgb.Conn, GlxPixmap Pixmap) []byte { size := 8 b := 0 @@ -1786,30 +1851,35 @@ func destroyGLXPixmapRequest(c *xgb.Conn, GlxPixmap Pixmap) []byte { return buf } -// Request VendorPrivate -// size: xgb.Pad((12 + xgb.Pad((len(Data) * 1)))) +// VendorPrivateCookie is a cookie used only for VendorPrivate requests. type VendorPrivateCookie struct { *xgb.Cookie } -// Write request to wire for VendorPrivate +// VendorPrivate sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func VendorPrivate(c *xgb.Conn, VendorCode uint32, ContextTag ContextTag, Data []byte) VendorPrivateCookie { cookie := c.NewCookie(false, false) c.NewRequest(vendorPrivateRequest(c, VendorCode, ContextTag, Data), cookie) return VendorPrivateCookie{cookie} } +// VendorPrivateChecked sends a checked request. +// If an error occurs, it can be retrieved using VendorPrivateCookie.Check() func VendorPrivateChecked(c *xgb.Conn, VendorCode uint32, ContextTag ContextTag, Data []byte) VendorPrivateCookie { cookie := c.NewCookie(true, false) c.NewRequest(vendorPrivateRequest(c, VendorCode, ContextTag, Data), cookie) return VendorPrivateCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook VendorPrivateCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for VendorPrivate +// vendorPrivateRequest writes a VendorPrivate request to a byte slice. func vendorPrivateRequest(c *xgb.Conn, VendorCode uint32, ContextTag ContextTag, Data []byte) []byte { size := xgb.Pad((12 + xgb.Pad((len(Data) * 1)))) b := 0 @@ -1836,36 +1906,38 @@ func vendorPrivateRequest(c *xgb.Conn, VendorCode uint32, ContextTag ContextTag, return buf } -// Request VendorPrivateWithReply -// size: xgb.Pad((12 + xgb.Pad((len(Data) * 1)))) +// VendorPrivateWithReplyCookie is a cookie used only for VendorPrivateWithReply requests. type VendorPrivateWithReplyCookie struct { *xgb.Cookie } +// VendorPrivateWithReply sends a checked request. +// If an error occurs, it will be returned with the reply by calling VendorPrivateWithReplyCookie.Reply() func VendorPrivateWithReply(c *xgb.Conn, VendorCode uint32, ContextTag ContextTag, Data []byte) VendorPrivateWithReplyCookie { cookie := c.NewCookie(true, true) c.NewRequest(vendorPrivateWithReplyRequest(c, VendorCode, ContextTag, Data), cookie) return VendorPrivateWithReplyCookie{cookie} } +// VendorPrivateWithReplyUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func VendorPrivateWithReplyUnchecked(c *xgb.Conn, VendorCode uint32, ContextTag ContextTag, Data []byte) VendorPrivateWithReplyCookie { cookie := c.NewCookie(false, true) c.NewRequest(vendorPrivateWithReplyRequest(c, VendorCode, ContextTag, Data), cookie) return VendorPrivateWithReplyCookie{cookie} } -// Request reply for VendorPrivateWithReply -// size: (36 + xgb.Pad(((int(Length) * 4) * 1))) +// VendorPrivateWithReplyReply represents the data returned from a VendorPrivateWithReply request. type VendorPrivateWithReplyReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Retval uint32 Data1 []byte // size: 24 Data2 []byte // size: xgb.Pad(((int(Length) * 4) * 1)) } -// Waits and reads reply data from request VendorPrivateWithReply +// Reply blocks and returns the reply data for a VendorPrivateWithReply request. func (cook VendorPrivateWithReplyCookie) Reply() (*VendorPrivateWithReplyReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1877,7 +1949,7 @@ func (cook VendorPrivateWithReplyCookie) Reply() (*VendorPrivateWithReplyReply, return vendorPrivateWithReplyReply(buf), nil } -// Read reply into structure from buffer for VendorPrivateWithReply +// vendorPrivateWithReplyReply reads a byte slice into a VendorPrivateWithReplyReply value. func vendorPrivateWithReplyReply(buf []byte) *VendorPrivateWithReplyReply { v := new(VendorPrivateWithReplyReply) b := 1 // skip reply determinant @@ -1905,6 +1977,7 @@ func vendorPrivateWithReplyReply(buf []byte) *VendorPrivateWithReplyReply { } // Write request to wire for VendorPrivateWithReply +// vendorPrivateWithReplyRequest writes a VendorPrivateWithReply request to a byte slice. func vendorPrivateWithReplyRequest(c *xgb.Conn, VendorCode uint32, ContextTag ContextTag, Data []byte) []byte { size := xgb.Pad((12 + xgb.Pad((len(Data) * 1)))) b := 0 @@ -1931,36 +2004,38 @@ func vendorPrivateWithReplyRequest(c *xgb.Conn, VendorCode uint32, ContextTag Co return buf } -// Request QueryExtensionsString -// size: 8 +// QueryExtensionsStringCookie is a cookie used only for QueryExtensionsString requests. type QueryExtensionsStringCookie struct { *xgb.Cookie } +// QueryExtensionsString sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryExtensionsStringCookie.Reply() func QueryExtensionsString(c *xgb.Conn, Screen uint32) QueryExtensionsStringCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryExtensionsStringRequest(c, Screen), cookie) return QueryExtensionsStringCookie{cookie} } +// QueryExtensionsStringUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryExtensionsStringUnchecked(c *xgb.Conn, Screen uint32) QueryExtensionsStringCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryExtensionsStringRequest(c, Screen), cookie) return QueryExtensionsStringCookie{cookie} } -// Request reply for QueryExtensionsString -// size: 32 +// QueryExtensionsStringReply represents the data returned from a QueryExtensionsString request. type QueryExtensionsStringReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 4 bytes N uint32 // padding: 16 bytes } -// Waits and reads reply data from request QueryExtensionsString +// Reply blocks and returns the reply data for a QueryExtensionsString request. func (cook QueryExtensionsStringCookie) Reply() (*QueryExtensionsStringReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1972,7 +2047,7 @@ func (cook QueryExtensionsStringCookie) Reply() (*QueryExtensionsStringReply, er return queryExtensionsStringReply(buf), nil } -// Read reply into structure from buffer for QueryExtensionsString +// queryExtensionsStringReply reads a byte slice into a QueryExtensionsStringReply value. func queryExtensionsStringReply(buf []byte) *QueryExtensionsStringReply { v := new(QueryExtensionsStringReply) b := 1 // skip reply determinant @@ -1996,6 +2071,7 @@ func queryExtensionsStringReply(buf []byte) *QueryExtensionsStringReply { } // Write request to wire for QueryExtensionsString +// queryExtensionsStringRequest writes a QueryExtensionsString request to a byte slice. func queryExtensionsStringRequest(c *xgb.Conn, Screen uint32) []byte { size := 8 b := 0 @@ -2016,29 +2092,31 @@ func queryExtensionsStringRequest(c *xgb.Conn, Screen uint32) []byte { return buf } -// Request QueryServerString -// size: 12 +// QueryServerStringCookie is a cookie used only for QueryServerString requests. type QueryServerStringCookie struct { *xgb.Cookie } +// QueryServerString sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryServerStringCookie.Reply() func QueryServerString(c *xgb.Conn, Screen uint32, Name uint32) QueryServerStringCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryServerStringRequest(c, Screen, Name), cookie) return QueryServerStringCookie{cookie} } +// QueryServerStringUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryServerStringUnchecked(c *xgb.Conn, Screen uint32, Name uint32) QueryServerStringCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryServerStringRequest(c, Screen, Name), cookie) return QueryServerStringCookie{cookie} } -// Request reply for QueryServerString -// size: (32 + xgb.Pad((int(StrLen) * 1))) +// QueryServerStringReply represents the data returned from a QueryServerString request. type QueryServerStringReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 4 bytes StrLen uint32 @@ -2046,7 +2124,7 @@ type QueryServerStringReply struct { String string // size: xgb.Pad((int(StrLen) * 1)) } -// Waits and reads reply data from request QueryServerString +// Reply blocks and returns the reply data for a QueryServerString request. func (cook QueryServerStringCookie) Reply() (*QueryServerStringReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -2058,7 +2136,7 @@ func (cook QueryServerStringCookie) Reply() (*QueryServerStringReply, error) { return queryServerStringReply(buf), nil } -// Read reply into structure from buffer for QueryServerString +// queryServerStringReply reads a byte slice into a QueryServerStringReply value. func queryServerStringReply(buf []byte) *QueryServerStringReply { v := new(QueryServerStringReply) b := 1 // skip reply determinant @@ -2089,6 +2167,7 @@ func queryServerStringReply(buf []byte) *QueryServerStringReply { } // Write request to wire for QueryServerString +// queryServerStringRequest writes a QueryServerString request to a byte slice. func queryServerStringRequest(c *xgb.Conn, Screen uint32, Name uint32) []byte { size := 12 b := 0 @@ -2112,30 +2191,35 @@ func queryServerStringRequest(c *xgb.Conn, Screen uint32, Name uint32) []byte { return buf } -// Request ClientInfo -// size: xgb.Pad((16 + xgb.Pad((int(StrLen) * 1)))) +// ClientInfoCookie is a cookie used only for ClientInfo requests. type ClientInfoCookie struct { *xgb.Cookie } -// Write request to wire for ClientInfo +// ClientInfo sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ClientInfo(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, StrLen uint32, String string) ClientInfoCookie { cookie := c.NewCookie(false, false) c.NewRequest(clientInfoRequest(c, MajorVersion, MinorVersion, StrLen, String), cookie) return ClientInfoCookie{cookie} } +// ClientInfoChecked sends a checked request. +// If an error occurs, it can be retrieved using ClientInfoCookie.Check() func ClientInfoChecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, StrLen uint32, String string) ClientInfoCookie { cookie := c.NewCookie(true, false) c.NewRequest(clientInfoRequest(c, MajorVersion, MinorVersion, StrLen, String), cookie) return ClientInfoCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook ClientInfoCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ClientInfo +// clientInfoRequest writes a ClientInfo request to a byte slice. func clientInfoRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, StrLen uint32, String string) []byte { size := xgb.Pad((16 + xgb.Pad((int(StrLen) * 1)))) b := 0 @@ -2165,29 +2249,31 @@ func clientInfoRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, St return buf } -// Request GetFBConfigs -// size: 8 +// GetFBConfigsCookie is a cookie used only for GetFBConfigs requests. type GetFBConfigsCookie struct { *xgb.Cookie } +// GetFBConfigs sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetFBConfigsCookie.Reply() func GetFBConfigs(c *xgb.Conn, Screen uint32) GetFBConfigsCookie { cookie := c.NewCookie(true, true) c.NewRequest(getFBConfigsRequest(c, Screen), cookie) return GetFBConfigsCookie{cookie} } +// GetFBConfigsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetFBConfigsUnchecked(c *xgb.Conn, Screen uint32) GetFBConfigsCookie { cookie := c.NewCookie(false, true) c.NewRequest(getFBConfigsRequest(c, Screen), cookie) return GetFBConfigsCookie{cookie} } -// Request reply for GetFBConfigs -// size: (32 + xgb.Pad((int(Length) * 4))) +// GetFBConfigsReply represents the data returned from a GetFBConfigs request. type GetFBConfigsReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes NumFbConfigs uint32 NumProperties uint32 @@ -2195,7 +2281,7 @@ type GetFBConfigsReply struct { PropertyList []uint32 // size: xgb.Pad((int(Length) * 4)) } -// Waits and reads reply data from request GetFBConfigs +// Reply blocks and returns the reply data for a GetFBConfigs request. func (cook GetFBConfigsCookie) Reply() (*GetFBConfigsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -2207,7 +2293,7 @@ func (cook GetFBConfigsCookie) Reply() (*GetFBConfigsReply, error) { return getFBConfigsReply(buf), nil } -// Read reply into structure from buffer for GetFBConfigs +// getFBConfigsReply reads a byte slice into a GetFBConfigsReply value. func getFBConfigsReply(buf []byte) *GetFBConfigsReply { v := new(GetFBConfigsReply) b := 1 // skip reply determinant @@ -2239,6 +2325,7 @@ func getFBConfigsReply(buf []byte) *GetFBConfigsReply { } // Write request to wire for GetFBConfigs +// getFBConfigsRequest writes a GetFBConfigs request to a byte slice. func getFBConfigsRequest(c *xgb.Conn, Screen uint32) []byte { size := 8 b := 0 @@ -2259,30 +2346,35 @@ func getFBConfigsRequest(c *xgb.Conn, Screen uint32) []byte { return buf } -// Request CreatePixmap -// size: xgb.Pad((24 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) +// CreatePixmapCookie is a cookie used only for CreatePixmap requests. type CreatePixmapCookie struct { *xgb.Cookie } -// Write request to wire for CreatePixmap +// CreatePixmap sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreatePixmap(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Pixmap xproto.Pixmap, GlxPixmap Pixmap, NumAttribs uint32, Attribs []uint32) CreatePixmapCookie { cookie := c.NewCookie(false, false) c.NewRequest(createPixmapRequest(c, Screen, Fbconfig, Pixmap, GlxPixmap, NumAttribs, Attribs), cookie) return CreatePixmapCookie{cookie} } +// CreatePixmapChecked sends a checked request. +// If an error occurs, it can be retrieved using CreatePixmapCookie.Check() func CreatePixmapChecked(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Pixmap xproto.Pixmap, GlxPixmap Pixmap, NumAttribs uint32, Attribs []uint32) CreatePixmapCookie { cookie := c.NewCookie(true, false) c.NewRequest(createPixmapRequest(c, Screen, Fbconfig, Pixmap, GlxPixmap, NumAttribs, Attribs), cookie) return CreatePixmapCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CreatePixmapCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreatePixmap +// createPixmapRequest writes a CreatePixmap request to a byte slice. func createPixmapRequest(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Pixmap xproto.Pixmap, GlxPixmap Pixmap, NumAttribs uint32, Attribs []uint32) []byte { size := xgb.Pad((24 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) b := 0 @@ -2321,30 +2413,35 @@ func createPixmapRequest(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Pixmap x return buf } -// Request DestroyPixmap -// size: 8 +// DestroyPixmapCookie is a cookie used only for DestroyPixmap requests. type DestroyPixmapCookie struct { *xgb.Cookie } -// Write request to wire for DestroyPixmap +// DestroyPixmap sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func DestroyPixmap(c *xgb.Conn, GlxPixmap Pixmap) DestroyPixmapCookie { cookie := c.NewCookie(false, false) c.NewRequest(destroyPixmapRequest(c, GlxPixmap), cookie) return DestroyPixmapCookie{cookie} } +// DestroyPixmapChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroyPixmapCookie.Check() func DestroyPixmapChecked(c *xgb.Conn, GlxPixmap Pixmap) DestroyPixmapCookie { cookie := c.NewCookie(true, false) c.NewRequest(destroyPixmapRequest(c, GlxPixmap), cookie) return DestroyPixmapCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook DestroyPixmapCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for DestroyPixmap +// destroyPixmapRequest writes a DestroyPixmap request to a byte slice. func destroyPixmapRequest(c *xgb.Conn, GlxPixmap Pixmap) []byte { size := 8 b := 0 @@ -2365,30 +2462,35 @@ func destroyPixmapRequest(c *xgb.Conn, GlxPixmap Pixmap) []byte { return buf } -// Request CreateNewContext -// size: 28 +// CreateNewContextCookie is a cookie used only for CreateNewContext requests. type CreateNewContextCookie struct { *xgb.Cookie } -// Write request to wire for CreateNewContext +// CreateNewContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreateNewContext(c *xgb.Conn, Context Context, Fbconfig Fbconfig, Screen uint32, RenderType uint32, ShareList Context, IsDirect bool) CreateNewContextCookie { cookie := c.NewCookie(false, false) c.NewRequest(createNewContextRequest(c, Context, Fbconfig, Screen, RenderType, ShareList, IsDirect), cookie) return CreateNewContextCookie{cookie} } +// CreateNewContextChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateNewContextCookie.Check() func CreateNewContextChecked(c *xgb.Conn, Context Context, Fbconfig Fbconfig, Screen uint32, RenderType uint32, ShareList Context, IsDirect bool) CreateNewContextCookie { cookie := c.NewCookie(true, false) c.NewRequest(createNewContextRequest(c, Context, Fbconfig, Screen, RenderType, ShareList, IsDirect), cookie) return CreateNewContextCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CreateNewContextCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreateNewContext +// createNewContextRequest writes a CreateNewContext request to a byte slice. func createNewContextRequest(c *xgb.Conn, Context Context, Fbconfig Fbconfig, Screen uint32, RenderType uint32, ShareList Context, IsDirect bool) []byte { size := 28 b := 0 @@ -2430,36 +2532,38 @@ func createNewContextRequest(c *xgb.Conn, Context Context, Fbconfig Fbconfig, Sc return buf } -// Request QueryContext -// size: 8 +// QueryContextCookie is a cookie used only for QueryContext requests. type QueryContextCookie struct { *xgb.Cookie } +// QueryContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryContextCookie.Reply() func QueryContext(c *xgb.Conn, Context Context) QueryContextCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryContextRequest(c, Context), cookie) return QueryContextCookie{cookie} } +// QueryContextUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryContextUnchecked(c *xgb.Conn, Context Context) QueryContextCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryContextRequest(c, Context), cookie) return QueryContextCookie{cookie} } -// Request reply for QueryContext -// size: (32 + xgb.Pad(((int(NumAttribs) * 2) * 4))) +// QueryContextReply represents the data returned from a QueryContext request. type QueryContextReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes NumAttribs uint32 // padding: 20 bytes Attribs []uint32 // size: xgb.Pad(((int(NumAttribs) * 2) * 4)) } -// Waits and reads reply data from request QueryContext +// Reply blocks and returns the reply data for a QueryContext request. func (cook QueryContextCookie) Reply() (*QueryContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -2471,7 +2575,7 @@ func (cook QueryContextCookie) Reply() (*QueryContextReply, error) { return queryContextReply(buf), nil } -// Read reply into structure from buffer for QueryContext +// queryContextReply reads a byte slice into a QueryContextReply value. func queryContextReply(buf []byte) *QueryContextReply { v := new(QueryContextReply) b := 1 // skip reply determinant @@ -2500,6 +2604,7 @@ func queryContextReply(buf []byte) *QueryContextReply { } // Write request to wire for QueryContext +// queryContextRequest writes a QueryContext request to a byte slice. func queryContextRequest(c *xgb.Conn, Context Context) []byte { size := 8 b := 0 @@ -2520,35 +2625,37 @@ func queryContextRequest(c *xgb.Conn, Context Context) []byte { return buf } -// Request MakeContextCurrent -// size: 20 +// MakeContextCurrentCookie is a cookie used only for MakeContextCurrent requests. type MakeContextCurrentCookie struct { *xgb.Cookie } +// MakeContextCurrent sends a checked request. +// If an error occurs, it will be returned with the reply by calling MakeContextCurrentCookie.Reply() func MakeContextCurrent(c *xgb.Conn, OldContextTag ContextTag, Drawable Drawable, ReadDrawable Drawable, Context Context) MakeContextCurrentCookie { cookie := c.NewCookie(true, true) c.NewRequest(makeContextCurrentRequest(c, OldContextTag, Drawable, ReadDrawable, Context), cookie) return MakeContextCurrentCookie{cookie} } +// MakeContextCurrentUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func MakeContextCurrentUnchecked(c *xgb.Conn, OldContextTag ContextTag, Drawable Drawable, ReadDrawable Drawable, Context Context) MakeContextCurrentCookie { cookie := c.NewCookie(false, true) c.NewRequest(makeContextCurrentRequest(c, OldContextTag, Drawable, ReadDrawable, Context), cookie) return MakeContextCurrentCookie{cookie} } -// Request reply for MakeContextCurrent -// size: 32 +// MakeContextCurrentReply represents the data returned from a MakeContextCurrent request. type MakeContextCurrentReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes ContextTag ContextTag // padding: 20 bytes } -// Waits and reads reply data from request MakeContextCurrent +// Reply blocks and returns the reply data for a MakeContextCurrent request. func (cook MakeContextCurrentCookie) Reply() (*MakeContextCurrentReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -2560,7 +2667,7 @@ func (cook MakeContextCurrentCookie) Reply() (*MakeContextCurrentReply, error) { return makeContextCurrentReply(buf), nil } -// Read reply into structure from buffer for MakeContextCurrent +// makeContextCurrentReply reads a byte slice into a MakeContextCurrentReply value. func makeContextCurrentReply(buf []byte) *MakeContextCurrentReply { v := new(MakeContextCurrentReply) b := 1 // skip reply determinant @@ -2582,6 +2689,7 @@ func makeContextCurrentReply(buf []byte) *MakeContextCurrentReply { } // Write request to wire for MakeContextCurrent +// makeContextCurrentRequest writes a MakeContextCurrent request to a byte slice. func makeContextCurrentRequest(c *xgb.Conn, OldContextTag ContextTag, Drawable Drawable, ReadDrawable Drawable, Context Context) []byte { size := 20 b := 0 @@ -2611,30 +2719,35 @@ func makeContextCurrentRequest(c *xgb.Conn, OldContextTag ContextTag, Drawable D return buf } -// Request CreatePbuffer -// size: xgb.Pad((20 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) +// CreatePbufferCookie is a cookie used only for CreatePbuffer requests. type CreatePbufferCookie struct { *xgb.Cookie } -// Write request to wire for CreatePbuffer +// CreatePbuffer sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreatePbuffer(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Pbuffer Pbuffer, NumAttribs uint32, Attribs []uint32) CreatePbufferCookie { cookie := c.NewCookie(false, false) c.NewRequest(createPbufferRequest(c, Screen, Fbconfig, Pbuffer, NumAttribs, Attribs), cookie) return CreatePbufferCookie{cookie} } +// CreatePbufferChecked sends a checked request. +// If an error occurs, it can be retrieved using CreatePbufferCookie.Check() func CreatePbufferChecked(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Pbuffer Pbuffer, NumAttribs uint32, Attribs []uint32) CreatePbufferCookie { cookie := c.NewCookie(true, false) c.NewRequest(createPbufferRequest(c, Screen, Fbconfig, Pbuffer, NumAttribs, Attribs), cookie) return CreatePbufferCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CreatePbufferCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreatePbuffer +// createPbufferRequest writes a CreatePbuffer request to a byte slice. func createPbufferRequest(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Pbuffer Pbuffer, NumAttribs uint32, Attribs []uint32) []byte { size := xgb.Pad((20 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) b := 0 @@ -2670,30 +2783,35 @@ func createPbufferRequest(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Pbuffer return buf } -// Request DestroyPbuffer -// size: 8 +// DestroyPbufferCookie is a cookie used only for DestroyPbuffer requests. type DestroyPbufferCookie struct { *xgb.Cookie } -// Write request to wire for DestroyPbuffer +// DestroyPbuffer sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func DestroyPbuffer(c *xgb.Conn, Pbuffer Pbuffer) DestroyPbufferCookie { cookie := c.NewCookie(false, false) c.NewRequest(destroyPbufferRequest(c, Pbuffer), cookie) return DestroyPbufferCookie{cookie} } +// DestroyPbufferChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroyPbufferCookie.Check() func DestroyPbufferChecked(c *xgb.Conn, Pbuffer Pbuffer) DestroyPbufferCookie { cookie := c.NewCookie(true, false) c.NewRequest(destroyPbufferRequest(c, Pbuffer), cookie) return DestroyPbufferCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook DestroyPbufferCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for DestroyPbuffer +// destroyPbufferRequest writes a DestroyPbuffer request to a byte slice. func destroyPbufferRequest(c *xgb.Conn, Pbuffer Pbuffer) []byte { size := 8 b := 0 @@ -2714,36 +2832,38 @@ func destroyPbufferRequest(c *xgb.Conn, Pbuffer Pbuffer) []byte { return buf } -// Request GetDrawableAttributes -// size: 8 +// GetDrawableAttributesCookie is a cookie used only for GetDrawableAttributes requests. type GetDrawableAttributesCookie struct { *xgb.Cookie } +// GetDrawableAttributes sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetDrawableAttributesCookie.Reply() func GetDrawableAttributes(c *xgb.Conn, Drawable Drawable) GetDrawableAttributesCookie { cookie := c.NewCookie(true, true) c.NewRequest(getDrawableAttributesRequest(c, Drawable), cookie) return GetDrawableAttributesCookie{cookie} } +// GetDrawableAttributesUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetDrawableAttributesUnchecked(c *xgb.Conn, Drawable Drawable) GetDrawableAttributesCookie { cookie := c.NewCookie(false, true) c.NewRequest(getDrawableAttributesRequest(c, Drawable), cookie) return GetDrawableAttributesCookie{cookie} } -// Request reply for GetDrawableAttributes -// size: (32 + xgb.Pad(((int(NumAttribs) * 2) * 4))) +// GetDrawableAttributesReply represents the data returned from a GetDrawableAttributes request. type GetDrawableAttributesReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes NumAttribs uint32 // padding: 20 bytes Attribs []uint32 // size: xgb.Pad(((int(NumAttribs) * 2) * 4)) } -// Waits and reads reply data from request GetDrawableAttributes +// Reply blocks and returns the reply data for a GetDrawableAttributes request. func (cook GetDrawableAttributesCookie) Reply() (*GetDrawableAttributesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -2755,7 +2875,7 @@ func (cook GetDrawableAttributesCookie) Reply() (*GetDrawableAttributesReply, er return getDrawableAttributesReply(buf), nil } -// Read reply into structure from buffer for GetDrawableAttributes +// getDrawableAttributesReply reads a byte slice into a GetDrawableAttributesReply value. func getDrawableAttributesReply(buf []byte) *GetDrawableAttributesReply { v := new(GetDrawableAttributesReply) b := 1 // skip reply determinant @@ -2784,6 +2904,7 @@ func getDrawableAttributesReply(buf []byte) *GetDrawableAttributesReply { } // Write request to wire for GetDrawableAttributes +// getDrawableAttributesRequest writes a GetDrawableAttributes request to a byte slice. func getDrawableAttributesRequest(c *xgb.Conn, Drawable Drawable) []byte { size := 8 b := 0 @@ -2804,30 +2925,35 @@ func getDrawableAttributesRequest(c *xgb.Conn, Drawable Drawable) []byte { return buf } -// Request ChangeDrawableAttributes -// size: xgb.Pad((12 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) +// ChangeDrawableAttributesCookie is a cookie used only for ChangeDrawableAttributes requests. type ChangeDrawableAttributesCookie struct { *xgb.Cookie } -// Write request to wire for ChangeDrawableAttributes +// ChangeDrawableAttributes sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ChangeDrawableAttributes(c *xgb.Conn, Drawable Drawable, NumAttribs uint32, Attribs []uint32) ChangeDrawableAttributesCookie { cookie := c.NewCookie(false, false) c.NewRequest(changeDrawableAttributesRequest(c, Drawable, NumAttribs, Attribs), cookie) return ChangeDrawableAttributesCookie{cookie} } +// ChangeDrawableAttributesChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeDrawableAttributesCookie.Check() func ChangeDrawableAttributesChecked(c *xgb.Conn, Drawable Drawable, NumAttribs uint32, Attribs []uint32) ChangeDrawableAttributesCookie { cookie := c.NewCookie(true, false) c.NewRequest(changeDrawableAttributesRequest(c, Drawable, NumAttribs, Attribs), cookie) return ChangeDrawableAttributesCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook ChangeDrawableAttributesCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ChangeDrawableAttributes +// changeDrawableAttributesRequest writes a ChangeDrawableAttributes request to a byte slice. func changeDrawableAttributesRequest(c *xgb.Conn, Drawable Drawable, NumAttribs uint32, Attribs []uint32) []byte { size := xgb.Pad((12 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) b := 0 @@ -2857,30 +2983,35 @@ func changeDrawableAttributesRequest(c *xgb.Conn, Drawable Drawable, NumAttribs return buf } -// Request CreateWindow -// size: xgb.Pad((24 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) +// CreateWindowCookie is a cookie used only for CreateWindow requests. type CreateWindowCookie struct { *xgb.Cookie } -// Write request to wire for CreateWindow +// CreateWindow sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreateWindow(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Window xproto.Window, GlxWindow Window, NumAttribs uint32, Attribs []uint32) CreateWindowCookie { cookie := c.NewCookie(false, false) c.NewRequest(createWindowRequest(c, Screen, Fbconfig, Window, GlxWindow, NumAttribs, Attribs), cookie) return CreateWindowCookie{cookie} } +// CreateWindowChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateWindowCookie.Check() func CreateWindowChecked(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Window xproto.Window, GlxWindow Window, NumAttribs uint32, Attribs []uint32) CreateWindowCookie { cookie := c.NewCookie(true, false) c.NewRequest(createWindowRequest(c, Screen, Fbconfig, Window, GlxWindow, NumAttribs, Attribs), cookie) return CreateWindowCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CreateWindowCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreateWindow +// createWindowRequest writes a CreateWindow request to a byte slice. func createWindowRequest(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Window xproto.Window, GlxWindow Window, NumAttribs uint32, Attribs []uint32) []byte { size := xgb.Pad((24 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) b := 0 @@ -2919,30 +3050,35 @@ func createWindowRequest(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Window x return buf } -// Request DeleteWindow -// size: 8 +// DeleteWindowCookie is a cookie used only for DeleteWindow requests. type DeleteWindowCookie struct { *xgb.Cookie } -// Write request to wire for DeleteWindow +// DeleteWindow sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func DeleteWindow(c *xgb.Conn, Glxwindow Window) DeleteWindowCookie { cookie := c.NewCookie(false, false) c.NewRequest(deleteWindowRequest(c, Glxwindow), cookie) return DeleteWindowCookie{cookie} } +// DeleteWindowChecked sends a checked request. +// If an error occurs, it can be retrieved using DeleteWindowCookie.Check() func DeleteWindowChecked(c *xgb.Conn, Glxwindow Window) DeleteWindowCookie { cookie := c.NewCookie(true, false) c.NewRequest(deleteWindowRequest(c, Glxwindow), cookie) return DeleteWindowCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook DeleteWindowCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for DeleteWindow +// deleteWindowRequest writes a DeleteWindow request to a byte slice. func deleteWindowRequest(c *xgb.Conn, Glxwindow Window) []byte { size := 8 b := 0 @@ -2963,30 +3099,35 @@ func deleteWindowRequest(c *xgb.Conn, Glxwindow Window) []byte { return buf } -// Request SetClientInfoARB -// size: xgb.Pad((((24 + xgb.Pad(((int(NumVersions) * 2) * 4))) + xgb.Pad((int(GlStrLen) * 1))) + xgb.Pad((int(GlxStrLen) * 1)))) +// SetClientInfoARBCookie is a cookie used only for SetClientInfoARB requests. type SetClientInfoARBCookie struct { *xgb.Cookie } -// Write request to wire for SetClientInfoARB +// SetClientInfoARB sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetClientInfoARB(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) SetClientInfoARBCookie { cookie := c.NewCookie(false, false) c.NewRequest(setClientInfoARBRequest(c, MajorVersion, MinorVersion, NumVersions, GlStrLen, GlxStrLen, GlVersions, GlExtensionString, GlxExtensionString), cookie) return SetClientInfoARBCookie{cookie} } +// SetClientInfoARBChecked sends a checked request. +// If an error occurs, it can be retrieved using SetClientInfoARBCookie.Check() func SetClientInfoARBChecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) SetClientInfoARBCookie { cookie := c.NewCookie(true, false) c.NewRequest(setClientInfoARBRequest(c, MajorVersion, MinorVersion, NumVersions, GlStrLen, GlxStrLen, GlVersions, GlExtensionString, GlxExtensionString), cookie) return SetClientInfoARBCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetClientInfoARBCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetClientInfoARB +// setClientInfoARBRequest writes a SetClientInfoARB request to a byte slice. func setClientInfoARBRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) []byte { size := xgb.Pad((((24 + xgb.Pad(((int(NumVersions) * 2) * 4))) + xgb.Pad((int(GlStrLen) * 1))) + xgb.Pad((int(GlxStrLen) * 1)))) b := 0 @@ -3031,30 +3172,35 @@ func setClientInfoARBRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint return buf } -// Request CreateContextAttribsARB -// size: xgb.Pad((28 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) +// CreateContextAttribsARBCookie is a cookie used only for CreateContextAttribsARB requests. type CreateContextAttribsARBCookie struct { *xgb.Cookie } -// Write request to wire for CreateContextAttribsARB +// CreateContextAttribsARB sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreateContextAttribsARB(c *xgb.Conn, Context Context, Fbconfig Fbconfig, Screen uint32, ShareList Context, IsDirect bool, NumAttribs uint32, Attribs []uint32) CreateContextAttribsARBCookie { cookie := c.NewCookie(false, false) c.NewRequest(createContextAttribsARBRequest(c, Context, Fbconfig, Screen, ShareList, IsDirect, NumAttribs, Attribs), cookie) return CreateContextAttribsARBCookie{cookie} } +// CreateContextAttribsARBChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateContextAttribsARBCookie.Check() func CreateContextAttribsARBChecked(c *xgb.Conn, Context Context, Fbconfig Fbconfig, Screen uint32, ShareList Context, IsDirect bool, NumAttribs uint32, Attribs []uint32) CreateContextAttribsARBCookie { cookie := c.NewCookie(true, false) c.NewRequest(createContextAttribsARBRequest(c, Context, Fbconfig, Screen, ShareList, IsDirect, NumAttribs, Attribs), cookie) return CreateContextAttribsARBCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CreateContextAttribsARBCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreateContextAttribsARB +// createContextAttribsARBRequest writes a CreateContextAttribsARB request to a byte slice. func createContextAttribsARBRequest(c *xgb.Conn, Context Context, Fbconfig Fbconfig, Screen uint32, ShareList Context, IsDirect bool, NumAttribs uint32, Attribs []uint32) []byte { size := xgb.Pad((28 + xgb.Pad(((int(NumAttribs) * 2) * 4)))) b := 0 @@ -3102,30 +3248,35 @@ func createContextAttribsARBRequest(c *xgb.Conn, Context Context, Fbconfig Fbcon return buf } -// Request SetClientInfo2ARB -// size: xgb.Pad((((24 + xgb.Pad(((int(NumVersions) * 3) * 4))) + xgb.Pad((int(GlStrLen) * 1))) + xgb.Pad((int(GlxStrLen) * 1)))) +// SetClientInfo2ARBCookie is a cookie used only for SetClientInfo2ARB requests. type SetClientInfo2ARBCookie struct { *xgb.Cookie } -// Write request to wire for SetClientInfo2ARB +// SetClientInfo2ARB sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetClientInfo2ARB(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) SetClientInfo2ARBCookie { cookie := c.NewCookie(false, false) c.NewRequest(setClientInfo2ARBRequest(c, MajorVersion, MinorVersion, NumVersions, GlStrLen, GlxStrLen, GlVersions, GlExtensionString, GlxExtensionString), cookie) return SetClientInfo2ARBCookie{cookie} } +// SetClientInfo2ARBChecked sends a checked request. +// If an error occurs, it can be retrieved using SetClientInfo2ARBCookie.Check() func SetClientInfo2ARBChecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) SetClientInfo2ARBCookie { cookie := c.NewCookie(true, false) c.NewRequest(setClientInfo2ARBRequest(c, MajorVersion, MinorVersion, NumVersions, GlStrLen, GlxStrLen, GlVersions, GlExtensionString, GlxExtensionString), cookie) return SetClientInfo2ARBCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetClientInfo2ARBCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetClientInfo2ARB +// setClientInfo2ARBRequest writes a SetClientInfo2ARB request to a byte slice. func setClientInfo2ARBRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) []byte { size := xgb.Pad((((24 + xgb.Pad(((int(NumVersions) * 3) * 4))) + xgb.Pad((int(GlStrLen) * 1))) + xgb.Pad((int(GlxStrLen) * 1)))) b := 0 @@ -3170,30 +3321,35 @@ func setClientInfo2ARBRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uin return buf } -// Request NewList -// size: 16 +// NewListCookie is a cookie used only for NewList requests. type NewListCookie struct { *xgb.Cookie } -// Write request to wire for NewList +// NewList sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func NewList(c *xgb.Conn, ContextTag ContextTag, List uint32, Mode uint32) NewListCookie { cookie := c.NewCookie(false, false) c.NewRequest(newListRequest(c, ContextTag, List, Mode), cookie) return NewListCookie{cookie} } +// NewListChecked sends a checked request. +// If an error occurs, it can be retrieved using NewListCookie.Check() func NewListChecked(c *xgb.Conn, ContextTag ContextTag, List uint32, Mode uint32) NewListCookie { cookie := c.NewCookie(true, false) c.NewRequest(newListRequest(c, ContextTag, List, Mode), cookie) return NewListCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook NewListCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for NewList +// newListRequest writes a NewList request to a byte slice. func newListRequest(c *xgb.Conn, ContextTag ContextTag, List uint32, Mode uint32) []byte { size := 16 b := 0 @@ -3220,30 +3376,35 @@ func newListRequest(c *xgb.Conn, ContextTag ContextTag, List uint32, Mode uint32 return buf } -// Request EndList -// size: 8 +// EndListCookie is a cookie used only for EndList requests. type EndListCookie struct { *xgb.Cookie } -// Write request to wire for EndList +// EndList sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func EndList(c *xgb.Conn, ContextTag ContextTag) EndListCookie { cookie := c.NewCookie(false, false) c.NewRequest(endListRequest(c, ContextTag), cookie) return EndListCookie{cookie} } +// EndListChecked sends a checked request. +// If an error occurs, it can be retrieved using EndListCookie.Check() func EndListChecked(c *xgb.Conn, ContextTag ContextTag) EndListCookie { cookie := c.NewCookie(true, false) c.NewRequest(endListRequest(c, ContextTag), cookie) return EndListCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook EndListCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for EndList +// endListRequest writes a EndList request to a byte slice. func endListRequest(c *xgb.Conn, ContextTag ContextTag) []byte { size := 8 b := 0 @@ -3264,30 +3425,35 @@ func endListRequest(c *xgb.Conn, ContextTag ContextTag) []byte { return buf } -// Request DeleteLists -// size: 16 +// DeleteListsCookie is a cookie used only for DeleteLists requests. type DeleteListsCookie struct { *xgb.Cookie } -// Write request to wire for DeleteLists +// DeleteLists sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func DeleteLists(c *xgb.Conn, ContextTag ContextTag, List uint32, Range int32) DeleteListsCookie { cookie := c.NewCookie(false, false) c.NewRequest(deleteListsRequest(c, ContextTag, List, Range), cookie) return DeleteListsCookie{cookie} } +// DeleteListsChecked sends a checked request. +// If an error occurs, it can be retrieved using DeleteListsCookie.Check() func DeleteListsChecked(c *xgb.Conn, ContextTag ContextTag, List uint32, Range int32) DeleteListsCookie { cookie := c.NewCookie(true, false) c.NewRequest(deleteListsRequest(c, ContextTag, List, Range), cookie) return DeleteListsCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook DeleteListsCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for DeleteLists +// deleteListsRequest writes a DeleteLists request to a byte slice. func deleteListsRequest(c *xgb.Conn, ContextTag ContextTag, List uint32, Range int32) []byte { size := 16 b := 0 @@ -3314,34 +3480,36 @@ func deleteListsRequest(c *xgb.Conn, ContextTag ContextTag, List uint32, Range i return buf } -// Request GenLists -// size: 12 +// GenListsCookie is a cookie used only for GenLists requests. type GenListsCookie struct { *xgb.Cookie } +// GenLists sends a checked request. +// If an error occurs, it will be returned with the reply by calling GenListsCookie.Reply() func GenLists(c *xgb.Conn, ContextTag ContextTag, Range int32) GenListsCookie { cookie := c.NewCookie(true, true) c.NewRequest(genListsRequest(c, ContextTag, Range), cookie) return GenListsCookie{cookie} } +// GenListsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GenListsUnchecked(c *xgb.Conn, ContextTag ContextTag, Range int32) GenListsCookie { cookie := c.NewCookie(false, true) c.NewRequest(genListsRequest(c, ContextTag, Range), cookie) return GenListsCookie{cookie} } -// Request reply for GenLists -// size: 12 +// GenListsReply represents the data returned from a GenLists request. type GenListsReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes RetVal uint32 } -// Waits and reads reply data from request GenLists +// Reply blocks and returns the reply data for a GenLists request. func (cook GenListsCookie) Reply() (*GenListsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -3353,7 +3521,7 @@ func (cook GenListsCookie) Reply() (*GenListsReply, error) { return genListsReply(buf), nil } -// Read reply into structure from buffer for GenLists +// genListsReply reads a byte slice into a GenListsReply value. func genListsReply(buf []byte) *GenListsReply { v := new(GenListsReply) b := 1 // skip reply determinant @@ -3373,6 +3541,7 @@ func genListsReply(buf []byte) *GenListsReply { } // Write request to wire for GenLists +// genListsRequest writes a GenLists request to a byte slice. func genListsRequest(c *xgb.Conn, ContextTag ContextTag, Range int32) []byte { size := 12 b := 0 @@ -3396,30 +3565,35 @@ func genListsRequest(c *xgb.Conn, ContextTag ContextTag, Range int32) []byte { return buf } -// Request FeedbackBuffer -// size: 16 +// FeedbackBufferCookie is a cookie used only for FeedbackBuffer requests. type FeedbackBufferCookie struct { *xgb.Cookie } -// Write request to wire for FeedbackBuffer +// FeedbackBuffer sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func FeedbackBuffer(c *xgb.Conn, ContextTag ContextTag, Size int32, Type int32) FeedbackBufferCookie { cookie := c.NewCookie(false, false) c.NewRequest(feedbackBufferRequest(c, ContextTag, Size, Type), cookie) return FeedbackBufferCookie{cookie} } +// FeedbackBufferChecked sends a checked request. +// If an error occurs, it can be retrieved using FeedbackBufferCookie.Check() func FeedbackBufferChecked(c *xgb.Conn, ContextTag ContextTag, Size int32, Type int32) FeedbackBufferCookie { cookie := c.NewCookie(true, false) c.NewRequest(feedbackBufferRequest(c, ContextTag, Size, Type), cookie) return FeedbackBufferCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook FeedbackBufferCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for FeedbackBuffer +// feedbackBufferRequest writes a FeedbackBuffer request to a byte slice. func feedbackBufferRequest(c *xgb.Conn, ContextTag ContextTag, Size int32, Type int32) []byte { size := 16 b := 0 @@ -3446,30 +3620,35 @@ func feedbackBufferRequest(c *xgb.Conn, ContextTag ContextTag, Size int32, Type return buf } -// Request SelectBuffer -// size: 12 +// SelectBufferCookie is a cookie used only for SelectBuffer requests. type SelectBufferCookie struct { *xgb.Cookie } -// Write request to wire for SelectBuffer +// SelectBuffer sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SelectBuffer(c *xgb.Conn, ContextTag ContextTag, Size int32) SelectBufferCookie { cookie := c.NewCookie(false, false) c.NewRequest(selectBufferRequest(c, ContextTag, Size), cookie) return SelectBufferCookie{cookie} } +// SelectBufferChecked sends a checked request. +// If an error occurs, it can be retrieved using SelectBufferCookie.Check() func SelectBufferChecked(c *xgb.Conn, ContextTag ContextTag, Size int32) SelectBufferCookie { cookie := c.NewCookie(true, false) c.NewRequest(selectBufferRequest(c, ContextTag, Size), cookie) return SelectBufferCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SelectBufferCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SelectBuffer +// selectBufferRequest writes a SelectBuffer request to a byte slice. func selectBufferRequest(c *xgb.Conn, ContextTag ContextTag, Size int32) []byte { size := 12 b := 0 @@ -3493,29 +3672,31 @@ func selectBufferRequest(c *xgb.Conn, ContextTag ContextTag, Size int32) []byte return buf } -// Request RenderMode -// size: 12 +// RenderModeCookie is a cookie used only for RenderMode requests. type RenderModeCookie struct { *xgb.Cookie } +// RenderMode sends a checked request. +// If an error occurs, it will be returned with the reply by calling RenderModeCookie.Reply() func RenderMode(c *xgb.Conn, ContextTag ContextTag, Mode uint32) RenderModeCookie { cookie := c.NewCookie(true, true) c.NewRequest(renderModeRequest(c, ContextTag, Mode), cookie) return RenderModeCookie{cookie} } +// RenderModeUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func RenderModeUnchecked(c *xgb.Conn, ContextTag ContextTag, Mode uint32) RenderModeCookie { cookie := c.NewCookie(false, true) c.NewRequest(renderModeRequest(c, ContextTag, Mode), cookie) return RenderModeCookie{cookie} } -// Request reply for RenderMode -// size: (32 + xgb.Pad((int(N) * 4))) +// RenderModeReply represents the data returned from a RenderMode request. type RenderModeReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes RetVal uint32 N uint32 @@ -3524,7 +3705,7 @@ type RenderModeReply struct { Data []uint32 // size: xgb.Pad((int(N) * 4)) } -// Waits and reads reply data from request RenderMode +// Reply blocks and returns the reply data for a RenderMode request. func (cook RenderModeCookie) Reply() (*RenderModeReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -3536,7 +3717,7 @@ func (cook RenderModeCookie) Reply() (*RenderModeReply, error) { return renderModeReply(buf), nil } -// Read reply into structure from buffer for RenderMode +// renderModeReply reads a byte slice into a RenderModeReply value. func renderModeReply(buf []byte) *RenderModeReply { v := new(RenderModeReply) b := 1 // skip reply determinant @@ -3571,6 +3752,7 @@ func renderModeReply(buf []byte) *RenderModeReply { } // Write request to wire for RenderMode +// renderModeRequest writes a RenderMode request to a byte slice. func renderModeRequest(c *xgb.Conn, ContextTag ContextTag, Mode uint32) []byte { size := 12 b := 0 @@ -3594,33 +3776,35 @@ func renderModeRequest(c *xgb.Conn, ContextTag ContextTag, Mode uint32) []byte { return buf } -// Request Finish -// size: 8 +// FinishCookie is a cookie used only for Finish requests. type FinishCookie struct { *xgb.Cookie } +// Finish sends a checked request. +// If an error occurs, it will be returned with the reply by calling FinishCookie.Reply() func Finish(c *xgb.Conn, ContextTag ContextTag) FinishCookie { cookie := c.NewCookie(true, true) c.NewRequest(finishRequest(c, ContextTag), cookie) return FinishCookie{cookie} } +// FinishUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func FinishUnchecked(c *xgb.Conn, ContextTag ContextTag) FinishCookie { cookie := c.NewCookie(false, true) c.NewRequest(finishRequest(c, ContextTag), cookie) return FinishCookie{cookie} } -// Request reply for Finish -// size: 8 +// FinishReply represents the data returned from a Finish request. type FinishReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes } -// Waits and reads reply data from request Finish +// Reply blocks and returns the reply data for a Finish request. func (cook FinishCookie) Reply() (*FinishReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -3632,7 +3816,7 @@ func (cook FinishCookie) Reply() (*FinishReply, error) { return finishReply(buf), nil } -// Read reply into structure from buffer for Finish +// finishReply reads a byte slice into a FinishReply value. func finishReply(buf []byte) *FinishReply { v := new(FinishReply) b := 1 // skip reply determinant @@ -3649,6 +3833,7 @@ func finishReply(buf []byte) *FinishReply { } // Write request to wire for Finish +// finishRequest writes a Finish request to a byte slice. func finishRequest(c *xgb.Conn, ContextTag ContextTag) []byte { size := 8 b := 0 @@ -3669,30 +3854,35 @@ func finishRequest(c *xgb.Conn, ContextTag ContextTag) []byte { return buf } -// Request PixelStoref -// size: 16 +// PixelStorefCookie is a cookie used only for PixelStoref requests. type PixelStorefCookie struct { *xgb.Cookie } -// Write request to wire for PixelStoref +// PixelStoref sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PixelStoref(c *xgb.Conn, ContextTag ContextTag, Pname uint32, Datum Float32) PixelStorefCookie { cookie := c.NewCookie(false, false) c.NewRequest(pixelStorefRequest(c, ContextTag, Pname, Datum), cookie) return PixelStorefCookie{cookie} } +// PixelStorefChecked sends a checked request. +// If an error occurs, it can be retrieved using PixelStorefCookie.Check() func PixelStorefChecked(c *xgb.Conn, ContextTag ContextTag, Pname uint32, Datum Float32) PixelStorefCookie { cookie := c.NewCookie(true, false) c.NewRequest(pixelStorefRequest(c, ContextTag, Pname, Datum), cookie) return PixelStorefCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook PixelStorefCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for PixelStoref +// pixelStorefRequest writes a PixelStoref request to a byte slice. func pixelStorefRequest(c *xgb.Conn, ContextTag ContextTag, Pname uint32, Datum Float32) []byte { size := 16 b := 0 @@ -3719,30 +3909,35 @@ func pixelStorefRequest(c *xgb.Conn, ContextTag ContextTag, Pname uint32, Datum return buf } -// Request PixelStorei -// size: 16 +// PixelStoreiCookie is a cookie used only for PixelStorei requests. type PixelStoreiCookie struct { *xgb.Cookie } -// Write request to wire for PixelStorei +// PixelStorei sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PixelStorei(c *xgb.Conn, ContextTag ContextTag, Pname uint32, Datum int32) PixelStoreiCookie { cookie := c.NewCookie(false, false) c.NewRequest(pixelStoreiRequest(c, ContextTag, Pname, Datum), cookie) return PixelStoreiCookie{cookie} } +// PixelStoreiChecked sends a checked request. +// If an error occurs, it can be retrieved using PixelStoreiCookie.Check() func PixelStoreiChecked(c *xgb.Conn, ContextTag ContextTag, Pname uint32, Datum int32) PixelStoreiCookie { cookie := c.NewCookie(true, false) c.NewRequest(pixelStoreiRequest(c, ContextTag, Pname, Datum), cookie) return PixelStoreiCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook PixelStoreiCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for PixelStorei +// pixelStoreiRequest writes a PixelStorei request to a byte slice. func pixelStoreiRequest(c *xgb.Conn, ContextTag ContextTag, Pname uint32, Datum int32) []byte { size := 16 b := 0 @@ -3769,35 +3964,37 @@ func pixelStoreiRequest(c *xgb.Conn, ContextTag ContextTag, Pname uint32, Datum return buf } -// Request ReadPixels -// size: 36 +// ReadPixelsCookie is a cookie used only for ReadPixels requests. type ReadPixelsCookie struct { *xgb.Cookie } +// ReadPixels sends a checked request. +// If an error occurs, it will be returned with the reply by calling ReadPixelsCookie.Reply() func ReadPixels(c *xgb.Conn, ContextTag ContextTag, X int32, Y int32, Width int32, Height int32, Format uint32, Type uint32, SwapBytes bool, LsbFirst bool) ReadPixelsCookie { cookie := c.NewCookie(true, true) c.NewRequest(readPixelsRequest(c, ContextTag, X, Y, Width, Height, Format, Type, SwapBytes, LsbFirst), cookie) return ReadPixelsCookie{cookie} } +// ReadPixelsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ReadPixelsUnchecked(c *xgb.Conn, ContextTag ContextTag, X int32, Y int32, Width int32, Height int32, Format uint32, Type uint32, SwapBytes bool, LsbFirst bool) ReadPixelsCookie { cookie := c.NewCookie(false, true) c.NewRequest(readPixelsRequest(c, ContextTag, X, Y, Width, Height, Format, Type, SwapBytes, LsbFirst), cookie) return ReadPixelsCookie{cookie} } -// Request reply for ReadPixels -// size: (32 + xgb.Pad(((int(Length) * 4) * 1))) +// ReadPixelsReply represents the data returned from a ReadPixels request. type ReadPixelsReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 24 bytes Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) } -// Waits and reads reply data from request ReadPixels +// Reply blocks and returns the reply data for a ReadPixels request. func (cook ReadPixelsCookie) Reply() (*ReadPixelsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -3809,7 +4006,7 @@ func (cook ReadPixelsCookie) Reply() (*ReadPixelsReply, error) { return readPixelsReply(buf), nil } -// Read reply into structure from buffer for ReadPixels +// readPixelsReply reads a byte slice into a ReadPixelsReply value. func readPixelsReply(buf []byte) *ReadPixelsReply { v := new(ReadPixelsReply) b := 1 // skip reply determinant @@ -3832,6 +4029,7 @@ func readPixelsReply(buf []byte) *ReadPixelsReply { } // Write request to wire for ReadPixels +// readPixelsRequest writes a ReadPixels request to a byte slice. func readPixelsRequest(c *xgb.Conn, ContextTag ContextTag, X int32, Y int32, Width int32, Height int32, Format uint32, Type uint32, SwapBytes bool, LsbFirst bool) []byte { size := 36 b := 0 @@ -3884,29 +4082,31 @@ func readPixelsRequest(c *xgb.Conn, ContextTag ContextTag, X int32, Y int32, Wid return buf } -// Request GetBooleanv -// size: 12 +// GetBooleanvCookie is a cookie used only for GetBooleanv requests. type GetBooleanvCookie struct { *xgb.Cookie } +// GetBooleanv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetBooleanvCookie.Reply() func GetBooleanv(c *xgb.Conn, ContextTag ContextTag, Pname int32) GetBooleanvCookie { cookie := c.NewCookie(true, true) c.NewRequest(getBooleanvRequest(c, ContextTag, Pname), cookie) return GetBooleanvCookie{cookie} } +// GetBooleanvUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetBooleanvUnchecked(c *xgb.Conn, ContextTag ContextTag, Pname int32) GetBooleanvCookie { cookie := c.NewCookie(false, true) c.NewRequest(getBooleanvRequest(c, ContextTag, Pname), cookie) return GetBooleanvCookie{cookie} } -// Request reply for GetBooleanv -// size: (32 + xgb.Pad((int(N) * 1))) +// GetBooleanvReply represents the data returned from a GetBooleanv request. type GetBooleanvReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 4 bytes N uint32 @@ -3915,7 +4115,7 @@ type GetBooleanvReply struct { Data []bool // size: xgb.Pad((int(N) * 1)) } -// Waits and reads reply data from request GetBooleanv +// Reply blocks and returns the reply data for a GetBooleanv request. func (cook GetBooleanvCookie) Reply() (*GetBooleanvReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -3927,7 +4127,7 @@ func (cook GetBooleanvCookie) Reply() (*GetBooleanvReply, error) { return getBooleanvReply(buf), nil } -// Read reply into structure from buffer for GetBooleanv +// getBooleanvReply reads a byte slice into a GetBooleanvReply value. func getBooleanvReply(buf []byte) *GetBooleanvReply { v := new(GetBooleanvReply) b := 1 // skip reply determinant @@ -3969,6 +4169,7 @@ func getBooleanvReply(buf []byte) *GetBooleanvReply { } // Write request to wire for GetBooleanv +// getBooleanvRequest writes a GetBooleanv request to a byte slice. func getBooleanvRequest(c *xgb.Conn, ContextTag ContextTag, Pname int32) []byte { size := 12 b := 0 @@ -3992,35 +4193,37 @@ func getBooleanvRequest(c *xgb.Conn, ContextTag ContextTag, Pname int32) []byte return buf } -// Request GetClipPlane -// size: 12 +// GetClipPlaneCookie is a cookie used only for GetClipPlane requests. type GetClipPlaneCookie struct { *xgb.Cookie } +// GetClipPlane sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetClipPlaneCookie.Reply() func GetClipPlane(c *xgb.Conn, ContextTag ContextTag, Plane int32) GetClipPlaneCookie { cookie := c.NewCookie(true, true) c.NewRequest(getClipPlaneRequest(c, ContextTag, Plane), cookie) return GetClipPlaneCookie{cookie} } +// GetClipPlaneUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetClipPlaneUnchecked(c *xgb.Conn, ContextTag ContextTag, Plane int32) GetClipPlaneCookie { cookie := c.NewCookie(false, true) c.NewRequest(getClipPlaneRequest(c, ContextTag, Plane), cookie) return GetClipPlaneCookie{cookie} } -// Request reply for GetClipPlane -// size: (32 + xgb.Pad(((int(Length) / 2) * 8))) +// GetClipPlaneReply represents the data returned from a GetClipPlane request. type GetClipPlaneReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 24 bytes Data []Float64 // size: xgb.Pad(((int(Length) / 2) * 8)) } -// Waits and reads reply data from request GetClipPlane +// Reply blocks and returns the reply data for a GetClipPlane request. func (cook GetClipPlaneCookie) Reply() (*GetClipPlaneReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -4032,7 +4235,7 @@ func (cook GetClipPlaneCookie) Reply() (*GetClipPlaneReply, error) { return getClipPlaneReply(buf), nil } -// Read reply into structure from buffer for GetClipPlane +// getClipPlaneReply reads a byte slice into a GetClipPlaneReply value. func getClipPlaneReply(buf []byte) *GetClipPlaneReply { v := new(GetClipPlaneReply) b := 1 // skip reply determinant @@ -4058,6 +4261,7 @@ func getClipPlaneReply(buf []byte) *GetClipPlaneReply { } // Write request to wire for GetClipPlane +// getClipPlaneRequest writes a GetClipPlane request to a byte slice. func getClipPlaneRequest(c *xgb.Conn, ContextTag ContextTag, Plane int32) []byte { size := 12 b := 0 @@ -4081,29 +4285,31 @@ func getClipPlaneRequest(c *xgb.Conn, ContextTag ContextTag, Plane int32) []byte return buf } -// Request GetDoublev -// size: 12 +// GetDoublevCookie is a cookie used only for GetDoublev requests. type GetDoublevCookie struct { *xgb.Cookie } +// GetDoublev sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetDoublevCookie.Reply() func GetDoublev(c *xgb.Conn, ContextTag ContextTag, Pname uint32) GetDoublevCookie { cookie := c.NewCookie(true, true) c.NewRequest(getDoublevRequest(c, ContextTag, Pname), cookie) return GetDoublevCookie{cookie} } +// GetDoublevUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetDoublevUnchecked(c *xgb.Conn, ContextTag ContextTag, Pname uint32) GetDoublevCookie { cookie := c.NewCookie(false, true) c.NewRequest(getDoublevRequest(c, ContextTag, Pname), cookie) return GetDoublevCookie{cookie} } -// Request reply for GetDoublev -// size: (32 + xgb.Pad((int(N) * 8))) +// GetDoublevReply represents the data returned from a GetDoublev request. type GetDoublevReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 4 bytes N uint32 @@ -4112,7 +4318,7 @@ type GetDoublevReply struct { Data []Float64 // size: xgb.Pad((int(N) * 8)) } -// Waits and reads reply data from request GetDoublev +// Reply blocks and returns the reply data for a GetDoublev request. func (cook GetDoublevCookie) Reply() (*GetDoublevReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -4124,7 +4330,7 @@ func (cook GetDoublevCookie) Reply() (*GetDoublevReply, error) { return getDoublevReply(buf), nil } -// Read reply into structure from buffer for GetDoublev +// getDoublevReply reads a byte slice into a GetDoublevReply value. func getDoublevReply(buf []byte) *GetDoublevReply { v := new(GetDoublevReply) b := 1 // skip reply determinant @@ -4158,6 +4364,7 @@ func getDoublevReply(buf []byte) *GetDoublevReply { } // Write request to wire for GetDoublev +// getDoublevRequest writes a GetDoublev request to a byte slice. func getDoublevRequest(c *xgb.Conn, ContextTag ContextTag, Pname uint32) []byte { size := 12 b := 0 @@ -4181,34 +4388,36 @@ func getDoublevRequest(c *xgb.Conn, ContextTag ContextTag, Pname uint32) []byte return buf } -// Request GetError -// size: 8 +// GetErrorCookie is a cookie used only for GetError requests. type GetErrorCookie struct { *xgb.Cookie } +// GetError sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetErrorCookie.Reply() func GetError(c *xgb.Conn, ContextTag ContextTag) GetErrorCookie { cookie := c.NewCookie(true, true) c.NewRequest(getErrorRequest(c, ContextTag), cookie) return GetErrorCookie{cookie} } +// GetErrorUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetErrorUnchecked(c *xgb.Conn, ContextTag ContextTag) GetErrorCookie { cookie := c.NewCookie(false, true) c.NewRequest(getErrorRequest(c, ContextTag), cookie) return GetErrorCookie{cookie} } -// Request reply for GetError -// size: 12 +// GetErrorReply represents the data returned from a GetError request. type GetErrorReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Error int32 } -// Waits and reads reply data from request GetError +// Reply blocks and returns the reply data for a GetError request. func (cook GetErrorCookie) Reply() (*GetErrorReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -4220,7 +4429,7 @@ func (cook GetErrorCookie) Reply() (*GetErrorReply, error) { return getErrorReply(buf), nil } -// Read reply into structure from buffer for GetError +// getErrorReply reads a byte slice into a GetErrorReply value. func getErrorReply(buf []byte) *GetErrorReply { v := new(GetErrorReply) b := 1 // skip reply determinant @@ -4240,6 +4449,7 @@ func getErrorReply(buf []byte) *GetErrorReply { } // Write request to wire for GetError +// getErrorRequest writes a GetError request to a byte slice. func getErrorRequest(c *xgb.Conn, ContextTag ContextTag) []byte { size := 8 b := 0 @@ -4260,29 +4470,31 @@ func getErrorRequest(c *xgb.Conn, ContextTag ContextTag) []byte { return buf } -// Request GetFloatv -// size: 12 +// GetFloatvCookie is a cookie used only for GetFloatv requests. type GetFloatvCookie struct { *xgb.Cookie } +// GetFloatv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetFloatvCookie.Reply() func GetFloatv(c *xgb.Conn, ContextTag ContextTag, Pname uint32) GetFloatvCookie { cookie := c.NewCookie(true, true) c.NewRequest(getFloatvRequest(c, ContextTag, Pname), cookie) return GetFloatvCookie{cookie} } +// GetFloatvUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetFloatvUnchecked(c *xgb.Conn, ContextTag ContextTag, Pname uint32) GetFloatvCookie { cookie := c.NewCookie(false, true) c.NewRequest(getFloatvRequest(c, ContextTag, Pname), cookie) return GetFloatvCookie{cookie} } -// Request reply for GetFloatv -// size: (32 + xgb.Pad((int(N) * 4))) +// GetFloatvReply represents the data returned from a GetFloatv request. type GetFloatvReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 4 bytes N uint32 @@ -4291,7 +4503,7 @@ type GetFloatvReply struct { Data []Float32 // size: xgb.Pad((int(N) * 4)) } -// Waits and reads reply data from request GetFloatv +// Reply blocks and returns the reply data for a GetFloatv request. func (cook GetFloatvCookie) Reply() (*GetFloatvReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -4303,7 +4515,7 @@ func (cook GetFloatvCookie) Reply() (*GetFloatvReply, error) { return getFloatvReply(buf), nil } -// Read reply into structure from buffer for GetFloatv +// getFloatvReply reads a byte slice into a GetFloatvReply value. func getFloatvReply(buf []byte) *GetFloatvReply { v := new(GetFloatvReply) b := 1 // skip reply determinant @@ -4337,6 +4549,7 @@ func getFloatvReply(buf []byte) *GetFloatvReply { } // Write request to wire for GetFloatv +// getFloatvRequest writes a GetFloatv request to a byte slice. func getFloatvRequest(c *xgb.Conn, ContextTag ContextTag, Pname uint32) []byte { size := 12 b := 0 @@ -4360,29 +4573,31 @@ func getFloatvRequest(c *xgb.Conn, ContextTag ContextTag, Pname uint32) []byte { return buf } -// Request GetIntegerv -// size: 12 +// GetIntegervCookie is a cookie used only for GetIntegerv requests. type GetIntegervCookie struct { *xgb.Cookie } +// GetIntegerv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetIntegervCookie.Reply() func GetIntegerv(c *xgb.Conn, ContextTag ContextTag, Pname uint32) GetIntegervCookie { cookie := c.NewCookie(true, true) c.NewRequest(getIntegervRequest(c, ContextTag, Pname), cookie) return GetIntegervCookie{cookie} } +// GetIntegervUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetIntegervUnchecked(c *xgb.Conn, ContextTag ContextTag, Pname uint32) GetIntegervCookie { cookie := c.NewCookie(false, true) c.NewRequest(getIntegervRequest(c, ContextTag, Pname), cookie) return GetIntegervCookie{cookie} } -// Request reply for GetIntegerv -// size: (32 + xgb.Pad((int(N) * 4))) +// GetIntegervReply represents the data returned from a GetIntegerv request. type GetIntegervReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 4 bytes N uint32 @@ -4391,7 +4606,7 @@ type GetIntegervReply struct { Data []int32 // size: xgb.Pad((int(N) * 4)) } -// Waits and reads reply data from request GetIntegerv +// Reply blocks and returns the reply data for a GetIntegerv request. func (cook GetIntegervCookie) Reply() (*GetIntegervReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -4403,7 +4618,7 @@ func (cook GetIntegervCookie) Reply() (*GetIntegervReply, error) { return getIntegervReply(buf), nil } -// Read reply into structure from buffer for GetIntegerv +// getIntegervReply reads a byte slice into a GetIntegervReply value. func getIntegervReply(buf []byte) *GetIntegervReply { v := new(GetIntegervReply) b := 1 // skip reply determinant @@ -4437,6 +4652,7 @@ func getIntegervReply(buf []byte) *GetIntegervReply { } // Write request to wire for GetIntegerv +// getIntegervRequest writes a GetIntegerv request to a byte slice. func getIntegervRequest(c *xgb.Conn, ContextTag ContextTag, Pname uint32) []byte { size := 12 b := 0 @@ -4460,29 +4676,31 @@ func getIntegervRequest(c *xgb.Conn, ContextTag ContextTag, Pname uint32) []byte return buf } -// Request GetLightfv -// size: 16 +// GetLightfvCookie is a cookie used only for GetLightfv requests. type GetLightfvCookie struct { *xgb.Cookie } +// GetLightfv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetLightfvCookie.Reply() func GetLightfv(c *xgb.Conn, ContextTag ContextTag, Light uint32, Pname uint32) GetLightfvCookie { cookie := c.NewCookie(true, true) c.NewRequest(getLightfvRequest(c, ContextTag, Light, Pname), cookie) return GetLightfvCookie{cookie} } +// GetLightfvUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetLightfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Light uint32, Pname uint32) GetLightfvCookie { cookie := c.NewCookie(false, true) c.NewRequest(getLightfvRequest(c, ContextTag, Light, Pname), cookie) return GetLightfvCookie{cookie} } -// Request reply for GetLightfv -// size: (32 + xgb.Pad((int(N) * 4))) +// GetLightfvReply represents the data returned from a GetLightfv request. type GetLightfvReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 4 bytes N uint32 @@ -4491,7 +4709,7 @@ type GetLightfvReply struct { Data []Float32 // size: xgb.Pad((int(N) * 4)) } -// Waits and reads reply data from request GetLightfv +// Reply blocks and returns the reply data for a GetLightfv request. func (cook GetLightfvCookie) Reply() (*GetLightfvReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -4503,7 +4721,7 @@ func (cook GetLightfvCookie) Reply() (*GetLightfvReply, error) { return getLightfvReply(buf), nil } -// Read reply into structure from buffer for GetLightfv +// getLightfvReply reads a byte slice into a GetLightfvReply value. func getLightfvReply(buf []byte) *GetLightfvReply { v := new(GetLightfvReply) b := 1 // skip reply determinant @@ -4537,6 +4755,7 @@ func getLightfvReply(buf []byte) *GetLightfvReply { } // Write request to wire for GetLightfv +// getLightfvRequest writes a GetLightfv request to a byte slice. func getLightfvRequest(c *xgb.Conn, ContextTag ContextTag, Light uint32, Pname uint32) []byte { size := 16 b := 0 @@ -4563,29 +4782,31 @@ func getLightfvRequest(c *xgb.Conn, ContextTag ContextTag, Light uint32, Pname u return buf } -// Request GetLightiv -// size: 16 +// GetLightivCookie is a cookie used only for GetLightiv requests. type GetLightivCookie struct { *xgb.Cookie } +// GetLightiv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetLightivCookie.Reply() func GetLightiv(c *xgb.Conn, ContextTag ContextTag, Light uint32, Pname uint32) GetLightivCookie { cookie := c.NewCookie(true, true) c.NewRequest(getLightivRequest(c, ContextTag, Light, Pname), cookie) return GetLightivCookie{cookie} } +// GetLightivUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetLightivUnchecked(c *xgb.Conn, ContextTag ContextTag, Light uint32, Pname uint32) GetLightivCookie { cookie := c.NewCookie(false, true) c.NewRequest(getLightivRequest(c, ContextTag, Light, Pname), cookie) return GetLightivCookie{cookie} } -// Request reply for GetLightiv -// size: (32 + xgb.Pad((int(N) * 4))) +// GetLightivReply represents the data returned from a GetLightiv request. type GetLightivReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 4 bytes N uint32 @@ -4594,7 +4815,7 @@ type GetLightivReply struct { Data []int32 // size: xgb.Pad((int(N) * 4)) } -// Waits and reads reply data from request GetLightiv +// Reply blocks and returns the reply data for a GetLightiv request. func (cook GetLightivCookie) Reply() (*GetLightivReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -4606,7 +4827,7 @@ func (cook GetLightivCookie) Reply() (*GetLightivReply, error) { return getLightivReply(buf), nil } -// Read reply into structure from buffer for GetLightiv +// getLightivReply reads a byte slice into a GetLightivReply value. func getLightivReply(buf []byte) *GetLightivReply { v := new(GetLightivReply) b := 1 // skip reply determinant @@ -4640,6 +4861,7 @@ func getLightivReply(buf []byte) *GetLightivReply { } // Write request to wire for GetLightiv +// getLightivRequest writes a GetLightiv request to a byte slice. func getLightivRequest(c *xgb.Conn, ContextTag ContextTag, Light uint32, Pname uint32) []byte { size := 16 b := 0 @@ -4666,29 +4888,31 @@ func getLightivRequest(c *xgb.Conn, ContextTag ContextTag, Light uint32, Pname u return buf } -// Request GetMapdv -// size: 16 +// GetMapdvCookie is a cookie used only for GetMapdv requests. type GetMapdvCookie struct { *xgb.Cookie } +// GetMapdv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetMapdvCookie.Reply() func GetMapdv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) GetMapdvCookie { cookie := c.NewCookie(true, true) c.NewRequest(getMapdvRequest(c, ContextTag, Target, Query), cookie) return GetMapdvCookie{cookie} } +// GetMapdvUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetMapdvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) GetMapdvCookie { cookie := c.NewCookie(false, true) c.NewRequest(getMapdvRequest(c, ContextTag, Target, Query), cookie) return GetMapdvCookie{cookie} } -// Request reply for GetMapdv -// size: (32 + xgb.Pad((int(N) * 8))) +// GetMapdvReply represents the data returned from a GetMapdv request. type GetMapdvReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 4 bytes N uint32 @@ -4697,7 +4921,7 @@ type GetMapdvReply struct { Data []Float64 // size: xgb.Pad((int(N) * 8)) } -// Waits and reads reply data from request GetMapdv +// Reply blocks and returns the reply data for a GetMapdv request. func (cook GetMapdvCookie) Reply() (*GetMapdvReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -4709,7 +4933,7 @@ func (cook GetMapdvCookie) Reply() (*GetMapdvReply, error) { return getMapdvReply(buf), nil } -// Read reply into structure from buffer for GetMapdv +// getMapdvReply reads a byte slice into a GetMapdvReply value. func getMapdvReply(buf []byte) *GetMapdvReply { v := new(GetMapdvReply) b := 1 // skip reply determinant @@ -4743,6 +4967,7 @@ func getMapdvReply(buf []byte) *GetMapdvReply { } // Write request to wire for GetMapdv +// getMapdvRequest writes a GetMapdv request to a byte slice. func getMapdvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) []byte { size := 16 b := 0 @@ -4769,29 +4994,31 @@ func getMapdvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query ui return buf } -// Request GetMapfv -// size: 16 +// GetMapfvCookie is a cookie used only for GetMapfv requests. type GetMapfvCookie struct { *xgb.Cookie } +// GetMapfv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetMapfvCookie.Reply() func GetMapfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) GetMapfvCookie { cookie := c.NewCookie(true, true) c.NewRequest(getMapfvRequest(c, ContextTag, Target, Query), cookie) return GetMapfvCookie{cookie} } +// GetMapfvUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetMapfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) GetMapfvCookie { cookie := c.NewCookie(false, true) c.NewRequest(getMapfvRequest(c, ContextTag, Target, Query), cookie) return GetMapfvCookie{cookie} } -// Request reply for GetMapfv -// size: (32 + xgb.Pad((int(N) * 4))) +// GetMapfvReply represents the data returned from a GetMapfv request. type GetMapfvReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 4 bytes N uint32 @@ -4800,7 +5027,7 @@ type GetMapfvReply struct { Data []Float32 // size: xgb.Pad((int(N) * 4)) } -// Waits and reads reply data from request GetMapfv +// Reply blocks and returns the reply data for a GetMapfv request. func (cook GetMapfvCookie) Reply() (*GetMapfvReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -4812,7 +5039,7 @@ func (cook GetMapfvCookie) Reply() (*GetMapfvReply, error) { return getMapfvReply(buf), nil } -// Read reply into structure from buffer for GetMapfv +// getMapfvReply reads a byte slice into a GetMapfvReply value. func getMapfvReply(buf []byte) *GetMapfvReply { v := new(GetMapfvReply) b := 1 // skip reply determinant @@ -4846,6 +5073,7 @@ func getMapfvReply(buf []byte) *GetMapfvReply { } // Write request to wire for GetMapfv +// getMapfvRequest writes a GetMapfv request to a byte slice. func getMapfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) []byte { size := 16 b := 0 @@ -4872,29 +5100,31 @@ func getMapfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query ui return buf } -// Request GetMapiv -// size: 16 +// GetMapivCookie is a cookie used only for GetMapiv requests. type GetMapivCookie struct { *xgb.Cookie } +// GetMapiv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetMapivCookie.Reply() func GetMapiv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) GetMapivCookie { cookie := c.NewCookie(true, true) c.NewRequest(getMapivRequest(c, ContextTag, Target, Query), cookie) return GetMapivCookie{cookie} } +// GetMapivUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetMapivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) GetMapivCookie { cookie := c.NewCookie(false, true) c.NewRequest(getMapivRequest(c, ContextTag, Target, Query), cookie) return GetMapivCookie{cookie} } -// Request reply for GetMapiv -// size: (32 + xgb.Pad((int(N) * 4))) +// GetMapivReply represents the data returned from a GetMapiv request. type GetMapivReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 4 bytes N uint32 @@ -4903,7 +5133,7 @@ type GetMapivReply struct { Data []int32 // size: xgb.Pad((int(N) * 4)) } -// Waits and reads reply data from request GetMapiv +// Reply blocks and returns the reply data for a GetMapiv request. func (cook GetMapivCookie) Reply() (*GetMapivReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -4915,7 +5145,7 @@ func (cook GetMapivCookie) Reply() (*GetMapivReply, error) { return getMapivReply(buf), nil } -// Read reply into structure from buffer for GetMapiv +// getMapivReply reads a byte slice into a GetMapivReply value. func getMapivReply(buf []byte) *GetMapivReply { v := new(GetMapivReply) b := 1 // skip reply determinant @@ -4949,6 +5179,7 @@ func getMapivReply(buf []byte) *GetMapivReply { } // Write request to wire for GetMapiv +// getMapivRequest writes a GetMapiv request to a byte slice. func getMapivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query uint32) []byte { size := 16 b := 0 @@ -4975,29 +5206,31 @@ func getMapivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Query ui return buf } -// Request GetMaterialfv -// size: 16 +// GetMaterialfvCookie is a cookie used only for GetMaterialfv requests. type GetMaterialfvCookie struct { *xgb.Cookie } +// GetMaterialfv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetMaterialfvCookie.Reply() func GetMaterialfv(c *xgb.Conn, ContextTag ContextTag, Face uint32, Pname uint32) GetMaterialfvCookie { cookie := c.NewCookie(true, true) c.NewRequest(getMaterialfvRequest(c, ContextTag, Face, Pname), cookie) return GetMaterialfvCookie{cookie} } +// GetMaterialfvUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetMaterialfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Face uint32, Pname uint32) GetMaterialfvCookie { cookie := c.NewCookie(false, true) c.NewRequest(getMaterialfvRequest(c, ContextTag, Face, Pname), cookie) return GetMaterialfvCookie{cookie} } -// Request reply for GetMaterialfv -// size: (32 + xgb.Pad((int(N) * 4))) +// GetMaterialfvReply represents the data returned from a GetMaterialfv request. type GetMaterialfvReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 4 bytes N uint32 @@ -5006,7 +5239,7 @@ type GetMaterialfvReply struct { Data []Float32 // size: xgb.Pad((int(N) * 4)) } -// Waits and reads reply data from request GetMaterialfv +// Reply blocks and returns the reply data for a GetMaterialfv request. func (cook GetMaterialfvCookie) Reply() (*GetMaterialfvReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -5018,7 +5251,7 @@ func (cook GetMaterialfvCookie) Reply() (*GetMaterialfvReply, error) { return getMaterialfvReply(buf), nil } -// Read reply into structure from buffer for GetMaterialfv +// getMaterialfvReply reads a byte slice into a GetMaterialfvReply value. func getMaterialfvReply(buf []byte) *GetMaterialfvReply { v := new(GetMaterialfvReply) b := 1 // skip reply determinant @@ -5052,6 +5285,7 @@ func getMaterialfvReply(buf []byte) *GetMaterialfvReply { } // Write request to wire for GetMaterialfv +// getMaterialfvRequest writes a GetMaterialfv request to a byte slice. func getMaterialfvRequest(c *xgb.Conn, ContextTag ContextTag, Face uint32, Pname uint32) []byte { size := 16 b := 0 @@ -5078,29 +5312,31 @@ func getMaterialfvRequest(c *xgb.Conn, ContextTag ContextTag, Face uint32, Pname return buf } -// Request GetMaterialiv -// size: 16 +// GetMaterialivCookie is a cookie used only for GetMaterialiv requests. type GetMaterialivCookie struct { *xgb.Cookie } +// GetMaterialiv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetMaterialivCookie.Reply() func GetMaterialiv(c *xgb.Conn, ContextTag ContextTag, Face uint32, Pname uint32) GetMaterialivCookie { cookie := c.NewCookie(true, true) c.NewRequest(getMaterialivRequest(c, ContextTag, Face, Pname), cookie) return GetMaterialivCookie{cookie} } +// GetMaterialivUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetMaterialivUnchecked(c *xgb.Conn, ContextTag ContextTag, Face uint32, Pname uint32) GetMaterialivCookie { cookie := c.NewCookie(false, true) c.NewRequest(getMaterialivRequest(c, ContextTag, Face, Pname), cookie) return GetMaterialivCookie{cookie} } -// Request reply for GetMaterialiv -// size: (32 + xgb.Pad((int(N) * 4))) +// GetMaterialivReply represents the data returned from a GetMaterialiv request. type GetMaterialivReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 4 bytes N uint32 @@ -5109,7 +5345,7 @@ type GetMaterialivReply struct { Data []int32 // size: xgb.Pad((int(N) * 4)) } -// Waits and reads reply data from request GetMaterialiv +// Reply blocks and returns the reply data for a GetMaterialiv request. func (cook GetMaterialivCookie) Reply() (*GetMaterialivReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -5121,7 +5357,7 @@ func (cook GetMaterialivCookie) Reply() (*GetMaterialivReply, error) { return getMaterialivReply(buf), nil } -// Read reply into structure from buffer for GetMaterialiv +// getMaterialivReply reads a byte slice into a GetMaterialivReply value. func getMaterialivReply(buf []byte) *GetMaterialivReply { v := new(GetMaterialivReply) b := 1 // skip reply determinant @@ -5155,6 +5391,7 @@ func getMaterialivReply(buf []byte) *GetMaterialivReply { } // Write request to wire for GetMaterialiv +// getMaterialivRequest writes a GetMaterialiv request to a byte slice. func getMaterialivRequest(c *xgb.Conn, ContextTag ContextTag, Face uint32, Pname uint32) []byte { size := 16 b := 0 @@ -5181,29 +5418,31 @@ func getMaterialivRequest(c *xgb.Conn, ContextTag ContextTag, Face uint32, Pname return buf } -// Request GetPixelMapfv -// size: 12 +// GetPixelMapfvCookie is a cookie used only for GetPixelMapfv requests. type GetPixelMapfvCookie struct { *xgb.Cookie } +// GetPixelMapfv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPixelMapfvCookie.Reply() func GetPixelMapfv(c *xgb.Conn, ContextTag ContextTag, Map uint32) GetPixelMapfvCookie { cookie := c.NewCookie(true, true) c.NewRequest(getPixelMapfvRequest(c, ContextTag, Map), cookie) return GetPixelMapfvCookie{cookie} } +// GetPixelMapfvUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetPixelMapfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Map uint32) GetPixelMapfvCookie { cookie := c.NewCookie(false, true) c.NewRequest(getPixelMapfvRequest(c, ContextTag, Map), cookie) return GetPixelMapfvCookie{cookie} } -// Request reply for GetPixelMapfv -// size: (32 + xgb.Pad((int(N) * 4))) +// GetPixelMapfvReply represents the data returned from a GetPixelMapfv request. type GetPixelMapfvReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 4 bytes N uint32 @@ -5212,7 +5451,7 @@ type GetPixelMapfvReply struct { Data []Float32 // size: xgb.Pad((int(N) * 4)) } -// Waits and reads reply data from request GetPixelMapfv +// Reply blocks and returns the reply data for a GetPixelMapfv request. func (cook GetPixelMapfvCookie) Reply() (*GetPixelMapfvReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -5224,7 +5463,7 @@ func (cook GetPixelMapfvCookie) Reply() (*GetPixelMapfvReply, error) { return getPixelMapfvReply(buf), nil } -// Read reply into structure from buffer for GetPixelMapfv +// getPixelMapfvReply reads a byte slice into a GetPixelMapfvReply value. func getPixelMapfvReply(buf []byte) *GetPixelMapfvReply { v := new(GetPixelMapfvReply) b := 1 // skip reply determinant @@ -5258,6 +5497,7 @@ func getPixelMapfvReply(buf []byte) *GetPixelMapfvReply { } // Write request to wire for GetPixelMapfv +// getPixelMapfvRequest writes a GetPixelMapfv request to a byte slice. func getPixelMapfvRequest(c *xgb.Conn, ContextTag ContextTag, Map uint32) []byte { size := 12 b := 0 @@ -5281,29 +5521,31 @@ func getPixelMapfvRequest(c *xgb.Conn, ContextTag ContextTag, Map uint32) []byte return buf } -// Request GetPixelMapuiv -// size: 12 +// GetPixelMapuivCookie is a cookie used only for GetPixelMapuiv requests. type GetPixelMapuivCookie struct { *xgb.Cookie } +// GetPixelMapuiv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPixelMapuivCookie.Reply() func GetPixelMapuiv(c *xgb.Conn, ContextTag ContextTag, Map uint32) GetPixelMapuivCookie { cookie := c.NewCookie(true, true) c.NewRequest(getPixelMapuivRequest(c, ContextTag, Map), cookie) return GetPixelMapuivCookie{cookie} } +// GetPixelMapuivUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetPixelMapuivUnchecked(c *xgb.Conn, ContextTag ContextTag, Map uint32) GetPixelMapuivCookie { cookie := c.NewCookie(false, true) c.NewRequest(getPixelMapuivRequest(c, ContextTag, Map), cookie) return GetPixelMapuivCookie{cookie} } -// Request reply for GetPixelMapuiv -// size: (32 + xgb.Pad((int(N) * 4))) +// GetPixelMapuivReply represents the data returned from a GetPixelMapuiv request. type GetPixelMapuivReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 4 bytes N uint32 @@ -5312,7 +5554,7 @@ type GetPixelMapuivReply struct { Data []uint32 // size: xgb.Pad((int(N) * 4)) } -// Waits and reads reply data from request GetPixelMapuiv +// Reply blocks and returns the reply data for a GetPixelMapuiv request. func (cook GetPixelMapuivCookie) Reply() (*GetPixelMapuivReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -5324,7 +5566,7 @@ func (cook GetPixelMapuivCookie) Reply() (*GetPixelMapuivReply, error) { return getPixelMapuivReply(buf), nil } -// Read reply into structure from buffer for GetPixelMapuiv +// getPixelMapuivReply reads a byte slice into a GetPixelMapuivReply value. func getPixelMapuivReply(buf []byte) *GetPixelMapuivReply { v := new(GetPixelMapuivReply) b := 1 // skip reply determinant @@ -5358,6 +5600,7 @@ func getPixelMapuivReply(buf []byte) *GetPixelMapuivReply { } // Write request to wire for GetPixelMapuiv +// getPixelMapuivRequest writes a GetPixelMapuiv request to a byte slice. func getPixelMapuivRequest(c *xgb.Conn, ContextTag ContextTag, Map uint32) []byte { size := 12 b := 0 @@ -5381,29 +5624,31 @@ func getPixelMapuivRequest(c *xgb.Conn, ContextTag ContextTag, Map uint32) []byt return buf } -// Request GetPixelMapusv -// size: 12 +// GetPixelMapusvCookie is a cookie used only for GetPixelMapusv requests. type GetPixelMapusvCookie struct { *xgb.Cookie } +// GetPixelMapusv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPixelMapusvCookie.Reply() func GetPixelMapusv(c *xgb.Conn, ContextTag ContextTag, Map uint32) GetPixelMapusvCookie { cookie := c.NewCookie(true, true) c.NewRequest(getPixelMapusvRequest(c, ContextTag, Map), cookie) return GetPixelMapusvCookie{cookie} } +// GetPixelMapusvUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetPixelMapusvUnchecked(c *xgb.Conn, ContextTag ContextTag, Map uint32) GetPixelMapusvCookie { cookie := c.NewCookie(false, true) c.NewRequest(getPixelMapusvRequest(c, ContextTag, Map), cookie) return GetPixelMapusvCookie{cookie} } -// Request reply for GetPixelMapusv -// size: (34 + xgb.Pad((int(N) * 2))) +// GetPixelMapusvReply represents the data returned from a GetPixelMapusv request. type GetPixelMapusvReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 4 bytes N uint32 @@ -5412,7 +5657,7 @@ type GetPixelMapusvReply struct { Data []uint16 // size: xgb.Pad((int(N) * 2)) } -// Waits and reads reply data from request GetPixelMapusv +// Reply blocks and returns the reply data for a GetPixelMapusv request. func (cook GetPixelMapusvCookie) Reply() (*GetPixelMapusvReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -5424,7 +5669,7 @@ func (cook GetPixelMapusvCookie) Reply() (*GetPixelMapusvReply, error) { return getPixelMapusvReply(buf), nil } -// Read reply into structure from buffer for GetPixelMapusv +// getPixelMapusvReply reads a byte slice into a GetPixelMapusvReply value. func getPixelMapusvReply(buf []byte) *GetPixelMapusvReply { v := new(GetPixelMapusvReply) b := 1 // skip reply determinant @@ -5458,6 +5703,7 @@ func getPixelMapusvReply(buf []byte) *GetPixelMapusvReply { } // Write request to wire for GetPixelMapusv +// getPixelMapusvRequest writes a GetPixelMapusv request to a byte slice. func getPixelMapusvRequest(c *xgb.Conn, ContextTag ContextTag, Map uint32) []byte { size := 12 b := 0 @@ -5481,35 +5727,37 @@ func getPixelMapusvRequest(c *xgb.Conn, ContextTag ContextTag, Map uint32) []byt return buf } -// Request GetPolygonStipple -// size: 12 +// GetPolygonStippleCookie is a cookie used only for GetPolygonStipple requests. type GetPolygonStippleCookie struct { *xgb.Cookie } +// GetPolygonStipple sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPolygonStippleCookie.Reply() func GetPolygonStipple(c *xgb.Conn, ContextTag ContextTag, LsbFirst bool) GetPolygonStippleCookie { cookie := c.NewCookie(true, true) c.NewRequest(getPolygonStippleRequest(c, ContextTag, LsbFirst), cookie) return GetPolygonStippleCookie{cookie} } +// GetPolygonStippleUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetPolygonStippleUnchecked(c *xgb.Conn, ContextTag ContextTag, LsbFirst bool) GetPolygonStippleCookie { cookie := c.NewCookie(false, true) c.NewRequest(getPolygonStippleRequest(c, ContextTag, LsbFirst), cookie) return GetPolygonStippleCookie{cookie} } -// Request reply for GetPolygonStipple -// size: (32 + xgb.Pad(((int(Length) * 4) * 1))) +// GetPolygonStippleReply represents the data returned from a GetPolygonStipple request. type GetPolygonStippleReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 24 bytes Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) } -// Waits and reads reply data from request GetPolygonStipple +// Reply blocks and returns the reply data for a GetPolygonStipple request. func (cook GetPolygonStippleCookie) Reply() (*GetPolygonStippleReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -5521,7 +5769,7 @@ func (cook GetPolygonStippleCookie) Reply() (*GetPolygonStippleReply, error) { return getPolygonStippleReply(buf), nil } -// Read reply into structure from buffer for GetPolygonStipple +// getPolygonStippleReply reads a byte slice into a GetPolygonStippleReply value. func getPolygonStippleReply(buf []byte) *GetPolygonStippleReply { v := new(GetPolygonStippleReply) b := 1 // skip reply determinant @@ -5544,6 +5792,7 @@ func getPolygonStippleReply(buf []byte) *GetPolygonStippleReply { } // Write request to wire for GetPolygonStipple +// getPolygonStippleRequest writes a GetPolygonStipple request to a byte slice. func getPolygonStippleRequest(c *xgb.Conn, ContextTag ContextTag, LsbFirst bool) []byte { size := 12 b := 0 @@ -5571,29 +5820,31 @@ func getPolygonStippleRequest(c *xgb.Conn, ContextTag ContextTag, LsbFirst bool) return buf } -// Request GetString -// size: 12 +// GetStringCookie is a cookie used only for GetString requests. type GetStringCookie struct { *xgb.Cookie } +// GetString sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetStringCookie.Reply() func GetString(c *xgb.Conn, ContextTag ContextTag, Name uint32) GetStringCookie { cookie := c.NewCookie(true, true) c.NewRequest(getStringRequest(c, ContextTag, Name), cookie) return GetStringCookie{cookie} } +// GetStringUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetStringUnchecked(c *xgb.Conn, ContextTag ContextTag, Name uint32) GetStringCookie { cookie := c.NewCookie(false, true) c.NewRequest(getStringRequest(c, ContextTag, Name), cookie) return GetStringCookie{cookie} } -// Request reply for GetString -// size: (32 + xgb.Pad((int(N) * 1))) +// GetStringReply represents the data returned from a GetString request. type GetStringReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 4 bytes N uint32 @@ -5601,7 +5852,7 @@ type GetStringReply struct { String string // size: xgb.Pad((int(N) * 1)) } -// Waits and reads reply data from request GetString +// Reply blocks and returns the reply data for a GetString request. func (cook GetStringCookie) Reply() (*GetStringReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -5613,7 +5864,7 @@ func (cook GetStringCookie) Reply() (*GetStringReply, error) { return getStringReply(buf), nil } -// Read reply into structure from buffer for GetString +// getStringReply reads a byte slice into a GetStringReply value. func getStringReply(buf []byte) *GetStringReply { v := new(GetStringReply) b := 1 // skip reply determinant @@ -5644,6 +5895,7 @@ func getStringReply(buf []byte) *GetStringReply { } // Write request to wire for GetString +// getStringRequest writes a GetString request to a byte slice. func getStringRequest(c *xgb.Conn, ContextTag ContextTag, Name uint32) []byte { size := 12 b := 0 @@ -5667,29 +5919,31 @@ func getStringRequest(c *xgb.Conn, ContextTag ContextTag, Name uint32) []byte { return buf } -// Request GetTexEnvfv -// size: 16 +// GetTexEnvfvCookie is a cookie used only for GetTexEnvfv requests. type GetTexEnvfvCookie struct { *xgb.Cookie } +// GetTexEnvfv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetTexEnvfvCookie.Reply() func GetTexEnvfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetTexEnvfvCookie { cookie := c.NewCookie(true, true) c.NewRequest(getTexEnvfvRequest(c, ContextTag, Target, Pname), cookie) return GetTexEnvfvCookie{cookie} } +// GetTexEnvfvUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetTexEnvfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetTexEnvfvCookie { cookie := c.NewCookie(false, true) c.NewRequest(getTexEnvfvRequest(c, ContextTag, Target, Pname), cookie) return GetTexEnvfvCookie{cookie} } -// Request reply for GetTexEnvfv -// size: (32 + xgb.Pad((int(N) * 4))) +// GetTexEnvfvReply represents the data returned from a GetTexEnvfv request. type GetTexEnvfvReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 4 bytes N uint32 @@ -5698,7 +5952,7 @@ type GetTexEnvfvReply struct { Data []Float32 // size: xgb.Pad((int(N) * 4)) } -// Waits and reads reply data from request GetTexEnvfv +// Reply blocks and returns the reply data for a GetTexEnvfv request. func (cook GetTexEnvfvCookie) Reply() (*GetTexEnvfvReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -5710,7 +5964,7 @@ func (cook GetTexEnvfvCookie) Reply() (*GetTexEnvfvReply, error) { return getTexEnvfvReply(buf), nil } -// Read reply into structure from buffer for GetTexEnvfv +// getTexEnvfvReply reads a byte slice into a GetTexEnvfvReply value. func getTexEnvfvReply(buf []byte) *GetTexEnvfvReply { v := new(GetTexEnvfvReply) b := 1 // skip reply determinant @@ -5744,6 +5998,7 @@ func getTexEnvfvReply(buf []byte) *GetTexEnvfvReply { } // Write request to wire for GetTexEnvfv +// getTexEnvfvRequest writes a GetTexEnvfv request to a byte slice. func getTexEnvfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { size := 16 b := 0 @@ -5770,29 +6025,31 @@ func getTexEnvfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname return buf } -// Request GetTexEnviv -// size: 16 +// GetTexEnvivCookie is a cookie used only for GetTexEnviv requests. type GetTexEnvivCookie struct { *xgb.Cookie } +// GetTexEnviv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetTexEnvivCookie.Reply() func GetTexEnviv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetTexEnvivCookie { cookie := c.NewCookie(true, true) c.NewRequest(getTexEnvivRequest(c, ContextTag, Target, Pname), cookie) return GetTexEnvivCookie{cookie} } +// GetTexEnvivUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetTexEnvivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetTexEnvivCookie { cookie := c.NewCookie(false, true) c.NewRequest(getTexEnvivRequest(c, ContextTag, Target, Pname), cookie) return GetTexEnvivCookie{cookie} } -// Request reply for GetTexEnviv -// size: (32 + xgb.Pad((int(N) * 4))) +// GetTexEnvivReply represents the data returned from a GetTexEnviv request. type GetTexEnvivReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 4 bytes N uint32 @@ -5801,7 +6058,7 @@ type GetTexEnvivReply struct { Data []int32 // size: xgb.Pad((int(N) * 4)) } -// Waits and reads reply data from request GetTexEnviv +// Reply blocks and returns the reply data for a GetTexEnviv request. func (cook GetTexEnvivCookie) Reply() (*GetTexEnvivReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -5813,7 +6070,7 @@ func (cook GetTexEnvivCookie) Reply() (*GetTexEnvivReply, error) { return getTexEnvivReply(buf), nil } -// Read reply into structure from buffer for GetTexEnviv +// getTexEnvivReply reads a byte slice into a GetTexEnvivReply value. func getTexEnvivReply(buf []byte) *GetTexEnvivReply { v := new(GetTexEnvivReply) b := 1 // skip reply determinant @@ -5847,6 +6104,7 @@ func getTexEnvivReply(buf []byte) *GetTexEnvivReply { } // Write request to wire for GetTexEnviv +// getTexEnvivRequest writes a GetTexEnviv request to a byte slice. func getTexEnvivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { size := 16 b := 0 @@ -5873,29 +6131,31 @@ func getTexEnvivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname return buf } -// Request GetTexGendv -// size: 16 +// GetTexGendvCookie is a cookie used only for GetTexGendv requests. type GetTexGendvCookie struct { *xgb.Cookie } +// GetTexGendv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetTexGendvCookie.Reply() func GetTexGendv(c *xgb.Conn, ContextTag ContextTag, Coord uint32, Pname uint32) GetTexGendvCookie { cookie := c.NewCookie(true, true) c.NewRequest(getTexGendvRequest(c, ContextTag, Coord, Pname), cookie) return GetTexGendvCookie{cookie} } +// GetTexGendvUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetTexGendvUnchecked(c *xgb.Conn, ContextTag ContextTag, Coord uint32, Pname uint32) GetTexGendvCookie { cookie := c.NewCookie(false, true) c.NewRequest(getTexGendvRequest(c, ContextTag, Coord, Pname), cookie) return GetTexGendvCookie{cookie} } -// Request reply for GetTexGendv -// size: (32 + xgb.Pad((int(N) * 8))) +// GetTexGendvReply represents the data returned from a GetTexGendv request. type GetTexGendvReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 4 bytes N uint32 @@ -5904,7 +6164,7 @@ type GetTexGendvReply struct { Data []Float64 // size: xgb.Pad((int(N) * 8)) } -// Waits and reads reply data from request GetTexGendv +// Reply blocks and returns the reply data for a GetTexGendv request. func (cook GetTexGendvCookie) Reply() (*GetTexGendvReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -5916,7 +6176,7 @@ func (cook GetTexGendvCookie) Reply() (*GetTexGendvReply, error) { return getTexGendvReply(buf), nil } -// Read reply into structure from buffer for GetTexGendv +// getTexGendvReply reads a byte slice into a GetTexGendvReply value. func getTexGendvReply(buf []byte) *GetTexGendvReply { v := new(GetTexGendvReply) b := 1 // skip reply determinant @@ -5950,6 +6210,7 @@ func getTexGendvReply(buf []byte) *GetTexGendvReply { } // Write request to wire for GetTexGendv +// getTexGendvRequest writes a GetTexGendv request to a byte slice. func getTexGendvRequest(c *xgb.Conn, ContextTag ContextTag, Coord uint32, Pname uint32) []byte { size := 16 b := 0 @@ -5976,29 +6237,31 @@ func getTexGendvRequest(c *xgb.Conn, ContextTag ContextTag, Coord uint32, Pname return buf } -// Request GetTexGenfv -// size: 16 +// GetTexGenfvCookie is a cookie used only for GetTexGenfv requests. type GetTexGenfvCookie struct { *xgb.Cookie } +// GetTexGenfv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetTexGenfvCookie.Reply() func GetTexGenfv(c *xgb.Conn, ContextTag ContextTag, Coord uint32, Pname uint32) GetTexGenfvCookie { cookie := c.NewCookie(true, true) c.NewRequest(getTexGenfvRequest(c, ContextTag, Coord, Pname), cookie) return GetTexGenfvCookie{cookie} } +// GetTexGenfvUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetTexGenfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Coord uint32, Pname uint32) GetTexGenfvCookie { cookie := c.NewCookie(false, true) c.NewRequest(getTexGenfvRequest(c, ContextTag, Coord, Pname), cookie) return GetTexGenfvCookie{cookie} } -// Request reply for GetTexGenfv -// size: (32 + xgb.Pad((int(N) * 4))) +// GetTexGenfvReply represents the data returned from a GetTexGenfv request. type GetTexGenfvReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 4 bytes N uint32 @@ -6007,7 +6270,7 @@ type GetTexGenfvReply struct { Data []Float32 // size: xgb.Pad((int(N) * 4)) } -// Waits and reads reply data from request GetTexGenfv +// Reply blocks and returns the reply data for a GetTexGenfv request. func (cook GetTexGenfvCookie) Reply() (*GetTexGenfvReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -6019,7 +6282,7 @@ func (cook GetTexGenfvCookie) Reply() (*GetTexGenfvReply, error) { return getTexGenfvReply(buf), nil } -// Read reply into structure from buffer for GetTexGenfv +// getTexGenfvReply reads a byte slice into a GetTexGenfvReply value. func getTexGenfvReply(buf []byte) *GetTexGenfvReply { v := new(GetTexGenfvReply) b := 1 // skip reply determinant @@ -6053,6 +6316,7 @@ func getTexGenfvReply(buf []byte) *GetTexGenfvReply { } // Write request to wire for GetTexGenfv +// getTexGenfvRequest writes a GetTexGenfv request to a byte slice. func getTexGenfvRequest(c *xgb.Conn, ContextTag ContextTag, Coord uint32, Pname uint32) []byte { size := 16 b := 0 @@ -6079,29 +6343,31 @@ func getTexGenfvRequest(c *xgb.Conn, ContextTag ContextTag, Coord uint32, Pname return buf } -// Request GetTexGeniv -// size: 16 +// GetTexGenivCookie is a cookie used only for GetTexGeniv requests. type GetTexGenivCookie struct { *xgb.Cookie } +// GetTexGeniv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetTexGenivCookie.Reply() func GetTexGeniv(c *xgb.Conn, ContextTag ContextTag, Coord uint32, Pname uint32) GetTexGenivCookie { cookie := c.NewCookie(true, true) c.NewRequest(getTexGenivRequest(c, ContextTag, Coord, Pname), cookie) return GetTexGenivCookie{cookie} } +// GetTexGenivUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetTexGenivUnchecked(c *xgb.Conn, ContextTag ContextTag, Coord uint32, Pname uint32) GetTexGenivCookie { cookie := c.NewCookie(false, true) c.NewRequest(getTexGenivRequest(c, ContextTag, Coord, Pname), cookie) return GetTexGenivCookie{cookie} } -// Request reply for GetTexGeniv -// size: (32 + xgb.Pad((int(N) * 4))) +// GetTexGenivReply represents the data returned from a GetTexGeniv request. type GetTexGenivReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 4 bytes N uint32 @@ -6110,7 +6376,7 @@ type GetTexGenivReply struct { Data []int32 // size: xgb.Pad((int(N) * 4)) } -// Waits and reads reply data from request GetTexGeniv +// Reply blocks and returns the reply data for a GetTexGeniv request. func (cook GetTexGenivCookie) Reply() (*GetTexGenivReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -6122,7 +6388,7 @@ func (cook GetTexGenivCookie) Reply() (*GetTexGenivReply, error) { return getTexGenivReply(buf), nil } -// Read reply into structure from buffer for GetTexGeniv +// getTexGenivReply reads a byte slice into a GetTexGenivReply value. func getTexGenivReply(buf []byte) *GetTexGenivReply { v := new(GetTexGenivReply) b := 1 // skip reply determinant @@ -6156,6 +6422,7 @@ func getTexGenivReply(buf []byte) *GetTexGenivReply { } // Write request to wire for GetTexGeniv +// getTexGenivRequest writes a GetTexGeniv request to a byte slice. func getTexGenivRequest(c *xgb.Conn, ContextTag ContextTag, Coord uint32, Pname uint32) []byte { size := 16 b := 0 @@ -6182,29 +6449,31 @@ func getTexGenivRequest(c *xgb.Conn, ContextTag ContextTag, Coord uint32, Pname return buf } -// Request GetTexImage -// size: 28 +// GetTexImageCookie is a cookie used only for GetTexImage requests. type GetTexImageCookie struct { *xgb.Cookie } +// GetTexImage sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetTexImageCookie.Reply() func GetTexImage(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Format uint32, Type uint32, SwapBytes bool) GetTexImageCookie { cookie := c.NewCookie(true, true) c.NewRequest(getTexImageRequest(c, ContextTag, Target, Level, Format, Type, SwapBytes), cookie) return GetTexImageCookie{cookie} } +// GetTexImageUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetTexImageUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Format uint32, Type uint32, SwapBytes bool) GetTexImageCookie { cookie := c.NewCookie(false, true) c.NewRequest(getTexImageRequest(c, ContextTag, Target, Level, Format, Type, SwapBytes), cookie) return GetTexImageCookie{cookie} } -// Request reply for GetTexImage -// size: (32 + xgb.Pad(((int(Length) * 4) * 1))) +// GetTexImageReply represents the data returned from a GetTexImage request. type GetTexImageReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 8 bytes Width int32 @@ -6214,7 +6483,7 @@ type GetTexImageReply struct { Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) } -// Waits and reads reply data from request GetTexImage +// Reply blocks and returns the reply data for a GetTexImage request. func (cook GetTexImageCookie) Reply() (*GetTexImageReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -6226,7 +6495,7 @@ func (cook GetTexImageCookie) Reply() (*GetTexImageReply, error) { return getTexImageReply(buf), nil } -// Read reply into structure from buffer for GetTexImage +// getTexImageReply reads a byte slice into a GetTexImageReply value. func getTexImageReply(buf []byte) *GetTexImageReply { v := new(GetTexImageReply) b := 1 // skip reply determinant @@ -6260,6 +6529,7 @@ func getTexImageReply(buf []byte) *GetTexImageReply { } // Write request to wire for GetTexImage +// getTexImageRequest writes a GetTexImage request to a byte slice. func getTexImageRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Format uint32, Type uint32, SwapBytes bool) []byte { size := 28 b := 0 @@ -6299,29 +6569,31 @@ func getTexImageRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level return buf } -// Request GetTexParameterfv -// size: 16 +// GetTexParameterfvCookie is a cookie used only for GetTexParameterfv requests. type GetTexParameterfvCookie struct { *xgb.Cookie } +// GetTexParameterfv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetTexParameterfvCookie.Reply() func GetTexParameterfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetTexParameterfvCookie { cookie := c.NewCookie(true, true) c.NewRequest(getTexParameterfvRequest(c, ContextTag, Target, Pname), cookie) return GetTexParameterfvCookie{cookie} } +// GetTexParameterfvUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetTexParameterfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetTexParameterfvCookie { cookie := c.NewCookie(false, true) c.NewRequest(getTexParameterfvRequest(c, ContextTag, Target, Pname), cookie) return GetTexParameterfvCookie{cookie} } -// Request reply for GetTexParameterfv -// size: (32 + xgb.Pad((int(N) * 4))) +// GetTexParameterfvReply represents the data returned from a GetTexParameterfv request. type GetTexParameterfvReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 4 bytes N uint32 @@ -6330,7 +6602,7 @@ type GetTexParameterfvReply struct { Data []Float32 // size: xgb.Pad((int(N) * 4)) } -// Waits and reads reply data from request GetTexParameterfv +// Reply blocks and returns the reply data for a GetTexParameterfv request. func (cook GetTexParameterfvCookie) Reply() (*GetTexParameterfvReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -6342,7 +6614,7 @@ func (cook GetTexParameterfvCookie) Reply() (*GetTexParameterfvReply, error) { return getTexParameterfvReply(buf), nil } -// Read reply into structure from buffer for GetTexParameterfv +// getTexParameterfvReply reads a byte slice into a GetTexParameterfvReply value. func getTexParameterfvReply(buf []byte) *GetTexParameterfvReply { v := new(GetTexParameterfvReply) b := 1 // skip reply determinant @@ -6376,6 +6648,7 @@ func getTexParameterfvReply(buf []byte) *GetTexParameterfvReply { } // Write request to wire for GetTexParameterfv +// getTexParameterfvRequest writes a GetTexParameterfv request to a byte slice. func getTexParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { size := 16 b := 0 @@ -6402,29 +6675,31 @@ func getTexParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, return buf } -// Request GetTexParameteriv -// size: 16 +// GetTexParameterivCookie is a cookie used only for GetTexParameteriv requests. type GetTexParameterivCookie struct { *xgb.Cookie } +// GetTexParameteriv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetTexParameterivCookie.Reply() func GetTexParameteriv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetTexParameterivCookie { cookie := c.NewCookie(true, true) c.NewRequest(getTexParameterivRequest(c, ContextTag, Target, Pname), cookie) return GetTexParameterivCookie{cookie} } +// GetTexParameterivUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetTexParameterivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetTexParameterivCookie { cookie := c.NewCookie(false, true) c.NewRequest(getTexParameterivRequest(c, ContextTag, Target, Pname), cookie) return GetTexParameterivCookie{cookie} } -// Request reply for GetTexParameteriv -// size: (32 + xgb.Pad((int(N) * 4))) +// GetTexParameterivReply represents the data returned from a GetTexParameteriv request. type GetTexParameterivReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 4 bytes N uint32 @@ -6433,7 +6708,7 @@ type GetTexParameterivReply struct { Data []int32 // size: xgb.Pad((int(N) * 4)) } -// Waits and reads reply data from request GetTexParameteriv +// Reply blocks and returns the reply data for a GetTexParameteriv request. func (cook GetTexParameterivCookie) Reply() (*GetTexParameterivReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -6445,7 +6720,7 @@ func (cook GetTexParameterivCookie) Reply() (*GetTexParameterivReply, error) { return getTexParameterivReply(buf), nil } -// Read reply into structure from buffer for GetTexParameteriv +// getTexParameterivReply reads a byte slice into a GetTexParameterivReply value. func getTexParameterivReply(buf []byte) *GetTexParameterivReply { v := new(GetTexParameterivReply) b := 1 // skip reply determinant @@ -6479,6 +6754,7 @@ func getTexParameterivReply(buf []byte) *GetTexParameterivReply { } // Write request to wire for GetTexParameteriv +// getTexParameterivRequest writes a GetTexParameteriv request to a byte slice. func getTexParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { size := 16 b := 0 @@ -6505,29 +6781,31 @@ func getTexParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, return buf } -// Request GetTexLevelParameterfv -// size: 20 +// GetTexLevelParameterfvCookie is a cookie used only for GetTexLevelParameterfv requests. type GetTexLevelParameterfvCookie struct { *xgb.Cookie } +// GetTexLevelParameterfv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetTexLevelParameterfvCookie.Reply() func GetTexLevelParameterfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Pname uint32) GetTexLevelParameterfvCookie { cookie := c.NewCookie(true, true) c.NewRequest(getTexLevelParameterfvRequest(c, ContextTag, Target, Level, Pname), cookie) return GetTexLevelParameterfvCookie{cookie} } +// GetTexLevelParameterfvUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetTexLevelParameterfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Pname uint32) GetTexLevelParameterfvCookie { cookie := c.NewCookie(false, true) c.NewRequest(getTexLevelParameterfvRequest(c, ContextTag, Target, Level, Pname), cookie) return GetTexLevelParameterfvCookie{cookie} } -// Request reply for GetTexLevelParameterfv -// size: (32 + xgb.Pad((int(N) * 4))) +// GetTexLevelParameterfvReply represents the data returned from a GetTexLevelParameterfv request. type GetTexLevelParameterfvReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 4 bytes N uint32 @@ -6536,7 +6814,7 @@ type GetTexLevelParameterfvReply struct { Data []Float32 // size: xgb.Pad((int(N) * 4)) } -// Waits and reads reply data from request GetTexLevelParameterfv +// Reply blocks and returns the reply data for a GetTexLevelParameterfv request. func (cook GetTexLevelParameterfvCookie) Reply() (*GetTexLevelParameterfvReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -6548,7 +6826,7 @@ func (cook GetTexLevelParameterfvCookie) Reply() (*GetTexLevelParameterfvReply, return getTexLevelParameterfvReply(buf), nil } -// Read reply into structure from buffer for GetTexLevelParameterfv +// getTexLevelParameterfvReply reads a byte slice into a GetTexLevelParameterfvReply value. func getTexLevelParameterfvReply(buf []byte) *GetTexLevelParameterfvReply { v := new(GetTexLevelParameterfvReply) b := 1 // skip reply determinant @@ -6582,6 +6860,7 @@ func getTexLevelParameterfvReply(buf []byte) *GetTexLevelParameterfvReply { } // Write request to wire for GetTexLevelParameterfv +// getTexLevelParameterfvRequest writes a GetTexLevelParameterfv request to a byte slice. func getTexLevelParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Pname uint32) []byte { size := 20 b := 0 @@ -6611,29 +6890,31 @@ func getTexLevelParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target ui return buf } -// Request GetTexLevelParameteriv -// size: 20 +// GetTexLevelParameterivCookie is a cookie used only for GetTexLevelParameteriv requests. type GetTexLevelParameterivCookie struct { *xgb.Cookie } +// GetTexLevelParameteriv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetTexLevelParameterivCookie.Reply() func GetTexLevelParameteriv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Pname uint32) GetTexLevelParameterivCookie { cookie := c.NewCookie(true, true) c.NewRequest(getTexLevelParameterivRequest(c, ContextTag, Target, Level, Pname), cookie) return GetTexLevelParameterivCookie{cookie} } +// GetTexLevelParameterivUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetTexLevelParameterivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Pname uint32) GetTexLevelParameterivCookie { cookie := c.NewCookie(false, true) c.NewRequest(getTexLevelParameterivRequest(c, ContextTag, Target, Level, Pname), cookie) return GetTexLevelParameterivCookie{cookie} } -// Request reply for GetTexLevelParameteriv -// size: (32 + xgb.Pad((int(N) * 4))) +// GetTexLevelParameterivReply represents the data returned from a GetTexLevelParameteriv request. type GetTexLevelParameterivReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 4 bytes N uint32 @@ -6642,7 +6923,7 @@ type GetTexLevelParameterivReply struct { Data []int32 // size: xgb.Pad((int(N) * 4)) } -// Waits and reads reply data from request GetTexLevelParameteriv +// Reply blocks and returns the reply data for a GetTexLevelParameteriv request. func (cook GetTexLevelParameterivCookie) Reply() (*GetTexLevelParameterivReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -6654,7 +6935,7 @@ func (cook GetTexLevelParameterivCookie) Reply() (*GetTexLevelParameterivReply, return getTexLevelParameterivReply(buf), nil } -// Read reply into structure from buffer for GetTexLevelParameteriv +// getTexLevelParameterivReply reads a byte slice into a GetTexLevelParameterivReply value. func getTexLevelParameterivReply(buf []byte) *GetTexLevelParameterivReply { v := new(GetTexLevelParameterivReply) b := 1 // skip reply determinant @@ -6688,6 +6969,7 @@ func getTexLevelParameterivReply(buf []byte) *GetTexLevelParameterivReply { } // Write request to wire for GetTexLevelParameteriv +// getTexLevelParameterivRequest writes a GetTexLevelParameteriv request to a byte slice. func getTexLevelParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32, Pname uint32) []byte { size := 20 b := 0 @@ -6717,34 +6999,36 @@ func getTexLevelParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target ui return buf } -// Request IsList -// size: 12 +// IsListCookie is a cookie used only for IsList requests. type IsListCookie struct { *xgb.Cookie } +// IsList sends a checked request. +// If an error occurs, it will be returned with the reply by calling IsListCookie.Reply() func IsList(c *xgb.Conn, ContextTag ContextTag, List uint32) IsListCookie { cookie := c.NewCookie(true, true) c.NewRequest(isListRequest(c, ContextTag, List), cookie) return IsListCookie{cookie} } +// IsListUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func IsListUnchecked(c *xgb.Conn, ContextTag ContextTag, List uint32) IsListCookie { cookie := c.NewCookie(false, true) c.NewRequest(isListRequest(c, ContextTag, List), cookie) return IsListCookie{cookie} } -// Request reply for IsList -// size: 12 +// IsListReply represents the data returned from a IsList request. type IsListReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes RetVal Bool32 } -// Waits and reads reply data from request IsList +// Reply blocks and returns the reply data for a IsList request. func (cook IsListCookie) Reply() (*IsListReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -6756,7 +7040,7 @@ func (cook IsListCookie) Reply() (*IsListReply, error) { return isListReply(buf), nil } -// Read reply into structure from buffer for IsList +// isListReply reads a byte slice into a IsListReply value. func isListReply(buf []byte) *IsListReply { v := new(IsListReply) b := 1 // skip reply determinant @@ -6776,6 +7060,7 @@ func isListReply(buf []byte) *IsListReply { } // Write request to wire for IsList +// isListRequest writes a IsList request to a byte slice. func isListRequest(c *xgb.Conn, ContextTag ContextTag, List uint32) []byte { size := 12 b := 0 @@ -6799,30 +7084,35 @@ func isListRequest(c *xgb.Conn, ContextTag ContextTag, List uint32) []byte { return buf } -// Request Flush -// size: 8 +// FlushCookie is a cookie used only for Flush requests. type FlushCookie struct { *xgb.Cookie } -// Write request to wire for Flush +// Flush sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func Flush(c *xgb.Conn, ContextTag ContextTag) FlushCookie { cookie := c.NewCookie(false, false) c.NewRequest(flushRequest(c, ContextTag), cookie) return FlushCookie{cookie} } +// FlushChecked sends a checked request. +// If an error occurs, it can be retrieved using FlushCookie.Check() func FlushChecked(c *xgb.Conn, ContextTag ContextTag) FlushCookie { cookie := c.NewCookie(true, false) c.NewRequest(flushRequest(c, ContextTag), cookie) return FlushCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook FlushCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for Flush +// flushRequest writes a Flush request to a byte slice. func flushRequest(c *xgb.Conn, ContextTag ContextTag) []byte { size := 8 b := 0 @@ -6843,36 +7133,38 @@ func flushRequest(c *xgb.Conn, ContextTag ContextTag) []byte { return buf } -// Request AreTexturesResident -// size: xgb.Pad((12 + xgb.Pad((int(N) * 4)))) +// AreTexturesResidentCookie is a cookie used only for AreTexturesResident requests. type AreTexturesResidentCookie struct { *xgb.Cookie } +// AreTexturesResident sends a checked request. +// If an error occurs, it will be returned with the reply by calling AreTexturesResidentCookie.Reply() func AreTexturesResident(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) AreTexturesResidentCookie { cookie := c.NewCookie(true, true) c.NewRequest(areTexturesResidentRequest(c, ContextTag, N, Textures), cookie) return AreTexturesResidentCookie{cookie} } +// AreTexturesResidentUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func AreTexturesResidentUnchecked(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) AreTexturesResidentCookie { cookie := c.NewCookie(false, true) c.NewRequest(areTexturesResidentRequest(c, ContextTag, N, Textures), cookie) return AreTexturesResidentCookie{cookie} } -// Request reply for AreTexturesResident -// size: (32 + xgb.Pad(((int(Length) * 4) * 1))) +// AreTexturesResidentReply represents the data returned from a AreTexturesResident request. type AreTexturesResidentReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes RetVal Bool32 // padding: 20 bytes Data []bool // size: xgb.Pad(((int(Length) * 4) * 1)) } -// Waits and reads reply data from request AreTexturesResident +// Reply blocks and returns the reply data for a AreTexturesResident request. func (cook AreTexturesResidentCookie) Reply() (*AreTexturesResidentReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -6884,7 +7176,7 @@ func (cook AreTexturesResidentCookie) Reply() (*AreTexturesResidentReply, error) return areTexturesResidentReply(buf), nil } -// Read reply into structure from buffer for AreTexturesResident +// areTexturesResidentReply reads a byte slice into a AreTexturesResidentReply value. func areTexturesResidentReply(buf []byte) *AreTexturesResidentReply { v := new(AreTexturesResidentReply) b := 1 // skip reply determinant @@ -6917,6 +7209,7 @@ func areTexturesResidentReply(buf []byte) *AreTexturesResidentReply { } // Write request to wire for AreTexturesResident +// areTexturesResidentRequest writes a AreTexturesResident request to a byte slice. func areTexturesResidentRequest(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) []byte { size := xgb.Pad((12 + xgb.Pad((int(N) * 4)))) b := 0 @@ -6946,30 +7239,35 @@ func areTexturesResidentRequest(c *xgb.Conn, ContextTag ContextTag, N int32, Tex return buf } -// Request DeleteTextures -// size: xgb.Pad((12 + xgb.Pad((int(N) * 4)))) +// DeleteTexturesCookie is a cookie used only for DeleteTextures requests. type DeleteTexturesCookie struct { *xgb.Cookie } -// Write request to wire for DeleteTextures +// DeleteTextures sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func DeleteTextures(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) DeleteTexturesCookie { cookie := c.NewCookie(false, false) c.NewRequest(deleteTexturesRequest(c, ContextTag, N, Textures), cookie) return DeleteTexturesCookie{cookie} } +// DeleteTexturesChecked sends a checked request. +// If an error occurs, it can be retrieved using DeleteTexturesCookie.Check() func DeleteTexturesChecked(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) DeleteTexturesCookie { cookie := c.NewCookie(true, false) c.NewRequest(deleteTexturesRequest(c, ContextTag, N, Textures), cookie) return DeleteTexturesCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook DeleteTexturesCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for DeleteTextures +// deleteTexturesRequest writes a DeleteTextures request to a byte slice. func deleteTexturesRequest(c *xgb.Conn, ContextTag ContextTag, N int32, Textures []uint32) []byte { size := xgb.Pad((12 + xgb.Pad((int(N) * 4)))) b := 0 @@ -6999,35 +7297,37 @@ func deleteTexturesRequest(c *xgb.Conn, ContextTag ContextTag, N int32, Textures return buf } -// Request GenTextures -// size: 12 +// GenTexturesCookie is a cookie used only for GenTextures requests. type GenTexturesCookie struct { *xgb.Cookie } +// GenTextures sends a checked request. +// If an error occurs, it will be returned with the reply by calling GenTexturesCookie.Reply() func GenTextures(c *xgb.Conn, ContextTag ContextTag, N int32) GenTexturesCookie { cookie := c.NewCookie(true, true) c.NewRequest(genTexturesRequest(c, ContextTag, N), cookie) return GenTexturesCookie{cookie} } +// GenTexturesUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GenTexturesUnchecked(c *xgb.Conn, ContextTag ContextTag, N int32) GenTexturesCookie { cookie := c.NewCookie(false, true) c.NewRequest(genTexturesRequest(c, ContextTag, N), cookie) return GenTexturesCookie{cookie} } -// Request reply for GenTextures -// size: (32 + xgb.Pad((int(Length) * 4))) +// GenTexturesReply represents the data returned from a GenTextures request. type GenTexturesReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 24 bytes Data []uint32 // size: xgb.Pad((int(Length) * 4)) } -// Waits and reads reply data from request GenTextures +// Reply blocks and returns the reply data for a GenTextures request. func (cook GenTexturesCookie) Reply() (*GenTexturesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -7039,7 +7339,7 @@ func (cook GenTexturesCookie) Reply() (*GenTexturesReply, error) { return genTexturesReply(buf), nil } -// Read reply into structure from buffer for GenTextures +// genTexturesReply reads a byte slice into a GenTexturesReply value. func genTexturesReply(buf []byte) *GenTexturesReply { v := new(GenTexturesReply) b := 1 // skip reply determinant @@ -7065,6 +7365,7 @@ func genTexturesReply(buf []byte) *GenTexturesReply { } // Write request to wire for GenTextures +// genTexturesRequest writes a GenTextures request to a byte slice. func genTexturesRequest(c *xgb.Conn, ContextTag ContextTag, N int32) []byte { size := 12 b := 0 @@ -7088,34 +7389,36 @@ func genTexturesRequest(c *xgb.Conn, ContextTag ContextTag, N int32) []byte { return buf } -// Request IsTexture -// size: 12 +// IsTextureCookie is a cookie used only for IsTexture requests. type IsTextureCookie struct { *xgb.Cookie } +// IsTexture sends a checked request. +// If an error occurs, it will be returned with the reply by calling IsTextureCookie.Reply() func IsTexture(c *xgb.Conn, ContextTag ContextTag, Texture uint32) IsTextureCookie { cookie := c.NewCookie(true, true) c.NewRequest(isTextureRequest(c, ContextTag, Texture), cookie) return IsTextureCookie{cookie} } +// IsTextureUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func IsTextureUnchecked(c *xgb.Conn, ContextTag ContextTag, Texture uint32) IsTextureCookie { cookie := c.NewCookie(false, true) c.NewRequest(isTextureRequest(c, ContextTag, Texture), cookie) return IsTextureCookie{cookie} } -// Request reply for IsTexture -// size: 12 +// IsTextureReply represents the data returned from a IsTexture request. type IsTextureReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes RetVal Bool32 } -// Waits and reads reply data from request IsTexture +// Reply blocks and returns the reply data for a IsTexture request. func (cook IsTextureCookie) Reply() (*IsTextureReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -7127,7 +7430,7 @@ func (cook IsTextureCookie) Reply() (*IsTextureReply, error) { return isTextureReply(buf), nil } -// Read reply into structure from buffer for IsTexture +// isTextureReply reads a byte slice into a IsTextureReply value. func isTextureReply(buf []byte) *IsTextureReply { v := new(IsTextureReply) b := 1 // skip reply determinant @@ -7147,6 +7450,7 @@ func isTextureReply(buf []byte) *IsTextureReply { } // Write request to wire for IsTexture +// isTextureRequest writes a IsTexture request to a byte slice. func isTextureRequest(c *xgb.Conn, ContextTag ContextTag, Texture uint32) []byte { size := 12 b := 0 @@ -7170,29 +7474,31 @@ func isTextureRequest(c *xgb.Conn, ContextTag ContextTag, Texture uint32) []byte return buf } -// Request GetColorTable -// size: 24 +// GetColorTableCookie is a cookie used only for GetColorTable requests. type GetColorTableCookie struct { *xgb.Cookie } +// GetColorTable sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetColorTableCookie.Reply() func GetColorTable(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetColorTableCookie { cookie := c.NewCookie(true, true) c.NewRequest(getColorTableRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) return GetColorTableCookie{cookie} } +// GetColorTableUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetColorTableUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetColorTableCookie { cookie := c.NewCookie(false, true) c.NewRequest(getColorTableRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) return GetColorTableCookie{cookie} } -// Request reply for GetColorTable -// size: (32 + xgb.Pad(((int(Length) * 4) * 1))) +// GetColorTableReply represents the data returned from a GetColorTable request. type GetColorTableReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 8 bytes Width int32 @@ -7200,7 +7506,7 @@ type GetColorTableReply struct { Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) } -// Waits and reads reply data from request GetColorTable +// Reply blocks and returns the reply data for a GetColorTable request. func (cook GetColorTableCookie) Reply() (*GetColorTableReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -7212,7 +7518,7 @@ func (cook GetColorTableCookie) Reply() (*GetColorTableReply, error) { return getColorTableReply(buf), nil } -// Read reply into structure from buffer for GetColorTable +// getColorTableReply reads a byte slice into a GetColorTableReply value. func getColorTableReply(buf []byte) *GetColorTableReply { v := new(GetColorTableReply) b := 1 // skip reply determinant @@ -7240,6 +7546,7 @@ func getColorTableReply(buf []byte) *GetColorTableReply { } // Write request to wire for GetColorTable +// getColorTableRequest writes a GetColorTable request to a byte slice. func getColorTableRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) []byte { size := 24 b := 0 @@ -7276,29 +7583,31 @@ func getColorTableRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, For return buf } -// Request GetColorTableParameterfv -// size: 16 +// GetColorTableParameterfvCookie is a cookie used only for GetColorTableParameterfv requests. type GetColorTableParameterfvCookie struct { *xgb.Cookie } +// GetColorTableParameterfv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetColorTableParameterfvCookie.Reply() func GetColorTableParameterfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetColorTableParameterfvCookie { cookie := c.NewCookie(true, true) c.NewRequest(getColorTableParameterfvRequest(c, ContextTag, Target, Pname), cookie) return GetColorTableParameterfvCookie{cookie} } +// GetColorTableParameterfvUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetColorTableParameterfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetColorTableParameterfvCookie { cookie := c.NewCookie(false, true) c.NewRequest(getColorTableParameterfvRequest(c, ContextTag, Target, Pname), cookie) return GetColorTableParameterfvCookie{cookie} } -// Request reply for GetColorTableParameterfv -// size: (32 + xgb.Pad((int(N) * 4))) +// GetColorTableParameterfvReply represents the data returned from a GetColorTableParameterfv request. type GetColorTableParameterfvReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 4 bytes N uint32 @@ -7307,7 +7616,7 @@ type GetColorTableParameterfvReply struct { Data []Float32 // size: xgb.Pad((int(N) * 4)) } -// Waits and reads reply data from request GetColorTableParameterfv +// Reply blocks and returns the reply data for a GetColorTableParameterfv request. func (cook GetColorTableParameterfvCookie) Reply() (*GetColorTableParameterfvReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -7319,7 +7628,7 @@ func (cook GetColorTableParameterfvCookie) Reply() (*GetColorTableParameterfvRep return getColorTableParameterfvReply(buf), nil } -// Read reply into structure from buffer for GetColorTableParameterfv +// getColorTableParameterfvReply reads a byte slice into a GetColorTableParameterfvReply value. func getColorTableParameterfvReply(buf []byte) *GetColorTableParameterfvReply { v := new(GetColorTableParameterfvReply) b := 1 // skip reply determinant @@ -7353,6 +7662,7 @@ func getColorTableParameterfvReply(buf []byte) *GetColorTableParameterfvReply { } // Write request to wire for GetColorTableParameterfv +// getColorTableParameterfvRequest writes a GetColorTableParameterfv request to a byte slice. func getColorTableParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { size := 16 b := 0 @@ -7379,29 +7689,31 @@ func getColorTableParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target return buf } -// Request GetColorTableParameteriv -// size: 16 +// GetColorTableParameterivCookie is a cookie used only for GetColorTableParameteriv requests. type GetColorTableParameterivCookie struct { *xgb.Cookie } +// GetColorTableParameteriv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetColorTableParameterivCookie.Reply() func GetColorTableParameteriv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetColorTableParameterivCookie { cookie := c.NewCookie(true, true) c.NewRequest(getColorTableParameterivRequest(c, ContextTag, Target, Pname), cookie) return GetColorTableParameterivCookie{cookie} } +// GetColorTableParameterivUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetColorTableParameterivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetColorTableParameterivCookie { cookie := c.NewCookie(false, true) c.NewRequest(getColorTableParameterivRequest(c, ContextTag, Target, Pname), cookie) return GetColorTableParameterivCookie{cookie} } -// Request reply for GetColorTableParameteriv -// size: (32 + xgb.Pad((int(N) * 4))) +// GetColorTableParameterivReply represents the data returned from a GetColorTableParameteriv request. type GetColorTableParameterivReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 4 bytes N uint32 @@ -7410,7 +7722,7 @@ type GetColorTableParameterivReply struct { Data []int32 // size: xgb.Pad((int(N) * 4)) } -// Waits and reads reply data from request GetColorTableParameteriv +// Reply blocks and returns the reply data for a GetColorTableParameteriv request. func (cook GetColorTableParameterivCookie) Reply() (*GetColorTableParameterivReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -7422,7 +7734,7 @@ func (cook GetColorTableParameterivCookie) Reply() (*GetColorTableParameterivRep return getColorTableParameterivReply(buf), nil } -// Read reply into structure from buffer for GetColorTableParameteriv +// getColorTableParameterivReply reads a byte slice into a GetColorTableParameterivReply value. func getColorTableParameterivReply(buf []byte) *GetColorTableParameterivReply { v := new(GetColorTableParameterivReply) b := 1 // skip reply determinant @@ -7456,6 +7768,7 @@ func getColorTableParameterivReply(buf []byte) *GetColorTableParameterivReply { } // Write request to wire for GetColorTableParameteriv +// getColorTableParameterivRequest writes a GetColorTableParameteriv request to a byte slice. func getColorTableParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { size := 16 b := 0 @@ -7482,29 +7795,31 @@ func getColorTableParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target return buf } -// Request GetConvolutionFilter -// size: 24 +// GetConvolutionFilterCookie is a cookie used only for GetConvolutionFilter requests. type GetConvolutionFilterCookie struct { *xgb.Cookie } +// GetConvolutionFilter sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetConvolutionFilterCookie.Reply() func GetConvolutionFilter(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetConvolutionFilterCookie { cookie := c.NewCookie(true, true) c.NewRequest(getConvolutionFilterRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) return GetConvolutionFilterCookie{cookie} } +// GetConvolutionFilterUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetConvolutionFilterUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetConvolutionFilterCookie { cookie := c.NewCookie(false, true) c.NewRequest(getConvolutionFilterRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) return GetConvolutionFilterCookie{cookie} } -// Request reply for GetConvolutionFilter -// size: (32 + xgb.Pad(((int(Length) * 4) * 1))) +// GetConvolutionFilterReply represents the data returned from a GetConvolutionFilter request. type GetConvolutionFilterReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 8 bytes Width int32 @@ -7513,7 +7828,7 @@ type GetConvolutionFilterReply struct { Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) } -// Waits and reads reply data from request GetConvolutionFilter +// Reply blocks and returns the reply data for a GetConvolutionFilter request. func (cook GetConvolutionFilterCookie) Reply() (*GetConvolutionFilterReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -7525,7 +7840,7 @@ func (cook GetConvolutionFilterCookie) Reply() (*GetConvolutionFilterReply, erro return getConvolutionFilterReply(buf), nil } -// Read reply into structure from buffer for GetConvolutionFilter +// getConvolutionFilterReply reads a byte slice into a GetConvolutionFilterReply value. func getConvolutionFilterReply(buf []byte) *GetConvolutionFilterReply { v := new(GetConvolutionFilterReply) b := 1 // skip reply determinant @@ -7556,6 +7871,7 @@ func getConvolutionFilterReply(buf []byte) *GetConvolutionFilterReply { } // Write request to wire for GetConvolutionFilter +// getConvolutionFilterRequest writes a GetConvolutionFilter request to a byte slice. func getConvolutionFilterRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) []byte { size := 24 b := 0 @@ -7592,29 +7908,31 @@ func getConvolutionFilterRequest(c *xgb.Conn, ContextTag ContextTag, Target uint return buf } -// Request GetConvolutionParameterfv -// size: 16 +// GetConvolutionParameterfvCookie is a cookie used only for GetConvolutionParameterfv requests. type GetConvolutionParameterfvCookie struct { *xgb.Cookie } +// GetConvolutionParameterfv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetConvolutionParameterfvCookie.Reply() func GetConvolutionParameterfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetConvolutionParameterfvCookie { cookie := c.NewCookie(true, true) c.NewRequest(getConvolutionParameterfvRequest(c, ContextTag, Target, Pname), cookie) return GetConvolutionParameterfvCookie{cookie} } +// GetConvolutionParameterfvUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetConvolutionParameterfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetConvolutionParameterfvCookie { cookie := c.NewCookie(false, true) c.NewRequest(getConvolutionParameterfvRequest(c, ContextTag, Target, Pname), cookie) return GetConvolutionParameterfvCookie{cookie} } -// Request reply for GetConvolutionParameterfv -// size: (32 + xgb.Pad((int(N) * 4))) +// GetConvolutionParameterfvReply represents the data returned from a GetConvolutionParameterfv request. type GetConvolutionParameterfvReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 4 bytes N uint32 @@ -7623,7 +7941,7 @@ type GetConvolutionParameterfvReply struct { Data []Float32 // size: xgb.Pad((int(N) * 4)) } -// Waits and reads reply data from request GetConvolutionParameterfv +// Reply blocks and returns the reply data for a GetConvolutionParameterfv request. func (cook GetConvolutionParameterfvCookie) Reply() (*GetConvolutionParameterfvReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -7635,7 +7953,7 @@ func (cook GetConvolutionParameterfvCookie) Reply() (*GetConvolutionParameterfvR return getConvolutionParameterfvReply(buf), nil } -// Read reply into structure from buffer for GetConvolutionParameterfv +// getConvolutionParameterfvReply reads a byte slice into a GetConvolutionParameterfvReply value. func getConvolutionParameterfvReply(buf []byte) *GetConvolutionParameterfvReply { v := new(GetConvolutionParameterfvReply) b := 1 // skip reply determinant @@ -7669,6 +7987,7 @@ func getConvolutionParameterfvReply(buf []byte) *GetConvolutionParameterfvReply } // Write request to wire for GetConvolutionParameterfv +// getConvolutionParameterfvRequest writes a GetConvolutionParameterfv request to a byte slice. func getConvolutionParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { size := 16 b := 0 @@ -7695,29 +8014,31 @@ func getConvolutionParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target return buf } -// Request GetConvolutionParameteriv -// size: 16 +// GetConvolutionParameterivCookie is a cookie used only for GetConvolutionParameteriv requests. type GetConvolutionParameterivCookie struct { *xgb.Cookie } +// GetConvolutionParameteriv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetConvolutionParameterivCookie.Reply() func GetConvolutionParameteriv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetConvolutionParameterivCookie { cookie := c.NewCookie(true, true) c.NewRequest(getConvolutionParameterivRequest(c, ContextTag, Target, Pname), cookie) return GetConvolutionParameterivCookie{cookie} } +// GetConvolutionParameterivUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetConvolutionParameterivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetConvolutionParameterivCookie { cookie := c.NewCookie(false, true) c.NewRequest(getConvolutionParameterivRequest(c, ContextTag, Target, Pname), cookie) return GetConvolutionParameterivCookie{cookie} } -// Request reply for GetConvolutionParameteriv -// size: (32 + xgb.Pad((int(N) * 4))) +// GetConvolutionParameterivReply represents the data returned from a GetConvolutionParameteriv request. type GetConvolutionParameterivReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 4 bytes N uint32 @@ -7726,7 +8047,7 @@ type GetConvolutionParameterivReply struct { Data []int32 // size: xgb.Pad((int(N) * 4)) } -// Waits and reads reply data from request GetConvolutionParameteriv +// Reply blocks and returns the reply data for a GetConvolutionParameteriv request. func (cook GetConvolutionParameterivCookie) Reply() (*GetConvolutionParameterivReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -7738,7 +8059,7 @@ func (cook GetConvolutionParameterivCookie) Reply() (*GetConvolutionParameterivR return getConvolutionParameterivReply(buf), nil } -// Read reply into structure from buffer for GetConvolutionParameteriv +// getConvolutionParameterivReply reads a byte slice into a GetConvolutionParameterivReply value. func getConvolutionParameterivReply(buf []byte) *GetConvolutionParameterivReply { v := new(GetConvolutionParameterivReply) b := 1 // skip reply determinant @@ -7772,6 +8093,7 @@ func getConvolutionParameterivReply(buf []byte) *GetConvolutionParameterivReply } // Write request to wire for GetConvolutionParameteriv +// getConvolutionParameterivRequest writes a GetConvolutionParameteriv request to a byte slice. func getConvolutionParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { size := 16 b := 0 @@ -7798,29 +8120,31 @@ func getConvolutionParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target return buf } -// Request GetSeparableFilter -// size: 24 +// GetSeparableFilterCookie is a cookie used only for GetSeparableFilter requests. type GetSeparableFilterCookie struct { *xgb.Cookie } +// GetSeparableFilter sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetSeparableFilterCookie.Reply() func GetSeparableFilter(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetSeparableFilterCookie { cookie := c.NewCookie(true, true) c.NewRequest(getSeparableFilterRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) return GetSeparableFilterCookie{cookie} } +// GetSeparableFilterUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetSeparableFilterUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) GetSeparableFilterCookie { cookie := c.NewCookie(false, true) c.NewRequest(getSeparableFilterRequest(c, ContextTag, Target, Format, Type, SwapBytes), cookie) return GetSeparableFilterCookie{cookie} } -// Request reply for GetSeparableFilter -// size: (32 + xgb.Pad(((int(Length) * 4) * 1))) +// GetSeparableFilterReply represents the data returned from a GetSeparableFilter request. type GetSeparableFilterReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 8 bytes RowW int32 @@ -7829,7 +8153,7 @@ type GetSeparableFilterReply struct { RowsAndCols []byte // size: xgb.Pad(((int(Length) * 4) * 1)) } -// Waits and reads reply data from request GetSeparableFilter +// Reply blocks and returns the reply data for a GetSeparableFilter request. func (cook GetSeparableFilterCookie) Reply() (*GetSeparableFilterReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -7841,7 +8165,7 @@ func (cook GetSeparableFilterCookie) Reply() (*GetSeparableFilterReply, error) { return getSeparableFilterReply(buf), nil } -// Read reply into structure from buffer for GetSeparableFilter +// getSeparableFilterReply reads a byte slice into a GetSeparableFilterReply value. func getSeparableFilterReply(buf []byte) *GetSeparableFilterReply { v := new(GetSeparableFilterReply) b := 1 // skip reply determinant @@ -7872,6 +8196,7 @@ func getSeparableFilterReply(buf []byte) *GetSeparableFilterReply { } // Write request to wire for GetSeparableFilter +// getSeparableFilterRequest writes a GetSeparableFilter request to a byte slice. func getSeparableFilterRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool) []byte { size := 24 b := 0 @@ -7908,29 +8233,31 @@ func getSeparableFilterRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32 return buf } -// Request GetHistogram -// size: 24 +// GetHistogramCookie is a cookie used only for GetHistogram requests. type GetHistogramCookie struct { *xgb.Cookie } +// GetHistogram sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetHistogramCookie.Reply() func GetHistogram(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) GetHistogramCookie { cookie := c.NewCookie(true, true) c.NewRequest(getHistogramRequest(c, ContextTag, Target, Format, Type, SwapBytes, Reset), cookie) return GetHistogramCookie{cookie} } +// GetHistogramUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetHistogramUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) GetHistogramCookie { cookie := c.NewCookie(false, true) c.NewRequest(getHistogramRequest(c, ContextTag, Target, Format, Type, SwapBytes, Reset), cookie) return GetHistogramCookie{cookie} } -// Request reply for GetHistogram -// size: (32 + xgb.Pad(((int(Length) * 4) * 1))) +// GetHistogramReply represents the data returned from a GetHistogram request. type GetHistogramReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 8 bytes Width int32 @@ -7938,7 +8265,7 @@ type GetHistogramReply struct { Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) } -// Waits and reads reply data from request GetHistogram +// Reply blocks and returns the reply data for a GetHistogram request. func (cook GetHistogramCookie) Reply() (*GetHistogramReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -7950,7 +8277,7 @@ func (cook GetHistogramCookie) Reply() (*GetHistogramReply, error) { return getHistogramReply(buf), nil } -// Read reply into structure from buffer for GetHistogram +// getHistogramReply reads a byte slice into a GetHistogramReply value. func getHistogramReply(buf []byte) *GetHistogramReply { v := new(GetHistogramReply) b := 1 // skip reply determinant @@ -7978,6 +8305,7 @@ func getHistogramReply(buf []byte) *GetHistogramReply { } // Write request to wire for GetHistogram +// getHistogramRequest writes a GetHistogram request to a byte slice. func getHistogramRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) []byte { size := 24 b := 0 @@ -8021,29 +8349,31 @@ func getHistogramRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Form return buf } -// Request GetHistogramParameterfv -// size: 16 +// GetHistogramParameterfvCookie is a cookie used only for GetHistogramParameterfv requests. type GetHistogramParameterfvCookie struct { *xgb.Cookie } +// GetHistogramParameterfv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetHistogramParameterfvCookie.Reply() func GetHistogramParameterfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetHistogramParameterfvCookie { cookie := c.NewCookie(true, true) c.NewRequest(getHistogramParameterfvRequest(c, ContextTag, Target, Pname), cookie) return GetHistogramParameterfvCookie{cookie} } +// GetHistogramParameterfvUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetHistogramParameterfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetHistogramParameterfvCookie { cookie := c.NewCookie(false, true) c.NewRequest(getHistogramParameterfvRequest(c, ContextTag, Target, Pname), cookie) return GetHistogramParameterfvCookie{cookie} } -// Request reply for GetHistogramParameterfv -// size: (32 + xgb.Pad((int(N) * 4))) +// GetHistogramParameterfvReply represents the data returned from a GetHistogramParameterfv request. type GetHistogramParameterfvReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 4 bytes N uint32 @@ -8052,7 +8382,7 @@ type GetHistogramParameterfvReply struct { Data []Float32 // size: xgb.Pad((int(N) * 4)) } -// Waits and reads reply data from request GetHistogramParameterfv +// Reply blocks and returns the reply data for a GetHistogramParameterfv request. func (cook GetHistogramParameterfvCookie) Reply() (*GetHistogramParameterfvReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -8064,7 +8394,7 @@ func (cook GetHistogramParameterfvCookie) Reply() (*GetHistogramParameterfvReply return getHistogramParameterfvReply(buf), nil } -// Read reply into structure from buffer for GetHistogramParameterfv +// getHistogramParameterfvReply reads a byte slice into a GetHistogramParameterfvReply value. func getHistogramParameterfvReply(buf []byte) *GetHistogramParameterfvReply { v := new(GetHistogramParameterfvReply) b := 1 // skip reply determinant @@ -8098,6 +8428,7 @@ func getHistogramParameterfvReply(buf []byte) *GetHistogramParameterfvReply { } // Write request to wire for GetHistogramParameterfv +// getHistogramParameterfvRequest writes a GetHistogramParameterfv request to a byte slice. func getHistogramParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { size := 16 b := 0 @@ -8124,29 +8455,31 @@ func getHistogramParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target u return buf } -// Request GetHistogramParameteriv -// size: 16 +// GetHistogramParameterivCookie is a cookie used only for GetHistogramParameteriv requests. type GetHistogramParameterivCookie struct { *xgb.Cookie } +// GetHistogramParameteriv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetHistogramParameterivCookie.Reply() func GetHistogramParameteriv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetHistogramParameterivCookie { cookie := c.NewCookie(true, true) c.NewRequest(getHistogramParameterivRequest(c, ContextTag, Target, Pname), cookie) return GetHistogramParameterivCookie{cookie} } +// GetHistogramParameterivUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetHistogramParameterivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetHistogramParameterivCookie { cookie := c.NewCookie(false, true) c.NewRequest(getHistogramParameterivRequest(c, ContextTag, Target, Pname), cookie) return GetHistogramParameterivCookie{cookie} } -// Request reply for GetHistogramParameteriv -// size: (32 + xgb.Pad((int(N) * 4))) +// GetHistogramParameterivReply represents the data returned from a GetHistogramParameteriv request. type GetHistogramParameterivReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 4 bytes N uint32 @@ -8155,7 +8488,7 @@ type GetHistogramParameterivReply struct { Data []int32 // size: xgb.Pad((int(N) * 4)) } -// Waits and reads reply data from request GetHistogramParameteriv +// Reply blocks and returns the reply data for a GetHistogramParameteriv request. func (cook GetHistogramParameterivCookie) Reply() (*GetHistogramParameterivReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -8167,7 +8500,7 @@ func (cook GetHistogramParameterivCookie) Reply() (*GetHistogramParameterivReply return getHistogramParameterivReply(buf), nil } -// Read reply into structure from buffer for GetHistogramParameteriv +// getHistogramParameterivReply reads a byte slice into a GetHistogramParameterivReply value. func getHistogramParameterivReply(buf []byte) *GetHistogramParameterivReply { v := new(GetHistogramParameterivReply) b := 1 // skip reply determinant @@ -8201,6 +8534,7 @@ func getHistogramParameterivReply(buf []byte) *GetHistogramParameterivReply { } // Write request to wire for GetHistogramParameteriv +// getHistogramParameterivRequest writes a GetHistogramParameteriv request to a byte slice. func getHistogramParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { size := 16 b := 0 @@ -8227,35 +8561,37 @@ func getHistogramParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target u return buf } -// Request GetMinmax -// size: 24 +// GetMinmaxCookie is a cookie used only for GetMinmax requests. type GetMinmaxCookie struct { *xgb.Cookie } +// GetMinmax sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetMinmaxCookie.Reply() func GetMinmax(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) GetMinmaxCookie { cookie := c.NewCookie(true, true) c.NewRequest(getMinmaxRequest(c, ContextTag, Target, Format, Type, SwapBytes, Reset), cookie) return GetMinmaxCookie{cookie} } +// GetMinmaxUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetMinmaxUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) GetMinmaxCookie { cookie := c.NewCookie(false, true) c.NewRequest(getMinmaxRequest(c, ContextTag, Target, Format, Type, SwapBytes, Reset), cookie) return GetMinmaxCookie{cookie} } -// Request reply for GetMinmax -// size: (32 + xgb.Pad(((int(Length) * 4) * 1))) +// GetMinmaxReply represents the data returned from a GetMinmax request. type GetMinmaxReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 24 bytes Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) } -// Waits and reads reply data from request GetMinmax +// Reply blocks and returns the reply data for a GetMinmax request. func (cook GetMinmaxCookie) Reply() (*GetMinmaxReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -8267,7 +8603,7 @@ func (cook GetMinmaxCookie) Reply() (*GetMinmaxReply, error) { return getMinmaxReply(buf), nil } -// Read reply into structure from buffer for GetMinmax +// getMinmaxReply reads a byte slice into a GetMinmaxReply value. func getMinmaxReply(buf []byte) *GetMinmaxReply { v := new(GetMinmaxReply) b := 1 // skip reply determinant @@ -8290,6 +8626,7 @@ func getMinmaxReply(buf []byte) *GetMinmaxReply { } // Write request to wire for GetMinmax +// getMinmaxRequest writes a GetMinmax request to a byte slice. func getMinmaxRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format uint32, Type uint32, SwapBytes bool, Reset bool) []byte { size := 24 b := 0 @@ -8333,29 +8670,31 @@ func getMinmaxRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Format return buf } -// Request GetMinmaxParameterfv -// size: 16 +// GetMinmaxParameterfvCookie is a cookie used only for GetMinmaxParameterfv requests. type GetMinmaxParameterfvCookie struct { *xgb.Cookie } +// GetMinmaxParameterfv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetMinmaxParameterfvCookie.Reply() func GetMinmaxParameterfv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetMinmaxParameterfvCookie { cookie := c.NewCookie(true, true) c.NewRequest(getMinmaxParameterfvRequest(c, ContextTag, Target, Pname), cookie) return GetMinmaxParameterfvCookie{cookie} } +// GetMinmaxParameterfvUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetMinmaxParameterfvUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetMinmaxParameterfvCookie { cookie := c.NewCookie(false, true) c.NewRequest(getMinmaxParameterfvRequest(c, ContextTag, Target, Pname), cookie) return GetMinmaxParameterfvCookie{cookie} } -// Request reply for GetMinmaxParameterfv -// size: (32 + xgb.Pad((int(N) * 4))) +// GetMinmaxParameterfvReply represents the data returned from a GetMinmaxParameterfv request. type GetMinmaxParameterfvReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 4 bytes N uint32 @@ -8364,7 +8703,7 @@ type GetMinmaxParameterfvReply struct { Data []Float32 // size: xgb.Pad((int(N) * 4)) } -// Waits and reads reply data from request GetMinmaxParameterfv +// Reply blocks and returns the reply data for a GetMinmaxParameterfv request. func (cook GetMinmaxParameterfvCookie) Reply() (*GetMinmaxParameterfvReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -8376,7 +8715,7 @@ func (cook GetMinmaxParameterfvCookie) Reply() (*GetMinmaxParameterfvReply, erro return getMinmaxParameterfvReply(buf), nil } -// Read reply into structure from buffer for GetMinmaxParameterfv +// getMinmaxParameterfvReply reads a byte slice into a GetMinmaxParameterfvReply value. func getMinmaxParameterfvReply(buf []byte) *GetMinmaxParameterfvReply { v := new(GetMinmaxParameterfvReply) b := 1 // skip reply determinant @@ -8410,6 +8749,7 @@ func getMinmaxParameterfvReply(buf []byte) *GetMinmaxParameterfvReply { } // Write request to wire for GetMinmaxParameterfv +// getMinmaxParameterfvRequest writes a GetMinmaxParameterfv request to a byte slice. func getMinmaxParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { size := 16 b := 0 @@ -8436,29 +8776,31 @@ func getMinmaxParameterfvRequest(c *xgb.Conn, ContextTag ContextTag, Target uint return buf } -// Request GetMinmaxParameteriv -// size: 16 +// GetMinmaxParameterivCookie is a cookie used only for GetMinmaxParameteriv requests. type GetMinmaxParameterivCookie struct { *xgb.Cookie } +// GetMinmaxParameteriv sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetMinmaxParameterivCookie.Reply() func GetMinmaxParameteriv(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetMinmaxParameterivCookie { cookie := c.NewCookie(true, true) c.NewRequest(getMinmaxParameterivRequest(c, ContextTag, Target, Pname), cookie) return GetMinmaxParameterivCookie{cookie} } +// GetMinmaxParameterivUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetMinmaxParameterivUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetMinmaxParameterivCookie { cookie := c.NewCookie(false, true) c.NewRequest(getMinmaxParameterivRequest(c, ContextTag, Target, Pname), cookie) return GetMinmaxParameterivCookie{cookie} } -// Request reply for GetMinmaxParameteriv -// size: (32 + xgb.Pad((int(N) * 4))) +// GetMinmaxParameterivReply represents the data returned from a GetMinmaxParameteriv request. type GetMinmaxParameterivReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 4 bytes N uint32 @@ -8467,7 +8809,7 @@ type GetMinmaxParameterivReply struct { Data []int32 // size: xgb.Pad((int(N) * 4)) } -// Waits and reads reply data from request GetMinmaxParameteriv +// Reply blocks and returns the reply data for a GetMinmaxParameteriv request. func (cook GetMinmaxParameterivCookie) Reply() (*GetMinmaxParameterivReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -8479,7 +8821,7 @@ func (cook GetMinmaxParameterivCookie) Reply() (*GetMinmaxParameterivReply, erro return getMinmaxParameterivReply(buf), nil } -// Read reply into structure from buffer for GetMinmaxParameteriv +// getMinmaxParameterivReply reads a byte slice into a GetMinmaxParameterivReply value. func getMinmaxParameterivReply(buf []byte) *GetMinmaxParameterivReply { v := new(GetMinmaxParameterivReply) b := 1 // skip reply determinant @@ -8513,6 +8855,7 @@ func getMinmaxParameterivReply(buf []byte) *GetMinmaxParameterivReply { } // Write request to wire for GetMinmaxParameteriv +// getMinmaxParameterivRequest writes a GetMinmaxParameteriv request to a byte slice. func getMinmaxParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { size := 16 b := 0 @@ -8539,29 +8882,31 @@ func getMinmaxParameterivRequest(c *xgb.Conn, ContextTag ContextTag, Target uint return buf } -// Request GetCompressedTexImageARB -// size: 16 +// GetCompressedTexImageARBCookie is a cookie used only for GetCompressedTexImageARB requests. type GetCompressedTexImageARBCookie struct { *xgb.Cookie } +// GetCompressedTexImageARB sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetCompressedTexImageARBCookie.Reply() func GetCompressedTexImageARB(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32) GetCompressedTexImageARBCookie { cookie := c.NewCookie(true, true) c.NewRequest(getCompressedTexImageARBRequest(c, ContextTag, Target, Level), cookie) return GetCompressedTexImageARBCookie{cookie} } +// GetCompressedTexImageARBUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetCompressedTexImageARBUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32) GetCompressedTexImageARBCookie { cookie := c.NewCookie(false, true) c.NewRequest(getCompressedTexImageARBRequest(c, ContextTag, Target, Level), cookie) return GetCompressedTexImageARBCookie{cookie} } -// Request reply for GetCompressedTexImageARB -// size: (32 + xgb.Pad(((int(Length) * 4) * 1))) +// GetCompressedTexImageARBReply represents the data returned from a GetCompressedTexImageARB request. type GetCompressedTexImageARBReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 8 bytes Size int32 @@ -8569,7 +8914,7 @@ type GetCompressedTexImageARBReply struct { Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) } -// Waits and reads reply data from request GetCompressedTexImageARB +// Reply blocks and returns the reply data for a GetCompressedTexImageARB request. func (cook GetCompressedTexImageARBCookie) Reply() (*GetCompressedTexImageARBReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -8581,7 +8926,7 @@ func (cook GetCompressedTexImageARBCookie) Reply() (*GetCompressedTexImageARBRep return getCompressedTexImageARBReply(buf), nil } -// Read reply into structure from buffer for GetCompressedTexImageARB +// getCompressedTexImageARBReply reads a byte slice into a GetCompressedTexImageARBReply value. func getCompressedTexImageARBReply(buf []byte) *GetCompressedTexImageARBReply { v := new(GetCompressedTexImageARBReply) b := 1 // skip reply determinant @@ -8609,6 +8954,7 @@ func getCompressedTexImageARBReply(buf []byte) *GetCompressedTexImageARBReply { } // Write request to wire for GetCompressedTexImageARB +// getCompressedTexImageARBRequest writes a GetCompressedTexImageARB request to a byte slice. func getCompressedTexImageARBRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Level int32) []byte { size := 16 b := 0 @@ -8635,30 +8981,35 @@ func getCompressedTexImageARBRequest(c *xgb.Conn, ContextTag ContextTag, Target return buf } -// Request DeleteQueriesARB -// size: xgb.Pad((12 + xgb.Pad((int(N) * 4)))) +// DeleteQueriesARBCookie is a cookie used only for DeleteQueriesARB requests. type DeleteQueriesARBCookie struct { *xgb.Cookie } -// Write request to wire for DeleteQueriesARB +// DeleteQueriesARB sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func DeleteQueriesARB(c *xgb.Conn, ContextTag ContextTag, N int32, Ids []uint32) DeleteQueriesARBCookie { cookie := c.NewCookie(false, false) c.NewRequest(deleteQueriesARBRequest(c, ContextTag, N, Ids), cookie) return DeleteQueriesARBCookie{cookie} } +// DeleteQueriesARBChecked sends a checked request. +// If an error occurs, it can be retrieved using DeleteQueriesARBCookie.Check() func DeleteQueriesARBChecked(c *xgb.Conn, ContextTag ContextTag, N int32, Ids []uint32) DeleteQueriesARBCookie { cookie := c.NewCookie(true, false) c.NewRequest(deleteQueriesARBRequest(c, ContextTag, N, Ids), cookie) return DeleteQueriesARBCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook DeleteQueriesARBCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for DeleteQueriesARB +// deleteQueriesARBRequest writes a DeleteQueriesARB request to a byte slice. func deleteQueriesARBRequest(c *xgb.Conn, ContextTag ContextTag, N int32, Ids []uint32) []byte { size := xgb.Pad((12 + xgb.Pad((int(N) * 4)))) b := 0 @@ -8688,35 +9039,37 @@ func deleteQueriesARBRequest(c *xgb.Conn, ContextTag ContextTag, N int32, Ids [] return buf } -// Request GenQueriesARB -// size: 12 +// GenQueriesARBCookie is a cookie used only for GenQueriesARB requests. type GenQueriesARBCookie struct { *xgb.Cookie } +// GenQueriesARB sends a checked request. +// If an error occurs, it will be returned with the reply by calling GenQueriesARBCookie.Reply() func GenQueriesARB(c *xgb.Conn, ContextTag ContextTag, N int32) GenQueriesARBCookie { cookie := c.NewCookie(true, true) c.NewRequest(genQueriesARBRequest(c, ContextTag, N), cookie) return GenQueriesARBCookie{cookie} } +// GenQueriesARBUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GenQueriesARBUnchecked(c *xgb.Conn, ContextTag ContextTag, N int32) GenQueriesARBCookie { cookie := c.NewCookie(false, true) c.NewRequest(genQueriesARBRequest(c, ContextTag, N), cookie) return GenQueriesARBCookie{cookie} } -// Request reply for GenQueriesARB -// size: (32 + xgb.Pad((int(Length) * 4))) +// GenQueriesARBReply represents the data returned from a GenQueriesARB request. type GenQueriesARBReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 24 bytes Data []uint32 // size: xgb.Pad((int(Length) * 4)) } -// Waits and reads reply data from request GenQueriesARB +// Reply blocks and returns the reply data for a GenQueriesARB request. func (cook GenQueriesARBCookie) Reply() (*GenQueriesARBReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -8728,7 +9081,7 @@ func (cook GenQueriesARBCookie) Reply() (*GenQueriesARBReply, error) { return genQueriesARBReply(buf), nil } -// Read reply into structure from buffer for GenQueriesARB +// genQueriesARBReply reads a byte slice into a GenQueriesARBReply value. func genQueriesARBReply(buf []byte) *GenQueriesARBReply { v := new(GenQueriesARBReply) b := 1 // skip reply determinant @@ -8754,6 +9107,7 @@ func genQueriesARBReply(buf []byte) *GenQueriesARBReply { } // Write request to wire for GenQueriesARB +// genQueriesARBRequest writes a GenQueriesARB request to a byte slice. func genQueriesARBRequest(c *xgb.Conn, ContextTag ContextTag, N int32) []byte { size := 12 b := 0 @@ -8777,34 +9131,36 @@ func genQueriesARBRequest(c *xgb.Conn, ContextTag ContextTag, N int32) []byte { return buf } -// Request IsQueryARB -// size: 12 +// IsQueryARBCookie is a cookie used only for IsQueryARB requests. type IsQueryARBCookie struct { *xgb.Cookie } +// IsQueryARB sends a checked request. +// If an error occurs, it will be returned with the reply by calling IsQueryARBCookie.Reply() func IsQueryARB(c *xgb.Conn, ContextTag ContextTag, Id uint32) IsQueryARBCookie { cookie := c.NewCookie(true, true) c.NewRequest(isQueryARBRequest(c, ContextTag, Id), cookie) return IsQueryARBCookie{cookie} } +// IsQueryARBUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func IsQueryARBUnchecked(c *xgb.Conn, ContextTag ContextTag, Id uint32) IsQueryARBCookie { cookie := c.NewCookie(false, true) c.NewRequest(isQueryARBRequest(c, ContextTag, Id), cookie) return IsQueryARBCookie{cookie} } -// Request reply for IsQueryARB -// size: 12 +// IsQueryARBReply represents the data returned from a IsQueryARB request. type IsQueryARBReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes RetVal Bool32 } -// Waits and reads reply data from request IsQueryARB +// Reply blocks and returns the reply data for a IsQueryARB request. func (cook IsQueryARBCookie) Reply() (*IsQueryARBReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -8816,7 +9172,7 @@ func (cook IsQueryARBCookie) Reply() (*IsQueryARBReply, error) { return isQueryARBReply(buf), nil } -// Read reply into structure from buffer for IsQueryARB +// isQueryARBReply reads a byte slice into a IsQueryARBReply value. func isQueryARBReply(buf []byte) *IsQueryARBReply { v := new(IsQueryARBReply) b := 1 // skip reply determinant @@ -8836,6 +9192,7 @@ func isQueryARBReply(buf []byte) *IsQueryARBReply { } // Write request to wire for IsQueryARB +// isQueryARBRequest writes a IsQueryARB request to a byte slice. func isQueryARBRequest(c *xgb.Conn, ContextTag ContextTag, Id uint32) []byte { size := 12 b := 0 @@ -8859,29 +9216,31 @@ func isQueryARBRequest(c *xgb.Conn, ContextTag ContextTag, Id uint32) []byte { return buf } -// Request GetQueryivARB -// size: 16 +// GetQueryivARBCookie is a cookie used only for GetQueryivARB requests. type GetQueryivARBCookie struct { *xgb.Cookie } +// GetQueryivARB sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetQueryivARBCookie.Reply() func GetQueryivARB(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetQueryivARBCookie { cookie := c.NewCookie(true, true) c.NewRequest(getQueryivARBRequest(c, ContextTag, Target, Pname), cookie) return GetQueryivARBCookie{cookie} } +// GetQueryivARBUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetQueryivARBUnchecked(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) GetQueryivARBCookie { cookie := c.NewCookie(false, true) c.NewRequest(getQueryivARBRequest(c, ContextTag, Target, Pname), cookie) return GetQueryivARBCookie{cookie} } -// Request reply for GetQueryivARB -// size: (32 + xgb.Pad((int(N) * 4))) +// GetQueryivARBReply represents the data returned from a GetQueryivARB request. type GetQueryivARBReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 4 bytes N uint32 @@ -8890,7 +9249,7 @@ type GetQueryivARBReply struct { Data []int32 // size: xgb.Pad((int(N) * 4)) } -// Waits and reads reply data from request GetQueryivARB +// Reply blocks and returns the reply data for a GetQueryivARB request. func (cook GetQueryivARBCookie) Reply() (*GetQueryivARBReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -8902,7 +9261,7 @@ func (cook GetQueryivARBCookie) Reply() (*GetQueryivARBReply, error) { return getQueryivARBReply(buf), nil } -// Read reply into structure from buffer for GetQueryivARB +// getQueryivARBReply reads a byte slice into a GetQueryivARBReply value. func getQueryivARBReply(buf []byte) *GetQueryivARBReply { v := new(GetQueryivARBReply) b := 1 // skip reply determinant @@ -8936,6 +9295,7 @@ func getQueryivARBReply(buf []byte) *GetQueryivARBReply { } // Write request to wire for GetQueryivARB +// getQueryivARBRequest writes a GetQueryivARB request to a byte slice. func getQueryivARBRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pname uint32) []byte { size := 16 b := 0 @@ -8962,29 +9322,31 @@ func getQueryivARBRequest(c *xgb.Conn, ContextTag ContextTag, Target uint32, Pna return buf } -// Request GetQueryObjectivARB -// size: 16 +// GetQueryObjectivARBCookie is a cookie used only for GetQueryObjectivARB requests. type GetQueryObjectivARBCookie struct { *xgb.Cookie } +// GetQueryObjectivARB sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetQueryObjectivARBCookie.Reply() func GetQueryObjectivARB(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) GetQueryObjectivARBCookie { cookie := c.NewCookie(true, true) c.NewRequest(getQueryObjectivARBRequest(c, ContextTag, Id, Pname), cookie) return GetQueryObjectivARBCookie{cookie} } +// GetQueryObjectivARBUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetQueryObjectivARBUnchecked(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) GetQueryObjectivARBCookie { cookie := c.NewCookie(false, true) c.NewRequest(getQueryObjectivARBRequest(c, ContextTag, Id, Pname), cookie) return GetQueryObjectivARBCookie{cookie} } -// Request reply for GetQueryObjectivARB -// size: (32 + xgb.Pad((int(N) * 4))) +// GetQueryObjectivARBReply represents the data returned from a GetQueryObjectivARB request. type GetQueryObjectivARBReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 4 bytes N uint32 @@ -8993,7 +9355,7 @@ type GetQueryObjectivARBReply struct { Data []int32 // size: xgb.Pad((int(N) * 4)) } -// Waits and reads reply data from request GetQueryObjectivARB +// Reply blocks and returns the reply data for a GetQueryObjectivARB request. func (cook GetQueryObjectivARBCookie) Reply() (*GetQueryObjectivARBReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -9005,7 +9367,7 @@ func (cook GetQueryObjectivARBCookie) Reply() (*GetQueryObjectivARBReply, error) return getQueryObjectivARBReply(buf), nil } -// Read reply into structure from buffer for GetQueryObjectivARB +// getQueryObjectivARBReply reads a byte slice into a GetQueryObjectivARBReply value. func getQueryObjectivARBReply(buf []byte) *GetQueryObjectivARBReply { v := new(GetQueryObjectivARBReply) b := 1 // skip reply determinant @@ -9039,6 +9401,7 @@ func getQueryObjectivARBReply(buf []byte) *GetQueryObjectivARBReply { } // Write request to wire for GetQueryObjectivARB +// getQueryObjectivARBRequest writes a GetQueryObjectivARB request to a byte slice. func getQueryObjectivARBRequest(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) []byte { size := 16 b := 0 @@ -9065,29 +9428,31 @@ func getQueryObjectivARBRequest(c *xgb.Conn, ContextTag ContextTag, Id uint32, P return buf } -// Request GetQueryObjectuivARB -// size: 16 +// GetQueryObjectuivARBCookie is a cookie used only for GetQueryObjectuivARB requests. type GetQueryObjectuivARBCookie struct { *xgb.Cookie } +// GetQueryObjectuivARB sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetQueryObjectuivARBCookie.Reply() func GetQueryObjectuivARB(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) GetQueryObjectuivARBCookie { cookie := c.NewCookie(true, true) c.NewRequest(getQueryObjectuivARBRequest(c, ContextTag, Id, Pname), cookie) return GetQueryObjectuivARBCookie{cookie} } +// GetQueryObjectuivARBUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetQueryObjectuivARBUnchecked(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) GetQueryObjectuivARBCookie { cookie := c.NewCookie(false, true) c.NewRequest(getQueryObjectuivARBRequest(c, ContextTag, Id, Pname), cookie) return GetQueryObjectuivARBCookie{cookie} } -// Request reply for GetQueryObjectuivARB -// size: (32 + xgb.Pad((int(N) * 4))) +// GetQueryObjectuivARBReply represents the data returned from a GetQueryObjectuivARB request. type GetQueryObjectuivARBReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 4 bytes N uint32 @@ -9096,7 +9461,7 @@ type GetQueryObjectuivARBReply struct { Data []uint32 // size: xgb.Pad((int(N) * 4)) } -// Waits and reads reply data from request GetQueryObjectuivARB +// Reply blocks and returns the reply data for a GetQueryObjectuivARB request. func (cook GetQueryObjectuivARBCookie) Reply() (*GetQueryObjectuivARBReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -9108,7 +9473,7 @@ func (cook GetQueryObjectuivARBCookie) Reply() (*GetQueryObjectuivARBReply, erro return getQueryObjectuivARBReply(buf), nil } -// Read reply into structure from buffer for GetQueryObjectuivARB +// getQueryObjectuivARBReply reads a byte slice into a GetQueryObjectuivARBReply value. func getQueryObjectuivARBReply(buf []byte) *GetQueryObjectuivARBReply { v := new(GetQueryObjectuivARBReply) b := 1 // skip reply determinant @@ -9142,6 +9507,7 @@ func getQueryObjectuivARBReply(buf []byte) *GetQueryObjectuivARBReply { } // Write request to wire for GetQueryObjectuivARB +// getQueryObjectuivARBRequest writes a GetQueryObjectuivARB request to a byte slice. func getQueryObjectuivARBRequest(c *xgb.Conn, ContextTag ContextTag, Id uint32, Pname uint32) []byte { size := 16 b := 0 diff --git a/nexgb/randr/randr.go b/nexgb/randr/randr.go index ba8c0f2..35de3bf 100644 --- a/nexgb/randr/randr.go +++ b/nexgb/randr/randr.go @@ -2,7 +2,7 @@ package randr /* - This file was generated by randr.xml on May 10 2012 8:04:31pm EDT. + This file was generated by randr.xml on May 10 2012 11:56:19pm EDT. This file is automatically generated. Edit at your peril! */ @@ -41,6 +41,12 @@ func init() { xgb.NewExtErrorFuncs["RANDR"] = make(map[int]xgb.NewErrorFun) } +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + // Skipping definition for base type 'Void' // Skipping definition for base type 'Byte' @@ -59,12 +65,6 @@ func init() { // Skipping definition for base type 'Float' -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - const ( RotationRotate0 = 1 RotationRotate90 = 2 @@ -147,8 +147,6 @@ func NewOutputId(c *xgb.Conn) (Output, error) { return Output(id), nil } -// 'ScreenSize' struct definition -// Size: 8 type ScreenSize struct { Width uint16 Height uint16 @@ -156,7 +154,7 @@ type ScreenSize struct { Mheight uint16 } -// Struct read ScreenSize +// ScreenSizeRead reads a byte slice into a ScreenSize value. func ScreenSizeRead(buf []byte, v *ScreenSize) int { b := 0 @@ -175,7 +173,7 @@ func ScreenSizeRead(buf []byte, v *ScreenSize) int { return b } -// Struct list read ScreenSize +// ScreenSizeReadList reads a byte slice into a list of ScreenSize values. func ScreenSizeReadList(buf []byte, dest []ScreenSize) int { b := 0 for i := 0; i < len(dest); i++ { @@ -185,7 +183,7 @@ func ScreenSizeReadList(buf []byte, dest []ScreenSize) int { return xgb.Pad(b) } -// Struct write ScreenSize +// Bytes writes a ScreenSize value to a byte slice. func (v ScreenSize) Bytes() []byte { buf := make([]byte, 8) b := 0 @@ -205,7 +203,7 @@ func (v ScreenSize) Bytes() []byte { return buf } -// Write struct list ScreenSize +// ScreenSizeListBytes writes a list of %s(MISSING) values to a byte slice. func ScreenSizeListBytes(buf []byte, list []ScreenSize) int { b := 0 var structBytes []byte @@ -217,14 +215,12 @@ func ScreenSizeListBytes(buf []byte, list []ScreenSize) int { return b } -// 'RefreshRates' struct definition -// Size: (2 + xgb.Pad((int(NRates) * 2))) type RefreshRates struct { NRates uint16 Rates []uint16 // size: xgb.Pad((int(NRates) * 2)) } -// Struct read RefreshRates +// RefreshRatesRead reads a byte slice into a RefreshRates value. func RefreshRatesRead(buf []byte, v *RefreshRates) int { b := 0 @@ -241,7 +237,7 @@ func RefreshRatesRead(buf []byte, v *RefreshRates) int { return b } -// Struct list read RefreshRates +// RefreshRatesReadList reads a byte slice into a list of RefreshRates values. func RefreshRatesReadList(buf []byte, dest []RefreshRates) int { b := 0 for i := 0; i < len(dest); i++ { @@ -251,7 +247,7 @@ func RefreshRatesReadList(buf []byte, dest []RefreshRates) int { return xgb.Pad(b) } -// Struct write RefreshRates +// Bytes writes a RefreshRates value to a byte slice. func (v RefreshRates) Bytes() []byte { buf := make([]byte, (2 + xgb.Pad((int(v.NRates) * 2)))) b := 0 @@ -268,7 +264,7 @@ func (v RefreshRates) Bytes() []byte { return buf } -// Write struct list RefreshRates +// RefreshRatesListBytes writes a list of %s(MISSING) values to a byte slice. func RefreshRatesListBytes(buf []byte, list []RefreshRates) int { b := 0 var structBytes []byte @@ -280,7 +276,7 @@ func RefreshRatesListBytes(buf []byte, list []RefreshRates) int { return b } -// Struct list size RefreshRates +// RefreshRatesListSize computes the size (bytes) of a list of RefreshRates values. func RefreshRatesListSize(list []RefreshRates) int { size := 0 for _, item := range list { @@ -289,8 +285,6 @@ func RefreshRatesListSize(list []RefreshRates) int { return size } -// 'ModeInfo' struct definition -// Size: 32 type ModeInfo struct { Id uint32 Width uint16 @@ -307,7 +301,7 @@ type ModeInfo struct { ModeFlags uint32 } -// Struct read ModeInfo +// ModeInfoRead reads a byte slice into a ModeInfo value. func ModeInfoRead(buf []byte, v *ModeInfo) int { b := 0 @@ -353,7 +347,7 @@ func ModeInfoRead(buf []byte, v *ModeInfo) int { return b } -// Struct list read ModeInfo +// ModeInfoReadList reads a byte slice into a list of ModeInfo values. func ModeInfoReadList(buf []byte, dest []ModeInfo) int { b := 0 for i := 0; i < len(dest); i++ { @@ -363,7 +357,7 @@ func ModeInfoReadList(buf []byte, dest []ModeInfo) int { return xgb.Pad(b) } -// Struct write ModeInfo +// Bytes writes a ModeInfo value to a byte slice. func (v ModeInfo) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -410,7 +404,7 @@ func (v ModeInfo) Bytes() []byte { return buf } -// Write struct list ModeInfo +// ModeInfoListBytes writes a list of %s(MISSING) values to a byte slice. func ModeInfoListBytes(buf []byte, list []ModeInfo) int { b := 0 var structBytes []byte @@ -422,8 +416,6 @@ func ModeInfoListBytes(buf []byte, list []ModeInfo) int { return b } -// 'CrtcChange' struct definition -// Size: 28 type CrtcChange struct { Timestamp xproto.Timestamp Window xproto.Window @@ -437,7 +429,7 @@ type CrtcChange struct { Height uint16 } -// Struct read CrtcChange +// CrtcChangeRead reads a byte slice into a CrtcChange value. func CrtcChangeRead(buf []byte, v *CrtcChange) int { b := 0 @@ -473,7 +465,7 @@ func CrtcChangeRead(buf []byte, v *CrtcChange) int { return b } -// Struct list read CrtcChange +// CrtcChangeReadList reads a byte slice into a list of CrtcChange values. func CrtcChangeReadList(buf []byte, dest []CrtcChange) int { b := 0 for i := 0; i < len(dest); i++ { @@ -483,7 +475,7 @@ func CrtcChangeReadList(buf []byte, dest []CrtcChange) int { return xgb.Pad(b) } -// Struct write CrtcChange +// Bytes writes a CrtcChange value to a byte slice. func (v CrtcChange) Bytes() []byte { buf := make([]byte, 28) b := 0 @@ -520,7 +512,7 @@ func (v CrtcChange) Bytes() []byte { return buf } -// Write struct list CrtcChange +// CrtcChangeListBytes writes a list of %s(MISSING) values to a byte slice. func CrtcChangeListBytes(buf []byte, list []CrtcChange) int { b := 0 var structBytes []byte @@ -532,8 +524,6 @@ func CrtcChangeListBytes(buf []byte, list []CrtcChange) int { return b } -// 'OutputChange' struct definition -// Size: 28 type OutputChange struct { Timestamp xproto.Timestamp ConfigTimestamp xproto.Timestamp @@ -546,7 +536,7 @@ type OutputChange struct { SubpixelOrder byte } -// Struct read OutputChange +// OutputChangeRead reads a byte slice into a OutputChange value. func OutputChangeRead(buf []byte, v *OutputChange) int { b := 0 @@ -580,7 +570,7 @@ func OutputChangeRead(buf []byte, v *OutputChange) int { return b } -// Struct list read OutputChange +// OutputChangeReadList reads a byte slice into a list of OutputChange values. func OutputChangeReadList(buf []byte, dest []OutputChange) int { b := 0 for i := 0; i < len(dest); i++ { @@ -590,7 +580,7 @@ func OutputChangeReadList(buf []byte, dest []OutputChange) int { return xgb.Pad(b) } -// Struct write OutputChange +// Bytes writes a OutputChange value to a byte slice. func (v OutputChange) Bytes() []byte { buf := make([]byte, 28) b := 0 @@ -625,7 +615,7 @@ func (v OutputChange) Bytes() []byte { return buf } -// Write struct list OutputChange +// OutputChangeListBytes writes a list of %s(MISSING) values to a byte slice. func OutputChangeListBytes(buf []byte, list []OutputChange) int { b := 0 var structBytes []byte @@ -637,8 +627,6 @@ func OutputChangeListBytes(buf []byte, list []OutputChange) int { return b } -// 'OutputProperty' struct definition -// Size: 28 type OutputProperty struct { Window xproto.Window Output Output @@ -648,7 +636,7 @@ type OutputProperty struct { // padding: 11 bytes } -// Struct read OutputProperty +// OutputPropertyRead reads a byte slice into a OutputProperty value. func OutputPropertyRead(buf []byte, v *OutputProperty) int { b := 0 @@ -672,7 +660,7 @@ func OutputPropertyRead(buf []byte, v *OutputProperty) int { return b } -// Struct list read OutputProperty +// OutputPropertyReadList reads a byte slice into a list of OutputProperty values. func OutputPropertyReadList(buf []byte, dest []OutputProperty) int { b := 0 for i := 0; i < len(dest); i++ { @@ -682,7 +670,7 @@ func OutputPropertyReadList(buf []byte, dest []OutputProperty) int { return xgb.Pad(b) } -// Struct write OutputProperty +// Bytes writes a OutputProperty value to a byte slice. func (v OutputProperty) Bytes() []byte { buf := make([]byte, 28) b := 0 @@ -707,7 +695,7 @@ func (v OutputProperty) Bytes() []byte { return buf } -// Write struct list OutputProperty +// OutputPropertyListBytes writes a list of %s(MISSING) values to a byte slice. func OutputPropertyListBytes(buf []byte, list []OutputProperty) int { b := 0 var structBytes []byte @@ -719,7 +707,7 @@ func OutputPropertyListBytes(buf []byte, list []OutputProperty) int { return b } -// Union definition NotifyDataUnion +// NotifyDataUnion is a represention of the NotifyDataUnion union type. // Note that to *create* a Union, you should *never* create // this struct directly (unless you know what you're doing). // Instead use one of the following constructors for 'NotifyDataUnion': @@ -732,7 +720,7 @@ type NotifyDataUnion struct { Op OutputProperty } -// Union constructor for NotifyDataUnion for field Cc. +// NotifyDataUnionCcNew constructs a new NotifyDataUnion union type with the Cc field. func NotifyDataUnionCcNew(Cc CrtcChange) NotifyDataUnion { var b int buf := make([]byte, 28) @@ -763,7 +751,7 @@ func NotifyDataUnionCcNew(Cc CrtcChange) NotifyDataUnion { return v } -// Union constructor for NotifyDataUnion for field Oc. +// NotifyDataUnionOcNew constructs a new NotifyDataUnion union type with the Oc field. func NotifyDataUnionOcNew(Oc OutputChange) NotifyDataUnion { var b int buf := make([]byte, 28) @@ -794,7 +782,7 @@ func NotifyDataUnionOcNew(Oc OutputChange) NotifyDataUnion { return v } -// Union constructor for NotifyDataUnion for field Op. +// NotifyDataUnionOpNew constructs a new NotifyDataUnion union type with the Op field. func NotifyDataUnionOpNew(Op OutputProperty) NotifyDataUnion { var b int buf := make([]byte, 28) @@ -825,7 +813,7 @@ func NotifyDataUnionOpNew(Op OutputProperty) NotifyDataUnion { return v } -// Union read NotifyDataUnion +// NotifyDataUnionRead reads a byte slice into a NotifyDataUnion value. func NotifyDataUnionRead(buf []byte, v *NotifyDataUnion) int { var b int @@ -844,7 +832,7 @@ func NotifyDataUnionRead(buf []byte, v *NotifyDataUnion) int { return 28 } -// Union list read NotifyDataUnion +// NotifyDataUnionReadList reads a byte slice into a list of NotifyDataUnion values. func NotifyDataUnionReadList(buf []byte, dest []NotifyDataUnion) int { b := 0 for i := 0; i < len(dest); i++ { @@ -854,7 +842,7 @@ func NotifyDataUnionReadList(buf []byte, dest []NotifyDataUnion) int { return xgb.Pad(b) } -// Union write NotifyDataUnion +// Bytes writes a NotifyDataUnion value to a byte slice. // Each field in a union must contain the same data. // So simply pick the first field and write that to the wire. func (v NotifyDataUnion) Bytes() []byte { @@ -869,7 +857,7 @@ func (v NotifyDataUnion) Bytes() []byte { return buf } -// Union list write NotifyDataUnion +// NotifyDataUnionListBytes writes a list of %s(MISSING) values to a byte slice. func NotifyDataUnionListBytes(buf []byte, list []NotifyDataUnion) int { b := 0 var unionBytes []byte @@ -881,9 +869,7 @@ func NotifyDataUnionListBytes(buf []byte, list []NotifyDataUnion) int { return b } -// Event definition ScreenChangeNotify (0) -// Size: 32 - +// ScreenChangeNotify is the event number for a ScreenChangeNotifyEvent. const ScreenChangeNotify = 0 type ScreenChangeNotifyEvent struct { @@ -901,7 +887,7 @@ type ScreenChangeNotifyEvent struct { Mheight uint16 } -// Event read ScreenChangeNotify +// ScreenChangeNotifyEventNew constructs a ScreenChangeNotifyEvent value that implements xgb.Event from a byte slice. func ScreenChangeNotifyEventNew(buf []byte) xgb.Event { v := ScreenChangeNotifyEvent{} b := 1 // don't read event number @@ -945,7 +931,7 @@ func ScreenChangeNotifyEventNew(buf []byte) xgb.Event { return v } -// Event write ScreenChangeNotify +// Bytes writes a ScreenChangeNotifyEvent value to a byte slice. func (v ScreenChangeNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -992,12 +978,14 @@ func (v ScreenChangeNotifyEvent) Bytes() []byte { return buf } -func (v ScreenChangeNotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the ScreenChangeNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v ScreenChangeNotifyEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of ScreenChangeNotifyEvent. func (v ScreenChangeNotifyEvent) String() string { fieldVals := make([]string, 0, 11) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -1019,9 +1007,7 @@ func init() { xgb.NewExtEventFuncs["RANDR"][0] = ScreenChangeNotifyEventNew } -// Event definition Notify (1) -// Size: 32 - +// Notify is the event number for a NotifyEvent. const Notify = 1 type NotifyEvent struct { @@ -1030,7 +1016,7 @@ type NotifyEvent struct { U NotifyDataUnion } -// Event read Notify +// NotifyEventNew constructs a NotifyEvent value that implements xgb.Event from a byte slice. func NotifyEventNew(buf []byte) xgb.Event { v := NotifyEvent{} b := 1 // don't read event number @@ -1047,7 +1033,7 @@ func NotifyEventNew(buf []byte) xgb.Event { return v } -// Event write Notify +// Bytes writes a NotifyEvent value to a byte slice. func (v NotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -1070,12 +1056,14 @@ func (v NotifyEvent) Bytes() []byte { return buf } -func (v NotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the Notify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v NotifyEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of NotifyEvent. func (v NotifyEvent) String() string { fieldVals := make([]string, 0, 2) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -1087,9 +1075,7 @@ func init() { xgb.NewExtEventFuncs["RANDR"][1] = NotifyEventNew } -// Error definition BadOutput (0) -// Size: 32 - +// BadBadOutput is the error number for a BadBadOutput. const BadBadOutput = 0 type BadOutputError struct { @@ -1097,7 +1083,7 @@ type BadOutputError struct { NiceName string } -// Error read BadOutput +// BadOutputErrorNew constructs a BadOutputError value that implements xgb.Error from a byte slice. func BadOutputErrorNew(buf []byte) xgb.Error { v := BadOutputError{} v.NiceName = "BadOutput" @@ -1111,8 +1097,8 @@ func BadOutputErrorNew(buf []byte) xgb.Error { return v } -func (err BadOutputError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadBadOutput error. +// This is mostly used internally. func (err BadOutputError) SequenceId() uint16 { return err.Sequence } @@ -1132,9 +1118,7 @@ func init() { xgb.NewExtErrorFuncs["RANDR"][0] = BadOutputErrorNew } -// Error definition BadCrtc (1) -// Size: 32 - +// BadBadCrtc is the error number for a BadBadCrtc. const BadBadCrtc = 1 type BadCrtcError struct { @@ -1142,7 +1126,7 @@ type BadCrtcError struct { NiceName string } -// Error read BadCrtc +// BadCrtcErrorNew constructs a BadCrtcError value that implements xgb.Error from a byte slice. func BadCrtcErrorNew(buf []byte) xgb.Error { v := BadCrtcError{} v.NiceName = "BadCrtc" @@ -1156,8 +1140,8 @@ func BadCrtcErrorNew(buf []byte) xgb.Error { return v } -func (err BadCrtcError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadBadCrtc error. +// This is mostly used internally. func (err BadCrtcError) SequenceId() uint16 { return err.Sequence } @@ -1177,9 +1161,7 @@ func init() { xgb.NewExtErrorFuncs["RANDR"][1] = BadCrtcErrorNew } -// Error definition BadMode (2) -// Size: 32 - +// BadBadMode is the error number for a BadBadMode. const BadBadMode = 2 type BadModeError struct { @@ -1187,7 +1169,7 @@ type BadModeError struct { NiceName string } -// Error read BadMode +// BadModeErrorNew constructs a BadModeError value that implements xgb.Error from a byte slice. func BadModeErrorNew(buf []byte) xgb.Error { v := BadModeError{} v.NiceName = "BadMode" @@ -1201,8 +1183,8 @@ func BadModeErrorNew(buf []byte) xgb.Error { return v } -func (err BadModeError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadBadMode error. +// This is mostly used internally. func (err BadModeError) SequenceId() uint16 { return err.Sequence } @@ -1222,36 +1204,38 @@ func init() { xgb.NewExtErrorFuncs["RANDR"][2] = BadModeErrorNew } -// Request QueryVersion -// size: 12 +// QueryVersionCookie is a cookie used only for QueryVersion requests. type QueryVersionCookie struct { *xgb.Cookie } +// QueryVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() func QueryVersion(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) return QueryVersionCookie{cookie} } +// QueryVersionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryVersionUnchecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) return QueryVersionCookie{cookie} } -// Request reply for QueryVersion -// size: 32 +// QueryVersionReply represents the data returned from a QueryVersion request. type QueryVersionReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes MajorVersion uint32 MinorVersion uint32 // padding: 16 bytes } -// Waits and reads reply data from request QueryVersion +// Reply blocks and returns the reply data for a QueryVersion request. func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1263,7 +1247,7 @@ func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { return queryVersionReply(buf), nil } -// Read reply into structure from buffer for QueryVersion +// queryVersionReply reads a byte slice into a QueryVersionReply value. func queryVersionReply(buf []byte) *QueryVersionReply { v := new(QueryVersionReply) b := 1 // skip reply determinant @@ -1288,6 +1272,7 @@ func queryVersionReply(buf []byte) *QueryVersionReply { } // Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. func queryVersionRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) []byte { size := 12 b := 0 @@ -1311,29 +1296,31 @@ func queryVersionRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) return buf } -// Request SetScreenConfig -// size: 24 +// SetScreenConfigCookie is a cookie used only for SetScreenConfig requests. type SetScreenConfigCookie struct { *xgb.Cookie } +// SetScreenConfig sends a checked request. +// If an error occurs, it will be returned with the reply by calling SetScreenConfigCookie.Reply() func SetScreenConfig(c *xgb.Conn, Window xproto.Window, Timestamp xproto.Timestamp, ConfigTimestamp xproto.Timestamp, SizeID uint16, Rotation uint16, Rate uint16) SetScreenConfigCookie { cookie := c.NewCookie(true, true) c.NewRequest(setScreenConfigRequest(c, Window, Timestamp, ConfigTimestamp, SizeID, Rotation, Rate), cookie) return SetScreenConfigCookie{cookie} } +// SetScreenConfigUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetScreenConfigUnchecked(c *xgb.Conn, Window xproto.Window, Timestamp xproto.Timestamp, ConfigTimestamp xproto.Timestamp, SizeID uint16, Rotation uint16, Rate uint16) SetScreenConfigCookie { cookie := c.NewCookie(false, true) c.NewRequest(setScreenConfigRequest(c, Window, Timestamp, ConfigTimestamp, SizeID, Rotation, Rate), cookie) return SetScreenConfigCookie{cookie} } -// Request reply for SetScreenConfig -// size: 32 +// SetScreenConfigReply represents the data returned from a SetScreenConfig request. type SetScreenConfigReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply Status byte NewTimestamp xproto.Timestamp ConfigTimestamp xproto.Timestamp @@ -1342,7 +1329,7 @@ type SetScreenConfigReply struct { // padding: 10 bytes } -// Waits and reads reply data from request SetScreenConfig +// Reply blocks and returns the reply data for a SetScreenConfig request. func (cook SetScreenConfigCookie) Reply() (*SetScreenConfigReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1354,7 +1341,7 @@ func (cook SetScreenConfigCookie) Reply() (*SetScreenConfigReply, error) { return setScreenConfigReply(buf), nil } -// Read reply into structure from buffer for SetScreenConfig +// setScreenConfigReply reads a byte slice into a SetScreenConfigReply value. func setScreenConfigReply(buf []byte) *SetScreenConfigReply { v := new(SetScreenConfigReply) b := 1 // skip reply determinant @@ -1386,6 +1373,7 @@ func setScreenConfigReply(buf []byte) *SetScreenConfigReply { } // Write request to wire for SetScreenConfig +// setScreenConfigRequest writes a SetScreenConfig request to a byte slice. func setScreenConfigRequest(c *xgb.Conn, Window xproto.Window, Timestamp xproto.Timestamp, ConfigTimestamp xproto.Timestamp, SizeID uint16, Rotation uint16, Rate uint16) []byte { size := 24 b := 0 @@ -1423,30 +1411,35 @@ func setScreenConfigRequest(c *xgb.Conn, Window xproto.Window, Timestamp xproto. return buf } -// Request SelectInput -// size: 12 +// SelectInputCookie is a cookie used only for SelectInput requests. type SelectInputCookie struct { *xgb.Cookie } -// Write request to wire for SelectInput +// SelectInput sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SelectInput(c *xgb.Conn, Window xproto.Window, Enable uint16) SelectInputCookie { cookie := c.NewCookie(false, false) c.NewRequest(selectInputRequest(c, Window, Enable), cookie) return SelectInputCookie{cookie} } +// SelectInputChecked sends a checked request. +// If an error occurs, it can be retrieved using SelectInputCookie.Check() func SelectInputChecked(c *xgb.Conn, Window xproto.Window, Enable uint16) SelectInputCookie { cookie := c.NewCookie(true, false) c.NewRequest(selectInputRequest(c, Window, Enable), cookie) return SelectInputCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SelectInputCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SelectInput +// selectInputRequest writes a SelectInput request to a byte slice. func selectInputRequest(c *xgb.Conn, Window xproto.Window, Enable uint16) []byte { size := 12 b := 0 @@ -1472,29 +1465,31 @@ func selectInputRequest(c *xgb.Conn, Window xproto.Window, Enable uint16) []byte return buf } -// Request GetScreenInfo -// size: 8 +// GetScreenInfoCookie is a cookie used only for GetScreenInfo requests. type GetScreenInfoCookie struct { *xgb.Cookie } +// GetScreenInfo sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetScreenInfoCookie.Reply() func GetScreenInfo(c *xgb.Conn, Window xproto.Window) GetScreenInfoCookie { cookie := c.NewCookie(true, true) c.NewRequest(getScreenInfoRequest(c, Window), cookie) return GetScreenInfoCookie{cookie} } +// GetScreenInfoUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetScreenInfoUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenInfoCookie { cookie := c.NewCookie(false, true) c.NewRequest(getScreenInfoRequest(c, Window), cookie) return GetScreenInfoCookie{cookie} } -// Request reply for GetScreenInfo -// size: ((32 + xgb.Pad((int(NSizes) * 8))) + RefreshRatesListSize(Rates)) +// GetScreenInfoReply represents the data returned from a GetScreenInfo request. type GetScreenInfoReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply Rotations byte Root xproto.Window Timestamp xproto.Timestamp @@ -1509,7 +1504,7 @@ type GetScreenInfoReply struct { Rates []RefreshRates // size: RefreshRatesListSize(Rates) } -// Waits and reads reply data from request GetScreenInfo +// Reply blocks and returns the reply data for a GetScreenInfo request. func (cook GetScreenInfoCookie) Reply() (*GetScreenInfoReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1521,7 +1516,7 @@ func (cook GetScreenInfoCookie) Reply() (*GetScreenInfoReply, error) { return getScreenInfoReply(buf), nil } -// Read reply into structure from buffer for GetScreenInfo +// getScreenInfoReply reads a byte slice into a GetScreenInfoReply value. func getScreenInfoReply(buf []byte) *GetScreenInfoReply { v := new(GetScreenInfoReply) b := 1 // skip reply determinant @@ -1571,6 +1566,7 @@ func getScreenInfoReply(buf []byte) *GetScreenInfoReply { } // Write request to wire for GetScreenInfo +// getScreenInfoRequest writes a GetScreenInfo request to a byte slice. func getScreenInfoRequest(c *xgb.Conn, Window xproto.Window) []byte { size := 8 b := 0 @@ -1591,29 +1587,31 @@ func getScreenInfoRequest(c *xgb.Conn, Window xproto.Window) []byte { return buf } -// Request GetScreenSizeRange -// size: 8 +// GetScreenSizeRangeCookie is a cookie used only for GetScreenSizeRange requests. type GetScreenSizeRangeCookie struct { *xgb.Cookie } +// GetScreenSizeRange sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetScreenSizeRangeCookie.Reply() func GetScreenSizeRange(c *xgb.Conn, Window xproto.Window) GetScreenSizeRangeCookie { cookie := c.NewCookie(true, true) c.NewRequest(getScreenSizeRangeRequest(c, Window), cookie) return GetScreenSizeRangeCookie{cookie} } +// GetScreenSizeRangeUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetScreenSizeRangeUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenSizeRangeCookie { cookie := c.NewCookie(false, true) c.NewRequest(getScreenSizeRangeRequest(c, Window), cookie) return GetScreenSizeRangeCookie{cookie} } -// Request reply for GetScreenSizeRange -// size: 32 +// GetScreenSizeRangeReply represents the data returned from a GetScreenSizeRange request. type GetScreenSizeRangeReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes MinWidth uint16 MinHeight uint16 @@ -1622,7 +1620,7 @@ type GetScreenSizeRangeReply struct { // padding: 16 bytes } -// Waits and reads reply data from request GetScreenSizeRange +// Reply blocks and returns the reply data for a GetScreenSizeRange request. func (cook GetScreenSizeRangeCookie) Reply() (*GetScreenSizeRangeReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1634,7 +1632,7 @@ func (cook GetScreenSizeRangeCookie) Reply() (*GetScreenSizeRangeReply, error) { return getScreenSizeRangeReply(buf), nil } -// Read reply into structure from buffer for GetScreenSizeRange +// getScreenSizeRangeReply reads a byte slice into a GetScreenSizeRangeReply value. func getScreenSizeRangeReply(buf []byte) *GetScreenSizeRangeReply { v := new(GetScreenSizeRangeReply) b := 1 // skip reply determinant @@ -1665,6 +1663,7 @@ func getScreenSizeRangeReply(buf []byte) *GetScreenSizeRangeReply { } // Write request to wire for GetScreenSizeRange +// getScreenSizeRangeRequest writes a GetScreenSizeRange request to a byte slice. func getScreenSizeRangeRequest(c *xgb.Conn, Window xproto.Window) []byte { size := 8 b := 0 @@ -1685,30 +1684,35 @@ func getScreenSizeRangeRequest(c *xgb.Conn, Window xproto.Window) []byte { return buf } -// Request SetScreenSize -// size: 20 +// SetScreenSizeCookie is a cookie used only for SetScreenSize requests. type SetScreenSizeCookie struct { *xgb.Cookie } -// Write request to wire for SetScreenSize +// SetScreenSize sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetScreenSize(c *xgb.Conn, Window xproto.Window, Width uint16, Height uint16, MmWidth uint32, MmHeight uint32) SetScreenSizeCookie { cookie := c.NewCookie(false, false) c.NewRequest(setScreenSizeRequest(c, Window, Width, Height, MmWidth, MmHeight), cookie) return SetScreenSizeCookie{cookie} } +// SetScreenSizeChecked sends a checked request. +// If an error occurs, it can be retrieved using SetScreenSizeCookie.Check() func SetScreenSizeChecked(c *xgb.Conn, Window xproto.Window, Width uint16, Height uint16, MmWidth uint32, MmHeight uint32) SetScreenSizeCookie { cookie := c.NewCookie(true, false) c.NewRequest(setScreenSizeRequest(c, Window, Width, Height, MmWidth, MmHeight), cookie) return SetScreenSizeCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetScreenSizeCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetScreenSize +// setScreenSizeRequest writes a SetScreenSize request to a byte slice. func setScreenSizeRequest(c *xgb.Conn, Window xproto.Window, Width uint16, Height uint16, MmWidth uint32, MmHeight uint32) []byte { size := 20 b := 0 @@ -1741,29 +1745,31 @@ func setScreenSizeRequest(c *xgb.Conn, Window xproto.Window, Width uint16, Heigh return buf } -// Request GetScreenResources -// size: 8 +// GetScreenResourcesCookie is a cookie used only for GetScreenResources requests. type GetScreenResourcesCookie struct { *xgb.Cookie } +// GetScreenResources sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetScreenResourcesCookie.Reply() func GetScreenResources(c *xgb.Conn, Window xproto.Window) GetScreenResourcesCookie { cookie := c.NewCookie(true, true) c.NewRequest(getScreenResourcesRequest(c, Window), cookie) return GetScreenResourcesCookie{cookie} } +// GetScreenResourcesUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetScreenResourcesUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenResourcesCookie { cookie := c.NewCookie(false, true) c.NewRequest(getScreenResourcesRequest(c, Window), cookie) return GetScreenResourcesCookie{cookie} } -// Request reply for GetScreenResources -// size: ((((32 + xgb.Pad((int(NumCrtcs) * 4))) + xgb.Pad((int(NumOutputs) * 4))) + xgb.Pad((int(NumModes) * 32))) + xgb.Pad((int(NamesLen) * 1))) +// GetScreenResourcesReply represents the data returned from a GetScreenResources request. type GetScreenResourcesReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Timestamp xproto.Timestamp ConfigTimestamp xproto.Timestamp @@ -1778,7 +1784,7 @@ type GetScreenResourcesReply struct { Names []byte // size: xgb.Pad((int(NamesLen) * 1)) } -// Waits and reads reply data from request GetScreenResources +// Reply blocks and returns the reply data for a GetScreenResources request. func (cook GetScreenResourcesCookie) Reply() (*GetScreenResourcesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1790,7 +1796,7 @@ func (cook GetScreenResourcesCookie) Reply() (*GetScreenResourcesReply, error) { return getScreenResourcesReply(buf), nil } -// Read reply into structure from buffer for GetScreenResources +// getScreenResourcesReply reads a byte slice into a GetScreenResourcesReply value. func getScreenResourcesReply(buf []byte) *GetScreenResourcesReply { v := new(GetScreenResourcesReply) b := 1 // skip reply determinant @@ -1848,6 +1854,7 @@ func getScreenResourcesReply(buf []byte) *GetScreenResourcesReply { } // Write request to wire for GetScreenResources +// getScreenResourcesRequest writes a GetScreenResources request to a byte slice. func getScreenResourcesRequest(c *xgb.Conn, Window xproto.Window) []byte { size := 8 b := 0 @@ -1868,29 +1875,31 @@ func getScreenResourcesRequest(c *xgb.Conn, Window xproto.Window) []byte { return buf } -// Request GetOutputInfo -// size: 12 +// GetOutputInfoCookie is a cookie used only for GetOutputInfo requests. type GetOutputInfoCookie struct { *xgb.Cookie } +// GetOutputInfo sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetOutputInfoCookie.Reply() func GetOutputInfo(c *xgb.Conn, Output Output, ConfigTimestamp xproto.Timestamp) GetOutputInfoCookie { cookie := c.NewCookie(true, true) c.NewRequest(getOutputInfoRequest(c, Output, ConfigTimestamp), cookie) return GetOutputInfoCookie{cookie} } +// GetOutputInfoUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetOutputInfoUnchecked(c *xgb.Conn, Output Output, ConfigTimestamp xproto.Timestamp) GetOutputInfoCookie { cookie := c.NewCookie(false, true) c.NewRequest(getOutputInfoRequest(c, Output, ConfigTimestamp), cookie) return GetOutputInfoCookie{cookie} } -// Request reply for GetOutputInfo -// size: ((((36 + xgb.Pad((int(NumCrtcs) * 4))) + xgb.Pad((int(NumModes) * 4))) + xgb.Pad((int(NumClones) * 4))) + xgb.Pad((int(NameLen) * 1))) +// GetOutputInfoReply represents the data returned from a GetOutputInfo request. type GetOutputInfoReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply Status byte Timestamp xproto.Timestamp Crtc Crtc @@ -1909,7 +1918,7 @@ type GetOutputInfoReply struct { Name []byte // size: xgb.Pad((int(NameLen) * 1)) } -// Waits and reads reply data from request GetOutputInfo +// Reply blocks and returns the reply data for a GetOutputInfo request. func (cook GetOutputInfoCookie) Reply() (*GetOutputInfoReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1921,7 +1930,7 @@ func (cook GetOutputInfoCookie) Reply() (*GetOutputInfoReply, error) { return getOutputInfoReply(buf), nil } -// Read reply into structure from buffer for GetOutputInfo +// getOutputInfoReply reads a byte slice into a GetOutputInfoReply value. func getOutputInfoReply(buf []byte) *GetOutputInfoReply { v := new(GetOutputInfoReply) b := 1 // skip reply determinant @@ -1997,6 +2006,7 @@ func getOutputInfoReply(buf []byte) *GetOutputInfoReply { } // Write request to wire for GetOutputInfo +// getOutputInfoRequest writes a GetOutputInfo request to a byte slice. func getOutputInfoRequest(c *xgb.Conn, Output Output, ConfigTimestamp xproto.Timestamp) []byte { size := 12 b := 0 @@ -2020,36 +2030,38 @@ func getOutputInfoRequest(c *xgb.Conn, Output Output, ConfigTimestamp xproto.Tim return buf } -// Request ListOutputProperties -// size: 8 +// ListOutputPropertiesCookie is a cookie used only for ListOutputProperties requests. type ListOutputPropertiesCookie struct { *xgb.Cookie } +// ListOutputProperties sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListOutputPropertiesCookie.Reply() func ListOutputProperties(c *xgb.Conn, Output Output) ListOutputPropertiesCookie { cookie := c.NewCookie(true, true) c.NewRequest(listOutputPropertiesRequest(c, Output), cookie) return ListOutputPropertiesCookie{cookie} } +// ListOutputPropertiesUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ListOutputPropertiesUnchecked(c *xgb.Conn, Output Output) ListOutputPropertiesCookie { cookie := c.NewCookie(false, true) c.NewRequest(listOutputPropertiesRequest(c, Output), cookie) return ListOutputPropertiesCookie{cookie} } -// Request reply for ListOutputProperties -// size: (32 + xgb.Pad((int(NumAtoms) * 4))) +// ListOutputPropertiesReply represents the data returned from a ListOutputProperties request. type ListOutputPropertiesReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes NumAtoms uint16 // padding: 22 bytes Atoms []xproto.Atom // size: xgb.Pad((int(NumAtoms) * 4)) } -// Waits and reads reply data from request ListOutputProperties +// Reply blocks and returns the reply data for a ListOutputProperties request. func (cook ListOutputPropertiesCookie) Reply() (*ListOutputPropertiesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -2061,7 +2073,7 @@ func (cook ListOutputPropertiesCookie) Reply() (*ListOutputPropertiesReply, erro return listOutputPropertiesReply(buf), nil } -// Read reply into structure from buffer for ListOutputProperties +// listOutputPropertiesReply reads a byte slice into a ListOutputPropertiesReply value. func listOutputPropertiesReply(buf []byte) *ListOutputPropertiesReply { v := new(ListOutputPropertiesReply) b := 1 // skip reply determinant @@ -2090,6 +2102,7 @@ func listOutputPropertiesReply(buf []byte) *ListOutputPropertiesReply { } // Write request to wire for ListOutputProperties +// listOutputPropertiesRequest writes a ListOutputProperties request to a byte slice. func listOutputPropertiesRequest(c *xgb.Conn, Output Output) []byte { size := 8 b := 0 @@ -2110,29 +2123,31 @@ func listOutputPropertiesRequest(c *xgb.Conn, Output Output) []byte { return buf } -// Request QueryOutputProperty -// size: 12 +// QueryOutputPropertyCookie is a cookie used only for QueryOutputProperty requests. type QueryOutputPropertyCookie struct { *xgb.Cookie } +// QueryOutputProperty sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryOutputPropertyCookie.Reply() func QueryOutputProperty(c *xgb.Conn, Output Output, Property xproto.Atom) QueryOutputPropertyCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryOutputPropertyRequest(c, Output, Property), cookie) return QueryOutputPropertyCookie{cookie} } +// QueryOutputPropertyUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryOutputPropertyUnchecked(c *xgb.Conn, Output Output, Property xproto.Atom) QueryOutputPropertyCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryOutputPropertyRequest(c, Output, Property), cookie) return QueryOutputPropertyCookie{cookie} } -// Request reply for QueryOutputProperty -// size: (32 + xgb.Pad((int(Length) * 4))) +// QueryOutputPropertyReply represents the data returned from a QueryOutputProperty request. type QueryOutputPropertyReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Pending bool Range bool @@ -2141,7 +2156,7 @@ type QueryOutputPropertyReply struct { ValidValues []int32 // size: xgb.Pad((int(Length) * 4)) } -// Waits and reads reply data from request QueryOutputProperty +// Reply blocks and returns the reply data for a QueryOutputProperty request. func (cook QueryOutputPropertyCookie) Reply() (*QueryOutputPropertyReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -2153,7 +2168,7 @@ func (cook QueryOutputPropertyCookie) Reply() (*QueryOutputPropertyReply, error) return queryOutputPropertyReply(buf), nil } -// Read reply into structure from buffer for QueryOutputProperty +// queryOutputPropertyReply reads a byte slice into a QueryOutputPropertyReply value. func queryOutputPropertyReply(buf []byte) *QueryOutputPropertyReply { v := new(QueryOutputPropertyReply) b := 1 // skip reply determinant @@ -2200,6 +2215,7 @@ func queryOutputPropertyReply(buf []byte) *QueryOutputPropertyReply { } // Write request to wire for QueryOutputProperty +// queryOutputPropertyRequest writes a QueryOutputProperty request to a byte slice. func queryOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom) []byte { size := 12 b := 0 @@ -2223,30 +2239,35 @@ func queryOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom return buf } -// Request ConfigureOutputProperty -// size: xgb.Pad((16 + xgb.Pad((len(Values) * 4)))) +// ConfigureOutputPropertyCookie is a cookie used only for ConfigureOutputProperty requests. type ConfigureOutputPropertyCookie struct { *xgb.Cookie } -// Write request to wire for ConfigureOutputProperty +// ConfigureOutputProperty sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ConfigureOutputProperty(c *xgb.Conn, Output Output, Property xproto.Atom, Pending bool, Range bool, Values []int32) ConfigureOutputPropertyCookie { cookie := c.NewCookie(false, false) c.NewRequest(configureOutputPropertyRequest(c, Output, Property, Pending, Range, Values), cookie) return ConfigureOutputPropertyCookie{cookie} } +// ConfigureOutputPropertyChecked sends a checked request. +// If an error occurs, it can be retrieved using ConfigureOutputPropertyCookie.Check() func ConfigureOutputPropertyChecked(c *xgb.Conn, Output Output, Property xproto.Atom, Pending bool, Range bool, Values []int32) ConfigureOutputPropertyCookie { cookie := c.NewCookie(true, false) c.NewRequest(configureOutputPropertyRequest(c, Output, Property, Pending, Range, Values), cookie) return ConfigureOutputPropertyCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook ConfigureOutputPropertyCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ConfigureOutputProperty +// configureOutputPropertyRequest writes a ConfigureOutputProperty request to a byte slice. func configureOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom, Pending bool, Range bool, Values []int32) []byte { size := xgb.Pad((16 + xgb.Pad((len(Values) * 4)))) b := 0 @@ -2292,30 +2313,35 @@ func configureOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto. return buf } -// Request ChangeOutputProperty -// size: xgb.Pad((24 + xgb.Pad((((int(NumUnits) * int(Format)) / 8) * 1)))) +// ChangeOutputPropertyCookie is a cookie used only for ChangeOutputProperty requests. type ChangeOutputPropertyCookie struct { *xgb.Cookie } -// Write request to wire for ChangeOutputProperty +// ChangeOutputProperty sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ChangeOutputProperty(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, Format byte, Mode byte, NumUnits uint32, Data []byte) ChangeOutputPropertyCookie { cookie := c.NewCookie(false, false) c.NewRequest(changeOutputPropertyRequest(c, Output, Property, Type, Format, Mode, NumUnits, Data), cookie) return ChangeOutputPropertyCookie{cookie} } +// ChangeOutputPropertyChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeOutputPropertyCookie.Check() func ChangeOutputPropertyChecked(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, Format byte, Mode byte, NumUnits uint32, Data []byte) ChangeOutputPropertyCookie { cookie := c.NewCookie(true, false) c.NewRequest(changeOutputPropertyRequest(c, Output, Property, Type, Format, Mode, NumUnits, Data), cookie) return ChangeOutputPropertyCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook ChangeOutputPropertyCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ChangeOutputProperty +// changeOutputPropertyRequest writes a ChangeOutputProperty request to a byte slice. func changeOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, Format byte, Mode byte, NumUnits uint32, Data []byte) []byte { size := xgb.Pad((24 + xgb.Pad((((int(NumUnits) * int(Format)) / 8) * 1)))) b := 0 @@ -2356,30 +2382,35 @@ func changeOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Ato return buf } -// Request DeleteOutputProperty -// size: 12 +// DeleteOutputPropertyCookie is a cookie used only for DeleteOutputProperty requests. type DeleteOutputPropertyCookie struct { *xgb.Cookie } -// Write request to wire for DeleteOutputProperty +// DeleteOutputProperty sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func DeleteOutputProperty(c *xgb.Conn, Output Output, Property xproto.Atom) DeleteOutputPropertyCookie { cookie := c.NewCookie(false, false) c.NewRequest(deleteOutputPropertyRequest(c, Output, Property), cookie) return DeleteOutputPropertyCookie{cookie} } +// DeleteOutputPropertyChecked sends a checked request. +// If an error occurs, it can be retrieved using DeleteOutputPropertyCookie.Check() func DeleteOutputPropertyChecked(c *xgb.Conn, Output Output, Property xproto.Atom) DeleteOutputPropertyCookie { cookie := c.NewCookie(true, false) c.NewRequest(deleteOutputPropertyRequest(c, Output, Property), cookie) return DeleteOutputPropertyCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook DeleteOutputPropertyCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for DeleteOutputProperty +// deleteOutputPropertyRequest writes a DeleteOutputProperty request to a byte slice. func deleteOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom) []byte { size := 12 b := 0 @@ -2403,29 +2434,31 @@ func deleteOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Ato return buf } -// Request GetOutputProperty -// size: 28 +// GetOutputPropertyCookie is a cookie used only for GetOutputProperty requests. type GetOutputPropertyCookie struct { *xgb.Cookie } +// GetOutputProperty sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetOutputPropertyCookie.Reply() func GetOutputProperty(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, LongOffset uint32, LongLength uint32, Delete bool, Pending bool) GetOutputPropertyCookie { cookie := c.NewCookie(true, true) c.NewRequest(getOutputPropertyRequest(c, Output, Property, Type, LongOffset, LongLength, Delete, Pending), cookie) return GetOutputPropertyCookie{cookie} } +// GetOutputPropertyUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetOutputPropertyUnchecked(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, LongOffset uint32, LongLength uint32, Delete bool, Pending bool) GetOutputPropertyCookie { cookie := c.NewCookie(false, true) c.NewRequest(getOutputPropertyRequest(c, Output, Property, Type, LongOffset, LongLength, Delete, Pending), cookie) return GetOutputPropertyCookie{cookie} } -// Request reply for GetOutputProperty -// size: (32 + xgb.Pad(((int(NumItems) * (int(Format) / 8)) * 1))) +// GetOutputPropertyReply represents the data returned from a GetOutputProperty request. type GetOutputPropertyReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply Format byte Type xproto.Atom BytesAfter uint32 @@ -2434,7 +2467,7 @@ type GetOutputPropertyReply struct { Data []byte // size: xgb.Pad(((int(NumItems) * (int(Format) / 8)) * 1)) } -// Waits and reads reply data from request GetOutputProperty +// Reply blocks and returns the reply data for a GetOutputProperty request. func (cook GetOutputPropertyCookie) Reply() (*GetOutputPropertyReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -2446,7 +2479,7 @@ func (cook GetOutputPropertyCookie) Reply() (*GetOutputPropertyReply, error) { return getOutputPropertyReply(buf), nil } -// Read reply into structure from buffer for GetOutputProperty +// getOutputPropertyReply reads a byte slice into a GetOutputPropertyReply value. func getOutputPropertyReply(buf []byte) *GetOutputPropertyReply { v := new(GetOutputPropertyReply) b := 1 // skip reply determinant @@ -2479,6 +2512,7 @@ func getOutputPropertyReply(buf []byte) *GetOutputPropertyReply { } // Write request to wire for GetOutputProperty +// getOutputPropertyRequest writes a GetOutputProperty request to a byte slice. func getOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, LongOffset uint32, LongLength uint32, Delete bool, Pending bool) []byte { size := 28 b := 0 @@ -2527,35 +2561,37 @@ func getOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom, return buf } -// Request CreateMode -// size: xgb.Pad((40 + xgb.Pad((len(Name) * 1)))) +// CreateModeCookie is a cookie used only for CreateMode requests. type CreateModeCookie struct { *xgb.Cookie } +// CreateMode sends a checked request. +// If an error occurs, it will be returned with the reply by calling CreateModeCookie.Reply() func CreateMode(c *xgb.Conn, Window xproto.Window, ModeInfo ModeInfo, Name string) CreateModeCookie { cookie := c.NewCookie(true, true) c.NewRequest(createModeRequest(c, Window, ModeInfo, Name), cookie) return CreateModeCookie{cookie} } +// CreateModeUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreateModeUnchecked(c *xgb.Conn, Window xproto.Window, ModeInfo ModeInfo, Name string) CreateModeCookie { cookie := c.NewCookie(false, true) c.NewRequest(createModeRequest(c, Window, ModeInfo, Name), cookie) return CreateModeCookie{cookie} } -// Request reply for CreateMode -// size: 32 +// CreateModeReply represents the data returned from a CreateMode request. type CreateModeReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Mode Mode // padding: 20 bytes } -// Waits and reads reply data from request CreateMode +// Reply blocks and returns the reply data for a CreateMode request. func (cook CreateModeCookie) Reply() (*CreateModeReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -2567,7 +2603,7 @@ func (cook CreateModeCookie) Reply() (*CreateModeReply, error) { return createModeReply(buf), nil } -// Read reply into structure from buffer for CreateMode +// createModeReply reads a byte slice into a CreateModeReply value. func createModeReply(buf []byte) *CreateModeReply { v := new(CreateModeReply) b := 1 // skip reply determinant @@ -2589,6 +2625,7 @@ func createModeReply(buf []byte) *CreateModeReply { } // Write request to wire for CreateMode +// createModeRequest writes a CreateMode request to a byte slice. func createModeRequest(c *xgb.Conn, Window xproto.Window, ModeInfo ModeInfo, Name string) []byte { size := xgb.Pad((40 + xgb.Pad((len(Name) * 1)))) b := 0 @@ -2618,30 +2655,35 @@ func createModeRequest(c *xgb.Conn, Window xproto.Window, ModeInfo ModeInfo, Nam return buf } -// Request DestroyMode -// size: 8 +// DestroyModeCookie is a cookie used only for DestroyMode requests. type DestroyModeCookie struct { *xgb.Cookie } -// Write request to wire for DestroyMode +// DestroyMode sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func DestroyMode(c *xgb.Conn, Mode Mode) DestroyModeCookie { cookie := c.NewCookie(false, false) c.NewRequest(destroyModeRequest(c, Mode), cookie) return DestroyModeCookie{cookie} } +// DestroyModeChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroyModeCookie.Check() func DestroyModeChecked(c *xgb.Conn, Mode Mode) DestroyModeCookie { cookie := c.NewCookie(true, false) c.NewRequest(destroyModeRequest(c, Mode), cookie) return DestroyModeCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook DestroyModeCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for DestroyMode +// destroyModeRequest writes a DestroyMode request to a byte slice. func destroyModeRequest(c *xgb.Conn, Mode Mode) []byte { size := 8 b := 0 @@ -2662,30 +2704,35 @@ func destroyModeRequest(c *xgb.Conn, Mode Mode) []byte { return buf } -// Request AddOutputMode -// size: 12 +// AddOutputModeCookie is a cookie used only for AddOutputMode requests. type AddOutputModeCookie struct { *xgb.Cookie } -// Write request to wire for AddOutputMode +// AddOutputMode sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func AddOutputMode(c *xgb.Conn, Output Output, Mode Mode) AddOutputModeCookie { cookie := c.NewCookie(false, false) c.NewRequest(addOutputModeRequest(c, Output, Mode), cookie) return AddOutputModeCookie{cookie} } +// AddOutputModeChecked sends a checked request. +// If an error occurs, it can be retrieved using AddOutputModeCookie.Check() func AddOutputModeChecked(c *xgb.Conn, Output Output, Mode Mode) AddOutputModeCookie { cookie := c.NewCookie(true, false) c.NewRequest(addOutputModeRequest(c, Output, Mode), cookie) return AddOutputModeCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook AddOutputModeCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for AddOutputMode +// addOutputModeRequest writes a AddOutputMode request to a byte slice. func addOutputModeRequest(c *xgb.Conn, Output Output, Mode Mode) []byte { size := 12 b := 0 @@ -2709,30 +2756,35 @@ func addOutputModeRequest(c *xgb.Conn, Output Output, Mode Mode) []byte { return buf } -// Request DeleteOutputMode -// size: 12 +// DeleteOutputModeCookie is a cookie used only for DeleteOutputMode requests. type DeleteOutputModeCookie struct { *xgb.Cookie } -// Write request to wire for DeleteOutputMode +// DeleteOutputMode sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func DeleteOutputMode(c *xgb.Conn, Output Output, Mode Mode) DeleteOutputModeCookie { cookie := c.NewCookie(false, false) c.NewRequest(deleteOutputModeRequest(c, Output, Mode), cookie) return DeleteOutputModeCookie{cookie} } +// DeleteOutputModeChecked sends a checked request. +// If an error occurs, it can be retrieved using DeleteOutputModeCookie.Check() func DeleteOutputModeChecked(c *xgb.Conn, Output Output, Mode Mode) DeleteOutputModeCookie { cookie := c.NewCookie(true, false) c.NewRequest(deleteOutputModeRequest(c, Output, Mode), cookie) return DeleteOutputModeCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook DeleteOutputModeCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for DeleteOutputMode +// deleteOutputModeRequest writes a DeleteOutputMode request to a byte slice. func deleteOutputModeRequest(c *xgb.Conn, Output Output, Mode Mode) []byte { size := 12 b := 0 @@ -2756,29 +2808,31 @@ func deleteOutputModeRequest(c *xgb.Conn, Output Output, Mode Mode) []byte { return buf } -// Request GetCrtcInfo -// size: 12 +// GetCrtcInfoCookie is a cookie used only for GetCrtcInfo requests. type GetCrtcInfoCookie struct { *xgb.Cookie } +// GetCrtcInfo sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetCrtcInfoCookie.Reply() func GetCrtcInfo(c *xgb.Conn, Crtc Crtc, ConfigTimestamp xproto.Timestamp) GetCrtcInfoCookie { cookie := c.NewCookie(true, true) c.NewRequest(getCrtcInfoRequest(c, Crtc, ConfigTimestamp), cookie) return GetCrtcInfoCookie{cookie} } +// GetCrtcInfoUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetCrtcInfoUnchecked(c *xgb.Conn, Crtc Crtc, ConfigTimestamp xproto.Timestamp) GetCrtcInfoCookie { cookie := c.NewCookie(false, true) c.NewRequest(getCrtcInfoRequest(c, Crtc, ConfigTimestamp), cookie) return GetCrtcInfoCookie{cookie} } -// Request reply for GetCrtcInfo -// size: ((32 + xgb.Pad((int(NumOutputs) * 4))) + xgb.Pad((int(NumPossibleOutputs) * 4))) +// GetCrtcInfoReply represents the data returned from a GetCrtcInfo request. type GetCrtcInfoReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply Status byte Timestamp xproto.Timestamp X int16 @@ -2794,7 +2848,7 @@ type GetCrtcInfoReply struct { Possible []Output // size: xgb.Pad((int(NumPossibleOutputs) * 4)) } -// Waits and reads reply data from request GetCrtcInfo +// Reply blocks and returns the reply data for a GetCrtcInfo request. func (cook GetCrtcInfoCookie) Reply() (*GetCrtcInfoReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -2806,7 +2860,7 @@ func (cook GetCrtcInfoCookie) Reply() (*GetCrtcInfoReply, error) { return getCrtcInfoReply(buf), nil } -// Read reply into structure from buffer for GetCrtcInfo +// getCrtcInfoReply reads a byte slice into a GetCrtcInfoReply value. func getCrtcInfoReply(buf []byte) *GetCrtcInfoReply { v := new(GetCrtcInfoReply) b := 1 // skip reply determinant @@ -2868,6 +2922,7 @@ func getCrtcInfoReply(buf []byte) *GetCrtcInfoReply { } // Write request to wire for GetCrtcInfo +// getCrtcInfoRequest writes a GetCrtcInfo request to a byte slice. func getCrtcInfoRequest(c *xgb.Conn, Crtc Crtc, ConfigTimestamp xproto.Timestamp) []byte { size := 12 b := 0 @@ -2891,35 +2946,37 @@ func getCrtcInfoRequest(c *xgb.Conn, Crtc Crtc, ConfigTimestamp xproto.Timestamp return buf } -// Request SetCrtcConfig -// size: xgb.Pad((28 + xgb.Pad((len(Outputs) * 4)))) +// SetCrtcConfigCookie is a cookie used only for SetCrtcConfig requests. type SetCrtcConfigCookie struct { *xgb.Cookie } +// SetCrtcConfig sends a checked request. +// If an error occurs, it will be returned with the reply by calling SetCrtcConfigCookie.Reply() func SetCrtcConfig(c *xgb.Conn, Crtc Crtc, Timestamp xproto.Timestamp, ConfigTimestamp xproto.Timestamp, X int16, Y int16, Mode Mode, Rotation uint16, Outputs []Output) SetCrtcConfigCookie { cookie := c.NewCookie(true, true) c.NewRequest(setCrtcConfigRequest(c, Crtc, Timestamp, ConfigTimestamp, X, Y, Mode, Rotation, Outputs), cookie) return SetCrtcConfigCookie{cookie} } +// SetCrtcConfigUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetCrtcConfigUnchecked(c *xgb.Conn, Crtc Crtc, Timestamp xproto.Timestamp, ConfigTimestamp xproto.Timestamp, X int16, Y int16, Mode Mode, Rotation uint16, Outputs []Output) SetCrtcConfigCookie { cookie := c.NewCookie(false, true) c.NewRequest(setCrtcConfigRequest(c, Crtc, Timestamp, ConfigTimestamp, X, Y, Mode, Rotation, Outputs), cookie) return SetCrtcConfigCookie{cookie} } -// Request reply for SetCrtcConfig -// size: 32 +// SetCrtcConfigReply represents the data returned from a SetCrtcConfig request. type SetCrtcConfigReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply Status byte Timestamp xproto.Timestamp // padding: 20 bytes } -// Waits and reads reply data from request SetCrtcConfig +// Reply blocks and returns the reply data for a SetCrtcConfig request. func (cook SetCrtcConfigCookie) Reply() (*SetCrtcConfigReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -2931,7 +2988,7 @@ func (cook SetCrtcConfigCookie) Reply() (*SetCrtcConfigReply, error) { return setCrtcConfigReply(buf), nil } -// Read reply into structure from buffer for SetCrtcConfig +// setCrtcConfigReply reads a byte slice into a SetCrtcConfigReply value. func setCrtcConfigReply(buf []byte) *SetCrtcConfigReply { v := new(SetCrtcConfigReply) b := 1 // skip reply determinant @@ -2954,6 +3011,7 @@ func setCrtcConfigReply(buf []byte) *SetCrtcConfigReply { } // Write request to wire for SetCrtcConfig +// setCrtcConfigRequest writes a SetCrtcConfig request to a byte slice. func setCrtcConfigRequest(c *xgb.Conn, Crtc Crtc, Timestamp xproto.Timestamp, ConfigTimestamp xproto.Timestamp, X int16, Y int16, Mode Mode, Rotation uint16, Outputs []Output) []byte { size := xgb.Pad((28 + xgb.Pad((len(Outputs) * 4)))) b := 0 @@ -3000,35 +3058,37 @@ func setCrtcConfigRequest(c *xgb.Conn, Crtc Crtc, Timestamp xproto.Timestamp, Co return buf } -// Request GetCrtcGammaSize -// size: 8 +// GetCrtcGammaSizeCookie is a cookie used only for GetCrtcGammaSize requests. type GetCrtcGammaSizeCookie struct { *xgb.Cookie } +// GetCrtcGammaSize sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetCrtcGammaSizeCookie.Reply() func GetCrtcGammaSize(c *xgb.Conn, Crtc Crtc) GetCrtcGammaSizeCookie { cookie := c.NewCookie(true, true) c.NewRequest(getCrtcGammaSizeRequest(c, Crtc), cookie) return GetCrtcGammaSizeCookie{cookie} } +// GetCrtcGammaSizeUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetCrtcGammaSizeUnchecked(c *xgb.Conn, Crtc Crtc) GetCrtcGammaSizeCookie { cookie := c.NewCookie(false, true) c.NewRequest(getCrtcGammaSizeRequest(c, Crtc), cookie) return GetCrtcGammaSizeCookie{cookie} } -// Request reply for GetCrtcGammaSize -// size: 32 +// GetCrtcGammaSizeReply represents the data returned from a GetCrtcGammaSize request. type GetCrtcGammaSizeReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Size uint16 // padding: 22 bytes } -// Waits and reads reply data from request GetCrtcGammaSize +// Reply blocks and returns the reply data for a GetCrtcGammaSize request. func (cook GetCrtcGammaSizeCookie) Reply() (*GetCrtcGammaSizeReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -3040,7 +3100,7 @@ func (cook GetCrtcGammaSizeCookie) Reply() (*GetCrtcGammaSizeReply, error) { return getCrtcGammaSizeReply(buf), nil } -// Read reply into structure from buffer for GetCrtcGammaSize +// getCrtcGammaSizeReply reads a byte slice into a GetCrtcGammaSizeReply value. func getCrtcGammaSizeReply(buf []byte) *GetCrtcGammaSizeReply { v := new(GetCrtcGammaSizeReply) b := 1 // skip reply determinant @@ -3062,6 +3122,7 @@ func getCrtcGammaSizeReply(buf []byte) *GetCrtcGammaSizeReply { } // Write request to wire for GetCrtcGammaSize +// getCrtcGammaSizeRequest writes a GetCrtcGammaSize request to a byte slice. func getCrtcGammaSizeRequest(c *xgb.Conn, Crtc Crtc) []byte { size := 8 b := 0 @@ -3082,29 +3143,31 @@ func getCrtcGammaSizeRequest(c *xgb.Conn, Crtc Crtc) []byte { return buf } -// Request GetCrtcGamma -// size: 8 +// GetCrtcGammaCookie is a cookie used only for GetCrtcGamma requests. type GetCrtcGammaCookie struct { *xgb.Cookie } +// GetCrtcGamma sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetCrtcGammaCookie.Reply() func GetCrtcGamma(c *xgb.Conn, Crtc Crtc) GetCrtcGammaCookie { cookie := c.NewCookie(true, true) c.NewRequest(getCrtcGammaRequest(c, Crtc), cookie) return GetCrtcGammaCookie{cookie} } +// GetCrtcGammaUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetCrtcGammaUnchecked(c *xgb.Conn, Crtc Crtc) GetCrtcGammaCookie { cookie := c.NewCookie(false, true) c.NewRequest(getCrtcGammaRequest(c, Crtc), cookie) return GetCrtcGammaCookie{cookie} } -// Request reply for GetCrtcGamma -// size: (((32 + xgb.Pad((int(Size) * 2))) + xgb.Pad((int(Size) * 2))) + xgb.Pad((int(Size) * 2))) +// GetCrtcGammaReply represents the data returned from a GetCrtcGamma request. type GetCrtcGammaReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Size uint16 // padding: 22 bytes @@ -3113,7 +3176,7 @@ type GetCrtcGammaReply struct { Blue []uint16 // size: xgb.Pad((int(Size) * 2)) } -// Waits and reads reply data from request GetCrtcGamma +// Reply blocks and returns the reply data for a GetCrtcGamma request. func (cook GetCrtcGammaCookie) Reply() (*GetCrtcGammaReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -3125,7 +3188,7 @@ func (cook GetCrtcGammaCookie) Reply() (*GetCrtcGammaReply, error) { return getCrtcGammaReply(buf), nil } -// Read reply into structure from buffer for GetCrtcGamma +// getCrtcGammaReply reads a byte slice into a GetCrtcGammaReply value. func getCrtcGammaReply(buf []byte) *GetCrtcGammaReply { v := new(GetCrtcGammaReply) b := 1 // skip reply determinant @@ -3168,6 +3231,7 @@ func getCrtcGammaReply(buf []byte) *GetCrtcGammaReply { } // Write request to wire for GetCrtcGamma +// getCrtcGammaRequest writes a GetCrtcGamma request to a byte slice. func getCrtcGammaRequest(c *xgb.Conn, Crtc Crtc) []byte { size := 8 b := 0 @@ -3188,30 +3252,35 @@ func getCrtcGammaRequest(c *xgb.Conn, Crtc Crtc) []byte { return buf } -// Request SetCrtcGamma -// size: xgb.Pad((((12 + xgb.Pad((int(Size) * 2))) + xgb.Pad((int(Size) * 2))) + xgb.Pad((int(Size) * 2)))) +// SetCrtcGammaCookie is a cookie used only for SetCrtcGamma requests. type SetCrtcGammaCookie struct { *xgb.Cookie } -// Write request to wire for SetCrtcGamma +// SetCrtcGamma sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetCrtcGamma(c *xgb.Conn, Crtc Crtc, Size uint16, Red []uint16, Green []uint16, Blue []uint16) SetCrtcGammaCookie { cookie := c.NewCookie(false, false) c.NewRequest(setCrtcGammaRequest(c, Crtc, Size, Red, Green, Blue), cookie) return SetCrtcGammaCookie{cookie} } +// SetCrtcGammaChecked sends a checked request. +// If an error occurs, it can be retrieved using SetCrtcGammaCookie.Check() func SetCrtcGammaChecked(c *xgb.Conn, Crtc Crtc, Size uint16, Red []uint16, Green []uint16, Blue []uint16) SetCrtcGammaCookie { cookie := c.NewCookie(true, false) c.NewRequest(setCrtcGammaRequest(c, Crtc, Size, Red, Green, Blue), cookie) return SetCrtcGammaCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetCrtcGammaCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetCrtcGamma +// setCrtcGammaRequest writes a SetCrtcGamma request to a byte slice. func setCrtcGammaRequest(c *xgb.Conn, Crtc Crtc, Size uint16, Red []uint16, Green []uint16, Blue []uint16) []byte { size := xgb.Pad((((12 + xgb.Pad((int(Size) * 2))) + xgb.Pad((int(Size) * 2))) + xgb.Pad((int(Size) * 2)))) b := 0 @@ -3255,29 +3324,31 @@ func setCrtcGammaRequest(c *xgb.Conn, Crtc Crtc, Size uint16, Red []uint16, Gree return buf } -// Request GetScreenResourcesCurrent -// size: 8 +// GetScreenResourcesCurrentCookie is a cookie used only for GetScreenResourcesCurrent requests. type GetScreenResourcesCurrentCookie struct { *xgb.Cookie } +// GetScreenResourcesCurrent sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetScreenResourcesCurrentCookie.Reply() func GetScreenResourcesCurrent(c *xgb.Conn, Window xproto.Window) GetScreenResourcesCurrentCookie { cookie := c.NewCookie(true, true) c.NewRequest(getScreenResourcesCurrentRequest(c, Window), cookie) return GetScreenResourcesCurrentCookie{cookie} } +// GetScreenResourcesCurrentUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetScreenResourcesCurrentUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenResourcesCurrentCookie { cookie := c.NewCookie(false, true) c.NewRequest(getScreenResourcesCurrentRequest(c, Window), cookie) return GetScreenResourcesCurrentCookie{cookie} } -// Request reply for GetScreenResourcesCurrent -// size: ((((32 + xgb.Pad((int(NumCrtcs) * 4))) + xgb.Pad((int(NumOutputs) * 4))) + xgb.Pad((int(NumModes) * 32))) + xgb.Pad((int(NamesLen) * 1))) +// GetScreenResourcesCurrentReply represents the data returned from a GetScreenResourcesCurrent request. type GetScreenResourcesCurrentReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Timestamp xproto.Timestamp ConfigTimestamp xproto.Timestamp @@ -3292,7 +3363,7 @@ type GetScreenResourcesCurrentReply struct { Names []byte // size: xgb.Pad((int(NamesLen) * 1)) } -// Waits and reads reply data from request GetScreenResourcesCurrent +// Reply blocks and returns the reply data for a GetScreenResourcesCurrent request. func (cook GetScreenResourcesCurrentCookie) Reply() (*GetScreenResourcesCurrentReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -3304,7 +3375,7 @@ func (cook GetScreenResourcesCurrentCookie) Reply() (*GetScreenResourcesCurrentR return getScreenResourcesCurrentReply(buf), nil } -// Read reply into structure from buffer for GetScreenResourcesCurrent +// getScreenResourcesCurrentReply reads a byte slice into a GetScreenResourcesCurrentReply value. func getScreenResourcesCurrentReply(buf []byte) *GetScreenResourcesCurrentReply { v := new(GetScreenResourcesCurrentReply) b := 1 // skip reply determinant @@ -3362,6 +3433,7 @@ func getScreenResourcesCurrentReply(buf []byte) *GetScreenResourcesCurrentReply } // Write request to wire for GetScreenResourcesCurrent +// getScreenResourcesCurrentRequest writes a GetScreenResourcesCurrent request to a byte slice. func getScreenResourcesCurrentRequest(c *xgb.Conn, Window xproto.Window) []byte { size := 8 b := 0 @@ -3382,30 +3454,35 @@ func getScreenResourcesCurrentRequest(c *xgb.Conn, Window xproto.Window) []byte return buf } -// Request SetCrtcTransform -// size: xgb.Pad(((48 + xgb.Pad((int(FilterLen) * 1))) + xgb.Pad((len(FilterParams) * 4)))) +// SetCrtcTransformCookie is a cookie used only for SetCrtcTransform requests. type SetCrtcTransformCookie struct { *xgb.Cookie } -// Write request to wire for SetCrtcTransform +// SetCrtcTransform sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetCrtcTransform(c *xgb.Conn, Crtc Crtc, Transform render.Transform, FilterLen uint16, FilterName string, FilterParams []render.Fixed) SetCrtcTransformCookie { cookie := c.NewCookie(false, false) c.NewRequest(setCrtcTransformRequest(c, Crtc, Transform, FilterLen, FilterName, FilterParams), cookie) return SetCrtcTransformCookie{cookie} } +// SetCrtcTransformChecked sends a checked request. +// If an error occurs, it can be retrieved using SetCrtcTransformCookie.Check() func SetCrtcTransformChecked(c *xgb.Conn, Crtc Crtc, Transform render.Transform, FilterLen uint16, FilterName string, FilterParams []render.Fixed) SetCrtcTransformCookie { cookie := c.NewCookie(true, false) c.NewRequest(setCrtcTransformRequest(c, Crtc, Transform, FilterLen, FilterName, FilterParams), cookie) return SetCrtcTransformCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetCrtcTransformCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetCrtcTransform +// setCrtcTransformRequest writes a SetCrtcTransform request to a byte slice. func setCrtcTransformRequest(c *xgb.Conn, Crtc Crtc, Transform render.Transform, FilterLen uint16, FilterName string, FilterParams []render.Fixed) []byte { size := xgb.Pad(((48 + xgb.Pad((int(FilterLen) * 1))) + xgb.Pad((len(FilterParams) * 4)))) b := 0 @@ -3446,29 +3523,31 @@ func setCrtcTransformRequest(c *xgb.Conn, Crtc Crtc, Transform render.Transform, return buf } -// Request GetCrtcTransform -// size: 8 +// GetCrtcTransformCookie is a cookie used only for GetCrtcTransform requests. type GetCrtcTransformCookie struct { *xgb.Cookie } +// GetCrtcTransform sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetCrtcTransformCookie.Reply() func GetCrtcTransform(c *xgb.Conn, Crtc Crtc) GetCrtcTransformCookie { cookie := c.NewCookie(true, true) c.NewRequest(getCrtcTransformRequest(c, Crtc), cookie) return GetCrtcTransformCookie{cookie} } +// GetCrtcTransformUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetCrtcTransformUnchecked(c *xgb.Conn, Crtc Crtc) GetCrtcTransformCookie { cookie := c.NewCookie(false, true) c.NewRequest(getCrtcTransformRequest(c, Crtc), cookie) return GetCrtcTransformCookie{cookie} } -// Request reply for GetCrtcTransform -// size: ((((96 + xgb.Pad((int(PendingLen) * 1))) + xgb.Pad((int(PendingNparams) * 4))) + xgb.Pad((int(CurrentLen) * 1))) + xgb.Pad((int(CurrentNparams) * 4))) +// GetCrtcTransformReply represents the data returned from a GetCrtcTransform request. type GetCrtcTransformReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes PendingTransform render.Transform HasTransforms bool @@ -3485,7 +3564,7 @@ type GetCrtcTransformReply struct { CurrentParams []render.Fixed // size: xgb.Pad((int(CurrentNparams) * 4)) } -// Waits and reads reply data from request GetCrtcTransform +// Reply blocks and returns the reply data for a GetCrtcTransform request. func (cook GetCrtcTransformCookie) Reply() (*GetCrtcTransformReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -3497,7 +3576,7 @@ func (cook GetCrtcTransformCookie) Reply() (*GetCrtcTransformReply, error) { return getCrtcTransformReply(buf), nil } -// Read reply into structure from buffer for GetCrtcTransform +// getCrtcTransformReply reads a byte slice into a GetCrtcTransformReply value. func getCrtcTransformReply(buf []byte) *GetCrtcTransformReply { v := new(GetCrtcTransformReply) b := 1 // skip reply determinant @@ -3571,6 +3650,7 @@ func getCrtcTransformReply(buf []byte) *GetCrtcTransformReply { } // Write request to wire for GetCrtcTransform +// getCrtcTransformRequest writes a GetCrtcTransform request to a byte slice. func getCrtcTransformRequest(c *xgb.Conn, Crtc Crtc) []byte { size := 8 b := 0 @@ -3591,29 +3671,31 @@ func getCrtcTransformRequest(c *xgb.Conn, Crtc Crtc) []byte { return buf } -// Request GetPanning -// size: 8 +// GetPanningCookie is a cookie used only for GetPanning requests. type GetPanningCookie struct { *xgb.Cookie } +// GetPanning sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPanningCookie.Reply() func GetPanning(c *xgb.Conn, Crtc Crtc) GetPanningCookie { cookie := c.NewCookie(true, true) c.NewRequest(getPanningRequest(c, Crtc), cookie) return GetPanningCookie{cookie} } +// GetPanningUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetPanningUnchecked(c *xgb.Conn, Crtc Crtc) GetPanningCookie { cookie := c.NewCookie(false, true) c.NewRequest(getPanningRequest(c, Crtc), cookie) return GetPanningCookie{cookie} } -// Request reply for GetPanning -// size: 36 +// GetPanningReply represents the data returned from a GetPanning request. type GetPanningReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply Status byte Timestamp xproto.Timestamp Left uint16 @@ -3630,7 +3712,7 @@ type GetPanningReply struct { BorderBottom int16 } -// Waits and reads reply data from request GetPanning +// Reply blocks and returns the reply data for a GetPanning request. func (cook GetPanningCookie) Reply() (*GetPanningReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -3642,7 +3724,7 @@ func (cook GetPanningCookie) Reply() (*GetPanningReply, error) { return getPanningReply(buf), nil } -// Read reply into structure from buffer for GetPanning +// getPanningReply reads a byte slice into a GetPanningReply value. func getPanningReply(buf []byte) *GetPanningReply { v := new(GetPanningReply) b := 1 // skip reply determinant @@ -3699,6 +3781,7 @@ func getPanningReply(buf []byte) *GetPanningReply { } // Write request to wire for GetPanning +// getPanningRequest writes a GetPanning request to a byte slice. func getPanningRequest(c *xgb.Conn, Crtc Crtc) []byte { size := 8 b := 0 @@ -3719,34 +3802,36 @@ func getPanningRequest(c *xgb.Conn, Crtc Crtc) []byte { return buf } -// Request SetPanning -// size: 36 +// SetPanningCookie is a cookie used only for SetPanning requests. type SetPanningCookie struct { *xgb.Cookie } +// SetPanning sends a checked request. +// If an error occurs, it will be returned with the reply by calling SetPanningCookie.Reply() func SetPanning(c *xgb.Conn, Crtc Crtc, Timestamp xproto.Timestamp, Left uint16, Top uint16, Width uint16, Height uint16, TrackLeft uint16, TrackTop uint16, TrackWidth uint16, TrackHeight uint16, BorderLeft int16, BorderTop int16, BorderRight int16, BorderBottom int16) SetPanningCookie { cookie := c.NewCookie(true, true) c.NewRequest(setPanningRequest(c, Crtc, Timestamp, Left, Top, Width, Height, TrackLeft, TrackTop, TrackWidth, TrackHeight, BorderLeft, BorderTop, BorderRight, BorderBottom), cookie) return SetPanningCookie{cookie} } +// SetPanningUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetPanningUnchecked(c *xgb.Conn, Crtc Crtc, Timestamp xproto.Timestamp, Left uint16, Top uint16, Width uint16, Height uint16, TrackLeft uint16, TrackTop uint16, TrackWidth uint16, TrackHeight uint16, BorderLeft int16, BorderTop int16, BorderRight int16, BorderBottom int16) SetPanningCookie { cookie := c.NewCookie(false, true) c.NewRequest(setPanningRequest(c, Crtc, Timestamp, Left, Top, Width, Height, TrackLeft, TrackTop, TrackWidth, TrackHeight, BorderLeft, BorderTop, BorderRight, BorderBottom), cookie) return SetPanningCookie{cookie} } -// Request reply for SetPanning -// size: 12 +// SetPanningReply represents the data returned from a SetPanning request. type SetPanningReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply Status byte Timestamp xproto.Timestamp } -// Waits and reads reply data from request SetPanning +// Reply blocks and returns the reply data for a SetPanning request. func (cook SetPanningCookie) Reply() (*SetPanningReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -3758,7 +3843,7 @@ func (cook SetPanningCookie) Reply() (*SetPanningReply, error) { return setPanningReply(buf), nil } -// Read reply into structure from buffer for SetPanning +// setPanningReply reads a byte slice into a SetPanningReply value. func setPanningReply(buf []byte) *SetPanningReply { v := new(SetPanningReply) b := 1 // skip reply determinant @@ -3779,6 +3864,7 @@ func setPanningReply(buf []byte) *SetPanningReply { } // Write request to wire for SetPanning +// setPanningRequest writes a SetPanning request to a byte slice. func setPanningRequest(c *xgb.Conn, Crtc Crtc, Timestamp xproto.Timestamp, Left uint16, Top uint16, Width uint16, Height uint16, TrackLeft uint16, TrackTop uint16, TrackWidth uint16, TrackHeight uint16, BorderLeft int16, BorderTop int16, BorderRight int16, BorderBottom int16) []byte { size := 36 b := 0 @@ -3838,30 +3924,35 @@ func setPanningRequest(c *xgb.Conn, Crtc Crtc, Timestamp xproto.Timestamp, Left return buf } -// Request SetOutputPrimary -// size: 12 +// SetOutputPrimaryCookie is a cookie used only for SetOutputPrimary requests. type SetOutputPrimaryCookie struct { *xgb.Cookie } -// Write request to wire for SetOutputPrimary +// SetOutputPrimary sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetOutputPrimary(c *xgb.Conn, Window xproto.Window, Output Output) SetOutputPrimaryCookie { cookie := c.NewCookie(false, false) c.NewRequest(setOutputPrimaryRequest(c, Window, Output), cookie) return SetOutputPrimaryCookie{cookie} } +// SetOutputPrimaryChecked sends a checked request. +// If an error occurs, it can be retrieved using SetOutputPrimaryCookie.Check() func SetOutputPrimaryChecked(c *xgb.Conn, Window xproto.Window, Output Output) SetOutputPrimaryCookie { cookie := c.NewCookie(true, false) c.NewRequest(setOutputPrimaryRequest(c, Window, Output), cookie) return SetOutputPrimaryCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetOutputPrimaryCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetOutputPrimary +// setOutputPrimaryRequest writes a SetOutputPrimary request to a byte slice. func setOutputPrimaryRequest(c *xgb.Conn, Window xproto.Window, Output Output) []byte { size := 12 b := 0 @@ -3885,34 +3976,36 @@ func setOutputPrimaryRequest(c *xgb.Conn, Window xproto.Window, Output Output) [ return buf } -// Request GetOutputPrimary -// size: 8 +// GetOutputPrimaryCookie is a cookie used only for GetOutputPrimary requests. type GetOutputPrimaryCookie struct { *xgb.Cookie } +// GetOutputPrimary sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetOutputPrimaryCookie.Reply() func GetOutputPrimary(c *xgb.Conn, Window xproto.Window) GetOutputPrimaryCookie { cookie := c.NewCookie(true, true) c.NewRequest(getOutputPrimaryRequest(c, Window), cookie) return GetOutputPrimaryCookie{cookie} } +// GetOutputPrimaryUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetOutputPrimaryUnchecked(c *xgb.Conn, Window xproto.Window) GetOutputPrimaryCookie { cookie := c.NewCookie(false, true) c.NewRequest(getOutputPrimaryRequest(c, Window), cookie) return GetOutputPrimaryCookie{cookie} } -// Request reply for GetOutputPrimary -// size: 12 +// GetOutputPrimaryReply represents the data returned from a GetOutputPrimary request. type GetOutputPrimaryReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Output Output } -// Waits and reads reply data from request GetOutputPrimary +// Reply blocks and returns the reply data for a GetOutputPrimary request. func (cook GetOutputPrimaryCookie) Reply() (*GetOutputPrimaryReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -3924,7 +4017,7 @@ func (cook GetOutputPrimaryCookie) Reply() (*GetOutputPrimaryReply, error) { return getOutputPrimaryReply(buf), nil } -// Read reply into structure from buffer for GetOutputPrimary +// getOutputPrimaryReply reads a byte slice into a GetOutputPrimaryReply value. func getOutputPrimaryReply(buf []byte) *GetOutputPrimaryReply { v := new(GetOutputPrimaryReply) b := 1 // skip reply determinant @@ -3944,6 +4037,7 @@ func getOutputPrimaryReply(buf []byte) *GetOutputPrimaryReply { } // Write request to wire for GetOutputPrimary +// getOutputPrimaryRequest writes a GetOutputPrimary request to a byte slice. func getOutputPrimaryRequest(c *xgb.Conn, Window xproto.Window) []byte { size := 8 b := 0 diff --git a/nexgb/record/record.go b/nexgb/record/record.go index 740353d..28b268e 100644 --- a/nexgb/record/record.go +++ b/nexgb/record/record.go @@ -2,7 +2,7 @@ package record /* - This file was generated by record.xml on May 10 2012 8:04:32pm EDT. + This file was generated by record.xml on May 10 2012 11:56:19pm EDT. This file is automatically generated. Edit at your peril! */ @@ -90,14 +90,12 @@ type ElementHeader byte type ClientSpec uint32 -// 'Range8' struct definition -// Size: 2 type Range8 struct { First byte Last byte } -// Struct read Range8 +// Range8Read reads a byte slice into a Range8 value. func Range8Read(buf []byte, v *Range8) int { b := 0 @@ -110,7 +108,7 @@ func Range8Read(buf []byte, v *Range8) int { return b } -// Struct list read Range8 +// Range8ReadList reads a byte slice into a list of Range8 values. func Range8ReadList(buf []byte, dest []Range8) int { b := 0 for i := 0; i < len(dest); i++ { @@ -120,7 +118,7 @@ func Range8ReadList(buf []byte, dest []Range8) int { return xgb.Pad(b) } -// Struct write Range8 +// Bytes writes a Range8 value to a byte slice. func (v Range8) Bytes() []byte { buf := make([]byte, 2) b := 0 @@ -134,7 +132,7 @@ func (v Range8) Bytes() []byte { return buf } -// Write struct list Range8 +// Range8ListBytes writes a list of %s(MISSING) values to a byte slice. func Range8ListBytes(buf []byte, list []Range8) int { b := 0 var structBytes []byte @@ -146,14 +144,12 @@ func Range8ListBytes(buf []byte, list []Range8) int { return b } -// 'Range16' struct definition -// Size: 4 type Range16 struct { First uint16 Last uint16 } -// Struct read Range16 +// Range16Read reads a byte slice into a Range16 value. func Range16Read(buf []byte, v *Range16) int { b := 0 @@ -166,7 +162,7 @@ func Range16Read(buf []byte, v *Range16) int { return b } -// Struct list read Range16 +// Range16ReadList reads a byte slice into a list of Range16 values. func Range16ReadList(buf []byte, dest []Range16) int { b := 0 for i := 0; i < len(dest); i++ { @@ -176,7 +172,7 @@ func Range16ReadList(buf []byte, dest []Range16) int { return xgb.Pad(b) } -// Struct write Range16 +// Bytes writes a Range16 value to a byte slice. func (v Range16) Bytes() []byte { buf := make([]byte, 4) b := 0 @@ -190,7 +186,7 @@ func (v Range16) Bytes() []byte { return buf } -// Write struct list Range16 +// Range16ListBytes writes a list of %s(MISSING) values to a byte slice. func Range16ListBytes(buf []byte, list []Range16) int { b := 0 var structBytes []byte @@ -202,14 +198,12 @@ func Range16ListBytes(buf []byte, list []Range16) int { return b } -// 'ExtRange' struct definition -// Size: 6 type ExtRange struct { Major Range8 Minor Range16 } -// Struct read ExtRange +// ExtRangeRead reads a byte slice into a ExtRange value. func ExtRangeRead(buf []byte, v *ExtRange) int { b := 0 @@ -222,7 +216,7 @@ func ExtRangeRead(buf []byte, v *ExtRange) int { return b } -// Struct list read ExtRange +// ExtRangeReadList reads a byte slice into a list of ExtRange values. func ExtRangeReadList(buf []byte, dest []ExtRange) int { b := 0 for i := 0; i < len(dest); i++ { @@ -232,7 +226,7 @@ func ExtRangeReadList(buf []byte, dest []ExtRange) int { return xgb.Pad(b) } -// Struct write ExtRange +// Bytes writes a ExtRange value to a byte slice. func (v ExtRange) Bytes() []byte { buf := make([]byte, 6) b := 0 @@ -252,7 +246,7 @@ func (v ExtRange) Bytes() []byte { return buf } -// Write struct list ExtRange +// ExtRangeListBytes writes a list of %s(MISSING) values to a byte slice. func ExtRangeListBytes(buf []byte, list []ExtRange) int { b := 0 var structBytes []byte @@ -264,8 +258,6 @@ func ExtRangeListBytes(buf []byte, list []ExtRange) int { return b } -// 'Range' struct definition -// Size: 24 type Range struct { CoreRequests Range8 CoreReplies Range8 @@ -278,7 +270,7 @@ type Range struct { ClientDied bool } -// Struct read Range +// RangeRead reads a byte slice into a Range value. func RangeRead(buf []byte, v *Range) int { b := 0 @@ -320,7 +312,7 @@ func RangeRead(buf []byte, v *Range) int { return b } -// Struct list read Range +// RangeReadList reads a byte slice into a list of Range values. func RangeReadList(buf []byte, dest []Range) int { b := 0 for i := 0; i < len(dest); i++ { @@ -330,7 +322,7 @@ func RangeReadList(buf []byte, dest []Range) int { return xgb.Pad(b) } -// Struct write Range +// Bytes writes a Range value to a byte slice. func (v Range) Bytes() []byte { buf := make([]byte, 24) b := 0 @@ -394,7 +386,7 @@ func (v Range) Bytes() []byte { return buf } -// Write struct list Range +// RangeListBytes writes a list of %s(MISSING) values to a byte slice. func RangeListBytes(buf []byte, list []Range) int { b := 0 var structBytes []byte @@ -406,15 +398,13 @@ func RangeListBytes(buf []byte, list []Range) int { return b } -// 'ClientInfo' struct definition -// Size: (8 + xgb.Pad((int(NumRanges) * 24))) type ClientInfo struct { ClientResource ClientSpec NumRanges uint32 Ranges []Range // size: xgb.Pad((int(NumRanges) * 24)) } -// Struct read ClientInfo +// ClientInfoRead reads a byte slice into a ClientInfo value. func ClientInfoRead(buf []byte, v *ClientInfo) int { b := 0 @@ -430,7 +420,7 @@ func ClientInfoRead(buf []byte, v *ClientInfo) int { return b } -// Struct list read ClientInfo +// ClientInfoReadList reads a byte slice into a list of ClientInfo values. func ClientInfoReadList(buf []byte, dest []ClientInfo) int { b := 0 for i := 0; i < len(dest); i++ { @@ -440,7 +430,7 @@ func ClientInfoReadList(buf []byte, dest []ClientInfo) int { return xgb.Pad(b) } -// Struct write ClientInfo +// Bytes writes a ClientInfo value to a byte slice. func (v ClientInfo) Bytes() []byte { buf := make([]byte, (8 + xgb.Pad((int(v.NumRanges) * 24)))) b := 0 @@ -456,7 +446,7 @@ func (v ClientInfo) Bytes() []byte { return buf } -// Write struct list ClientInfo +// ClientInfoListBytes writes a list of %s(MISSING) values to a byte slice. func ClientInfoListBytes(buf []byte, list []ClientInfo) int { b := 0 var structBytes []byte @@ -468,7 +458,7 @@ func ClientInfoListBytes(buf []byte, list []ClientInfo) int { return b } -// Struct list size ClientInfo +// ClientInfoListSize computes the size (bytes) of a list of ClientInfo values. func ClientInfoListSize(list []ClientInfo) int { size := 0 for _, item := range list { @@ -477,9 +467,7 @@ func ClientInfoListSize(list []ClientInfo) int { return size } -// Error definition BadContext (0) -// Size: 32 - +// BadBadContext is the error number for a BadBadContext. const BadBadContext = 0 type BadContextError struct { @@ -488,7 +476,7 @@ type BadContextError struct { InvalidRecord uint32 } -// Error read BadContext +// BadContextErrorNew constructs a BadContextError value that implements xgb.Error from a byte slice. func BadContextErrorNew(buf []byte) xgb.Error { v := BadContextError{} v.NiceName = "BadContext" @@ -505,8 +493,8 @@ func BadContextErrorNew(buf []byte) xgb.Error { return v } -func (err BadContextError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadBadContext error. +// This is mostly used internally. func (err BadContextError) SequenceId() uint16 { return err.Sequence } @@ -527,35 +515,37 @@ func init() { xgb.NewExtErrorFuncs["RECORD"][0] = BadContextErrorNew } -// Request QueryVersion -// size: 8 +// QueryVersionCookie is a cookie used only for QueryVersion requests. type QueryVersionCookie struct { *xgb.Cookie } +// QueryVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() func QueryVersion(c *xgb.Conn, MajorVersion uint16, MinorVersion uint16) QueryVersionCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) return QueryVersionCookie{cookie} } +// QueryVersionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryVersionUnchecked(c *xgb.Conn, MajorVersion uint16, MinorVersion uint16) QueryVersionCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) return QueryVersionCookie{cookie} } -// Request reply for QueryVersion -// size: 12 +// QueryVersionReply represents the data returned from a QueryVersion request. type QueryVersionReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes MajorVersion uint16 MinorVersion uint16 } -// Waits and reads reply data from request QueryVersion +// Reply blocks and returns the reply data for a QueryVersion request. func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -567,7 +557,7 @@ func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { return queryVersionReply(buf), nil } -// Read reply into structure from buffer for QueryVersion +// queryVersionReply reads a byte slice into a QueryVersionReply value. func queryVersionReply(buf []byte) *QueryVersionReply { v := new(QueryVersionReply) b := 1 // skip reply determinant @@ -590,6 +580,7 @@ func queryVersionReply(buf []byte) *QueryVersionReply { } // Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. func queryVersionRequest(c *xgb.Conn, MajorVersion uint16, MinorVersion uint16) []byte { size := 8 b := 0 @@ -613,30 +604,35 @@ func queryVersionRequest(c *xgb.Conn, MajorVersion uint16, MinorVersion uint16) return buf } -// Request CreateContext -// size: xgb.Pad(((20 + xgb.Pad((int(NumClientSpecs) * 4))) + xgb.Pad((int(NumRanges) * 24)))) +// CreateContextCookie is a cookie used only for CreateContext requests. type CreateContextCookie struct { *xgb.Cookie } -// Write request to wire for CreateContext +// CreateContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreateContext(c *xgb.Conn, Context Context, ElementHeader ElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []ClientSpec, Ranges []Range) CreateContextCookie { cookie := c.NewCookie(false, false) c.NewRequest(createContextRequest(c, Context, ElementHeader, NumClientSpecs, NumRanges, ClientSpecs, Ranges), cookie) return CreateContextCookie{cookie} } +// CreateContextChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateContextCookie.Check() func CreateContextChecked(c *xgb.Conn, Context Context, ElementHeader ElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []ClientSpec, Ranges []Range) CreateContextCookie { cookie := c.NewCookie(true, false) c.NewRequest(createContextRequest(c, Context, ElementHeader, NumClientSpecs, NumRanges, ClientSpecs, Ranges), cookie) return CreateContextCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CreateContextCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreateContext +// createContextRequest writes a CreateContext request to a byte slice. func createContextRequest(c *xgb.Conn, Context Context, ElementHeader ElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []ClientSpec, Ranges []Range) []byte { size := xgb.Pad(((20 + xgb.Pad((int(NumClientSpecs) * 4))) + xgb.Pad((int(NumRanges) * 24)))) b := 0 @@ -676,30 +672,35 @@ func createContextRequest(c *xgb.Conn, Context Context, ElementHeader ElementHea return buf } -// Request RegisterClients -// size: xgb.Pad(((20 + xgb.Pad((int(NumClientSpecs) * 4))) + xgb.Pad((int(NumRanges) * 24)))) +// RegisterClientsCookie is a cookie used only for RegisterClients requests. type RegisterClientsCookie struct { *xgb.Cookie } -// Write request to wire for RegisterClients +// RegisterClients sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func RegisterClients(c *xgb.Conn, Context Context, ElementHeader ElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []ClientSpec, Ranges []Range) RegisterClientsCookie { cookie := c.NewCookie(false, false) c.NewRequest(registerClientsRequest(c, Context, ElementHeader, NumClientSpecs, NumRanges, ClientSpecs, Ranges), cookie) return RegisterClientsCookie{cookie} } +// RegisterClientsChecked sends a checked request. +// If an error occurs, it can be retrieved using RegisterClientsCookie.Check() func RegisterClientsChecked(c *xgb.Conn, Context Context, ElementHeader ElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []ClientSpec, Ranges []Range) RegisterClientsCookie { cookie := c.NewCookie(true, false) c.NewRequest(registerClientsRequest(c, Context, ElementHeader, NumClientSpecs, NumRanges, ClientSpecs, Ranges), cookie) return RegisterClientsCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook RegisterClientsCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for RegisterClients +// registerClientsRequest writes a RegisterClients request to a byte slice. func registerClientsRequest(c *xgb.Conn, Context Context, ElementHeader ElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []ClientSpec, Ranges []Range) []byte { size := xgb.Pad(((20 + xgb.Pad((int(NumClientSpecs) * 4))) + xgb.Pad((int(NumRanges) * 24)))) b := 0 @@ -739,30 +740,35 @@ func registerClientsRequest(c *xgb.Conn, Context Context, ElementHeader ElementH return buf } -// Request UnregisterClients -// size: xgb.Pad((12 + xgb.Pad((int(NumClientSpecs) * 4)))) +// UnregisterClientsCookie is a cookie used only for UnregisterClients requests. type UnregisterClientsCookie struct { *xgb.Cookie } -// Write request to wire for UnregisterClients +// UnregisterClients sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func UnregisterClients(c *xgb.Conn, Context Context, NumClientSpecs uint32, ClientSpecs []ClientSpec) UnregisterClientsCookie { cookie := c.NewCookie(false, false) c.NewRequest(unregisterClientsRequest(c, Context, NumClientSpecs, ClientSpecs), cookie) return UnregisterClientsCookie{cookie} } +// UnregisterClientsChecked sends a checked request. +// If an error occurs, it can be retrieved using UnregisterClientsCookie.Check() func UnregisterClientsChecked(c *xgb.Conn, Context Context, NumClientSpecs uint32, ClientSpecs []ClientSpec) UnregisterClientsCookie { cookie := c.NewCookie(true, false) c.NewRequest(unregisterClientsRequest(c, Context, NumClientSpecs, ClientSpecs), cookie) return UnregisterClientsCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook UnregisterClientsCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for UnregisterClients +// unregisterClientsRequest writes a UnregisterClients request to a byte slice. func unregisterClientsRequest(c *xgb.Conn, Context Context, NumClientSpecs uint32, ClientSpecs []ClientSpec) []byte { size := xgb.Pad((12 + xgb.Pad((int(NumClientSpecs) * 4)))) b := 0 @@ -792,29 +798,31 @@ func unregisterClientsRequest(c *xgb.Conn, Context Context, NumClientSpecs uint3 return buf } -// Request GetContext -// size: 8 +// GetContextCookie is a cookie used only for GetContext requests. type GetContextCookie struct { *xgb.Cookie } +// GetContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetContextCookie.Reply() func GetContext(c *xgb.Conn, Context Context) GetContextCookie { cookie := c.NewCookie(true, true) c.NewRequest(getContextRequest(c, Context), cookie) return GetContextCookie{cookie} } +// GetContextUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetContextUnchecked(c *xgb.Conn, Context Context) GetContextCookie { cookie := c.NewCookie(false, true) c.NewRequest(getContextRequest(c, Context), cookie) return GetContextCookie{cookie} } -// Request reply for GetContext -// size: (32 + ClientInfoListSize(InterceptedClients)) +// GetContextReply represents the data returned from a GetContext request. type GetContextReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply Enabled bool ElementHeader ElementHeader // padding: 3 bytes @@ -823,7 +831,7 @@ type GetContextReply struct { InterceptedClients []ClientInfo // size: ClientInfoListSize(InterceptedClients) } -// Waits and reads reply data from request GetContext +// Reply blocks and returns the reply data for a GetContext request. func (cook GetContextCookie) Reply() (*GetContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -835,7 +843,7 @@ func (cook GetContextCookie) Reply() (*GetContextReply, error) { return getContextReply(buf), nil } -// Read reply into structure from buffer for GetContext +// getContextReply reads a byte slice into a GetContextReply value. func getContextReply(buf []byte) *GetContextReply { v := new(GetContextReply) b := 1 // skip reply determinant @@ -870,6 +878,7 @@ func getContextReply(buf []byte) *GetContextReply { } // Write request to wire for GetContext +// getContextRequest writes a GetContext request to a byte slice. func getContextRequest(c *xgb.Conn, Context Context) []byte { size := 8 b := 0 @@ -890,29 +899,31 @@ func getContextRequest(c *xgb.Conn, Context Context) []byte { return buf } -// Request EnableContext -// size: 8 +// EnableContextCookie is a cookie used only for EnableContext requests. type EnableContextCookie struct { *xgb.Cookie } +// EnableContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling EnableContextCookie.Reply() func EnableContext(c *xgb.Conn, Context Context) EnableContextCookie { cookie := c.NewCookie(true, true) c.NewRequest(enableContextRequest(c, Context), cookie) return EnableContextCookie{cookie} } +// EnableContextUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func EnableContextUnchecked(c *xgb.Conn, Context Context) EnableContextCookie { cookie := c.NewCookie(false, true) c.NewRequest(enableContextRequest(c, Context), cookie) return EnableContextCookie{cookie} } -// Request reply for EnableContext -// size: (32 + xgb.Pad(((int(Length) * 4) * 1))) +// EnableContextReply represents the data returned from a EnableContext request. type EnableContextReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply Category byte ElementHeader ElementHeader ClientSwapped bool @@ -924,7 +935,7 @@ type EnableContextReply struct { Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) } -// Waits and reads reply data from request EnableContext +// Reply blocks and returns the reply data for a EnableContext request. func (cook EnableContextCookie) Reply() (*EnableContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -936,7 +947,7 @@ func (cook EnableContextCookie) Reply() (*EnableContextReply, error) { return enableContextReply(buf), nil } -// Read reply into structure from buffer for EnableContext +// enableContextReply reads a byte slice into a EnableContextReply value. func enableContextReply(buf []byte) *EnableContextReply { v := new(EnableContextReply) b := 1 // skip reply determinant @@ -981,6 +992,7 @@ func enableContextReply(buf []byte) *EnableContextReply { } // Write request to wire for EnableContext +// enableContextRequest writes a EnableContext request to a byte slice. func enableContextRequest(c *xgb.Conn, Context Context) []byte { size := 8 b := 0 @@ -1001,30 +1013,35 @@ func enableContextRequest(c *xgb.Conn, Context Context) []byte { return buf } -// Request DisableContext -// size: 8 +// DisableContextCookie is a cookie used only for DisableContext requests. type DisableContextCookie struct { *xgb.Cookie } -// Write request to wire for DisableContext +// DisableContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func DisableContext(c *xgb.Conn, Context Context) DisableContextCookie { cookie := c.NewCookie(false, false) c.NewRequest(disableContextRequest(c, Context), cookie) return DisableContextCookie{cookie} } +// DisableContextChecked sends a checked request. +// If an error occurs, it can be retrieved using DisableContextCookie.Check() func DisableContextChecked(c *xgb.Conn, Context Context) DisableContextCookie { cookie := c.NewCookie(true, false) c.NewRequest(disableContextRequest(c, Context), cookie) return DisableContextCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook DisableContextCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for DisableContext +// disableContextRequest writes a DisableContext request to a byte slice. func disableContextRequest(c *xgb.Conn, Context Context) []byte { size := 8 b := 0 @@ -1045,30 +1062,35 @@ func disableContextRequest(c *xgb.Conn, Context Context) []byte { return buf } -// Request FreeContext -// size: 8 +// FreeContextCookie is a cookie used only for FreeContext requests. type FreeContextCookie struct { *xgb.Cookie } -// Write request to wire for FreeContext +// FreeContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func FreeContext(c *xgb.Conn, Context Context) FreeContextCookie { cookie := c.NewCookie(false, false) c.NewRequest(freeContextRequest(c, Context), cookie) return FreeContextCookie{cookie} } +// FreeContextChecked sends a checked request. +// If an error occurs, it can be retrieved using FreeContextCookie.Check() func FreeContextChecked(c *xgb.Conn, Context Context) FreeContextCookie { cookie := c.NewCookie(true, false) c.NewRequest(freeContextRequest(c, Context), cookie) return FreeContextCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook FreeContextCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for FreeContext +// freeContextRequest writes a FreeContext request to a byte slice. func freeContextRequest(c *xgb.Conn, Context Context) []byte { size := 8 b := 0 diff --git a/nexgb/render/render.go b/nexgb/render/render.go index ca3f9bd..61f0b96 100644 --- a/nexgb/render/render.go +++ b/nexgb/render/render.go @@ -2,7 +2,7 @@ package render /* - This file was generated by render.xml on May 10 2012 8:04:32pm EDT. + This file was generated by render.xml on May 10 2012 11:56:19pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,10 +40,6 @@ func init() { xgb.NewExtErrorFuncs["RENDER"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - // Skipping definition for base type 'Int32' // Skipping definition for base type 'Void' @@ -64,6 +60,10 @@ func init() { // Skipping definition for base type 'Float' +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + const ( PictTypeIndexed = 0 PictTypeDirect = 1 @@ -205,8 +205,6 @@ type Glyph uint32 type Fixed int32 -// 'Directformat' struct definition -// Size: 16 type Directformat struct { RedShift uint16 RedMask uint16 @@ -218,7 +216,7 @@ type Directformat struct { AlphaMask uint16 } -// Struct read Directformat +// DirectformatRead reads a byte slice into a Directformat value. func DirectformatRead(buf []byte, v *Directformat) int { b := 0 @@ -249,7 +247,7 @@ func DirectformatRead(buf []byte, v *Directformat) int { return b } -// Struct list read Directformat +// DirectformatReadList reads a byte slice into a list of Directformat values. func DirectformatReadList(buf []byte, dest []Directformat) int { b := 0 for i := 0; i < len(dest); i++ { @@ -259,7 +257,7 @@ func DirectformatReadList(buf []byte, dest []Directformat) int { return xgb.Pad(b) } -// Struct write Directformat +// Bytes writes a Directformat value to a byte slice. func (v Directformat) Bytes() []byte { buf := make([]byte, 16) b := 0 @@ -291,7 +289,7 @@ func (v Directformat) Bytes() []byte { return buf } -// Write struct list Directformat +// DirectformatListBytes writes a list of %s(MISSING) values to a byte slice. func DirectformatListBytes(buf []byte, list []Directformat) int { b := 0 var structBytes []byte @@ -303,8 +301,6 @@ func DirectformatListBytes(buf []byte, list []Directformat) int { return b } -// 'Pictforminfo' struct definition -// Size: 28 type Pictforminfo struct { Id Pictformat Type byte @@ -314,7 +310,7 @@ type Pictforminfo struct { Colormap xproto.Colormap } -// Struct read Pictforminfo +// PictforminfoRead reads a byte slice into a Pictforminfo value. func PictforminfoRead(buf []byte, v *Pictforminfo) int { b := 0 @@ -338,7 +334,7 @@ func PictforminfoRead(buf []byte, v *Pictforminfo) int { return b } -// Struct list read Pictforminfo +// PictforminfoReadList reads a byte slice into a list of Pictforminfo values. func PictforminfoReadList(buf []byte, dest []Pictforminfo) int { b := 0 for i := 0; i < len(dest); i++ { @@ -348,7 +344,7 @@ func PictforminfoReadList(buf []byte, dest []Pictforminfo) int { return xgb.Pad(b) } -// Struct write Pictforminfo +// Bytes writes a Pictforminfo value to a byte slice. func (v Pictforminfo) Bytes() []byte { buf := make([]byte, 28) b := 0 @@ -376,7 +372,7 @@ func (v Pictforminfo) Bytes() []byte { return buf } -// Write struct list Pictforminfo +// PictforminfoListBytes writes a list of %s(MISSING) values to a byte slice. func PictforminfoListBytes(buf []byte, list []Pictforminfo) int { b := 0 var structBytes []byte @@ -388,14 +384,12 @@ func PictforminfoListBytes(buf []byte, list []Pictforminfo) int { return b } -// 'Pictvisual' struct definition -// Size: 8 type Pictvisual struct { Visual xproto.Visualid Format Pictformat } -// Struct read Pictvisual +// PictvisualRead reads a byte slice into a Pictvisual value. func PictvisualRead(buf []byte, v *Pictvisual) int { b := 0 @@ -408,7 +402,7 @@ func PictvisualRead(buf []byte, v *Pictvisual) int { return b } -// Struct list read Pictvisual +// PictvisualReadList reads a byte slice into a list of Pictvisual values. func PictvisualReadList(buf []byte, dest []Pictvisual) int { b := 0 for i := 0; i < len(dest); i++ { @@ -418,7 +412,7 @@ func PictvisualReadList(buf []byte, dest []Pictvisual) int { return xgb.Pad(b) } -// Struct write Pictvisual +// Bytes writes a Pictvisual value to a byte slice. func (v Pictvisual) Bytes() []byte { buf := make([]byte, 8) b := 0 @@ -432,7 +426,7 @@ func (v Pictvisual) Bytes() []byte { return buf } -// Write struct list Pictvisual +// PictvisualListBytes writes a list of %s(MISSING) values to a byte slice. func PictvisualListBytes(buf []byte, list []Pictvisual) int { b := 0 var structBytes []byte @@ -444,8 +438,6 @@ func PictvisualListBytes(buf []byte, list []Pictvisual) int { return b } -// 'Pictdepth' struct definition -// Size: (8 + xgb.Pad((int(NumVisuals) * 8))) type Pictdepth struct { Depth byte // padding: 1 bytes @@ -454,7 +446,7 @@ type Pictdepth struct { Visuals []Pictvisual // size: xgb.Pad((int(NumVisuals) * 8)) } -// Struct read Pictdepth +// PictdepthRead reads a byte slice into a Pictdepth value. func PictdepthRead(buf []byte, v *Pictdepth) int { b := 0 @@ -474,7 +466,7 @@ func PictdepthRead(buf []byte, v *Pictdepth) int { return b } -// Struct list read Pictdepth +// PictdepthReadList reads a byte slice into a list of Pictdepth values. func PictdepthReadList(buf []byte, dest []Pictdepth) int { b := 0 for i := 0; i < len(dest); i++ { @@ -484,7 +476,7 @@ func PictdepthReadList(buf []byte, dest []Pictdepth) int { return xgb.Pad(b) } -// Struct write Pictdepth +// Bytes writes a Pictdepth value to a byte slice. func (v Pictdepth) Bytes() []byte { buf := make([]byte, (8 + xgb.Pad((int(v.NumVisuals) * 8)))) b := 0 @@ -504,7 +496,7 @@ func (v Pictdepth) Bytes() []byte { return buf } -// Write struct list Pictdepth +// PictdepthListBytes writes a list of %s(MISSING) values to a byte slice. func PictdepthListBytes(buf []byte, list []Pictdepth) int { b := 0 var structBytes []byte @@ -516,7 +508,7 @@ func PictdepthListBytes(buf []byte, list []Pictdepth) int { return b } -// Struct list size Pictdepth +// PictdepthListSize computes the size (bytes) of a list of Pictdepth values. func PictdepthListSize(list []Pictdepth) int { size := 0 for _, item := range list { @@ -525,15 +517,13 @@ func PictdepthListSize(list []Pictdepth) int { return size } -// 'Pictscreen' struct definition -// Size: (8 + PictdepthListSize(Depths)) type Pictscreen struct { NumDepths uint32 Fallback Pictformat Depths []Pictdepth // size: PictdepthListSize(Depths) } -// Struct read Pictscreen +// PictscreenRead reads a byte slice into a Pictscreen value. func PictscreenRead(buf []byte, v *Pictscreen) int { b := 0 @@ -549,7 +539,7 @@ func PictscreenRead(buf []byte, v *Pictscreen) int { return b } -// Struct list read Pictscreen +// PictscreenReadList reads a byte slice into a list of Pictscreen values. func PictscreenReadList(buf []byte, dest []Pictscreen) int { b := 0 for i := 0; i < len(dest); i++ { @@ -559,7 +549,7 @@ func PictscreenReadList(buf []byte, dest []Pictscreen) int { return xgb.Pad(b) } -// Struct write Pictscreen +// Bytes writes a Pictscreen value to a byte slice. func (v Pictscreen) Bytes() []byte { buf := make([]byte, (8 + PictdepthListSize(v.Depths))) b := 0 @@ -575,7 +565,7 @@ func (v Pictscreen) Bytes() []byte { return buf } -// Write struct list Pictscreen +// PictscreenListBytes writes a list of %s(MISSING) values to a byte slice. func PictscreenListBytes(buf []byte, list []Pictscreen) int { b := 0 var structBytes []byte @@ -587,7 +577,7 @@ func PictscreenListBytes(buf []byte, list []Pictscreen) int { return b } -// Struct list size Pictscreen +// PictscreenListSize computes the size (bytes) of a list of Pictscreen values. func PictscreenListSize(list []Pictscreen) int { size := 0 for _, item := range list { @@ -596,8 +586,6 @@ func PictscreenListSize(list []Pictscreen) int { return size } -// 'Indexvalue' struct definition -// Size: 12 type Indexvalue struct { Pixel uint32 Red uint16 @@ -606,7 +594,7 @@ type Indexvalue struct { Alpha uint16 } -// Struct read Indexvalue +// IndexvalueRead reads a byte slice into a Indexvalue value. func IndexvalueRead(buf []byte, v *Indexvalue) int { b := 0 @@ -628,7 +616,7 @@ func IndexvalueRead(buf []byte, v *Indexvalue) int { return b } -// Struct list read Indexvalue +// IndexvalueReadList reads a byte slice into a list of Indexvalue values. func IndexvalueReadList(buf []byte, dest []Indexvalue) int { b := 0 for i := 0; i < len(dest); i++ { @@ -638,7 +626,7 @@ func IndexvalueReadList(buf []byte, dest []Indexvalue) int { return xgb.Pad(b) } -// Struct write Indexvalue +// Bytes writes a Indexvalue value to a byte slice. func (v Indexvalue) Bytes() []byte { buf := make([]byte, 12) b := 0 @@ -661,7 +649,7 @@ func (v Indexvalue) Bytes() []byte { return buf } -// Write struct list Indexvalue +// IndexvalueListBytes writes a list of %s(MISSING) values to a byte slice. func IndexvalueListBytes(buf []byte, list []Indexvalue) int { b := 0 var structBytes []byte @@ -673,8 +661,6 @@ func IndexvalueListBytes(buf []byte, list []Indexvalue) int { return b } -// 'Color' struct definition -// Size: 8 type Color struct { Red uint16 Green uint16 @@ -682,7 +668,7 @@ type Color struct { Alpha uint16 } -// Struct read Color +// ColorRead reads a byte slice into a Color value. func ColorRead(buf []byte, v *Color) int { b := 0 @@ -701,7 +687,7 @@ func ColorRead(buf []byte, v *Color) int { return b } -// Struct list read Color +// ColorReadList reads a byte slice into a list of Color values. func ColorReadList(buf []byte, dest []Color) int { b := 0 for i := 0; i < len(dest); i++ { @@ -711,7 +697,7 @@ func ColorReadList(buf []byte, dest []Color) int { return xgb.Pad(b) } -// Struct write Color +// Bytes writes a Color value to a byte slice. func (v Color) Bytes() []byte { buf := make([]byte, 8) b := 0 @@ -731,7 +717,7 @@ func (v Color) Bytes() []byte { return buf } -// Write struct list Color +// ColorListBytes writes a list of %s(MISSING) values to a byte slice. func ColorListBytes(buf []byte, list []Color) int { b := 0 var structBytes []byte @@ -743,14 +729,12 @@ func ColorListBytes(buf []byte, list []Color) int { return b } -// 'Pointfix' struct definition -// Size: 8 type Pointfix struct { X Fixed Y Fixed } -// Struct read Pointfix +// PointfixRead reads a byte slice into a Pointfix value. func PointfixRead(buf []byte, v *Pointfix) int { b := 0 @@ -763,7 +747,7 @@ func PointfixRead(buf []byte, v *Pointfix) int { return b } -// Struct list read Pointfix +// PointfixReadList reads a byte slice into a list of Pointfix values. func PointfixReadList(buf []byte, dest []Pointfix) int { b := 0 for i := 0; i < len(dest); i++ { @@ -773,7 +757,7 @@ func PointfixReadList(buf []byte, dest []Pointfix) int { return xgb.Pad(b) } -// Struct write Pointfix +// Bytes writes a Pointfix value to a byte slice. func (v Pointfix) Bytes() []byte { buf := make([]byte, 8) b := 0 @@ -787,7 +771,7 @@ func (v Pointfix) Bytes() []byte { return buf } -// Write struct list Pointfix +// PointfixListBytes writes a list of %s(MISSING) values to a byte slice. func PointfixListBytes(buf []byte, list []Pointfix) int { b := 0 var structBytes []byte @@ -799,14 +783,12 @@ func PointfixListBytes(buf []byte, list []Pointfix) int { return b } -// 'Linefix' struct definition -// Size: 16 type Linefix struct { P1 Pointfix P2 Pointfix } -// Struct read Linefix +// LinefixRead reads a byte slice into a Linefix value. func LinefixRead(buf []byte, v *Linefix) int { b := 0 @@ -819,7 +801,7 @@ func LinefixRead(buf []byte, v *Linefix) int { return b } -// Struct list read Linefix +// LinefixReadList reads a byte slice into a list of Linefix values. func LinefixReadList(buf []byte, dest []Linefix) int { b := 0 for i := 0; i < len(dest); i++ { @@ -829,7 +811,7 @@ func LinefixReadList(buf []byte, dest []Linefix) int { return xgb.Pad(b) } -// Struct write Linefix +// Bytes writes a Linefix value to a byte slice. func (v Linefix) Bytes() []byte { buf := make([]byte, 16) b := 0 @@ -849,7 +831,7 @@ func (v Linefix) Bytes() []byte { return buf } -// Write struct list Linefix +// LinefixListBytes writes a list of %s(MISSING) values to a byte slice. func LinefixListBytes(buf []byte, list []Linefix) int { b := 0 var structBytes []byte @@ -861,15 +843,13 @@ func LinefixListBytes(buf []byte, list []Linefix) int { return b } -// 'Triangle' struct definition -// Size: 24 type Triangle struct { P1 Pointfix P2 Pointfix P3 Pointfix } -// Struct read Triangle +// TriangleRead reads a byte slice into a Triangle value. func TriangleRead(buf []byte, v *Triangle) int { b := 0 @@ -885,7 +865,7 @@ func TriangleRead(buf []byte, v *Triangle) int { return b } -// Struct list read Triangle +// TriangleReadList reads a byte slice into a list of Triangle values. func TriangleReadList(buf []byte, dest []Triangle) int { b := 0 for i := 0; i < len(dest); i++ { @@ -895,7 +875,7 @@ func TriangleReadList(buf []byte, dest []Triangle) int { return xgb.Pad(b) } -// Struct write Triangle +// Bytes writes a Triangle value to a byte slice. func (v Triangle) Bytes() []byte { buf := make([]byte, 24) b := 0 @@ -921,7 +901,7 @@ func (v Triangle) Bytes() []byte { return buf } -// Write struct list Triangle +// TriangleListBytes writes a list of %s(MISSING) values to a byte slice. func TriangleListBytes(buf []byte, list []Triangle) int { b := 0 var structBytes []byte @@ -933,8 +913,6 @@ func TriangleListBytes(buf []byte, list []Triangle) int { return b } -// 'Trapezoid' struct definition -// Size: 40 type Trapezoid struct { Top Fixed Bottom Fixed @@ -942,7 +920,7 @@ type Trapezoid struct { Right Linefix } -// Struct read Trapezoid +// TrapezoidRead reads a byte slice into a Trapezoid value. func TrapezoidRead(buf []byte, v *Trapezoid) int { b := 0 @@ -961,7 +939,7 @@ func TrapezoidRead(buf []byte, v *Trapezoid) int { return b } -// Struct list read Trapezoid +// TrapezoidReadList reads a byte slice into a list of Trapezoid values. func TrapezoidReadList(buf []byte, dest []Trapezoid) int { b := 0 for i := 0; i < len(dest); i++ { @@ -971,7 +949,7 @@ func TrapezoidReadList(buf []byte, dest []Trapezoid) int { return xgb.Pad(b) } -// Struct write Trapezoid +// Bytes writes a Trapezoid value to a byte slice. func (v Trapezoid) Bytes() []byte { buf := make([]byte, 40) b := 0 @@ -997,7 +975,7 @@ func (v Trapezoid) Bytes() []byte { return buf } -// Write struct list Trapezoid +// TrapezoidListBytes writes a list of %s(MISSING) values to a byte slice. func TrapezoidListBytes(buf []byte, list []Trapezoid) int { b := 0 var structBytes []byte @@ -1009,8 +987,6 @@ func TrapezoidListBytes(buf []byte, list []Trapezoid) int { return b } -// 'Glyphinfo' struct definition -// Size: 12 type Glyphinfo struct { Width uint16 Height uint16 @@ -1020,7 +996,7 @@ type Glyphinfo struct { YOff int16 } -// Struct read Glyphinfo +// GlyphinfoRead reads a byte slice into a Glyphinfo value. func GlyphinfoRead(buf []byte, v *Glyphinfo) int { b := 0 @@ -1045,7 +1021,7 @@ func GlyphinfoRead(buf []byte, v *Glyphinfo) int { return b } -// Struct list read Glyphinfo +// GlyphinfoReadList reads a byte slice into a list of Glyphinfo values. func GlyphinfoReadList(buf []byte, dest []Glyphinfo) int { b := 0 for i := 0; i < len(dest); i++ { @@ -1055,7 +1031,7 @@ func GlyphinfoReadList(buf []byte, dest []Glyphinfo) int { return xgb.Pad(b) } -// Struct write Glyphinfo +// Bytes writes a Glyphinfo value to a byte slice. func (v Glyphinfo) Bytes() []byte { buf := make([]byte, 12) b := 0 @@ -1081,7 +1057,7 @@ func (v Glyphinfo) Bytes() []byte { return buf } -// Write struct list Glyphinfo +// GlyphinfoListBytes writes a list of %s(MISSING) values to a byte slice. func GlyphinfoListBytes(buf []byte, list []Glyphinfo) int { b := 0 var structBytes []byte @@ -1093,8 +1069,6 @@ func GlyphinfoListBytes(buf []byte, list []Glyphinfo) int { return b } -// 'Transform' struct definition -// Size: 36 type Transform struct { Matrix11 Fixed Matrix12 Fixed @@ -1107,7 +1081,7 @@ type Transform struct { Matrix33 Fixed } -// Struct read Transform +// TransformRead reads a byte slice into a Transform value. func TransformRead(buf []byte, v *Transform) int { b := 0 @@ -1141,7 +1115,7 @@ func TransformRead(buf []byte, v *Transform) int { return b } -// Struct list read Transform +// TransformReadList reads a byte slice into a list of Transform values. func TransformReadList(buf []byte, dest []Transform) int { b := 0 for i := 0; i < len(dest); i++ { @@ -1151,7 +1125,7 @@ func TransformReadList(buf []byte, dest []Transform) int { return xgb.Pad(b) } -// Struct write Transform +// Bytes writes a Transform value to a byte slice. func (v Transform) Bytes() []byte { buf := make([]byte, 36) b := 0 @@ -1186,7 +1160,7 @@ func (v Transform) Bytes() []byte { return buf } -// Write struct list Transform +// TransformListBytes writes a list of %s(MISSING) values to a byte slice. func TransformListBytes(buf []byte, list []Transform) int { b := 0 var structBytes []byte @@ -1198,14 +1172,12 @@ func TransformListBytes(buf []byte, list []Transform) int { return b } -// 'Animcursorelt' struct definition -// Size: 8 type Animcursorelt struct { Cursor xproto.Cursor Delay uint32 } -// Struct read Animcursorelt +// AnimcursoreltRead reads a byte slice into a Animcursorelt value. func AnimcursoreltRead(buf []byte, v *Animcursorelt) int { b := 0 @@ -1218,7 +1190,7 @@ func AnimcursoreltRead(buf []byte, v *Animcursorelt) int { return b } -// Struct list read Animcursorelt +// AnimcursoreltReadList reads a byte slice into a list of Animcursorelt values. func AnimcursoreltReadList(buf []byte, dest []Animcursorelt) int { b := 0 for i := 0; i < len(dest); i++ { @@ -1228,7 +1200,7 @@ func AnimcursoreltReadList(buf []byte, dest []Animcursorelt) int { return xgb.Pad(b) } -// Struct write Animcursorelt +// Bytes writes a Animcursorelt value to a byte slice. func (v Animcursorelt) Bytes() []byte { buf := make([]byte, 8) b := 0 @@ -1242,7 +1214,7 @@ func (v Animcursorelt) Bytes() []byte { return buf } -// Write struct list Animcursorelt +// AnimcursoreltListBytes writes a list of %s(MISSING) values to a byte slice. func AnimcursoreltListBytes(buf []byte, list []Animcursorelt) int { b := 0 var structBytes []byte @@ -1254,15 +1226,13 @@ func AnimcursoreltListBytes(buf []byte, list []Animcursorelt) int { return b } -// 'Spanfix' struct definition -// Size: 12 type Spanfix struct { L Fixed R Fixed Y Fixed } -// Struct read Spanfix +// SpanfixRead reads a byte slice into a Spanfix value. func SpanfixRead(buf []byte, v *Spanfix) int { b := 0 @@ -1278,7 +1248,7 @@ func SpanfixRead(buf []byte, v *Spanfix) int { return b } -// Struct list read Spanfix +// SpanfixReadList reads a byte slice into a list of Spanfix values. func SpanfixReadList(buf []byte, dest []Spanfix) int { b := 0 for i := 0; i < len(dest); i++ { @@ -1288,7 +1258,7 @@ func SpanfixReadList(buf []byte, dest []Spanfix) int { return xgb.Pad(b) } -// Struct write Spanfix +// Bytes writes a Spanfix value to a byte slice. func (v Spanfix) Bytes() []byte { buf := make([]byte, 12) b := 0 @@ -1305,7 +1275,7 @@ func (v Spanfix) Bytes() []byte { return buf } -// Write struct list Spanfix +// SpanfixListBytes writes a list of %s(MISSING) values to a byte slice. func SpanfixListBytes(buf []byte, list []Spanfix) int { b := 0 var structBytes []byte @@ -1317,14 +1287,12 @@ func SpanfixListBytes(buf []byte, list []Spanfix) int { return b } -// 'Trap' struct definition -// Size: 24 type Trap struct { Top Spanfix Bot Spanfix } -// Struct read Trap +// TrapRead reads a byte slice into a Trap value. func TrapRead(buf []byte, v *Trap) int { b := 0 @@ -1337,7 +1305,7 @@ func TrapRead(buf []byte, v *Trap) int { return b } -// Struct list read Trap +// TrapReadList reads a byte slice into a list of Trap values. func TrapReadList(buf []byte, dest []Trap) int { b := 0 for i := 0; i < len(dest); i++ { @@ -1347,7 +1315,7 @@ func TrapReadList(buf []byte, dest []Trap) int { return xgb.Pad(b) } -// Struct write Trap +// Bytes writes a Trap value to a byte slice. func (v Trap) Bytes() []byte { buf := make([]byte, 24) b := 0 @@ -1367,7 +1335,7 @@ func (v Trap) Bytes() []byte { return buf } -// Write struct list Trap +// TrapListBytes writes a list of %s(MISSING) values to a byte slice. func TrapListBytes(buf []byte, list []Trap) int { b := 0 var structBytes []byte @@ -1379,9 +1347,7 @@ func TrapListBytes(buf []byte, list []Trap) int { return b } -// Error definition PictFormat (0) -// Size: 32 - +// BadPictFormat is the error number for a BadPictFormat. const BadPictFormat = 0 type PictFormatError struct { @@ -1389,7 +1355,7 @@ type PictFormatError struct { NiceName string } -// Error read PictFormat +// PictFormatErrorNew constructs a PictFormatError value that implements xgb.Error from a byte slice. func PictFormatErrorNew(buf []byte) xgb.Error { v := PictFormatError{} v.NiceName = "PictFormat" @@ -1403,8 +1369,8 @@ func PictFormatErrorNew(buf []byte) xgb.Error { return v } -func (err PictFormatError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadPictFormat error. +// This is mostly used internally. func (err PictFormatError) SequenceId() uint16 { return err.Sequence } @@ -1424,9 +1390,7 @@ func init() { xgb.NewExtErrorFuncs["RENDER"][0] = PictFormatErrorNew } -// Error definition Picture (1) -// Size: 32 - +// BadPicture is the error number for a BadPicture. const BadPicture = 1 type PictureError struct { @@ -1434,7 +1398,7 @@ type PictureError struct { NiceName string } -// Error read Picture +// PictureErrorNew constructs a PictureError value that implements xgb.Error from a byte slice. func PictureErrorNew(buf []byte) xgb.Error { v := PictureError{} v.NiceName = "Picture" @@ -1448,8 +1412,8 @@ func PictureErrorNew(buf []byte) xgb.Error { return v } -func (err PictureError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadPicture error. +// This is mostly used internally. func (err PictureError) SequenceId() uint16 { return err.Sequence } @@ -1469,9 +1433,7 @@ func init() { xgb.NewExtErrorFuncs["RENDER"][1] = PictureErrorNew } -// Error definition PictOp (2) -// Size: 32 - +// BadPictOp is the error number for a BadPictOp. const BadPictOp = 2 type PictOpError struct { @@ -1479,7 +1441,7 @@ type PictOpError struct { NiceName string } -// Error read PictOp +// PictOpErrorNew constructs a PictOpError value that implements xgb.Error from a byte slice. func PictOpErrorNew(buf []byte) xgb.Error { v := PictOpError{} v.NiceName = "PictOp" @@ -1493,8 +1455,8 @@ func PictOpErrorNew(buf []byte) xgb.Error { return v } -func (err PictOpError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadPictOp error. +// This is mostly used internally. func (err PictOpError) SequenceId() uint16 { return err.Sequence } @@ -1514,9 +1476,7 @@ func init() { xgb.NewExtErrorFuncs["RENDER"][2] = PictOpErrorNew } -// Error definition GlyphSet (3) -// Size: 32 - +// BadGlyphSet is the error number for a BadGlyphSet. const BadGlyphSet = 3 type GlyphSetError struct { @@ -1524,7 +1484,7 @@ type GlyphSetError struct { NiceName string } -// Error read GlyphSet +// GlyphSetErrorNew constructs a GlyphSetError value that implements xgb.Error from a byte slice. func GlyphSetErrorNew(buf []byte) xgb.Error { v := GlyphSetError{} v.NiceName = "GlyphSet" @@ -1538,8 +1498,8 @@ func GlyphSetErrorNew(buf []byte) xgb.Error { return v } -func (err GlyphSetError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadGlyphSet error. +// This is mostly used internally. func (err GlyphSetError) SequenceId() uint16 { return err.Sequence } @@ -1559,9 +1519,7 @@ func init() { xgb.NewExtErrorFuncs["RENDER"][3] = GlyphSetErrorNew } -// Error definition Glyph (4) -// Size: 32 - +// BadGlyph is the error number for a BadGlyph. const BadGlyph = 4 type GlyphError struct { @@ -1569,7 +1527,7 @@ type GlyphError struct { NiceName string } -// Error read Glyph +// GlyphErrorNew constructs a GlyphError value that implements xgb.Error from a byte slice. func GlyphErrorNew(buf []byte) xgb.Error { v := GlyphError{} v.NiceName = "Glyph" @@ -1583,8 +1541,8 @@ func GlyphErrorNew(buf []byte) xgb.Error { return v } -func (err GlyphError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadGlyph error. +// This is mostly used internally. func (err GlyphError) SequenceId() uint16 { return err.Sequence } @@ -1604,36 +1562,38 @@ func init() { xgb.NewExtErrorFuncs["RENDER"][4] = GlyphErrorNew } -// Request QueryVersion -// size: 12 +// QueryVersionCookie is a cookie used only for QueryVersion requests. type QueryVersionCookie struct { *xgb.Cookie } +// QueryVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() func QueryVersion(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) return QueryVersionCookie{cookie} } +// QueryVersionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) return QueryVersionCookie{cookie} } -// Request reply for QueryVersion -// size: 32 +// QueryVersionReply represents the data returned from a QueryVersion request. type QueryVersionReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes MajorVersion uint32 MinorVersion uint32 // padding: 16 bytes } -// Waits and reads reply data from request QueryVersion +// Reply blocks and returns the reply data for a QueryVersion request. func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1645,7 +1605,7 @@ func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { return queryVersionReply(buf), nil } -// Read reply into structure from buffer for QueryVersion +// queryVersionReply reads a byte slice into a QueryVersionReply value. func queryVersionReply(buf []byte) *QueryVersionReply { v := new(QueryVersionReply) b := 1 // skip reply determinant @@ -1670,6 +1630,7 @@ func queryVersionReply(buf []byte) *QueryVersionReply { } // Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) []byte { size := 12 b := 0 @@ -1693,29 +1654,31 @@ func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVers return buf } -// Request QueryPictFormats -// size: 4 +// QueryPictFormatsCookie is a cookie used only for QueryPictFormats requests. type QueryPictFormatsCookie struct { *xgb.Cookie } +// QueryPictFormats sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryPictFormatsCookie.Reply() func QueryPictFormats(c *xgb.Conn) QueryPictFormatsCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryPictFormatsRequest(c), cookie) return QueryPictFormatsCookie{cookie} } +// QueryPictFormatsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryPictFormatsUnchecked(c *xgb.Conn) QueryPictFormatsCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryPictFormatsRequest(c), cookie) return QueryPictFormatsCookie{cookie} } -// Request reply for QueryPictFormats -// size: (((32 + xgb.Pad((int(NumFormats) * 28))) + PictscreenListSize(Screens)) + xgb.Pad((int(NumSubpixel) * 4))) +// QueryPictFormatsReply represents the data returned from a QueryPictFormats request. type QueryPictFormatsReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes NumFormats uint32 NumScreens uint32 @@ -1728,7 +1691,7 @@ type QueryPictFormatsReply struct { Subpixels []uint32 // size: xgb.Pad((int(NumSubpixel) * 4)) } -// Waits and reads reply data from request QueryPictFormats +// Reply blocks and returns the reply data for a QueryPictFormats request. func (cook QueryPictFormatsCookie) Reply() (*QueryPictFormatsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1740,7 +1703,7 @@ func (cook QueryPictFormatsCookie) Reply() (*QueryPictFormatsReply, error) { return queryPictFormatsReply(buf), nil } -// Read reply into structure from buffer for QueryPictFormats +// queryPictFormatsReply reads a byte slice into a QueryPictFormatsReply value. func queryPictFormatsReply(buf []byte) *QueryPictFormatsReply { v := new(QueryPictFormatsReply) b := 1 // skip reply determinant @@ -1787,6 +1750,7 @@ func queryPictFormatsReply(buf []byte) *QueryPictFormatsReply { } // Write request to wire for QueryPictFormats +// queryPictFormatsRequest writes a QueryPictFormats request to a byte slice. func queryPictFormatsRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -1804,36 +1768,38 @@ func queryPictFormatsRequest(c *xgb.Conn) []byte { return buf } -// Request QueryPictIndexValues -// size: 8 +// QueryPictIndexValuesCookie is a cookie used only for QueryPictIndexValues requests. type QueryPictIndexValuesCookie struct { *xgb.Cookie } +// QueryPictIndexValues sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryPictIndexValuesCookie.Reply() func QueryPictIndexValues(c *xgb.Conn, Format Pictformat) QueryPictIndexValuesCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryPictIndexValuesRequest(c, Format), cookie) return QueryPictIndexValuesCookie{cookie} } +// QueryPictIndexValuesUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryPictIndexValuesUnchecked(c *xgb.Conn, Format Pictformat) QueryPictIndexValuesCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryPictIndexValuesRequest(c, Format), cookie) return QueryPictIndexValuesCookie{cookie} } -// Request reply for QueryPictIndexValues -// size: (32 + xgb.Pad((int(NumValues) * 12))) +// QueryPictIndexValuesReply represents the data returned from a QueryPictIndexValues request. type QueryPictIndexValuesReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes NumValues uint32 // padding: 20 bytes Values []Indexvalue // size: xgb.Pad((int(NumValues) * 12)) } -// Waits and reads reply data from request QueryPictIndexValues +// Reply blocks and returns the reply data for a QueryPictIndexValues request. func (cook QueryPictIndexValuesCookie) Reply() (*QueryPictIndexValuesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1845,7 +1811,7 @@ func (cook QueryPictIndexValuesCookie) Reply() (*QueryPictIndexValuesReply, erro return queryPictIndexValuesReply(buf), nil } -// Read reply into structure from buffer for QueryPictIndexValues +// queryPictIndexValuesReply reads a byte slice into a QueryPictIndexValuesReply value. func queryPictIndexValuesReply(buf []byte) *QueryPictIndexValuesReply { v := new(QueryPictIndexValuesReply) b := 1 // skip reply determinant @@ -1870,6 +1836,7 @@ func queryPictIndexValuesReply(buf []byte) *QueryPictIndexValuesReply { } // Write request to wire for QueryPictIndexValues +// queryPictIndexValuesRequest writes a QueryPictIndexValues request to a byte slice. func queryPictIndexValuesRequest(c *xgb.Conn, Format Pictformat) []byte { size := 8 b := 0 @@ -1890,30 +1857,35 @@ func queryPictIndexValuesRequest(c *xgb.Conn, Format Pictformat) []byte { return buf } -// Request CreatePicture -// size: xgb.Pad((16 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +// CreatePictureCookie is a cookie used only for CreatePicture requests. type CreatePictureCookie struct { *xgb.Cookie } -// Write request to wire for CreatePicture +// CreatePicture sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreatePicture(c *xgb.Conn, Pid Picture, Drawable xproto.Drawable, Format Pictformat, ValueMask uint32, ValueList []uint32) CreatePictureCookie { cookie := c.NewCookie(false, false) c.NewRequest(createPictureRequest(c, Pid, Drawable, Format, ValueMask, ValueList), cookie) return CreatePictureCookie{cookie} } +// CreatePictureChecked sends a checked request. +// If an error occurs, it can be retrieved using CreatePictureCookie.Check() func CreatePictureChecked(c *xgb.Conn, Pid Picture, Drawable xproto.Drawable, Format Pictformat, ValueMask uint32, ValueList []uint32) CreatePictureCookie { cookie := c.NewCookie(true, false) c.NewRequest(createPictureRequest(c, Pid, Drawable, Format, ValueMask, ValueList), cookie) return CreatePictureCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CreatePictureCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreatePicture +// createPictureRequest writes a CreatePicture request to a byte slice. func createPictureRequest(c *xgb.Conn, Pid Picture, Drawable xproto.Drawable, Format Pictformat, ValueMask uint32, ValueList []uint32) []byte { size := xgb.Pad((16 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) b := 0 @@ -1948,30 +1920,35 @@ func createPictureRequest(c *xgb.Conn, Pid Picture, Drawable xproto.Drawable, Fo return buf } -// Request ChangePicture -// size: xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +// ChangePictureCookie is a cookie used only for ChangePicture requests. type ChangePictureCookie struct { *xgb.Cookie } -// Write request to wire for ChangePicture +// ChangePicture sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ChangePicture(c *xgb.Conn, Picture Picture, ValueMask uint32, ValueList []uint32) ChangePictureCookie { cookie := c.NewCookie(false, false) c.NewRequest(changePictureRequest(c, Picture, ValueMask, ValueList), cookie) return ChangePictureCookie{cookie} } +// ChangePictureChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangePictureCookie.Check() func ChangePictureChecked(c *xgb.Conn, Picture Picture, ValueMask uint32, ValueList []uint32) ChangePictureCookie { cookie := c.NewCookie(true, false) c.NewRequest(changePictureRequest(c, Picture, ValueMask, ValueList), cookie) return ChangePictureCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook ChangePictureCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ChangePicture +// changePictureRequest writes a ChangePicture request to a byte slice. func changePictureRequest(c *xgb.Conn, Picture Picture, ValueMask uint32, ValueList []uint32) []byte { size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) b := 0 @@ -2000,30 +1977,35 @@ func changePictureRequest(c *xgb.Conn, Picture Picture, ValueMask uint32, ValueL return buf } -// Request SetPictureClipRectangles -// size: xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) +// SetPictureClipRectanglesCookie is a cookie used only for SetPictureClipRectangles requests. type SetPictureClipRectanglesCookie struct { *xgb.Cookie } -// Write request to wire for SetPictureClipRectangles +// SetPictureClipRectangles sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetPictureClipRectangles(c *xgb.Conn, Picture Picture, ClipXOrigin int16, ClipYOrigin int16, Rectangles []xproto.Rectangle) SetPictureClipRectanglesCookie { cookie := c.NewCookie(false, false) c.NewRequest(setPictureClipRectanglesRequest(c, Picture, ClipXOrigin, ClipYOrigin, Rectangles), cookie) return SetPictureClipRectanglesCookie{cookie} } +// SetPictureClipRectanglesChecked sends a checked request. +// If an error occurs, it can be retrieved using SetPictureClipRectanglesCookie.Check() func SetPictureClipRectanglesChecked(c *xgb.Conn, Picture Picture, ClipXOrigin int16, ClipYOrigin int16, Rectangles []xproto.Rectangle) SetPictureClipRectanglesCookie { cookie := c.NewCookie(true, false) c.NewRequest(setPictureClipRectanglesRequest(c, Picture, ClipXOrigin, ClipYOrigin, Rectangles), cookie) return SetPictureClipRectanglesCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetPictureClipRectanglesCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetPictureClipRectangles +// setPictureClipRectanglesRequest writes a SetPictureClipRectangles request to a byte slice. func setPictureClipRectanglesRequest(c *xgb.Conn, Picture Picture, ClipXOrigin int16, ClipYOrigin int16, Rectangles []xproto.Rectangle) []byte { size := xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) b := 0 @@ -2052,30 +2034,35 @@ func setPictureClipRectanglesRequest(c *xgb.Conn, Picture Picture, ClipXOrigin i return buf } -// Request FreePicture -// size: 8 +// FreePictureCookie is a cookie used only for FreePicture requests. type FreePictureCookie struct { *xgb.Cookie } -// Write request to wire for FreePicture +// FreePicture sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func FreePicture(c *xgb.Conn, Picture Picture) FreePictureCookie { cookie := c.NewCookie(false, false) c.NewRequest(freePictureRequest(c, Picture), cookie) return FreePictureCookie{cookie} } +// FreePictureChecked sends a checked request. +// If an error occurs, it can be retrieved using FreePictureCookie.Check() func FreePictureChecked(c *xgb.Conn, Picture Picture) FreePictureCookie { cookie := c.NewCookie(true, false) c.NewRequest(freePictureRequest(c, Picture), cookie) return FreePictureCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook FreePictureCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for FreePicture +// freePictureRequest writes a FreePicture request to a byte slice. func freePictureRequest(c *xgb.Conn, Picture Picture) []byte { size := 8 b := 0 @@ -2096,30 +2083,35 @@ func freePictureRequest(c *xgb.Conn, Picture Picture) []byte { return buf } -// Request Composite -// size: 36 +// CompositeCookie is a cookie used only for Composite requests. type CompositeCookie struct { *xgb.Cookie } -// Write request to wire for Composite +// Composite sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func Composite(c *xgb.Conn, Op byte, Src Picture, Mask Picture, Dst Picture, SrcX int16, SrcY int16, MaskX int16, MaskY int16, DstX int16, DstY int16, Width uint16, Height uint16) CompositeCookie { cookie := c.NewCookie(false, false) c.NewRequest(compositeRequest(c, Op, Src, Mask, Dst, SrcX, SrcY, MaskX, MaskY, DstX, DstY, Width, Height), cookie) return CompositeCookie{cookie} } +// CompositeChecked sends a checked request. +// If an error occurs, it can be retrieved using CompositeCookie.Check() func CompositeChecked(c *xgb.Conn, Op byte, Src Picture, Mask Picture, Dst Picture, SrcX int16, SrcY int16, MaskX int16, MaskY int16, DstX int16, DstY int16, Width uint16, Height uint16) CompositeCookie { cookie := c.NewCookie(true, false) c.NewRequest(compositeRequest(c, Op, Src, Mask, Dst, SrcX, SrcY, MaskX, MaskY, DstX, DstY, Width, Height), cookie) return CompositeCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CompositeCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for Composite +// compositeRequest writes a Composite request to a byte slice. func compositeRequest(c *xgb.Conn, Op byte, Src Picture, Mask Picture, Dst Picture, SrcX int16, SrcY int16, MaskX int16, MaskY int16, DstX int16, DstY int16, Width uint16, Height uint16) []byte { size := 36 b := 0 @@ -2175,30 +2167,35 @@ func compositeRequest(c *xgb.Conn, Op byte, Src Picture, Mask Picture, Dst Pictu return buf } -// Request Trapezoids -// size: xgb.Pad((24 + xgb.Pad((len(Traps) * 40)))) +// TrapezoidsCookie is a cookie used only for Trapezoids requests. type TrapezoidsCookie struct { *xgb.Cookie } -// Write request to wire for Trapezoids +// Trapezoids sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func Trapezoids(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Traps []Trapezoid) TrapezoidsCookie { cookie := c.NewCookie(false, false) c.NewRequest(trapezoidsRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Traps), cookie) return TrapezoidsCookie{cookie} } +// TrapezoidsChecked sends a checked request. +// If an error occurs, it can be retrieved using TrapezoidsCookie.Check() func TrapezoidsChecked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Traps []Trapezoid) TrapezoidsCookie { cookie := c.NewCookie(true, false) c.NewRequest(trapezoidsRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Traps), cookie) return TrapezoidsCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook TrapezoidsCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for Trapezoids +// trapezoidsRequest writes a Trapezoids request to a byte slice. func trapezoidsRequest(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Traps []Trapezoid) []byte { size := xgb.Pad((24 + xgb.Pad((len(Traps) * 40)))) b := 0 @@ -2238,30 +2235,35 @@ func trapezoidsRequest(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskForma return buf } -// Request Triangles -// size: xgb.Pad((24 + xgb.Pad((len(Triangles) * 24)))) +// TrianglesCookie is a cookie used only for Triangles requests. type TrianglesCookie struct { *xgb.Cookie } -// Write request to wire for Triangles +// Triangles sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func Triangles(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Triangles []Triangle) TrianglesCookie { cookie := c.NewCookie(false, false) c.NewRequest(trianglesRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Triangles), cookie) return TrianglesCookie{cookie} } +// TrianglesChecked sends a checked request. +// If an error occurs, it can be retrieved using TrianglesCookie.Check() func TrianglesChecked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Triangles []Triangle) TrianglesCookie { cookie := c.NewCookie(true, false) c.NewRequest(trianglesRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Triangles), cookie) return TrianglesCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook TrianglesCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for Triangles +// trianglesRequest writes a Triangles request to a byte slice. func trianglesRequest(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Triangles []Triangle) []byte { size := xgb.Pad((24 + xgb.Pad((len(Triangles) * 24)))) b := 0 @@ -2301,30 +2303,35 @@ func trianglesRequest(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat return buf } -// Request TriStrip -// size: xgb.Pad((24 + xgb.Pad((len(Points) * 8)))) +// TriStripCookie is a cookie used only for TriStrip requests. type TriStripCookie struct { *xgb.Cookie } -// Write request to wire for TriStrip +// TriStrip sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func TriStrip(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) TriStripCookie { cookie := c.NewCookie(false, false) c.NewRequest(triStripRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie) return TriStripCookie{cookie} } +// TriStripChecked sends a checked request. +// If an error occurs, it can be retrieved using TriStripCookie.Check() func TriStripChecked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) TriStripCookie { cookie := c.NewCookie(true, false) c.NewRequest(triStripRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie) return TriStripCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook TriStripCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for TriStrip +// triStripRequest writes a TriStrip request to a byte slice. func triStripRequest(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) []byte { size := xgb.Pad((24 + xgb.Pad((len(Points) * 8)))) b := 0 @@ -2364,30 +2371,35 @@ func triStripRequest(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat return buf } -// Request TriFan -// size: xgb.Pad((24 + xgb.Pad((len(Points) * 8)))) +// TriFanCookie is a cookie used only for TriFan requests. type TriFanCookie struct { *xgb.Cookie } -// Write request to wire for TriFan +// TriFan sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func TriFan(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) TriFanCookie { cookie := c.NewCookie(false, false) c.NewRequest(triFanRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie) return TriFanCookie{cookie} } +// TriFanChecked sends a checked request. +// If an error occurs, it can be retrieved using TriFanCookie.Check() func TriFanChecked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) TriFanCookie { cookie := c.NewCookie(true, false) c.NewRequest(triFanRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie) return TriFanCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook TriFanCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for TriFan +// triFanRequest writes a TriFan request to a byte slice. func triFanRequest(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) []byte { size := xgb.Pad((24 + xgb.Pad((len(Points) * 8)))) b := 0 @@ -2427,30 +2439,35 @@ func triFanRequest(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pi return buf } -// Request CreateGlyphSet -// size: 12 +// CreateGlyphSetCookie is a cookie used only for CreateGlyphSet requests. type CreateGlyphSetCookie struct { *xgb.Cookie } -// Write request to wire for CreateGlyphSet +// CreateGlyphSet sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreateGlyphSet(c *xgb.Conn, Gsid Glyphset, Format Pictformat) CreateGlyphSetCookie { cookie := c.NewCookie(false, false) c.NewRequest(createGlyphSetRequest(c, Gsid, Format), cookie) return CreateGlyphSetCookie{cookie} } +// CreateGlyphSetChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateGlyphSetCookie.Check() func CreateGlyphSetChecked(c *xgb.Conn, Gsid Glyphset, Format Pictformat) CreateGlyphSetCookie { cookie := c.NewCookie(true, false) c.NewRequest(createGlyphSetRequest(c, Gsid, Format), cookie) return CreateGlyphSetCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CreateGlyphSetCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreateGlyphSet +// createGlyphSetRequest writes a CreateGlyphSet request to a byte slice. func createGlyphSetRequest(c *xgb.Conn, Gsid Glyphset, Format Pictformat) []byte { size := 12 b := 0 @@ -2474,30 +2491,35 @@ func createGlyphSetRequest(c *xgb.Conn, Gsid Glyphset, Format Pictformat) []byte return buf } -// Request ReferenceGlyphSet -// size: 12 +// ReferenceGlyphSetCookie is a cookie used only for ReferenceGlyphSet requests. type ReferenceGlyphSetCookie struct { *xgb.Cookie } -// Write request to wire for ReferenceGlyphSet +// ReferenceGlyphSet sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ReferenceGlyphSet(c *xgb.Conn, Gsid Glyphset, Existing Glyphset) ReferenceGlyphSetCookie { cookie := c.NewCookie(false, false) c.NewRequest(referenceGlyphSetRequest(c, Gsid, Existing), cookie) return ReferenceGlyphSetCookie{cookie} } +// ReferenceGlyphSetChecked sends a checked request. +// If an error occurs, it can be retrieved using ReferenceGlyphSetCookie.Check() func ReferenceGlyphSetChecked(c *xgb.Conn, Gsid Glyphset, Existing Glyphset) ReferenceGlyphSetCookie { cookie := c.NewCookie(true, false) c.NewRequest(referenceGlyphSetRequest(c, Gsid, Existing), cookie) return ReferenceGlyphSetCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook ReferenceGlyphSetCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ReferenceGlyphSet +// referenceGlyphSetRequest writes a ReferenceGlyphSet request to a byte slice. func referenceGlyphSetRequest(c *xgb.Conn, Gsid Glyphset, Existing Glyphset) []byte { size := 12 b := 0 @@ -2521,30 +2543,35 @@ func referenceGlyphSetRequest(c *xgb.Conn, Gsid Glyphset, Existing Glyphset) []b return buf } -// Request FreeGlyphSet -// size: 8 +// FreeGlyphSetCookie is a cookie used only for FreeGlyphSet requests. type FreeGlyphSetCookie struct { *xgb.Cookie } -// Write request to wire for FreeGlyphSet +// FreeGlyphSet sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func FreeGlyphSet(c *xgb.Conn, Glyphset Glyphset) FreeGlyphSetCookie { cookie := c.NewCookie(false, false) c.NewRequest(freeGlyphSetRequest(c, Glyphset), cookie) return FreeGlyphSetCookie{cookie} } +// FreeGlyphSetChecked sends a checked request. +// If an error occurs, it can be retrieved using FreeGlyphSetCookie.Check() func FreeGlyphSetChecked(c *xgb.Conn, Glyphset Glyphset) FreeGlyphSetCookie { cookie := c.NewCookie(true, false) c.NewRequest(freeGlyphSetRequest(c, Glyphset), cookie) return FreeGlyphSetCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook FreeGlyphSetCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for FreeGlyphSet +// freeGlyphSetRequest writes a FreeGlyphSet request to a byte slice. func freeGlyphSetRequest(c *xgb.Conn, Glyphset Glyphset) []byte { size := 8 b := 0 @@ -2565,30 +2592,35 @@ func freeGlyphSetRequest(c *xgb.Conn, Glyphset Glyphset) []byte { return buf } -// Request AddGlyphs -// size: xgb.Pad((((12 + xgb.Pad((int(GlyphsLen) * 4))) + xgb.Pad((int(GlyphsLen) * 12))) + xgb.Pad((len(Data) * 1)))) +// AddGlyphsCookie is a cookie used only for AddGlyphs requests. type AddGlyphsCookie struct { *xgb.Cookie } -// Write request to wire for AddGlyphs +// AddGlyphs sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func AddGlyphs(c *xgb.Conn, Glyphset Glyphset, GlyphsLen uint32, Glyphids []uint32, Glyphs []Glyphinfo, Data []byte) AddGlyphsCookie { cookie := c.NewCookie(false, false) c.NewRequest(addGlyphsRequest(c, Glyphset, GlyphsLen, Glyphids, Glyphs, Data), cookie) return AddGlyphsCookie{cookie} } +// AddGlyphsChecked sends a checked request. +// If an error occurs, it can be retrieved using AddGlyphsCookie.Check() func AddGlyphsChecked(c *xgb.Conn, Glyphset Glyphset, GlyphsLen uint32, Glyphids []uint32, Glyphs []Glyphinfo, Data []byte) AddGlyphsCookie { cookie := c.NewCookie(true, false) c.NewRequest(addGlyphsRequest(c, Glyphset, GlyphsLen, Glyphids, Glyphs, Data), cookie) return AddGlyphsCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook AddGlyphsCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for AddGlyphs +// addGlyphsRequest writes a AddGlyphs request to a byte slice. func addGlyphsRequest(c *xgb.Conn, Glyphset Glyphset, GlyphsLen uint32, Glyphids []uint32, Glyphs []Glyphinfo, Data []byte) []byte { size := xgb.Pad((((12 + xgb.Pad((int(GlyphsLen) * 4))) + xgb.Pad((int(GlyphsLen) * 12))) + xgb.Pad((len(Data) * 1)))) b := 0 @@ -2623,30 +2655,35 @@ func addGlyphsRequest(c *xgb.Conn, Glyphset Glyphset, GlyphsLen uint32, Glyphids return buf } -// Request FreeGlyphs -// size: xgb.Pad((8 + xgb.Pad((len(Glyphs) * 4)))) +// FreeGlyphsCookie is a cookie used only for FreeGlyphs requests. type FreeGlyphsCookie struct { *xgb.Cookie } -// Write request to wire for FreeGlyphs +// FreeGlyphs sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func FreeGlyphs(c *xgb.Conn, Glyphset Glyphset, Glyphs []Glyph) FreeGlyphsCookie { cookie := c.NewCookie(false, false) c.NewRequest(freeGlyphsRequest(c, Glyphset, Glyphs), cookie) return FreeGlyphsCookie{cookie} } +// FreeGlyphsChecked sends a checked request. +// If an error occurs, it can be retrieved using FreeGlyphsCookie.Check() func FreeGlyphsChecked(c *xgb.Conn, Glyphset Glyphset, Glyphs []Glyph) FreeGlyphsCookie { cookie := c.NewCookie(true, false) c.NewRequest(freeGlyphsRequest(c, Glyphset, Glyphs), cookie) return FreeGlyphsCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook FreeGlyphsCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for FreeGlyphs +// freeGlyphsRequest writes a FreeGlyphs request to a byte slice. func freeGlyphsRequest(c *xgb.Conn, Glyphset Glyphset, Glyphs []Glyph) []byte { size := xgb.Pad((8 + xgb.Pad((len(Glyphs) * 4)))) b := 0 @@ -2673,30 +2710,35 @@ func freeGlyphsRequest(c *xgb.Conn, Glyphset Glyphset, Glyphs []Glyph) []byte { return buf } -// Request CompositeGlyphs8 -// size: xgb.Pad((28 + xgb.Pad((len(Glyphcmds) * 1)))) +// CompositeGlyphs8Cookie is a cookie used only for CompositeGlyphs8 requests. type CompositeGlyphs8Cookie struct { *xgb.Cookie } -// Write request to wire for CompositeGlyphs8 +// CompositeGlyphs8 sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CompositeGlyphs8(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs8Cookie { cookie := c.NewCookie(false, false) c.NewRequest(compositeGlyphs8Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) return CompositeGlyphs8Cookie{cookie} } +// CompositeGlyphs8Checked sends a checked request. +// If an error occurs, it can be retrieved using CompositeGlyphs8Cookie.Check() func CompositeGlyphs8Checked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs8Cookie { cookie := c.NewCookie(true, false) c.NewRequest(compositeGlyphs8Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) return CompositeGlyphs8Cookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CompositeGlyphs8Cookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CompositeGlyphs8 +// compositeGlyphs8Request writes a CompositeGlyphs8 request to a byte slice. func compositeGlyphs8Request(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) []byte { size := xgb.Pad((28 + xgb.Pad((len(Glyphcmds) * 1)))) b := 0 @@ -2740,30 +2782,35 @@ func compositeGlyphs8Request(c *xgb.Conn, Op byte, Src Picture, Dst Picture, Mas return buf } -// Request CompositeGlyphs16 -// size: xgb.Pad((28 + xgb.Pad((len(Glyphcmds) * 1)))) +// CompositeGlyphs16Cookie is a cookie used only for CompositeGlyphs16 requests. type CompositeGlyphs16Cookie struct { *xgb.Cookie } -// Write request to wire for CompositeGlyphs16 +// CompositeGlyphs16 sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CompositeGlyphs16(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs16Cookie { cookie := c.NewCookie(false, false) c.NewRequest(compositeGlyphs16Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) return CompositeGlyphs16Cookie{cookie} } +// CompositeGlyphs16Checked sends a checked request. +// If an error occurs, it can be retrieved using CompositeGlyphs16Cookie.Check() func CompositeGlyphs16Checked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs16Cookie { cookie := c.NewCookie(true, false) c.NewRequest(compositeGlyphs16Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) return CompositeGlyphs16Cookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CompositeGlyphs16Cookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CompositeGlyphs16 +// compositeGlyphs16Request writes a CompositeGlyphs16 request to a byte slice. func compositeGlyphs16Request(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) []byte { size := xgb.Pad((28 + xgb.Pad((len(Glyphcmds) * 1)))) b := 0 @@ -2807,30 +2854,35 @@ func compositeGlyphs16Request(c *xgb.Conn, Op byte, Src Picture, Dst Picture, Ma return buf } -// Request CompositeGlyphs32 -// size: xgb.Pad((28 + xgb.Pad((len(Glyphcmds) * 1)))) +// CompositeGlyphs32Cookie is a cookie used only for CompositeGlyphs32 requests. type CompositeGlyphs32Cookie struct { *xgb.Cookie } -// Write request to wire for CompositeGlyphs32 +// CompositeGlyphs32 sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CompositeGlyphs32(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs32Cookie { cookie := c.NewCookie(false, false) c.NewRequest(compositeGlyphs32Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) return CompositeGlyphs32Cookie{cookie} } +// CompositeGlyphs32Checked sends a checked request. +// If an error occurs, it can be retrieved using CompositeGlyphs32Cookie.Check() func CompositeGlyphs32Checked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs32Cookie { cookie := c.NewCookie(true, false) c.NewRequest(compositeGlyphs32Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie) return CompositeGlyphs32Cookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CompositeGlyphs32Cookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CompositeGlyphs32 +// compositeGlyphs32Request writes a CompositeGlyphs32 request to a byte slice. func compositeGlyphs32Request(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) []byte { size := xgb.Pad((28 + xgb.Pad((len(Glyphcmds) * 1)))) b := 0 @@ -2874,30 +2926,35 @@ func compositeGlyphs32Request(c *xgb.Conn, Op byte, Src Picture, Dst Picture, Ma return buf } -// Request FillRectangles -// size: xgb.Pad((20 + xgb.Pad((len(Rects) * 8)))) +// FillRectanglesCookie is a cookie used only for FillRectangles requests. type FillRectanglesCookie struct { *xgb.Cookie } -// Write request to wire for FillRectangles +// FillRectangles sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func FillRectangles(c *xgb.Conn, Op byte, Dst Picture, Color Color, Rects []xproto.Rectangle) FillRectanglesCookie { cookie := c.NewCookie(false, false) c.NewRequest(fillRectanglesRequest(c, Op, Dst, Color, Rects), cookie) return FillRectanglesCookie{cookie} } +// FillRectanglesChecked sends a checked request. +// If an error occurs, it can be retrieved using FillRectanglesCookie.Check() func FillRectanglesChecked(c *xgb.Conn, Op byte, Dst Picture, Color Color, Rects []xproto.Rectangle) FillRectanglesCookie { cookie := c.NewCookie(true, false) c.NewRequest(fillRectanglesRequest(c, Op, Dst, Color, Rects), cookie) return FillRectanglesCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook FillRectanglesCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for FillRectangles +// fillRectanglesRequest writes a FillRectangles request to a byte slice. func fillRectanglesRequest(c *xgb.Conn, Op byte, Dst Picture, Color Color, Rects []xproto.Rectangle) []byte { size := xgb.Pad((20 + xgb.Pad((len(Rects) * 8)))) b := 0 @@ -2931,30 +2988,35 @@ func fillRectanglesRequest(c *xgb.Conn, Op byte, Dst Picture, Color Color, Rects return buf } -// Request CreateCursor -// size: 16 +// CreateCursorCookie is a cookie used only for CreateCursor requests. type CreateCursorCookie struct { *xgb.Cookie } -// Write request to wire for CreateCursor +// CreateCursor sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreateCursor(c *xgb.Conn, Cid xproto.Cursor, Source Picture, X uint16, Y uint16) CreateCursorCookie { cookie := c.NewCookie(false, false) c.NewRequest(createCursorRequest(c, Cid, Source, X, Y), cookie) return CreateCursorCookie{cookie} } +// CreateCursorChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateCursorCookie.Check() func CreateCursorChecked(c *xgb.Conn, Cid xproto.Cursor, Source Picture, X uint16, Y uint16) CreateCursorCookie { cookie := c.NewCookie(true, false) c.NewRequest(createCursorRequest(c, Cid, Source, X, Y), cookie) return CreateCursorCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CreateCursorCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreateCursor +// createCursorRequest writes a CreateCursor request to a byte slice. func createCursorRequest(c *xgb.Conn, Cid xproto.Cursor, Source Picture, X uint16, Y uint16) []byte { size := 16 b := 0 @@ -2984,30 +3046,35 @@ func createCursorRequest(c *xgb.Conn, Cid xproto.Cursor, Source Picture, X uint1 return buf } -// Request SetPictureTransform -// size: 44 +// SetPictureTransformCookie is a cookie used only for SetPictureTransform requests. type SetPictureTransformCookie struct { *xgb.Cookie } -// Write request to wire for SetPictureTransform +// SetPictureTransform sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetPictureTransform(c *xgb.Conn, Picture Picture, Transform Transform) SetPictureTransformCookie { cookie := c.NewCookie(false, false) c.NewRequest(setPictureTransformRequest(c, Picture, Transform), cookie) return SetPictureTransformCookie{cookie} } +// SetPictureTransformChecked sends a checked request. +// If an error occurs, it can be retrieved using SetPictureTransformCookie.Check() func SetPictureTransformChecked(c *xgb.Conn, Picture Picture, Transform Transform) SetPictureTransformCookie { cookie := c.NewCookie(true, false) c.NewRequest(setPictureTransformRequest(c, Picture, Transform), cookie) return SetPictureTransformCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetPictureTransformCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetPictureTransform +// setPictureTransformRequest writes a SetPictureTransform request to a byte slice. func setPictureTransformRequest(c *xgb.Conn, Picture Picture, Transform Transform) []byte { size := 44 b := 0 @@ -3034,29 +3101,31 @@ func setPictureTransformRequest(c *xgb.Conn, Picture Picture, Transform Transfor return buf } -// Request QueryFilters -// size: 8 +// QueryFiltersCookie is a cookie used only for QueryFilters requests. type QueryFiltersCookie struct { *xgb.Cookie } +// QueryFilters sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryFiltersCookie.Reply() func QueryFilters(c *xgb.Conn, Drawable xproto.Drawable) QueryFiltersCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryFiltersRequest(c, Drawable), cookie) return QueryFiltersCookie{cookie} } +// QueryFiltersUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryFiltersUnchecked(c *xgb.Conn, Drawable xproto.Drawable) QueryFiltersCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryFiltersRequest(c, Drawable), cookie) return QueryFiltersCookie{cookie} } -// Request reply for QueryFilters -// size: ((32 + xgb.Pad((int(NumAliases) * 2))) + xproto.StrListSize(Filters)) +// QueryFiltersReply represents the data returned from a QueryFilters request. type QueryFiltersReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes NumAliases uint32 NumFilters uint32 @@ -3065,7 +3134,7 @@ type QueryFiltersReply struct { Filters []xproto.Str // size: xproto.StrListSize(Filters) } -// Waits and reads reply data from request QueryFilters +// Reply blocks and returns the reply data for a QueryFilters request. func (cook QueryFiltersCookie) Reply() (*QueryFiltersReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -3077,7 +3146,7 @@ func (cook QueryFiltersCookie) Reply() (*QueryFiltersReply, error) { return queryFiltersReply(buf), nil } -// Read reply into structure from buffer for QueryFilters +// queryFiltersReply reads a byte slice into a QueryFiltersReply value. func queryFiltersReply(buf []byte) *QueryFiltersReply { v := new(QueryFiltersReply) b := 1 // skip reply determinant @@ -3112,6 +3181,7 @@ func queryFiltersReply(buf []byte) *QueryFiltersReply { } // Write request to wire for QueryFilters +// queryFiltersRequest writes a QueryFilters request to a byte slice. func queryFiltersRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte { size := 8 b := 0 @@ -3132,30 +3202,35 @@ func queryFiltersRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte { return buf } -// Request SetPictureFilter -// size: xgb.Pad(((12 + xgb.Pad((int(FilterLen) * 1))) + xgb.Pad((len(Values) * 4)))) +// SetPictureFilterCookie is a cookie used only for SetPictureFilter requests. type SetPictureFilterCookie struct { *xgb.Cookie } -// Write request to wire for SetPictureFilter +// SetPictureFilter sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetPictureFilter(c *xgb.Conn, Picture Picture, FilterLen uint16, Filter string, Values []Fixed) SetPictureFilterCookie { cookie := c.NewCookie(false, false) c.NewRequest(setPictureFilterRequest(c, Picture, FilterLen, Filter, Values), cookie) return SetPictureFilterCookie{cookie} } +// SetPictureFilterChecked sends a checked request. +// If an error occurs, it can be retrieved using SetPictureFilterCookie.Check() func SetPictureFilterChecked(c *xgb.Conn, Picture Picture, FilterLen uint16, Filter string, Values []Fixed) SetPictureFilterCookie { cookie := c.NewCookie(true, false) c.NewRequest(setPictureFilterRequest(c, Picture, FilterLen, Filter, Values), cookie) return SetPictureFilterCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetPictureFilterCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetPictureFilter +// setPictureFilterRequest writes a SetPictureFilter request to a byte slice. func setPictureFilterRequest(c *xgb.Conn, Picture Picture, FilterLen uint16, Filter string, Values []Fixed) []byte { size := xgb.Pad(((12 + xgb.Pad((int(FilterLen) * 1))) + xgb.Pad((len(Values) * 4)))) b := 0 @@ -3190,30 +3265,35 @@ func setPictureFilterRequest(c *xgb.Conn, Picture Picture, FilterLen uint16, Fil return buf } -// Request CreateAnimCursor -// size: xgb.Pad((8 + xgb.Pad((len(Cursors) * 8)))) +// CreateAnimCursorCookie is a cookie used only for CreateAnimCursor requests. type CreateAnimCursorCookie struct { *xgb.Cookie } -// Write request to wire for CreateAnimCursor +// CreateAnimCursor sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreateAnimCursor(c *xgb.Conn, Cid xproto.Cursor, Cursors []Animcursorelt) CreateAnimCursorCookie { cookie := c.NewCookie(false, false) c.NewRequest(createAnimCursorRequest(c, Cid, Cursors), cookie) return CreateAnimCursorCookie{cookie} } +// CreateAnimCursorChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateAnimCursorCookie.Check() func CreateAnimCursorChecked(c *xgb.Conn, Cid xproto.Cursor, Cursors []Animcursorelt) CreateAnimCursorCookie { cookie := c.NewCookie(true, false) c.NewRequest(createAnimCursorRequest(c, Cid, Cursors), cookie) return CreateAnimCursorCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CreateAnimCursorCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreateAnimCursor +// createAnimCursorRequest writes a CreateAnimCursor request to a byte slice. func createAnimCursorRequest(c *xgb.Conn, Cid xproto.Cursor, Cursors []Animcursorelt) []byte { size := xgb.Pad((8 + xgb.Pad((len(Cursors) * 8)))) b := 0 @@ -3236,30 +3316,35 @@ func createAnimCursorRequest(c *xgb.Conn, Cid xproto.Cursor, Cursors []Animcurso return buf } -// Request AddTraps -// size: xgb.Pad((12 + xgb.Pad((len(Traps) * 24)))) +// AddTrapsCookie is a cookie used only for AddTraps requests. type AddTrapsCookie struct { *xgb.Cookie } -// Write request to wire for AddTraps +// AddTraps sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func AddTraps(c *xgb.Conn, Picture Picture, XOff int16, YOff int16, Traps []Trap) AddTrapsCookie { cookie := c.NewCookie(false, false) c.NewRequest(addTrapsRequest(c, Picture, XOff, YOff, Traps), cookie) return AddTrapsCookie{cookie} } +// AddTrapsChecked sends a checked request. +// If an error occurs, it can be retrieved using AddTrapsCookie.Check() func AddTrapsChecked(c *xgb.Conn, Picture Picture, XOff int16, YOff int16, Traps []Trap) AddTrapsCookie { cookie := c.NewCookie(true, false) c.NewRequest(addTrapsRequest(c, Picture, XOff, YOff, Traps), cookie) return AddTrapsCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook AddTrapsCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for AddTraps +// addTrapsRequest writes a AddTraps request to a byte slice. func addTrapsRequest(c *xgb.Conn, Picture Picture, XOff int16, YOff int16, Traps []Trap) []byte { size := xgb.Pad((12 + xgb.Pad((len(Traps) * 24)))) b := 0 @@ -3288,30 +3373,35 @@ func addTrapsRequest(c *xgb.Conn, Picture Picture, XOff int16, YOff int16, Traps return buf } -// Request CreateSolidFill -// size: 16 +// CreateSolidFillCookie is a cookie used only for CreateSolidFill requests. type CreateSolidFillCookie struct { *xgb.Cookie } -// Write request to wire for CreateSolidFill +// CreateSolidFill sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreateSolidFill(c *xgb.Conn, Picture Picture, Color Color) CreateSolidFillCookie { cookie := c.NewCookie(false, false) c.NewRequest(createSolidFillRequest(c, Picture, Color), cookie) return CreateSolidFillCookie{cookie} } +// CreateSolidFillChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateSolidFillCookie.Check() func CreateSolidFillChecked(c *xgb.Conn, Picture Picture, Color Color) CreateSolidFillCookie { cookie := c.NewCookie(true, false) c.NewRequest(createSolidFillRequest(c, Picture, Color), cookie) return CreateSolidFillCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CreateSolidFillCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreateSolidFill +// createSolidFillRequest writes a CreateSolidFill request to a byte slice. func createSolidFillRequest(c *xgb.Conn, Picture Picture, Color Color) []byte { size := 16 b := 0 @@ -3338,30 +3428,35 @@ func createSolidFillRequest(c *xgb.Conn, Picture Picture, Color Color) []byte { return buf } -// Request CreateLinearGradient -// size: xgb.Pad(((28 + xgb.Pad((int(NumStops) * 4))) + xgb.Pad((int(NumStops) * 8)))) +// CreateLinearGradientCookie is a cookie used only for CreateLinearGradient requests. type CreateLinearGradientCookie struct { *xgb.Cookie } -// Write request to wire for CreateLinearGradient +// CreateLinearGradient sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreateLinearGradient(c *xgb.Conn, Picture Picture, P1 Pointfix, P2 Pointfix, NumStops uint32, Stops []Fixed, Colors []Color) CreateLinearGradientCookie { cookie := c.NewCookie(false, false) c.NewRequest(createLinearGradientRequest(c, Picture, P1, P2, NumStops, Stops, Colors), cookie) return CreateLinearGradientCookie{cookie} } +// CreateLinearGradientChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateLinearGradientCookie.Check() func CreateLinearGradientChecked(c *xgb.Conn, Picture Picture, P1 Pointfix, P2 Pointfix, NumStops uint32, Stops []Fixed, Colors []Color) CreateLinearGradientCookie { cookie := c.NewCookie(true, false) c.NewRequest(createLinearGradientRequest(c, Picture, P1, P2, NumStops, Stops, Colors), cookie) return CreateLinearGradientCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CreateLinearGradientCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreateLinearGradient +// createLinearGradientRequest writes a CreateLinearGradient request to a byte slice. func createLinearGradientRequest(c *xgb.Conn, Picture Picture, P1 Pointfix, P2 Pointfix, NumStops uint32, Stops []Fixed, Colors []Color) []byte { size := xgb.Pad(((28 + xgb.Pad((int(NumStops) * 4))) + xgb.Pad((int(NumStops) * 8)))) b := 0 @@ -3405,30 +3500,35 @@ func createLinearGradientRequest(c *xgb.Conn, Picture Picture, P1 Pointfix, P2 P return buf } -// Request CreateRadialGradient -// size: xgb.Pad(((36 + xgb.Pad((int(NumStops) * 4))) + xgb.Pad((int(NumStops) * 8)))) +// CreateRadialGradientCookie is a cookie used only for CreateRadialGradient requests. type CreateRadialGradientCookie struct { *xgb.Cookie } -// Write request to wire for CreateRadialGradient +// CreateRadialGradient sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreateRadialGradient(c *xgb.Conn, Picture Picture, Inner Pointfix, Outer Pointfix, InnerRadius Fixed, OuterRadius Fixed, NumStops uint32, Stops []Fixed, Colors []Color) CreateRadialGradientCookie { cookie := c.NewCookie(false, false) c.NewRequest(createRadialGradientRequest(c, Picture, Inner, Outer, InnerRadius, OuterRadius, NumStops, Stops, Colors), cookie) return CreateRadialGradientCookie{cookie} } +// CreateRadialGradientChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateRadialGradientCookie.Check() func CreateRadialGradientChecked(c *xgb.Conn, Picture Picture, Inner Pointfix, Outer Pointfix, InnerRadius Fixed, OuterRadius Fixed, NumStops uint32, Stops []Fixed, Colors []Color) CreateRadialGradientCookie { cookie := c.NewCookie(true, false) c.NewRequest(createRadialGradientRequest(c, Picture, Inner, Outer, InnerRadius, OuterRadius, NumStops, Stops, Colors), cookie) return CreateRadialGradientCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CreateRadialGradientCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreateRadialGradient +// createRadialGradientRequest writes a CreateRadialGradient request to a byte slice. func createRadialGradientRequest(c *xgb.Conn, Picture Picture, Inner Pointfix, Outer Pointfix, InnerRadius Fixed, OuterRadius Fixed, NumStops uint32, Stops []Fixed, Colors []Color) []byte { size := xgb.Pad(((36 + xgb.Pad((int(NumStops) * 4))) + xgb.Pad((int(NumStops) * 8)))) b := 0 @@ -3478,30 +3578,35 @@ func createRadialGradientRequest(c *xgb.Conn, Picture Picture, Inner Pointfix, O return buf } -// Request CreateConicalGradient -// size: xgb.Pad(((24 + xgb.Pad((int(NumStops) * 4))) + xgb.Pad((int(NumStops) * 8)))) +// CreateConicalGradientCookie is a cookie used only for CreateConicalGradient requests. type CreateConicalGradientCookie struct { *xgb.Cookie } -// Write request to wire for CreateConicalGradient +// CreateConicalGradient sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreateConicalGradient(c *xgb.Conn, Picture Picture, Center Pointfix, Angle Fixed, NumStops uint32, Stops []Fixed, Colors []Color) CreateConicalGradientCookie { cookie := c.NewCookie(false, false) c.NewRequest(createConicalGradientRequest(c, Picture, Center, Angle, NumStops, Stops, Colors), cookie) return CreateConicalGradientCookie{cookie} } +// CreateConicalGradientChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateConicalGradientCookie.Check() func CreateConicalGradientChecked(c *xgb.Conn, Picture Picture, Center Pointfix, Angle Fixed, NumStops uint32, Stops []Fixed, Colors []Color) CreateConicalGradientCookie { cookie := c.NewCookie(true, false) c.NewRequest(createConicalGradientRequest(c, Picture, Center, Angle, NumStops, Stops, Colors), cookie) return CreateConicalGradientCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CreateConicalGradientCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreateConicalGradient +// createConicalGradientRequest writes a CreateConicalGradient request to a byte slice. func createConicalGradientRequest(c *xgb.Conn, Picture Picture, Center Pointfix, Angle Fixed, NumStops uint32, Stops []Fixed, Colors []Color) []byte { size := xgb.Pad(((24 + xgb.Pad((int(NumStops) * 4))) + xgb.Pad((int(NumStops) * 8)))) b := 0 diff --git a/nexgb/res/res.go b/nexgb/res/res.go index e81fa96..ccc6192 100644 --- a/nexgb/res/res.go +++ b/nexgb/res/res.go @@ -2,7 +2,7 @@ package res /* - This file was generated by res.xml on May 10 2012 8:04:32pm EDT. + This file was generated by res.xml on May 10 2012 11:56:19pm EDT. This file is automatically generated. Edit at your peril! */ @@ -64,14 +64,12 @@ func init() { // Skipping definition for base type 'Char' -// 'Client' struct definition -// Size: 8 type Client struct { ResourceBase uint32 ResourceMask uint32 } -// Struct read Client +// ClientRead reads a byte slice into a Client value. func ClientRead(buf []byte, v *Client) int { b := 0 @@ -84,7 +82,7 @@ func ClientRead(buf []byte, v *Client) int { return b } -// Struct list read Client +// ClientReadList reads a byte slice into a list of Client values. func ClientReadList(buf []byte, dest []Client) int { b := 0 for i := 0; i < len(dest); i++ { @@ -94,7 +92,7 @@ func ClientReadList(buf []byte, dest []Client) int { return xgb.Pad(b) } -// Struct write Client +// Bytes writes a Client value to a byte slice. func (v Client) Bytes() []byte { buf := make([]byte, 8) b := 0 @@ -108,7 +106,7 @@ func (v Client) Bytes() []byte { return buf } -// Write struct list Client +// ClientListBytes writes a list of %s(MISSING) values to a byte slice. func ClientListBytes(buf []byte, list []Client) int { b := 0 var structBytes []byte @@ -120,14 +118,12 @@ func ClientListBytes(buf []byte, list []Client) int { return b } -// 'Type' struct definition -// Size: 8 type Type struct { ResourceType xproto.Atom Count uint32 } -// Struct read Type +// TypeRead reads a byte slice into a Type value. func TypeRead(buf []byte, v *Type) int { b := 0 @@ -140,7 +136,7 @@ func TypeRead(buf []byte, v *Type) int { return b } -// Struct list read Type +// TypeReadList reads a byte slice into a list of Type values. func TypeReadList(buf []byte, dest []Type) int { b := 0 for i := 0; i < len(dest); i++ { @@ -150,7 +146,7 @@ func TypeReadList(buf []byte, dest []Type) int { return xgb.Pad(b) } -// Struct write Type +// Bytes writes a Type value to a byte slice. func (v Type) Bytes() []byte { buf := make([]byte, 8) b := 0 @@ -164,7 +160,7 @@ func (v Type) Bytes() []byte { return buf } -// Write struct list Type +// TypeListBytes writes a list of %s(MISSING) values to a byte slice. func TypeListBytes(buf []byte, list []Type) int { b := 0 var structBytes []byte @@ -176,35 +172,37 @@ func TypeListBytes(buf []byte, list []Type) int { return b } -// Request QueryVersion -// size: 8 +// QueryVersionCookie is a cookie used only for QueryVersion requests. type QueryVersionCookie struct { *xgb.Cookie } +// QueryVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() func QueryVersion(c *xgb.Conn, ClientMajor byte, ClientMinor byte) QueryVersionCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryVersionRequest(c, ClientMajor, ClientMinor), cookie) return QueryVersionCookie{cookie} } +// QueryVersionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryVersionUnchecked(c *xgb.Conn, ClientMajor byte, ClientMinor byte) QueryVersionCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryVersionRequest(c, ClientMajor, ClientMinor), cookie) return QueryVersionCookie{cookie} } -// Request reply for QueryVersion -// size: 12 +// QueryVersionReply represents the data returned from a QueryVersion request. type QueryVersionReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes ServerMajor uint16 ServerMinor uint16 } -// Waits and reads reply data from request QueryVersion +// Reply blocks and returns the reply data for a QueryVersion request. func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -216,7 +214,7 @@ func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { return queryVersionReply(buf), nil } -// Read reply into structure from buffer for QueryVersion +// queryVersionReply reads a byte slice into a QueryVersionReply value. func queryVersionReply(buf []byte) *QueryVersionReply { v := new(QueryVersionReply) b := 1 // skip reply determinant @@ -239,6 +237,7 @@ func queryVersionReply(buf []byte) *QueryVersionReply { } // Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. func queryVersionRequest(c *xgb.Conn, ClientMajor byte, ClientMinor byte) []byte { size := 8 b := 0 @@ -262,36 +261,38 @@ func queryVersionRequest(c *xgb.Conn, ClientMajor byte, ClientMinor byte) []byte return buf } -// Request QueryClients -// size: 4 +// QueryClientsCookie is a cookie used only for QueryClients requests. type QueryClientsCookie struct { *xgb.Cookie } +// QueryClients sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryClientsCookie.Reply() func QueryClients(c *xgb.Conn) QueryClientsCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryClientsRequest(c), cookie) return QueryClientsCookie{cookie} } +// QueryClientsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryClientsUnchecked(c *xgb.Conn) QueryClientsCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryClientsRequest(c), cookie) return QueryClientsCookie{cookie} } -// Request reply for QueryClients -// size: (32 + xgb.Pad((int(NumClients) * 8))) +// QueryClientsReply represents the data returned from a QueryClients request. type QueryClientsReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes NumClients uint32 // padding: 20 bytes Clients []Client // size: xgb.Pad((int(NumClients) * 8)) } -// Waits and reads reply data from request QueryClients +// Reply blocks and returns the reply data for a QueryClients request. func (cook QueryClientsCookie) Reply() (*QueryClientsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -303,7 +304,7 @@ func (cook QueryClientsCookie) Reply() (*QueryClientsReply, error) { return queryClientsReply(buf), nil } -// Read reply into structure from buffer for QueryClients +// queryClientsReply reads a byte slice into a QueryClientsReply value. func queryClientsReply(buf []byte) *QueryClientsReply { v := new(QueryClientsReply) b := 1 // skip reply determinant @@ -328,6 +329,7 @@ func queryClientsReply(buf []byte) *QueryClientsReply { } // Write request to wire for QueryClients +// queryClientsRequest writes a QueryClients request to a byte slice. func queryClientsRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -345,36 +347,38 @@ func queryClientsRequest(c *xgb.Conn) []byte { return buf } -// Request QueryClientResources -// size: 8 +// QueryClientResourcesCookie is a cookie used only for QueryClientResources requests. type QueryClientResourcesCookie struct { *xgb.Cookie } +// QueryClientResources sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryClientResourcesCookie.Reply() func QueryClientResources(c *xgb.Conn, Xid uint32) QueryClientResourcesCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryClientResourcesRequest(c, Xid), cookie) return QueryClientResourcesCookie{cookie} } +// QueryClientResourcesUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryClientResourcesUnchecked(c *xgb.Conn, Xid uint32) QueryClientResourcesCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryClientResourcesRequest(c, Xid), cookie) return QueryClientResourcesCookie{cookie} } -// Request reply for QueryClientResources -// size: (32 + xgb.Pad((int(NumTypes) * 8))) +// QueryClientResourcesReply represents the data returned from a QueryClientResources request. type QueryClientResourcesReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes NumTypes uint32 // padding: 20 bytes Types []Type // size: xgb.Pad((int(NumTypes) * 8)) } -// Waits and reads reply data from request QueryClientResources +// Reply blocks and returns the reply data for a QueryClientResources request. func (cook QueryClientResourcesCookie) Reply() (*QueryClientResourcesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -386,7 +390,7 @@ func (cook QueryClientResourcesCookie) Reply() (*QueryClientResourcesReply, erro return queryClientResourcesReply(buf), nil } -// Read reply into structure from buffer for QueryClientResources +// queryClientResourcesReply reads a byte slice into a QueryClientResourcesReply value. func queryClientResourcesReply(buf []byte) *QueryClientResourcesReply { v := new(QueryClientResourcesReply) b := 1 // skip reply determinant @@ -411,6 +415,7 @@ func queryClientResourcesReply(buf []byte) *QueryClientResourcesReply { } // Write request to wire for QueryClientResources +// queryClientResourcesRequest writes a QueryClientResources request to a byte slice. func queryClientResourcesRequest(c *xgb.Conn, Xid uint32) []byte { size := 8 b := 0 @@ -431,35 +436,37 @@ func queryClientResourcesRequest(c *xgb.Conn, Xid uint32) []byte { return buf } -// Request QueryClientPixmapBytes -// size: 8 +// QueryClientPixmapBytesCookie is a cookie used only for QueryClientPixmapBytes requests. type QueryClientPixmapBytesCookie struct { *xgb.Cookie } +// QueryClientPixmapBytes sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryClientPixmapBytesCookie.Reply() func QueryClientPixmapBytes(c *xgb.Conn, Xid uint32) QueryClientPixmapBytesCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryClientPixmapBytesRequest(c, Xid), cookie) return QueryClientPixmapBytesCookie{cookie} } +// QueryClientPixmapBytesUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryClientPixmapBytesUnchecked(c *xgb.Conn, Xid uint32) QueryClientPixmapBytesCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryClientPixmapBytesRequest(c, Xid), cookie) return QueryClientPixmapBytesCookie{cookie} } -// Request reply for QueryClientPixmapBytes -// size: 16 +// QueryClientPixmapBytesReply represents the data returned from a QueryClientPixmapBytes request. type QueryClientPixmapBytesReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Bytes uint32 BytesOverflow uint32 } -// Waits and reads reply data from request QueryClientPixmapBytes +// Reply blocks and returns the reply data for a QueryClientPixmapBytes request. func (cook QueryClientPixmapBytesCookie) Reply() (*QueryClientPixmapBytesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -471,7 +478,7 @@ func (cook QueryClientPixmapBytesCookie) Reply() (*QueryClientPixmapBytesReply, return queryClientPixmapBytesReply(buf), nil } -// Read reply into structure from buffer for QueryClientPixmapBytes +// queryClientPixmapBytesReply reads a byte slice into a QueryClientPixmapBytesReply value. func queryClientPixmapBytesReply(buf []byte) *QueryClientPixmapBytesReply { v := new(QueryClientPixmapBytesReply) b := 1 // skip reply determinant @@ -494,6 +501,7 @@ func queryClientPixmapBytesReply(buf []byte) *QueryClientPixmapBytesReply { } // Write request to wire for QueryClientPixmapBytes +// queryClientPixmapBytesRequest writes a QueryClientPixmapBytes request to a byte slice. func queryClientPixmapBytesRequest(c *xgb.Conn, Xid uint32) []byte { size := 8 b := 0 diff --git a/nexgb/screensaver/screensaver.go b/nexgb/screensaver/screensaver.go index f11113e..0b6ef23 100644 --- a/nexgb/screensaver/screensaver.go +++ b/nexgb/screensaver/screensaver.go @@ -2,7 +2,7 @@ package screensaver /* - This file was generated by screensaver.xml on May 10 2012 8:04:32pm EDT. + This file was generated by screensaver.xml on May 10 2012 11:56:19pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,6 +40,10 @@ func init() { xgb.NewExtErrorFuncs["MIT-SCREEN-SAVER"] = make(map[int]xgb.NewErrorFun) } +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + // Skipping definition for base type 'Bool' // Skipping definition for base type 'Float' @@ -60,10 +64,6 @@ func init() { // Skipping definition for base type 'Char' -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - const ( KindBlanked = 0 KindInternal = 1 @@ -82,9 +82,7 @@ const ( StateDisabled = 3 ) -// Event definition Notify (0) -// Size: 32 - +// Notify is the event number for a NotifyEvent. const Notify = 0 type NotifyEvent struct { @@ -101,7 +99,7 @@ type NotifyEvent struct { // padding: 14 bytes } -// Event read Notify +// NotifyEventNew constructs a NotifyEvent value that implements xgb.Event from a byte slice. func NotifyEventNew(buf []byte) xgb.Event { v := NotifyEvent{} b := 1 // don't read event number @@ -144,7 +142,7 @@ func NotifyEventNew(buf []byte) xgb.Event { return v } -// Event write Notify +// Bytes writes a NotifyEvent value to a byte slice. func (v NotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -190,12 +188,14 @@ func (v NotifyEvent) Bytes() []byte { return buf } -func (v NotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the Notify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v NotifyEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of NotifyEvent. func (v NotifyEvent) String() string { fieldVals := make([]string, 0, 10) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -214,36 +214,38 @@ func init() { xgb.NewExtEventFuncs["MIT-SCREEN-SAVER"][0] = NotifyEventNew } -// Request QueryVersion -// size: 8 +// QueryVersionCookie is a cookie used only for QueryVersion requests. type QueryVersionCookie struct { *xgb.Cookie } +// QueryVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() func QueryVersion(c *xgb.Conn, ClientMajorVersion byte, ClientMinorVersion byte) QueryVersionCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) return QueryVersionCookie{cookie} } +// QueryVersionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion byte, ClientMinorVersion byte) QueryVersionCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) return QueryVersionCookie{cookie} } -// Request reply for QueryVersion -// size: 32 +// QueryVersionReply represents the data returned from a QueryVersion request. type QueryVersionReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes ServerMajorVersion uint16 ServerMinorVersion uint16 // padding: 20 bytes } -// Waits and reads reply data from request QueryVersion +// Reply blocks and returns the reply data for a QueryVersion request. func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -255,7 +257,7 @@ func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { return queryVersionReply(buf), nil } -// Read reply into structure from buffer for QueryVersion +// queryVersionReply reads a byte slice into a QueryVersionReply value. func queryVersionReply(buf []byte) *QueryVersionReply { v := new(QueryVersionReply) b := 1 // skip reply determinant @@ -280,6 +282,7 @@ func queryVersionReply(buf []byte) *QueryVersionReply { } // Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. func queryVersionRequest(c *xgb.Conn, ClientMajorVersion byte, ClientMinorVersion byte) []byte { size := 8 b := 0 @@ -305,29 +308,31 @@ func queryVersionRequest(c *xgb.Conn, ClientMajorVersion byte, ClientMinorVersio return buf } -// Request QueryInfo -// size: 8 +// QueryInfoCookie is a cookie used only for QueryInfo requests. type QueryInfoCookie struct { *xgb.Cookie } +// QueryInfo sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryInfoCookie.Reply() func QueryInfo(c *xgb.Conn, Drawable xproto.Drawable) QueryInfoCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryInfoRequest(c, Drawable), cookie) return QueryInfoCookie{cookie} } +// QueryInfoUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryInfoUnchecked(c *xgb.Conn, Drawable xproto.Drawable) QueryInfoCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryInfoRequest(c, Drawable), cookie) return QueryInfoCookie{cookie} } -// Request reply for QueryInfo -// size: 32 +// QueryInfoReply represents the data returned from a QueryInfo request. type QueryInfoReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply State byte SaverWindow xproto.Window MsUntilServer uint32 @@ -337,7 +342,7 @@ type QueryInfoReply struct { // padding: 7 bytes } -// Waits and reads reply data from request QueryInfo +// Reply blocks and returns the reply data for a QueryInfo request. func (cook QueryInfoCookie) Reply() (*QueryInfoReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -349,7 +354,7 @@ func (cook QueryInfoCookie) Reply() (*QueryInfoReply, error) { return queryInfoReply(buf), nil } -// Read reply into structure from buffer for QueryInfo +// queryInfoReply reads a byte slice into a QueryInfoReply value. func queryInfoReply(buf []byte) *QueryInfoReply { v := new(QueryInfoReply) b := 1 // skip reply determinant @@ -384,6 +389,7 @@ func queryInfoReply(buf []byte) *QueryInfoReply { } // Write request to wire for QueryInfo +// queryInfoRequest writes a QueryInfo request to a byte slice. func queryInfoRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte { size := 8 b := 0 @@ -404,30 +410,35 @@ func queryInfoRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte { return buf } -// Request SelectInput -// size: 12 +// SelectInputCookie is a cookie used only for SelectInput requests. type SelectInputCookie struct { *xgb.Cookie } -// Write request to wire for SelectInput +// SelectInput sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SelectInput(c *xgb.Conn, Drawable xproto.Drawable, EventMask uint32) SelectInputCookie { cookie := c.NewCookie(false, false) c.NewRequest(selectInputRequest(c, Drawable, EventMask), cookie) return SelectInputCookie{cookie} } +// SelectInputChecked sends a checked request. +// If an error occurs, it can be retrieved using SelectInputCookie.Check() func SelectInputChecked(c *xgb.Conn, Drawable xproto.Drawable, EventMask uint32) SelectInputCookie { cookie := c.NewCookie(true, false) c.NewRequest(selectInputRequest(c, Drawable, EventMask), cookie) return SelectInputCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SelectInputCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SelectInput +// selectInputRequest writes a SelectInput request to a byte slice. func selectInputRequest(c *xgb.Conn, Drawable xproto.Drawable, EventMask uint32) []byte { size := 12 b := 0 @@ -451,30 +462,35 @@ func selectInputRequest(c *xgb.Conn, Drawable xproto.Drawable, EventMask uint32) return buf } -// Request SetAttributes -// size: xgb.Pad((24 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +// SetAttributesCookie is a cookie used only for SetAttributes requests. type SetAttributesCookie struct { *xgb.Cookie } -// Write request to wire for SetAttributes +// SetAttributes sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetAttributes(c *xgb.Conn, Drawable xproto.Drawable, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class byte, Depth byte, Visual xproto.Visualid, ValueMask uint32, ValueList []uint32) SetAttributesCookie { cookie := c.NewCookie(false, false) c.NewRequest(setAttributesRequest(c, Drawable, X, Y, Width, Height, BorderWidth, Class, Depth, Visual, ValueMask, ValueList), cookie) return SetAttributesCookie{cookie} } +// SetAttributesChecked sends a checked request. +// If an error occurs, it can be retrieved using SetAttributesCookie.Check() func SetAttributesChecked(c *xgb.Conn, Drawable xproto.Drawable, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class byte, Depth byte, Visual xproto.Visualid, ValueMask uint32, ValueList []uint32) SetAttributesCookie { cookie := c.NewCookie(true, false) c.NewRequest(setAttributesRequest(c, Drawable, X, Y, Width, Height, BorderWidth, Class, Depth, Visual, ValueMask, ValueList), cookie) return SetAttributesCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetAttributesCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetAttributes +// setAttributesRequest writes a SetAttributes request to a byte slice. func setAttributesRequest(c *xgb.Conn, Drawable xproto.Drawable, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class byte, Depth byte, Visual xproto.Visualid, ValueMask uint32, ValueList []uint32) []byte { size := xgb.Pad((24 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) b := 0 @@ -527,30 +543,35 @@ func setAttributesRequest(c *xgb.Conn, Drawable xproto.Drawable, X int16, Y int1 return buf } -// Request UnsetAttributes -// size: 8 +// UnsetAttributesCookie is a cookie used only for UnsetAttributes requests. type UnsetAttributesCookie struct { *xgb.Cookie } -// Write request to wire for UnsetAttributes +// UnsetAttributes sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func UnsetAttributes(c *xgb.Conn, Drawable xproto.Drawable) UnsetAttributesCookie { cookie := c.NewCookie(false, false) c.NewRequest(unsetAttributesRequest(c, Drawable), cookie) return UnsetAttributesCookie{cookie} } +// UnsetAttributesChecked sends a checked request. +// If an error occurs, it can be retrieved using UnsetAttributesCookie.Check() func UnsetAttributesChecked(c *xgb.Conn, Drawable xproto.Drawable) UnsetAttributesCookie { cookie := c.NewCookie(true, false) c.NewRequest(unsetAttributesRequest(c, Drawable), cookie) return UnsetAttributesCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook UnsetAttributesCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for UnsetAttributes +// unsetAttributesRequest writes a UnsetAttributes request to a byte slice. func unsetAttributesRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte { size := 8 b := 0 @@ -571,30 +592,35 @@ func unsetAttributesRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte { return buf } -// Request Suspend -// size: 8 +// SuspendCookie is a cookie used only for Suspend requests. type SuspendCookie struct { *xgb.Cookie } -// Write request to wire for Suspend +// Suspend sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func Suspend(c *xgb.Conn, Suspend bool) SuspendCookie { cookie := c.NewCookie(false, false) c.NewRequest(suspendRequest(c, Suspend), cookie) return SuspendCookie{cookie} } +// SuspendChecked sends a checked request. +// If an error occurs, it can be retrieved using SuspendCookie.Check() func SuspendChecked(c *xgb.Conn, Suspend bool) SuspendCookie { cookie := c.NewCookie(true, false) c.NewRequest(suspendRequest(c, Suspend), cookie) return SuspendCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SuspendCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for Suspend +// suspendRequest writes a Suspend request to a byte slice. func suspendRequest(c *xgb.Conn, Suspend bool) []byte { size := 8 b := 0 diff --git a/nexgb/shape/shape.go b/nexgb/shape/shape.go index 97be0f7..664c5f4 100644 --- a/nexgb/shape/shape.go +++ b/nexgb/shape/shape.go @@ -2,7 +2,7 @@ package shape /* - This file was generated by shape.xml on May 10 2012 8:04:32pm EDT. + This file was generated by shape.xml on May 10 2012 11:56:19pm EDT. This file is automatically generated. Edit at your peril! */ @@ -82,9 +82,7 @@ type Op byte type Kind byte -// Event definition Notify (0) -// Size: 32 - +// Notify is the event number for a NotifyEvent. const Notify = 0 type NotifyEvent struct { @@ -100,7 +98,7 @@ type NotifyEvent struct { // padding: 11 bytes } -// Event read Notify +// NotifyEventNew constructs a NotifyEvent value that implements xgb.Event from a byte slice. func NotifyEventNew(buf []byte) xgb.Event { v := NotifyEvent{} b := 1 // don't read event number @@ -141,7 +139,7 @@ func NotifyEventNew(buf []byte) xgb.Event { return v } -// Event write Notify +// Bytes writes a NotifyEvent value to a byte slice. func (v NotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -185,12 +183,14 @@ func (v NotifyEvent) Bytes() []byte { return buf } -func (v NotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the Notify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v NotifyEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of NotifyEvent. func (v NotifyEvent) String() string { fieldVals := make([]string, 0, 9) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -209,35 +209,37 @@ func init() { xgb.NewExtEventFuncs["SHAPE"][0] = NotifyEventNew } -// Request QueryVersion -// size: 4 +// QueryVersionCookie is a cookie used only for QueryVersion requests. type QueryVersionCookie struct { *xgb.Cookie } +// QueryVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() func QueryVersion(c *xgb.Conn) QueryVersionCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryVersionRequest(c), cookie) return QueryVersionCookie{cookie} } +// QueryVersionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryVersionUnchecked(c *xgb.Conn) QueryVersionCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryVersionRequest(c), cookie) return QueryVersionCookie{cookie} } -// Request reply for QueryVersion -// size: 12 +// QueryVersionReply represents the data returned from a QueryVersion request. type QueryVersionReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes MajorVersion uint16 MinorVersion uint16 } -// Waits and reads reply data from request QueryVersion +// Reply blocks and returns the reply data for a QueryVersion request. func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -249,7 +251,7 @@ func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { return queryVersionReply(buf), nil } -// Read reply into structure from buffer for QueryVersion +// queryVersionReply reads a byte slice into a QueryVersionReply value. func queryVersionReply(buf []byte) *QueryVersionReply { v := new(QueryVersionReply) b := 1 // skip reply determinant @@ -272,6 +274,7 @@ func queryVersionReply(buf []byte) *QueryVersionReply { } // Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. func queryVersionRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -289,30 +292,35 @@ func queryVersionRequest(c *xgb.Conn) []byte { return buf } -// Request Rectangles -// size: xgb.Pad((16 + xgb.Pad((len(Rectangles) * 8)))) +// RectanglesCookie is a cookie used only for Rectangles requests. type RectanglesCookie struct { *xgb.Cookie } -// Write request to wire for Rectangles +// Rectangles sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func Rectangles(c *xgb.Conn, Operation Op, DestinationKind Kind, Ordering byte, DestinationWindow xproto.Window, XOffset int16, YOffset int16, Rectangles []xproto.Rectangle) RectanglesCookie { cookie := c.NewCookie(false, false) c.NewRequest(rectanglesRequest(c, Operation, DestinationKind, Ordering, DestinationWindow, XOffset, YOffset, Rectangles), cookie) return RectanglesCookie{cookie} } +// RectanglesChecked sends a checked request. +// If an error occurs, it can be retrieved using RectanglesCookie.Check() func RectanglesChecked(c *xgb.Conn, Operation Op, DestinationKind Kind, Ordering byte, DestinationWindow xproto.Window, XOffset int16, YOffset int16, Rectangles []xproto.Rectangle) RectanglesCookie { cookie := c.NewCookie(true, false) c.NewRequest(rectanglesRequest(c, Operation, DestinationKind, Ordering, DestinationWindow, XOffset, YOffset, Rectangles), cookie) return RectanglesCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook RectanglesCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for Rectangles +// rectanglesRequest writes a Rectangles request to a byte slice. func rectanglesRequest(c *xgb.Conn, Operation Op, DestinationKind Kind, Ordering byte, DestinationWindow xproto.Window, XOffset int16, YOffset int16, Rectangles []xproto.Rectangle) []byte { size := xgb.Pad((16 + xgb.Pad((len(Rectangles) * 8)))) b := 0 @@ -352,30 +360,35 @@ func rectanglesRequest(c *xgb.Conn, Operation Op, DestinationKind Kind, Ordering return buf } -// Request Mask -// size: 20 +// MaskCookie is a cookie used only for Mask requests. type MaskCookie struct { *xgb.Cookie } -// Write request to wire for Mask +// Mask sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func Mask(c *xgb.Conn, Operation Op, DestinationKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16, SourceBitmap xproto.Pixmap) MaskCookie { cookie := c.NewCookie(false, false) c.NewRequest(maskRequest(c, Operation, DestinationKind, DestinationWindow, XOffset, YOffset, SourceBitmap), cookie) return MaskCookie{cookie} } +// MaskChecked sends a checked request. +// If an error occurs, it can be retrieved using MaskCookie.Check() func MaskChecked(c *xgb.Conn, Operation Op, DestinationKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16, SourceBitmap xproto.Pixmap) MaskCookie { cookie := c.NewCookie(true, false) c.NewRequest(maskRequest(c, Operation, DestinationKind, DestinationWindow, XOffset, YOffset, SourceBitmap), cookie) return MaskCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook MaskCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for Mask +// maskRequest writes a Mask request to a byte slice. func maskRequest(c *xgb.Conn, Operation Op, DestinationKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16, SourceBitmap xproto.Pixmap) []byte { size := 20 b := 0 @@ -413,30 +426,35 @@ func maskRequest(c *xgb.Conn, Operation Op, DestinationKind Kind, DestinationWin return buf } -// Request Combine -// size: 20 +// CombineCookie is a cookie used only for Combine requests. type CombineCookie struct { *xgb.Cookie } -// Write request to wire for Combine +// Combine sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func Combine(c *xgb.Conn, Operation Op, DestinationKind Kind, SourceKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16, SourceWindow xproto.Window) CombineCookie { cookie := c.NewCookie(false, false) c.NewRequest(combineRequest(c, Operation, DestinationKind, SourceKind, DestinationWindow, XOffset, YOffset, SourceWindow), cookie) return CombineCookie{cookie} } +// CombineChecked sends a checked request. +// If an error occurs, it can be retrieved using CombineCookie.Check() func CombineChecked(c *xgb.Conn, Operation Op, DestinationKind Kind, SourceKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16, SourceWindow xproto.Window) CombineCookie { cookie := c.NewCookie(true, false) c.NewRequest(combineRequest(c, Operation, DestinationKind, SourceKind, DestinationWindow, XOffset, YOffset, SourceWindow), cookie) return CombineCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CombineCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for Combine +// combineRequest writes a Combine request to a byte slice. func combineRequest(c *xgb.Conn, Operation Op, DestinationKind Kind, SourceKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16, SourceWindow xproto.Window) []byte { size := 20 b := 0 @@ -477,30 +495,35 @@ func combineRequest(c *xgb.Conn, Operation Op, DestinationKind Kind, SourceKind return buf } -// Request Offset -// size: 16 +// OffsetCookie is a cookie used only for Offset requests. type OffsetCookie struct { *xgb.Cookie } -// Write request to wire for Offset +// Offset sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func Offset(c *xgb.Conn, DestinationKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16) OffsetCookie { cookie := c.NewCookie(false, false) c.NewRequest(offsetRequest(c, DestinationKind, DestinationWindow, XOffset, YOffset), cookie) return OffsetCookie{cookie} } +// OffsetChecked sends a checked request. +// If an error occurs, it can be retrieved using OffsetCookie.Check() func OffsetChecked(c *xgb.Conn, DestinationKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16) OffsetCookie { cookie := c.NewCookie(true, false) c.NewRequest(offsetRequest(c, DestinationKind, DestinationWindow, XOffset, YOffset), cookie) return OffsetCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook OffsetCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for Offset +// offsetRequest writes a Offset request to a byte slice. func offsetRequest(c *xgb.Conn, DestinationKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16) []byte { size := 16 b := 0 @@ -532,29 +555,31 @@ func offsetRequest(c *xgb.Conn, DestinationKind Kind, DestinationWindow xproto.W return buf } -// Request QueryExtents -// size: 8 +// QueryExtentsCookie is a cookie used only for QueryExtents requests. type QueryExtentsCookie struct { *xgb.Cookie } +// QueryExtents sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryExtentsCookie.Reply() func QueryExtents(c *xgb.Conn, DestinationWindow xproto.Window) QueryExtentsCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryExtentsRequest(c, DestinationWindow), cookie) return QueryExtentsCookie{cookie} } +// QueryExtentsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryExtentsUnchecked(c *xgb.Conn, DestinationWindow xproto.Window) QueryExtentsCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryExtentsRequest(c, DestinationWindow), cookie) return QueryExtentsCookie{cookie} } -// Request reply for QueryExtents -// size: 28 +// QueryExtentsReply represents the data returned from a QueryExtents request. type QueryExtentsReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes BoundingShaped bool ClipShaped bool @@ -569,7 +594,7 @@ type QueryExtentsReply struct { ClipShapeExtentsHeight uint16 } -// Waits and reads reply data from request QueryExtents +// Reply blocks and returns the reply data for a QueryExtents request. func (cook QueryExtentsCookie) Reply() (*QueryExtentsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -581,7 +606,7 @@ func (cook QueryExtentsCookie) Reply() (*QueryExtentsReply, error) { return queryExtentsReply(buf), nil } -// Read reply into structure from buffer for QueryExtents +// queryExtentsReply reads a byte slice into a QueryExtentsReply value. func queryExtentsReply(buf []byte) *QueryExtentsReply { v := new(QueryExtentsReply) b := 1 // skip reply determinant @@ -638,6 +663,7 @@ func queryExtentsReply(buf []byte) *QueryExtentsReply { } // Write request to wire for QueryExtents +// queryExtentsRequest writes a QueryExtents request to a byte slice. func queryExtentsRequest(c *xgb.Conn, DestinationWindow xproto.Window) []byte { size := 8 b := 0 @@ -658,30 +684,35 @@ func queryExtentsRequest(c *xgb.Conn, DestinationWindow xproto.Window) []byte { return buf } -// Request SelectInput -// size: 12 +// SelectInputCookie is a cookie used only for SelectInput requests. type SelectInputCookie struct { *xgb.Cookie } -// Write request to wire for SelectInput +// SelectInput sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SelectInput(c *xgb.Conn, DestinationWindow xproto.Window, Enable bool) SelectInputCookie { cookie := c.NewCookie(false, false) c.NewRequest(selectInputRequest(c, DestinationWindow, Enable), cookie) return SelectInputCookie{cookie} } +// SelectInputChecked sends a checked request. +// If an error occurs, it can be retrieved using SelectInputCookie.Check() func SelectInputChecked(c *xgb.Conn, DestinationWindow xproto.Window, Enable bool) SelectInputCookie { cookie := c.NewCookie(true, false) c.NewRequest(selectInputRequest(c, DestinationWindow, Enable), cookie) return SelectInputCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SelectInputCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SelectInput +// selectInputRequest writes a SelectInput request to a byte slice. func selectInputRequest(c *xgb.Conn, DestinationWindow xproto.Window, Enable bool) []byte { size := 12 b := 0 @@ -711,33 +742,35 @@ func selectInputRequest(c *xgb.Conn, DestinationWindow xproto.Window, Enable boo return buf } -// Request InputSelected -// size: 8 +// InputSelectedCookie is a cookie used only for InputSelected requests. type InputSelectedCookie struct { *xgb.Cookie } +// InputSelected sends a checked request. +// If an error occurs, it will be returned with the reply by calling InputSelectedCookie.Reply() func InputSelected(c *xgb.Conn, DestinationWindow xproto.Window) InputSelectedCookie { cookie := c.NewCookie(true, true) c.NewRequest(inputSelectedRequest(c, DestinationWindow), cookie) return InputSelectedCookie{cookie} } +// InputSelectedUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func InputSelectedUnchecked(c *xgb.Conn, DestinationWindow xproto.Window) InputSelectedCookie { cookie := c.NewCookie(false, true) c.NewRequest(inputSelectedRequest(c, DestinationWindow), cookie) return InputSelectedCookie{cookie} } -// Request reply for InputSelected -// size: 8 +// InputSelectedReply represents the data returned from a InputSelected request. type InputSelectedReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply Enabled bool } -// Waits and reads reply data from request InputSelected +// Reply blocks and returns the reply data for a InputSelected request. func (cook InputSelectedCookie) Reply() (*InputSelectedReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -749,7 +782,7 @@ func (cook InputSelectedCookie) Reply() (*InputSelectedReply, error) { return inputSelectedReply(buf), nil } -// Read reply into structure from buffer for InputSelected +// inputSelectedReply reads a byte slice into a InputSelectedReply value. func inputSelectedReply(buf []byte) *InputSelectedReply { v := new(InputSelectedReply) b := 1 // skip reply determinant @@ -771,6 +804,7 @@ func inputSelectedReply(buf []byte) *InputSelectedReply { } // Write request to wire for InputSelected +// inputSelectedRequest writes a InputSelected request to a byte slice. func inputSelectedRequest(c *xgb.Conn, DestinationWindow xproto.Window) []byte { size := 8 b := 0 @@ -791,36 +825,38 @@ func inputSelectedRequest(c *xgb.Conn, DestinationWindow xproto.Window) []byte { return buf } -// Request GetRectangles -// size: 12 +// GetRectanglesCookie is a cookie used only for GetRectangles requests. type GetRectanglesCookie struct { *xgb.Cookie } +// GetRectangles sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetRectanglesCookie.Reply() func GetRectangles(c *xgb.Conn, Window xproto.Window, SourceKind Kind) GetRectanglesCookie { cookie := c.NewCookie(true, true) c.NewRequest(getRectanglesRequest(c, Window, SourceKind), cookie) return GetRectanglesCookie{cookie} } +// GetRectanglesUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetRectanglesUnchecked(c *xgb.Conn, Window xproto.Window, SourceKind Kind) GetRectanglesCookie { cookie := c.NewCookie(false, true) c.NewRequest(getRectanglesRequest(c, Window, SourceKind), cookie) return GetRectanglesCookie{cookie} } -// Request reply for GetRectangles -// size: (32 + xgb.Pad((int(RectanglesLen) * 8))) +// GetRectanglesReply represents the data returned from a GetRectangles request. type GetRectanglesReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply Ordering byte RectanglesLen uint32 // padding: 20 bytes Rectangles []xproto.Rectangle // size: xgb.Pad((int(RectanglesLen) * 8)) } -// Waits and reads reply data from request GetRectangles +// Reply blocks and returns the reply data for a GetRectangles request. func (cook GetRectanglesCookie) Reply() (*GetRectanglesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -832,7 +868,7 @@ func (cook GetRectanglesCookie) Reply() (*GetRectanglesReply, error) { return getRectanglesReply(buf), nil } -// Read reply into structure from buffer for GetRectangles +// getRectanglesReply reads a byte slice into a GetRectanglesReply value. func getRectanglesReply(buf []byte) *GetRectanglesReply { v := new(GetRectanglesReply) b := 1 // skip reply determinant @@ -858,6 +894,7 @@ func getRectanglesReply(buf []byte) *GetRectanglesReply { } // Write request to wire for GetRectangles +// getRectanglesRequest writes a GetRectangles request to a byte slice. func getRectanglesRequest(c *xgb.Conn, Window xproto.Window, SourceKind Kind) []byte { size := 12 b := 0 diff --git a/nexgb/shm/shm.go b/nexgb/shm/shm.go index d262667..b24be97 100644 --- a/nexgb/shm/shm.go +++ b/nexgb/shm/shm.go @@ -2,7 +2,7 @@ package shm /* - This file was generated by shm.xml on May 10 2012 8:04:32pm EDT. + This file was generated by shm.xml on May 10 2012 11:56:19pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,6 +40,8 @@ func init() { xgb.NewExtErrorFuncs["MIT-SHM"] = make(map[int]xgb.NewErrorFun) } +// Skipping definition for base type 'Int32' + // Skipping definition for base type 'Void' // Skipping definition for base type 'Byte' @@ -62,8 +64,6 @@ func init() { // Skipping definition for base type 'Int16' -// Skipping definition for base type 'Int32' - type Seg uint32 func NewSegId(c *xgb.Conn) (Seg, error) { @@ -74,9 +74,7 @@ func NewSegId(c *xgb.Conn) (Seg, error) { return Seg(id), nil } -// Event definition Completion (0) -// Size: 32 - +// Completion is the event number for a CompletionEvent. const Completion = 0 type CompletionEvent struct { @@ -90,7 +88,7 @@ type CompletionEvent struct { Offset uint32 } -// Event read Completion +// CompletionEventNew constructs a CompletionEvent value that implements xgb.Event from a byte slice. func CompletionEventNew(buf []byte) xgb.Event { v := CompletionEvent{} b := 1 // don't read event number @@ -120,7 +118,7 @@ func CompletionEventNew(buf []byte) xgb.Event { return v } -// Event write Completion +// Bytes writes a CompletionEvent value to a byte slice. func (v CompletionEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -153,12 +151,14 @@ func (v CompletionEvent) Bytes() []byte { return buf } -func (v CompletionEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the Completion event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v CompletionEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of CompletionEvent. func (v CompletionEvent) String() string { fieldVals := make([]string, 0, 7) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -174,20 +174,20 @@ func init() { xgb.NewExtEventFuncs["MIT-SHM"][0] = CompletionEventNew } -// ErrorCopy definition BadSeg (0) - +// BadBadSeg is the error number for a BadBadSeg. const BadBadSeg = 0 type BadSegError xproto.ValueError +// BadSegErrorNew constructs a BadSegError value that implements xgb.Error from a byte slice. func BadSegErrorNew(buf []byte) xgb.Error { v := BadSegError(xproto.ValueErrorNew(buf).(xproto.ValueError)) v.NiceName = "BadSeg" return v } -func (err BadSegError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadBadSeg error. +// This is mostly used internally. func (err BadSegError) SequenceId() uint16 { return err.Sequence } @@ -210,29 +210,31 @@ func init() { xgb.NewExtErrorFuncs["MIT-SHM"][0] = BadSegErrorNew } -// Request QueryVersion -// size: 4 +// QueryVersionCookie is a cookie used only for QueryVersion requests. type QueryVersionCookie struct { *xgb.Cookie } +// QueryVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() func QueryVersion(c *xgb.Conn) QueryVersionCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryVersionRequest(c), cookie) return QueryVersionCookie{cookie} } +// QueryVersionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryVersionUnchecked(c *xgb.Conn) QueryVersionCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryVersionRequest(c), cookie) return QueryVersionCookie{cookie} } -// Request reply for QueryVersion -// size: 32 +// QueryVersionReply represents the data returned from a QueryVersion request. type QueryVersionReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply SharedPixmaps bool MajorVersion uint16 MinorVersion uint16 @@ -242,7 +244,7 @@ type QueryVersionReply struct { // padding: 15 bytes } -// Waits and reads reply data from request QueryVersion +// Reply blocks and returns the reply data for a QueryVersion request. func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -254,7 +256,7 @@ func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { return queryVersionReply(buf), nil } -// Read reply into structure from buffer for QueryVersion +// queryVersionReply reads a byte slice into a QueryVersionReply value. func queryVersionReply(buf []byte) *QueryVersionReply { v := new(QueryVersionReply) b := 1 // skip reply determinant @@ -293,6 +295,7 @@ func queryVersionReply(buf []byte) *QueryVersionReply { } // Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. func queryVersionRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -310,30 +313,35 @@ func queryVersionRequest(c *xgb.Conn) []byte { return buf } -// Request Attach -// size: 16 +// AttachCookie is a cookie used only for Attach requests. type AttachCookie struct { *xgb.Cookie } -// Write request to wire for Attach +// Attach sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func Attach(c *xgb.Conn, Shmseg Seg, Shmid uint32, ReadOnly bool) AttachCookie { cookie := c.NewCookie(false, false) c.NewRequest(attachRequest(c, Shmseg, Shmid, ReadOnly), cookie) return AttachCookie{cookie} } +// AttachChecked sends a checked request. +// If an error occurs, it can be retrieved using AttachCookie.Check() func AttachChecked(c *xgb.Conn, Shmseg Seg, Shmid uint32, ReadOnly bool) AttachCookie { cookie := c.NewCookie(true, false) c.NewRequest(attachRequest(c, Shmseg, Shmid, ReadOnly), cookie) return AttachCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook AttachCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for Attach +// attachRequest writes a Attach request to a byte slice. func attachRequest(c *xgb.Conn, Shmseg Seg, Shmid uint32, ReadOnly bool) []byte { size := 16 b := 0 @@ -366,30 +374,35 @@ func attachRequest(c *xgb.Conn, Shmseg Seg, Shmid uint32, ReadOnly bool) []byte return buf } -// Request Detach -// size: 8 +// DetachCookie is a cookie used only for Detach requests. type DetachCookie struct { *xgb.Cookie } -// Write request to wire for Detach +// Detach sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func Detach(c *xgb.Conn, Shmseg Seg) DetachCookie { cookie := c.NewCookie(false, false) c.NewRequest(detachRequest(c, Shmseg), cookie) return DetachCookie{cookie} } +// DetachChecked sends a checked request. +// If an error occurs, it can be retrieved using DetachCookie.Check() func DetachChecked(c *xgb.Conn, Shmseg Seg) DetachCookie { cookie := c.NewCookie(true, false) c.NewRequest(detachRequest(c, Shmseg), cookie) return DetachCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook DetachCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for Detach +// detachRequest writes a Detach request to a byte slice. func detachRequest(c *xgb.Conn, Shmseg Seg) []byte { size := 8 b := 0 @@ -410,30 +423,35 @@ func detachRequest(c *xgb.Conn, Shmseg Seg) []byte { return buf } -// Request PutImage -// size: 40 +// PutImageCookie is a cookie used only for PutImage requests. type PutImageCookie struct { *xgb.Cookie } -// Write request to wire for PutImage +// PutImage sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PutImage(c *xgb.Conn, Drawable xproto.Drawable, Gc xproto.Gcontext, TotalWidth uint16, TotalHeight uint16, SrcX uint16, SrcY uint16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16, Depth byte, Format byte, SendEvent byte, Shmseg Seg, Offset uint32) PutImageCookie { cookie := c.NewCookie(false, false) c.NewRequest(putImageRequest(c, Drawable, Gc, TotalWidth, TotalHeight, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY, Depth, Format, SendEvent, Shmseg, Offset), cookie) return PutImageCookie{cookie} } +// PutImageChecked sends a checked request. +// If an error occurs, it can be retrieved using PutImageCookie.Check() func PutImageChecked(c *xgb.Conn, Drawable xproto.Drawable, Gc xproto.Gcontext, TotalWidth uint16, TotalHeight uint16, SrcX uint16, SrcY uint16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16, Depth byte, Format byte, SendEvent byte, Shmseg Seg, Offset uint32) PutImageCookie { cookie := c.NewCookie(true, false) c.NewRequest(putImageRequest(c, Drawable, Gc, TotalWidth, TotalHeight, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY, Depth, Format, SendEvent, Shmseg, Offset), cookie) return PutImageCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook PutImageCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for PutImage +// putImageRequest writes a PutImage request to a byte slice. func putImageRequest(c *xgb.Conn, Drawable xproto.Drawable, Gc xproto.Gcontext, TotalWidth uint16, TotalHeight uint16, SrcX uint16, SrcY uint16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16, Depth byte, Format byte, SendEvent byte, Shmseg Seg, Offset uint32) []byte { size := 40 b := 0 @@ -498,35 +516,37 @@ func putImageRequest(c *xgb.Conn, Drawable xproto.Drawable, Gc xproto.Gcontext, return buf } -// Request GetImage -// size: 32 +// GetImageCookie is a cookie used only for GetImage requests. type GetImageCookie struct { *xgb.Cookie } +// GetImage sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetImageCookie.Reply() func GetImage(c *xgb.Conn, Drawable xproto.Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32, Format byte, Shmseg Seg, Offset uint32) GetImageCookie { cookie := c.NewCookie(true, true) c.NewRequest(getImageRequest(c, Drawable, X, Y, Width, Height, PlaneMask, Format, Shmseg, Offset), cookie) return GetImageCookie{cookie} } +// GetImageUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetImageUnchecked(c *xgb.Conn, Drawable xproto.Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32, Format byte, Shmseg Seg, Offset uint32) GetImageCookie { cookie := c.NewCookie(false, true) c.NewRequest(getImageRequest(c, Drawable, X, Y, Width, Height, PlaneMask, Format, Shmseg, Offset), cookie) return GetImageCookie{cookie} } -// Request reply for GetImage -// size: 16 +// GetImageReply represents the data returned from a GetImage request. type GetImageReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply Depth byte Visual xproto.Visualid Size uint32 } -// Waits and reads reply data from request GetImage +// Reply blocks and returns the reply data for a GetImage request. func (cook GetImageCookie) Reply() (*GetImageReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -538,7 +558,7 @@ func (cook GetImageCookie) Reply() (*GetImageReply, error) { return getImageReply(buf), nil } -// Read reply into structure from buffer for GetImage +// getImageReply reads a byte slice into a GetImageReply value. func getImageReply(buf []byte) *GetImageReply { v := new(GetImageReply) b := 1 // skip reply determinant @@ -562,6 +582,7 @@ func getImageReply(buf []byte) *GetImageReply { } // Write request to wire for GetImage +// getImageRequest writes a GetImage request to a byte slice. func getImageRequest(c *xgb.Conn, Drawable xproto.Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32, Format byte, Shmseg Seg, Offset uint32) []byte { size := 32 b := 0 @@ -608,30 +629,35 @@ func getImageRequest(c *xgb.Conn, Drawable xproto.Drawable, X int16, Y int16, Wi return buf } -// Request CreatePixmap -// size: 28 +// CreatePixmapCookie is a cookie used only for CreatePixmap requests. type CreatePixmapCookie struct { *xgb.Cookie } -// Write request to wire for CreatePixmap +// CreatePixmap sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreatePixmap(c *xgb.Conn, Pid xproto.Pixmap, Drawable xproto.Drawable, Width uint16, Height uint16, Depth byte, Shmseg Seg, Offset uint32) CreatePixmapCookie { cookie := c.NewCookie(false, false) c.NewRequest(createPixmapRequest(c, Pid, Drawable, Width, Height, Depth, Shmseg, Offset), cookie) return CreatePixmapCookie{cookie} } +// CreatePixmapChecked sends a checked request. +// If an error occurs, it can be retrieved using CreatePixmapCookie.Check() func CreatePixmapChecked(c *xgb.Conn, Pid xproto.Pixmap, Drawable xproto.Drawable, Width uint16, Height uint16, Depth byte, Shmseg Seg, Offset uint32) CreatePixmapCookie { cookie := c.NewCookie(true, false) c.NewRequest(createPixmapRequest(c, Pid, Drawable, Width, Height, Depth, Shmseg, Offset), cookie) return CreatePixmapCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CreatePixmapCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreatePixmap +// createPixmapRequest writes a CreatePixmap request to a byte slice. func createPixmapRequest(c *xgb.Conn, Pid xproto.Pixmap, Drawable xproto.Drawable, Width uint16, Height uint16, Depth byte, Shmseg Seg, Offset uint32) []byte { size := 28 b := 0 diff --git a/nexgb/sync/sync.go b/nexgb/sync/sync.go index cde5cab..7a32bc4 100644 --- a/nexgb/sync/sync.go +++ b/nexgb/sync/sync.go @@ -2,7 +2,7 @@ package sync /* - This file was generated by sync.xml on May 10 2012 8:04:32pm EDT. + This file was generated by sync.xml on May 10 2012 11:56:19pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,6 +40,10 @@ func init() { xgb.NewExtErrorFuncs["SYNC"] = make(map[int]xgb.NewErrorFun) } +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + // Skipping definition for base type 'Int32' // Skipping definition for base type 'Void' @@ -60,10 +64,6 @@ func init() { // Skipping definition for base type 'Float' -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - const ( AlarmstateActive = 0 AlarmstateInactive = 1 @@ -121,14 +121,12 @@ func NewFenceId(c *xgb.Conn) (Fence, error) { return Fence(id), nil } -// 'Int64' struct definition -// Size: 8 type Int64 struct { Hi int32 Lo uint32 } -// Struct read Int64 +// Int64Read reads a byte slice into a Int64 value. func Int64Read(buf []byte, v *Int64) int { b := 0 @@ -141,7 +139,7 @@ func Int64Read(buf []byte, v *Int64) int { return b } -// Struct list read Int64 +// Int64ReadList reads a byte slice into a list of Int64 values. func Int64ReadList(buf []byte, dest []Int64) int { b := 0 for i := 0; i < len(dest); i++ { @@ -151,7 +149,7 @@ func Int64ReadList(buf []byte, dest []Int64) int { return xgb.Pad(b) } -// Struct write Int64 +// Bytes writes a Int64 value to a byte slice. func (v Int64) Bytes() []byte { buf := make([]byte, 8) b := 0 @@ -165,7 +163,7 @@ func (v Int64) Bytes() []byte { return buf } -// Write struct list Int64 +// Int64ListBytes writes a list of %s(MISSING) values to a byte slice. func Int64ListBytes(buf []byte, list []Int64) int { b := 0 var structBytes []byte @@ -177,8 +175,6 @@ func Int64ListBytes(buf []byte, list []Int64) int { return b } -// 'Systemcounter' struct definition -// Size: (14 + xgb.Pad((int(NameLen) * 1))) type Systemcounter struct { Counter Counter Resolution Int64 @@ -186,7 +182,7 @@ type Systemcounter struct { Name string // size: xgb.Pad((int(NameLen) * 1)) } -// Struct read Systemcounter +// SystemcounterRead reads a byte slice into a Systemcounter value. func SystemcounterRead(buf []byte, v *Systemcounter) int { b := 0 @@ -209,7 +205,7 @@ func SystemcounterRead(buf []byte, v *Systemcounter) int { return b } -// Struct list read Systemcounter +// SystemcounterReadList reads a byte slice into a list of Systemcounter values. func SystemcounterReadList(buf []byte, dest []Systemcounter) int { b := 0 for i := 0; i < len(dest); i++ { @@ -219,7 +215,7 @@ func SystemcounterReadList(buf []byte, dest []Systemcounter) int { return xgb.Pad(b) } -// Struct write Systemcounter +// Bytes writes a Systemcounter value to a byte slice. func (v Systemcounter) Bytes() []byte { buf := make([]byte, (14 + xgb.Pad((int(v.NameLen) * 1)))) b := 0 @@ -242,7 +238,7 @@ func (v Systemcounter) Bytes() []byte { return buf } -// Write struct list Systemcounter +// SystemcounterListBytes writes a list of %s(MISSING) values to a byte slice. func SystemcounterListBytes(buf []byte, list []Systemcounter) int { b := 0 var structBytes []byte @@ -254,7 +250,7 @@ func SystemcounterListBytes(buf []byte, list []Systemcounter) int { return b } -// Struct list size Systemcounter +// SystemcounterListSize computes the size (bytes) of a list of Systemcounter values. func SystemcounterListSize(list []Systemcounter) int { size := 0 for _, item := range list { @@ -263,8 +259,6 @@ func SystemcounterListSize(list []Systemcounter) int { return size } -// 'Trigger' struct definition -// Size: 20 type Trigger struct { Counter Counter WaitType uint32 @@ -272,7 +266,7 @@ type Trigger struct { TestType uint32 } -// Struct read Trigger +// TriggerRead reads a byte slice into a Trigger value. func TriggerRead(buf []byte, v *Trigger) int { b := 0 @@ -291,7 +285,7 @@ func TriggerRead(buf []byte, v *Trigger) int { return b } -// Struct list read Trigger +// TriggerReadList reads a byte slice into a list of Trigger values. func TriggerReadList(buf []byte, dest []Trigger) int { b := 0 for i := 0; i < len(dest); i++ { @@ -301,7 +295,7 @@ func TriggerReadList(buf []byte, dest []Trigger) int { return xgb.Pad(b) } -// Struct write Trigger +// Bytes writes a Trigger value to a byte slice. func (v Trigger) Bytes() []byte { buf := make([]byte, 20) b := 0 @@ -324,7 +318,7 @@ func (v Trigger) Bytes() []byte { return buf } -// Write struct list Trigger +// TriggerListBytes writes a list of %s(MISSING) values to a byte slice. func TriggerListBytes(buf []byte, list []Trigger) int { b := 0 var structBytes []byte @@ -336,14 +330,12 @@ func TriggerListBytes(buf []byte, list []Trigger) int { return b } -// 'Waitcondition' struct definition -// Size: 28 type Waitcondition struct { Trigger Trigger EventThreshold Int64 } -// Struct read Waitcondition +// WaitconditionRead reads a byte slice into a Waitcondition value. func WaitconditionRead(buf []byte, v *Waitcondition) int { b := 0 @@ -356,7 +348,7 @@ func WaitconditionRead(buf []byte, v *Waitcondition) int { return b } -// Struct list read Waitcondition +// WaitconditionReadList reads a byte slice into a list of Waitcondition values. func WaitconditionReadList(buf []byte, dest []Waitcondition) int { b := 0 for i := 0; i < len(dest); i++ { @@ -366,7 +358,7 @@ func WaitconditionReadList(buf []byte, dest []Waitcondition) int { return xgb.Pad(b) } -// Struct write Waitcondition +// Bytes writes a Waitcondition value to a byte slice. func (v Waitcondition) Bytes() []byte { buf := make([]byte, 28) b := 0 @@ -386,7 +378,7 @@ func (v Waitcondition) Bytes() []byte { return buf } -// Write struct list Waitcondition +// WaitconditionListBytes writes a list of %s(MISSING) values to a byte slice. func WaitconditionListBytes(buf []byte, list []Waitcondition) int { b := 0 var structBytes []byte @@ -398,9 +390,7 @@ func WaitconditionListBytes(buf []byte, list []Waitcondition) int { return b } -// Event definition CounterNotify (0) -// Size: 32 - +// CounterNotify is the event number for a CounterNotifyEvent. const CounterNotify = 0 type CounterNotifyEvent struct { @@ -415,7 +405,7 @@ type CounterNotifyEvent struct { // padding: 1 bytes } -// Event read CounterNotify +// CounterNotifyEventNew constructs a CounterNotifyEvent value that implements xgb.Event from a byte slice. func CounterNotifyEventNew(buf []byte) xgb.Event { v := CounterNotifyEvent{} b := 1 // don't read event number @@ -453,7 +443,7 @@ func CounterNotifyEventNew(buf []byte) xgb.Event { return v } -// Event write CounterNotify +// Bytes writes a CounterNotifyEvent value to a byte slice. func (v CounterNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -500,12 +490,14 @@ func (v CounterNotifyEvent) Bytes() []byte { return buf } -func (v CounterNotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the CounterNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v CounterNotifyEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of CounterNotifyEvent. func (v CounterNotifyEvent) String() string { fieldVals := make([]string, 0, 8) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -521,9 +513,7 @@ func init() { xgb.NewExtEventFuncs["SYNC"][0] = CounterNotifyEventNew } -// Event definition AlarmNotify (1) -// Size: 32 - +// AlarmNotify is the event number for a AlarmNotifyEvent. const AlarmNotify = 1 type AlarmNotifyEvent struct { @@ -537,7 +527,7 @@ type AlarmNotifyEvent struct { // padding: 3 bytes } -// Event read AlarmNotify +// AlarmNotifyEventNew constructs a AlarmNotifyEvent value that implements xgb.Event from a byte slice. func AlarmNotifyEventNew(buf []byte) xgb.Event { v := AlarmNotifyEvent{} b := 1 // don't read event number @@ -568,7 +558,7 @@ func AlarmNotifyEventNew(buf []byte) xgb.Event { return v } -// Event write AlarmNotify +// Bytes writes a AlarmNotifyEvent value to a byte slice. func (v AlarmNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -608,12 +598,14 @@ func (v AlarmNotifyEvent) Bytes() []byte { return buf } -func (v AlarmNotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the AlarmNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v AlarmNotifyEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of AlarmNotifyEvent. func (v AlarmNotifyEvent) String() string { fieldVals := make([]string, 0, 7) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -628,9 +620,7 @@ func init() { xgb.NewExtEventFuncs["SYNC"][1] = AlarmNotifyEventNew } -// Error definition Counter (0) -// Size: 32 - +// BadCounter is the error number for a BadCounter. const BadCounter = 0 type CounterError struct { @@ -641,7 +631,7 @@ type CounterError struct { MajorOpcode byte } -// Error read Counter +// CounterErrorNew constructs a CounterError value that implements xgb.Error from a byte slice. func CounterErrorNew(buf []byte) xgb.Error { v := CounterError{} v.NiceName = "Counter" @@ -664,8 +654,8 @@ func CounterErrorNew(buf []byte) xgb.Error { return v } -func (err CounterError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadCounter error. +// This is mostly used internally. func (err CounterError) SequenceId() uint16 { return err.Sequence } @@ -688,9 +678,7 @@ func init() { xgb.NewExtErrorFuncs["SYNC"][0] = CounterErrorNew } -// Error definition Alarm (1) -// Size: 32 - +// BadAlarm is the error number for a BadAlarm. const BadAlarm = 1 type AlarmError struct { @@ -701,7 +689,7 @@ type AlarmError struct { MajorOpcode byte } -// Error read Alarm +// AlarmErrorNew constructs a AlarmError value that implements xgb.Error from a byte slice. func AlarmErrorNew(buf []byte) xgb.Error { v := AlarmError{} v.NiceName = "Alarm" @@ -724,8 +712,8 @@ func AlarmErrorNew(buf []byte) xgb.Error { return v } -func (err AlarmError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadAlarm error. +// This is mostly used internally. func (err AlarmError) SequenceId() uint16 { return err.Sequence } @@ -748,36 +736,38 @@ func init() { xgb.NewExtErrorFuncs["SYNC"][1] = AlarmErrorNew } -// Request Initialize -// size: 8 +// InitializeCookie is a cookie used only for Initialize requests. type InitializeCookie struct { *xgb.Cookie } +// Initialize sends a checked request. +// If an error occurs, it will be returned with the reply by calling InitializeCookie.Reply() func Initialize(c *xgb.Conn, DesiredMajorVersion byte, DesiredMinorVersion byte) InitializeCookie { cookie := c.NewCookie(true, true) c.NewRequest(initializeRequest(c, DesiredMajorVersion, DesiredMinorVersion), cookie) return InitializeCookie{cookie} } +// InitializeUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func InitializeUnchecked(c *xgb.Conn, DesiredMajorVersion byte, DesiredMinorVersion byte) InitializeCookie { cookie := c.NewCookie(false, true) c.NewRequest(initializeRequest(c, DesiredMajorVersion, DesiredMinorVersion), cookie) return InitializeCookie{cookie} } -// Request reply for Initialize -// size: 32 +// InitializeReply represents the data returned from a Initialize request. type InitializeReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes MajorVersion byte MinorVersion byte // padding: 22 bytes } -// Waits and reads reply data from request Initialize +// Reply blocks and returns the reply data for a Initialize request. func (cook InitializeCookie) Reply() (*InitializeReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -789,7 +779,7 @@ func (cook InitializeCookie) Reply() (*InitializeReply, error) { return initializeReply(buf), nil } -// Read reply into structure from buffer for Initialize +// initializeReply reads a byte slice into a InitializeReply value. func initializeReply(buf []byte) *InitializeReply { v := new(InitializeReply) b := 1 // skip reply determinant @@ -814,6 +804,7 @@ func initializeReply(buf []byte) *InitializeReply { } // Write request to wire for Initialize +// initializeRequest writes a Initialize request to a byte slice. func initializeRequest(c *xgb.Conn, DesiredMajorVersion byte, DesiredMinorVersion byte) []byte { size := 8 b := 0 @@ -837,36 +828,38 @@ func initializeRequest(c *xgb.Conn, DesiredMajorVersion byte, DesiredMinorVersio return buf } -// Request ListSystemCounters -// size: 4 +// ListSystemCountersCookie is a cookie used only for ListSystemCounters requests. type ListSystemCountersCookie struct { *xgb.Cookie } +// ListSystemCounters sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListSystemCountersCookie.Reply() func ListSystemCounters(c *xgb.Conn) ListSystemCountersCookie { cookie := c.NewCookie(true, true) c.NewRequest(listSystemCountersRequest(c), cookie) return ListSystemCountersCookie{cookie} } +// ListSystemCountersUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ListSystemCountersUnchecked(c *xgb.Conn) ListSystemCountersCookie { cookie := c.NewCookie(false, true) c.NewRequest(listSystemCountersRequest(c), cookie) return ListSystemCountersCookie{cookie} } -// Request reply for ListSystemCounters -// size: (32 + SystemcounterListSize(Counters)) +// ListSystemCountersReply represents the data returned from a ListSystemCounters request. type ListSystemCountersReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes CountersLen uint32 // padding: 20 bytes Counters []Systemcounter // size: SystemcounterListSize(Counters) } -// Waits and reads reply data from request ListSystemCounters +// Reply blocks and returns the reply data for a ListSystemCounters request. func (cook ListSystemCountersCookie) Reply() (*ListSystemCountersReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -878,7 +871,7 @@ func (cook ListSystemCountersCookie) Reply() (*ListSystemCountersReply, error) { return listSystemCountersReply(buf), nil } -// Read reply into structure from buffer for ListSystemCounters +// listSystemCountersReply reads a byte slice into a ListSystemCountersReply value. func listSystemCountersReply(buf []byte) *ListSystemCountersReply { v := new(ListSystemCountersReply) b := 1 // skip reply determinant @@ -903,6 +896,7 @@ func listSystemCountersReply(buf []byte) *ListSystemCountersReply { } // Write request to wire for ListSystemCounters +// listSystemCountersRequest writes a ListSystemCounters request to a byte slice. func listSystemCountersRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -920,30 +914,35 @@ func listSystemCountersRequest(c *xgb.Conn) []byte { return buf } -// Request CreateCounter -// size: 16 +// CreateCounterCookie is a cookie used only for CreateCounter requests. type CreateCounterCookie struct { *xgb.Cookie } -// Write request to wire for CreateCounter +// CreateCounter sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreateCounter(c *xgb.Conn, Id Counter, InitialValue Int64) CreateCounterCookie { cookie := c.NewCookie(false, false) c.NewRequest(createCounterRequest(c, Id, InitialValue), cookie) return CreateCounterCookie{cookie} } +// CreateCounterChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateCounterCookie.Check() func CreateCounterChecked(c *xgb.Conn, Id Counter, InitialValue Int64) CreateCounterCookie { cookie := c.NewCookie(true, false) c.NewRequest(createCounterRequest(c, Id, InitialValue), cookie) return CreateCounterCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CreateCounterCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreateCounter +// createCounterRequest writes a CreateCounter request to a byte slice. func createCounterRequest(c *xgb.Conn, Id Counter, InitialValue Int64) []byte { size := 16 b := 0 @@ -970,30 +969,35 @@ func createCounterRequest(c *xgb.Conn, Id Counter, InitialValue Int64) []byte { return buf } -// Request DestroyCounter -// size: 8 +// DestroyCounterCookie is a cookie used only for DestroyCounter requests. type DestroyCounterCookie struct { *xgb.Cookie } -// Write request to wire for DestroyCounter +// DestroyCounter sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func DestroyCounter(c *xgb.Conn, Counter Counter) DestroyCounterCookie { cookie := c.NewCookie(false, false) c.NewRequest(destroyCounterRequest(c, Counter), cookie) return DestroyCounterCookie{cookie} } +// DestroyCounterChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroyCounterCookie.Check() func DestroyCounterChecked(c *xgb.Conn, Counter Counter) DestroyCounterCookie { cookie := c.NewCookie(true, false) c.NewRequest(destroyCounterRequest(c, Counter), cookie) return DestroyCounterCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook DestroyCounterCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for DestroyCounter +// destroyCounterRequest writes a DestroyCounter request to a byte slice. func destroyCounterRequest(c *xgb.Conn, Counter Counter) []byte { size := 8 b := 0 @@ -1014,34 +1018,36 @@ func destroyCounterRequest(c *xgb.Conn, Counter Counter) []byte { return buf } -// Request QueryCounter -// size: 8 +// QueryCounterCookie is a cookie used only for QueryCounter requests. type QueryCounterCookie struct { *xgb.Cookie } +// QueryCounter sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryCounterCookie.Reply() func QueryCounter(c *xgb.Conn, Counter Counter) QueryCounterCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryCounterRequest(c, Counter), cookie) return QueryCounterCookie{cookie} } +// QueryCounterUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryCounterUnchecked(c *xgb.Conn, Counter Counter) QueryCounterCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryCounterRequest(c, Counter), cookie) return QueryCounterCookie{cookie} } -// Request reply for QueryCounter -// size: 16 +// QueryCounterReply represents the data returned from a QueryCounter request. type QueryCounterReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes CounterValue Int64 } -// Waits and reads reply data from request QueryCounter +// Reply blocks and returns the reply data for a QueryCounter request. func (cook QueryCounterCookie) Reply() (*QueryCounterReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1053,7 +1059,7 @@ func (cook QueryCounterCookie) Reply() (*QueryCounterReply, error) { return queryCounterReply(buf), nil } -// Read reply into structure from buffer for QueryCounter +// queryCounterReply reads a byte slice into a QueryCounterReply value. func queryCounterReply(buf []byte) *QueryCounterReply { v := new(QueryCounterReply) b := 1 // skip reply determinant @@ -1073,6 +1079,7 @@ func queryCounterReply(buf []byte) *QueryCounterReply { } // Write request to wire for QueryCounter +// queryCounterRequest writes a QueryCounter request to a byte slice. func queryCounterRequest(c *xgb.Conn, Counter Counter) []byte { size := 8 b := 0 @@ -1093,30 +1100,35 @@ func queryCounterRequest(c *xgb.Conn, Counter Counter) []byte { return buf } -// Request Await -// size: xgb.Pad((4 + xgb.Pad((len(WaitList) * 28)))) +// AwaitCookie is a cookie used only for Await requests. type AwaitCookie struct { *xgb.Cookie } -// Write request to wire for Await +// Await sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func Await(c *xgb.Conn, WaitList []Waitcondition) AwaitCookie { cookie := c.NewCookie(false, false) c.NewRequest(awaitRequest(c, WaitList), cookie) return AwaitCookie{cookie} } +// AwaitChecked sends a checked request. +// If an error occurs, it can be retrieved using AwaitCookie.Check() func AwaitChecked(c *xgb.Conn, WaitList []Waitcondition) AwaitCookie { cookie := c.NewCookie(true, false) c.NewRequest(awaitRequest(c, WaitList), cookie) return AwaitCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook AwaitCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for Await +// awaitRequest writes a Await request to a byte slice. func awaitRequest(c *xgb.Conn, WaitList []Waitcondition) []byte { size := xgb.Pad((4 + xgb.Pad((len(WaitList) * 28)))) b := 0 @@ -1136,30 +1148,35 @@ func awaitRequest(c *xgb.Conn, WaitList []Waitcondition) []byte { return buf } -// Request ChangeCounter -// size: 16 +// ChangeCounterCookie is a cookie used only for ChangeCounter requests. type ChangeCounterCookie struct { *xgb.Cookie } -// Write request to wire for ChangeCounter +// ChangeCounter sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ChangeCounter(c *xgb.Conn, Counter Counter, Amount Int64) ChangeCounterCookie { cookie := c.NewCookie(false, false) c.NewRequest(changeCounterRequest(c, Counter, Amount), cookie) return ChangeCounterCookie{cookie} } +// ChangeCounterChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeCounterCookie.Check() func ChangeCounterChecked(c *xgb.Conn, Counter Counter, Amount Int64) ChangeCounterCookie { cookie := c.NewCookie(true, false) c.NewRequest(changeCounterRequest(c, Counter, Amount), cookie) return ChangeCounterCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook ChangeCounterCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ChangeCounter +// changeCounterRequest writes a ChangeCounter request to a byte slice. func changeCounterRequest(c *xgb.Conn, Counter Counter, Amount Int64) []byte { size := 16 b := 0 @@ -1186,30 +1203,35 @@ func changeCounterRequest(c *xgb.Conn, Counter Counter, Amount Int64) []byte { return buf } -// Request SetCounter -// size: 16 +// SetCounterCookie is a cookie used only for SetCounter requests. type SetCounterCookie struct { *xgb.Cookie } -// Write request to wire for SetCounter +// SetCounter sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetCounter(c *xgb.Conn, Counter Counter, Value Int64) SetCounterCookie { cookie := c.NewCookie(false, false) c.NewRequest(setCounterRequest(c, Counter, Value), cookie) return SetCounterCookie{cookie} } +// SetCounterChecked sends a checked request. +// If an error occurs, it can be retrieved using SetCounterCookie.Check() func SetCounterChecked(c *xgb.Conn, Counter Counter, Value Int64) SetCounterCookie { cookie := c.NewCookie(true, false) c.NewRequest(setCounterRequest(c, Counter, Value), cookie) return SetCounterCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetCounterCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetCounter +// setCounterRequest writes a SetCounter request to a byte slice. func setCounterRequest(c *xgb.Conn, Counter Counter, Value Int64) []byte { size := 16 b := 0 @@ -1236,30 +1258,35 @@ func setCounterRequest(c *xgb.Conn, Counter Counter, Value Int64) []byte { return buf } -// Request CreateAlarm -// size: xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +// CreateAlarmCookie is a cookie used only for CreateAlarm requests. type CreateAlarmCookie struct { *xgb.Cookie } -// Write request to wire for CreateAlarm +// CreateAlarm sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreateAlarm(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uint32) CreateAlarmCookie { cookie := c.NewCookie(false, false) c.NewRequest(createAlarmRequest(c, Id, ValueMask, ValueList), cookie) return CreateAlarmCookie{cookie} } +// CreateAlarmChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateAlarmCookie.Check() func CreateAlarmChecked(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uint32) CreateAlarmCookie { cookie := c.NewCookie(true, false) c.NewRequest(createAlarmRequest(c, Id, ValueMask, ValueList), cookie) return CreateAlarmCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CreateAlarmCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreateAlarm +// createAlarmRequest writes a CreateAlarm request to a byte slice. func createAlarmRequest(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uint32) []byte { size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) b := 0 @@ -1288,30 +1315,35 @@ func createAlarmRequest(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uin return buf } -// Request ChangeAlarm -// size: xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +// ChangeAlarmCookie is a cookie used only for ChangeAlarm requests. type ChangeAlarmCookie struct { *xgb.Cookie } -// Write request to wire for ChangeAlarm +// ChangeAlarm sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ChangeAlarm(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uint32) ChangeAlarmCookie { cookie := c.NewCookie(false, false) c.NewRequest(changeAlarmRequest(c, Id, ValueMask, ValueList), cookie) return ChangeAlarmCookie{cookie} } +// ChangeAlarmChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeAlarmCookie.Check() func ChangeAlarmChecked(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uint32) ChangeAlarmCookie { cookie := c.NewCookie(true, false) c.NewRequest(changeAlarmRequest(c, Id, ValueMask, ValueList), cookie) return ChangeAlarmCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook ChangeAlarmCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ChangeAlarm +// changeAlarmRequest writes a ChangeAlarm request to a byte slice. func changeAlarmRequest(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uint32) []byte { size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) b := 0 @@ -1340,30 +1372,35 @@ func changeAlarmRequest(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uin return buf } -// Request DestroyAlarm -// size: 8 +// DestroyAlarmCookie is a cookie used only for DestroyAlarm requests. type DestroyAlarmCookie struct { *xgb.Cookie } -// Write request to wire for DestroyAlarm +// DestroyAlarm sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func DestroyAlarm(c *xgb.Conn, Alarm Alarm) DestroyAlarmCookie { cookie := c.NewCookie(false, false) c.NewRequest(destroyAlarmRequest(c, Alarm), cookie) return DestroyAlarmCookie{cookie} } +// DestroyAlarmChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroyAlarmCookie.Check() func DestroyAlarmChecked(c *xgb.Conn, Alarm Alarm) DestroyAlarmCookie { cookie := c.NewCookie(true, false) c.NewRequest(destroyAlarmRequest(c, Alarm), cookie) return DestroyAlarmCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook DestroyAlarmCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for DestroyAlarm +// destroyAlarmRequest writes a DestroyAlarm request to a byte slice. func destroyAlarmRequest(c *xgb.Conn, Alarm Alarm) []byte { size := 8 b := 0 @@ -1384,29 +1421,31 @@ func destroyAlarmRequest(c *xgb.Conn, Alarm Alarm) []byte { return buf } -// Request QueryAlarm -// size: 8 +// QueryAlarmCookie is a cookie used only for QueryAlarm requests. type QueryAlarmCookie struct { *xgb.Cookie } +// QueryAlarm sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryAlarmCookie.Reply() func QueryAlarm(c *xgb.Conn, Alarm Alarm) QueryAlarmCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryAlarmRequest(c, Alarm), cookie) return QueryAlarmCookie{cookie} } +// QueryAlarmUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryAlarmUnchecked(c *xgb.Conn, Alarm Alarm) QueryAlarmCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryAlarmRequest(c, Alarm), cookie) return QueryAlarmCookie{cookie} } -// Request reply for QueryAlarm -// size: 40 +// QueryAlarmReply represents the data returned from a QueryAlarm request. type QueryAlarmReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Trigger Trigger Delta Int64 @@ -1415,7 +1454,7 @@ type QueryAlarmReply struct { // padding: 2 bytes } -// Waits and reads reply data from request QueryAlarm +// Reply blocks and returns the reply data for a QueryAlarm request. func (cook QueryAlarmCookie) Reply() (*QueryAlarmReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1427,7 +1466,7 @@ func (cook QueryAlarmCookie) Reply() (*QueryAlarmReply, error) { return queryAlarmReply(buf), nil } -// Read reply into structure from buffer for QueryAlarm +// queryAlarmReply reads a byte slice into a QueryAlarmReply value. func queryAlarmReply(buf []byte) *QueryAlarmReply { v := new(QueryAlarmReply) b := 1 // skip reply determinant @@ -1462,6 +1501,7 @@ func queryAlarmReply(buf []byte) *QueryAlarmReply { } // Write request to wire for QueryAlarm +// queryAlarmRequest writes a QueryAlarm request to a byte slice. func queryAlarmRequest(c *xgb.Conn, Alarm Alarm) []byte { size := 8 b := 0 @@ -1482,30 +1522,35 @@ func queryAlarmRequest(c *xgb.Conn, Alarm Alarm) []byte { return buf } -// Request SetPriority -// size: 12 +// SetPriorityCookie is a cookie used only for SetPriority requests. type SetPriorityCookie struct { *xgb.Cookie } -// Write request to wire for SetPriority +// SetPriority sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetPriority(c *xgb.Conn, Id uint32, Priority int32) SetPriorityCookie { cookie := c.NewCookie(false, false) c.NewRequest(setPriorityRequest(c, Id, Priority), cookie) return SetPriorityCookie{cookie} } +// SetPriorityChecked sends a checked request. +// If an error occurs, it can be retrieved using SetPriorityCookie.Check() func SetPriorityChecked(c *xgb.Conn, Id uint32, Priority int32) SetPriorityCookie { cookie := c.NewCookie(true, false) c.NewRequest(setPriorityRequest(c, Id, Priority), cookie) return SetPriorityCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetPriorityCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetPriority +// setPriorityRequest writes a SetPriority request to a byte slice. func setPriorityRequest(c *xgb.Conn, Id uint32, Priority int32) []byte { size := 12 b := 0 @@ -1529,34 +1574,36 @@ func setPriorityRequest(c *xgb.Conn, Id uint32, Priority int32) []byte { return buf } -// Request GetPriority -// size: 8 +// GetPriorityCookie is a cookie used only for GetPriority requests. type GetPriorityCookie struct { *xgb.Cookie } +// GetPriority sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPriorityCookie.Reply() func GetPriority(c *xgb.Conn, Id uint32) GetPriorityCookie { cookie := c.NewCookie(true, true) c.NewRequest(getPriorityRequest(c, Id), cookie) return GetPriorityCookie{cookie} } +// GetPriorityUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetPriorityUnchecked(c *xgb.Conn, Id uint32) GetPriorityCookie { cookie := c.NewCookie(false, true) c.NewRequest(getPriorityRequest(c, Id), cookie) return GetPriorityCookie{cookie} } -// Request reply for GetPriority -// size: 12 +// GetPriorityReply represents the data returned from a GetPriority request. type GetPriorityReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Priority int32 } -// Waits and reads reply data from request GetPriority +// Reply blocks and returns the reply data for a GetPriority request. func (cook GetPriorityCookie) Reply() (*GetPriorityReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1568,7 +1615,7 @@ func (cook GetPriorityCookie) Reply() (*GetPriorityReply, error) { return getPriorityReply(buf), nil } -// Read reply into structure from buffer for GetPriority +// getPriorityReply reads a byte slice into a GetPriorityReply value. func getPriorityReply(buf []byte) *GetPriorityReply { v := new(GetPriorityReply) b := 1 // skip reply determinant @@ -1588,6 +1635,7 @@ func getPriorityReply(buf []byte) *GetPriorityReply { } // Write request to wire for GetPriority +// getPriorityRequest writes a GetPriority request to a byte slice. func getPriorityRequest(c *xgb.Conn, Id uint32) []byte { size := 8 b := 0 @@ -1608,30 +1656,35 @@ func getPriorityRequest(c *xgb.Conn, Id uint32) []byte { return buf } -// Request CreateFence -// size: 16 +// CreateFenceCookie is a cookie used only for CreateFence requests. type CreateFenceCookie struct { *xgb.Cookie } -// Write request to wire for CreateFence +// CreateFence sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreateFence(c *xgb.Conn, Drawable xproto.Drawable, Fence Fence, InitiallyTriggered bool) CreateFenceCookie { cookie := c.NewCookie(false, false) c.NewRequest(createFenceRequest(c, Drawable, Fence, InitiallyTriggered), cookie) return CreateFenceCookie{cookie} } +// CreateFenceChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateFenceCookie.Check() func CreateFenceChecked(c *xgb.Conn, Drawable xproto.Drawable, Fence Fence, InitiallyTriggered bool) CreateFenceCookie { cookie := c.NewCookie(true, false) c.NewRequest(createFenceRequest(c, Drawable, Fence, InitiallyTriggered), cookie) return CreateFenceCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CreateFenceCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreateFence +// createFenceRequest writes a CreateFence request to a byte slice. func createFenceRequest(c *xgb.Conn, Drawable xproto.Drawable, Fence Fence, InitiallyTriggered bool) []byte { size := 16 b := 0 @@ -1662,30 +1715,35 @@ func createFenceRequest(c *xgb.Conn, Drawable xproto.Drawable, Fence Fence, Init return buf } -// Request TriggerFence -// size: 8 +// TriggerFenceCookie is a cookie used only for TriggerFence requests. type TriggerFenceCookie struct { *xgb.Cookie } -// Write request to wire for TriggerFence +// TriggerFence sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func TriggerFence(c *xgb.Conn, Fence Fence) TriggerFenceCookie { cookie := c.NewCookie(false, false) c.NewRequest(triggerFenceRequest(c, Fence), cookie) return TriggerFenceCookie{cookie} } +// TriggerFenceChecked sends a checked request. +// If an error occurs, it can be retrieved using TriggerFenceCookie.Check() func TriggerFenceChecked(c *xgb.Conn, Fence Fence) TriggerFenceCookie { cookie := c.NewCookie(true, false) c.NewRequest(triggerFenceRequest(c, Fence), cookie) return TriggerFenceCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook TriggerFenceCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for TriggerFence +// triggerFenceRequest writes a TriggerFence request to a byte slice. func triggerFenceRequest(c *xgb.Conn, Fence Fence) []byte { size := 8 b := 0 @@ -1706,30 +1764,35 @@ func triggerFenceRequest(c *xgb.Conn, Fence Fence) []byte { return buf } -// Request ResetFence -// size: 8 +// ResetFenceCookie is a cookie used only for ResetFence requests. type ResetFenceCookie struct { *xgb.Cookie } -// Write request to wire for ResetFence +// ResetFence sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ResetFence(c *xgb.Conn, Fence Fence) ResetFenceCookie { cookie := c.NewCookie(false, false) c.NewRequest(resetFenceRequest(c, Fence), cookie) return ResetFenceCookie{cookie} } +// ResetFenceChecked sends a checked request. +// If an error occurs, it can be retrieved using ResetFenceCookie.Check() func ResetFenceChecked(c *xgb.Conn, Fence Fence) ResetFenceCookie { cookie := c.NewCookie(true, false) c.NewRequest(resetFenceRequest(c, Fence), cookie) return ResetFenceCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook ResetFenceCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ResetFence +// resetFenceRequest writes a ResetFence request to a byte slice. func resetFenceRequest(c *xgb.Conn, Fence Fence) []byte { size := 8 b := 0 @@ -1750,30 +1813,35 @@ func resetFenceRequest(c *xgb.Conn, Fence Fence) []byte { return buf } -// Request DestroyFence -// size: 8 +// DestroyFenceCookie is a cookie used only for DestroyFence requests. type DestroyFenceCookie struct { *xgb.Cookie } -// Write request to wire for DestroyFence +// DestroyFence sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func DestroyFence(c *xgb.Conn, Fence Fence) DestroyFenceCookie { cookie := c.NewCookie(false, false) c.NewRequest(destroyFenceRequest(c, Fence), cookie) return DestroyFenceCookie{cookie} } +// DestroyFenceChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroyFenceCookie.Check() func DestroyFenceChecked(c *xgb.Conn, Fence Fence) DestroyFenceCookie { cookie := c.NewCookie(true, false) c.NewRequest(destroyFenceRequest(c, Fence), cookie) return DestroyFenceCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook DestroyFenceCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for DestroyFence +// destroyFenceRequest writes a DestroyFence request to a byte slice. func destroyFenceRequest(c *xgb.Conn, Fence Fence) []byte { size := 8 b := 0 @@ -1794,35 +1862,37 @@ func destroyFenceRequest(c *xgb.Conn, Fence Fence) []byte { return buf } -// Request QueryFence -// size: 8 +// QueryFenceCookie is a cookie used only for QueryFence requests. type QueryFenceCookie struct { *xgb.Cookie } +// QueryFence sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryFenceCookie.Reply() func QueryFence(c *xgb.Conn, Fence Fence) QueryFenceCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryFenceRequest(c, Fence), cookie) return QueryFenceCookie{cookie} } +// QueryFenceUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryFenceUnchecked(c *xgb.Conn, Fence Fence) QueryFenceCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryFenceRequest(c, Fence), cookie) return QueryFenceCookie{cookie} } -// Request reply for QueryFence -// size: 32 +// QueryFenceReply represents the data returned from a QueryFence request. type QueryFenceReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Triggered bool // padding: 23 bytes } -// Waits and reads reply data from request QueryFence +// Reply blocks and returns the reply data for a QueryFence request. func (cook QueryFenceCookie) Reply() (*QueryFenceReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1834,7 +1904,7 @@ func (cook QueryFenceCookie) Reply() (*QueryFenceReply, error) { return queryFenceReply(buf), nil } -// Read reply into structure from buffer for QueryFence +// queryFenceReply reads a byte slice into a QueryFenceReply value. func queryFenceReply(buf []byte) *QueryFenceReply { v := new(QueryFenceReply) b := 1 // skip reply determinant @@ -1860,6 +1930,7 @@ func queryFenceReply(buf []byte) *QueryFenceReply { } // Write request to wire for QueryFence +// queryFenceRequest writes a QueryFence request to a byte slice. func queryFenceRequest(c *xgb.Conn, Fence Fence) []byte { size := 8 b := 0 @@ -1880,30 +1951,35 @@ func queryFenceRequest(c *xgb.Conn, Fence Fence) []byte { return buf } -// Request AwaitFence -// size: xgb.Pad((4 + xgb.Pad((len(FenceList) * 4)))) +// AwaitFenceCookie is a cookie used only for AwaitFence requests. type AwaitFenceCookie struct { *xgb.Cookie } -// Write request to wire for AwaitFence +// AwaitFence sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func AwaitFence(c *xgb.Conn, FenceList []Fence) AwaitFenceCookie { cookie := c.NewCookie(false, false) c.NewRequest(awaitFenceRequest(c, FenceList), cookie) return AwaitFenceCookie{cookie} } +// AwaitFenceChecked sends a checked request. +// If an error occurs, it can be retrieved using AwaitFenceCookie.Check() func AwaitFenceChecked(c *xgb.Conn, FenceList []Fence) AwaitFenceCookie { cookie := c.NewCookie(true, false) c.NewRequest(awaitFenceRequest(c, FenceList), cookie) return AwaitFenceCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook AwaitFenceCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for AwaitFence +// awaitFenceRequest writes a AwaitFence request to a byte slice. func awaitFenceRequest(c *xgb.Conn, FenceList []Fence) []byte { size := xgb.Pad((4 + xgb.Pad((len(FenceList) * 4)))) b := 0 diff --git a/nexgb/xcmisc/xcmisc.go b/nexgb/xcmisc/xcmisc.go index d4f7b0d..5157119 100644 --- a/nexgb/xcmisc/xcmisc.go +++ b/nexgb/xcmisc/xcmisc.go @@ -2,7 +2,7 @@ package xcmisc /* - This file was generated by xc_misc.xml on May 10 2012 8:04:32pm EDT. + This file was generated by xc_misc.xml on May 10 2012 11:56:19pm EDT. This file is automatically generated. Edit at your peril! */ @@ -64,35 +64,37 @@ func init() { // Skipping definition for base type 'Bool' -// Request GetVersion -// size: 8 +// GetVersionCookie is a cookie used only for GetVersion requests. type GetVersionCookie struct { *xgb.Cookie } +// GetVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetVersionCookie.Reply() func GetVersion(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) GetVersionCookie { cookie := c.NewCookie(true, true) c.NewRequest(getVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) return GetVersionCookie{cookie} } +// GetVersionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) GetVersionCookie { cookie := c.NewCookie(false, true) c.NewRequest(getVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) return GetVersionCookie{cookie} } -// Request reply for GetVersion -// size: 12 +// GetVersionReply represents the data returned from a GetVersion request. type GetVersionReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes ServerMajorVersion uint16 ServerMinorVersion uint16 } -// Waits and reads reply data from request GetVersion +// Reply blocks and returns the reply data for a GetVersion request. func (cook GetVersionCookie) Reply() (*GetVersionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -104,7 +106,7 @@ func (cook GetVersionCookie) Reply() (*GetVersionReply, error) { return getVersionReply(buf), nil } -// Read reply into structure from buffer for GetVersion +// getVersionReply reads a byte slice into a GetVersionReply value. func getVersionReply(buf []byte) *GetVersionReply { v := new(GetVersionReply) b := 1 // skip reply determinant @@ -127,6 +129,7 @@ func getVersionReply(buf []byte) *GetVersionReply { } // Write request to wire for GetVersion +// getVersionRequest writes a GetVersion request to a byte slice. func getVersionRequest(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) []byte { size := 8 b := 0 @@ -150,35 +153,37 @@ func getVersionRequest(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersio return buf } -// Request GetXIDRange -// size: 4 +// GetXIDRangeCookie is a cookie used only for GetXIDRange requests. type GetXIDRangeCookie struct { *xgb.Cookie } +// GetXIDRange sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetXIDRangeCookie.Reply() func GetXIDRange(c *xgb.Conn) GetXIDRangeCookie { cookie := c.NewCookie(true, true) c.NewRequest(getXIDRangeRequest(c), cookie) return GetXIDRangeCookie{cookie} } +// GetXIDRangeUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetXIDRangeUnchecked(c *xgb.Conn) GetXIDRangeCookie { cookie := c.NewCookie(false, true) c.NewRequest(getXIDRangeRequest(c), cookie) return GetXIDRangeCookie{cookie} } -// Request reply for GetXIDRange -// size: 16 +// GetXIDRangeReply represents the data returned from a GetXIDRange request. type GetXIDRangeReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes StartId uint32 Count uint32 } -// Waits and reads reply data from request GetXIDRange +// Reply blocks and returns the reply data for a GetXIDRange request. func (cook GetXIDRangeCookie) Reply() (*GetXIDRangeReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -190,7 +195,7 @@ func (cook GetXIDRangeCookie) Reply() (*GetXIDRangeReply, error) { return getXIDRangeReply(buf), nil } -// Read reply into structure from buffer for GetXIDRange +// getXIDRangeReply reads a byte slice into a GetXIDRangeReply value. func getXIDRangeReply(buf []byte) *GetXIDRangeReply { v := new(GetXIDRangeReply) b := 1 // skip reply determinant @@ -213,6 +218,7 @@ func getXIDRangeReply(buf []byte) *GetXIDRangeReply { } // Write request to wire for GetXIDRange +// getXIDRangeRequest writes a GetXIDRange request to a byte slice. func getXIDRangeRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -230,36 +236,38 @@ func getXIDRangeRequest(c *xgb.Conn) []byte { return buf } -// Request GetXIDList -// size: 8 +// GetXIDListCookie is a cookie used only for GetXIDList requests. type GetXIDListCookie struct { *xgb.Cookie } +// GetXIDList sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetXIDListCookie.Reply() func GetXIDList(c *xgb.Conn, Count uint32) GetXIDListCookie { cookie := c.NewCookie(true, true) c.NewRequest(getXIDListRequest(c, Count), cookie) return GetXIDListCookie{cookie} } +// GetXIDListUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetXIDListUnchecked(c *xgb.Conn, Count uint32) GetXIDListCookie { cookie := c.NewCookie(false, true) c.NewRequest(getXIDListRequest(c, Count), cookie) return GetXIDListCookie{cookie} } -// Request reply for GetXIDList -// size: (32 + xgb.Pad((int(IdsLen) * 4))) +// GetXIDListReply represents the data returned from a GetXIDList request. type GetXIDListReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes IdsLen uint32 // padding: 20 bytes Ids []uint32 // size: xgb.Pad((int(IdsLen) * 4)) } -// Waits and reads reply data from request GetXIDList +// Reply blocks and returns the reply data for a GetXIDList request. func (cook GetXIDListCookie) Reply() (*GetXIDListReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -271,7 +279,7 @@ func (cook GetXIDListCookie) Reply() (*GetXIDListReply, error) { return getXIDListReply(buf), nil } -// Read reply into structure from buffer for GetXIDList +// getXIDListReply reads a byte slice into a GetXIDListReply value. func getXIDListReply(buf []byte) *GetXIDListReply { v := new(GetXIDListReply) b := 1 // skip reply determinant @@ -300,6 +308,7 @@ func getXIDListReply(buf []byte) *GetXIDListReply { } // Write request to wire for GetXIDList +// getXIDListRequest writes a GetXIDList request to a byte slice. func getXIDListRequest(c *xgb.Conn, Count uint32) []byte { size := 8 b := 0 diff --git a/nexgb/xevie/xevie.go b/nexgb/xevie/xevie.go index 47d9146..3076680 100644 --- a/nexgb/xevie/xevie.go +++ b/nexgb/xevie/xevie.go @@ -2,7 +2,7 @@ package xevie /* - This file was generated by xevie.xml on May 10 2012 8:04:32pm EDT. + This file was generated by xevie.xml on May 10 2012 11:56:19pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,16 +40,6 @@ func init() { xgb.NewExtErrorFuncs["XEVIE"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - // Skipping definition for base type 'Int8' // Skipping definition for base type 'Card16' @@ -64,18 +54,26 @@ func init() { // Skipping definition for base type 'Float' +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + const ( DatatypeUnmodified = 0 DatatypeModified = 1 ) -// 'Event' struct definition -// Size: 32 type Event struct { // padding: 32 bytes } -// Struct read Event +// EventRead reads a byte slice into a Event value. func EventRead(buf []byte, v *Event) int { b := 0 @@ -84,7 +82,7 @@ func EventRead(buf []byte, v *Event) int { return b } -// Struct list read Event +// EventReadList reads a byte slice into a list of Event values. func EventReadList(buf []byte, dest []Event) int { b := 0 for i := 0; i < len(dest); i++ { @@ -94,7 +92,7 @@ func EventReadList(buf []byte, dest []Event) int { return xgb.Pad(b) } -// Struct write Event +// Bytes writes a Event value to a byte slice. func (v Event) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -104,7 +102,7 @@ func (v Event) Bytes() []byte { return buf } -// Write struct list Event +// EventListBytes writes a list of %s(MISSING) values to a byte slice. func EventListBytes(buf []byte, list []Event) int { b := 0 var structBytes []byte @@ -116,36 +114,38 @@ func EventListBytes(buf []byte, list []Event) int { return b } -// Request QueryVersion -// size: 8 +// QueryVersionCookie is a cookie used only for QueryVersion requests. type QueryVersionCookie struct { *xgb.Cookie } +// QueryVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() func QueryVersion(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) QueryVersionCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) return QueryVersionCookie{cookie} } +// QueryVersionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) QueryVersionCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) return QueryVersionCookie{cookie} } -// Request reply for QueryVersion -// size: 32 +// QueryVersionReply represents the data returned from a QueryVersion request. type QueryVersionReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes ServerMajorVersion uint16 ServerMinorVersion uint16 // padding: 20 bytes } -// Waits and reads reply data from request QueryVersion +// Reply blocks and returns the reply data for a QueryVersion request. func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -157,7 +157,7 @@ func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { return queryVersionReply(buf), nil } -// Read reply into structure from buffer for QueryVersion +// queryVersionReply reads a byte slice into a QueryVersionReply value. func queryVersionReply(buf []byte) *QueryVersionReply { v := new(QueryVersionReply) b := 1 // skip reply determinant @@ -182,6 +182,7 @@ func queryVersionReply(buf []byte) *QueryVersionReply { } // Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) []byte { size := 8 b := 0 @@ -205,34 +206,36 @@ func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVers return buf } -// Request Start -// size: 8 +// StartCookie is a cookie used only for Start requests. type StartCookie struct { *xgb.Cookie } +// Start sends a checked request. +// If an error occurs, it will be returned with the reply by calling StartCookie.Reply() func Start(c *xgb.Conn, Screen uint32) StartCookie { cookie := c.NewCookie(true, true) c.NewRequest(startRequest(c, Screen), cookie) return StartCookie{cookie} } +// StartUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func StartUnchecked(c *xgb.Conn, Screen uint32) StartCookie { cookie := c.NewCookie(false, true) c.NewRequest(startRequest(c, Screen), cookie) return StartCookie{cookie} } -// Request reply for Start -// size: 32 +// StartReply represents the data returned from a Start request. type StartReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 24 bytes } -// Waits and reads reply data from request Start +// Reply blocks and returns the reply data for a Start request. func (cook StartCookie) Reply() (*StartReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -244,7 +247,7 @@ func (cook StartCookie) Reply() (*StartReply, error) { return startReply(buf), nil } -// Read reply into structure from buffer for Start +// startReply reads a byte slice into a StartReply value. func startReply(buf []byte) *StartReply { v := new(StartReply) b := 1 // skip reply determinant @@ -263,6 +266,7 @@ func startReply(buf []byte) *StartReply { } // Write request to wire for Start +// startRequest writes a Start request to a byte slice. func startRequest(c *xgb.Conn, Screen uint32) []byte { size := 8 b := 0 @@ -283,34 +287,36 @@ func startRequest(c *xgb.Conn, Screen uint32) []byte { return buf } -// Request End -// size: 8 +// EndCookie is a cookie used only for End requests. type EndCookie struct { *xgb.Cookie } +// End sends a checked request. +// If an error occurs, it will be returned with the reply by calling EndCookie.Reply() func End(c *xgb.Conn, Cmap uint32) EndCookie { cookie := c.NewCookie(true, true) c.NewRequest(endRequest(c, Cmap), cookie) return EndCookie{cookie} } +// EndUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func EndUnchecked(c *xgb.Conn, Cmap uint32) EndCookie { cookie := c.NewCookie(false, true) c.NewRequest(endRequest(c, Cmap), cookie) return EndCookie{cookie} } -// Request reply for End -// size: 32 +// EndReply represents the data returned from a End request. type EndReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 24 bytes } -// Waits and reads reply data from request End +// Reply blocks and returns the reply data for a End request. func (cook EndCookie) Reply() (*EndReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -322,7 +328,7 @@ func (cook EndCookie) Reply() (*EndReply, error) { return endReply(buf), nil } -// Read reply into structure from buffer for End +// endReply reads a byte slice into a EndReply value. func endReply(buf []byte) *EndReply { v := new(EndReply) b := 1 // skip reply determinant @@ -341,6 +347,7 @@ func endReply(buf []byte) *EndReply { } // Write request to wire for End +// endRequest writes a End request to a byte slice. func endRequest(c *xgb.Conn, Cmap uint32) []byte { size := 8 b := 0 @@ -361,34 +368,36 @@ func endRequest(c *xgb.Conn, Cmap uint32) []byte { return buf } -// Request Send -// size: 104 +// SendCookie is a cookie used only for Send requests. type SendCookie struct { *xgb.Cookie } +// Send sends a checked request. +// If an error occurs, it will be returned with the reply by calling SendCookie.Reply() func Send(c *xgb.Conn, Event Event, DataType uint32) SendCookie { cookie := c.NewCookie(true, true) c.NewRequest(sendRequest(c, Event, DataType), cookie) return SendCookie{cookie} } +// SendUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SendUnchecked(c *xgb.Conn, Event Event, DataType uint32) SendCookie { cookie := c.NewCookie(false, true) c.NewRequest(sendRequest(c, Event, DataType), cookie) return SendCookie{cookie} } -// Request reply for Send -// size: 32 +// SendReply represents the data returned from a Send request. type SendReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 24 bytes } -// Waits and reads reply data from request Send +// Reply blocks and returns the reply data for a Send request. func (cook SendCookie) Reply() (*SendReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -400,7 +409,7 @@ func (cook SendCookie) Reply() (*SendReply, error) { return sendReply(buf), nil } -// Read reply into structure from buffer for Send +// sendReply reads a byte slice into a SendReply value. func sendReply(buf []byte) *SendReply { v := new(SendReply) b := 1 // skip reply determinant @@ -419,6 +428,7 @@ func sendReply(buf []byte) *SendReply { } // Write request to wire for Send +// sendRequest writes a Send request to a byte slice. func sendRequest(c *xgb.Conn, Event Event, DataType uint32) []byte { size := 104 b := 0 @@ -447,34 +457,36 @@ func sendRequest(c *xgb.Conn, Event Event, DataType uint32) []byte { return buf } -// Request SelectInput -// size: 8 +// SelectInputCookie is a cookie used only for SelectInput requests. type SelectInputCookie struct { *xgb.Cookie } +// SelectInput sends a checked request. +// If an error occurs, it will be returned with the reply by calling SelectInputCookie.Reply() func SelectInput(c *xgb.Conn, EventMask uint32) SelectInputCookie { cookie := c.NewCookie(true, true) c.NewRequest(selectInputRequest(c, EventMask), cookie) return SelectInputCookie{cookie} } +// SelectInputUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SelectInputUnchecked(c *xgb.Conn, EventMask uint32) SelectInputCookie { cookie := c.NewCookie(false, true) c.NewRequest(selectInputRequest(c, EventMask), cookie) return SelectInputCookie{cookie} } -// Request reply for SelectInput -// size: 32 +// SelectInputReply represents the data returned from a SelectInput request. type SelectInputReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 24 bytes } -// Waits and reads reply data from request SelectInput +// Reply blocks and returns the reply data for a SelectInput request. func (cook SelectInputCookie) Reply() (*SelectInputReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -486,7 +498,7 @@ func (cook SelectInputCookie) Reply() (*SelectInputReply, error) { return selectInputReply(buf), nil } -// Read reply into structure from buffer for SelectInput +// selectInputReply reads a byte slice into a SelectInputReply value. func selectInputReply(buf []byte) *SelectInputReply { v := new(SelectInputReply) b := 1 // skip reply determinant @@ -505,6 +517,7 @@ func selectInputReply(buf []byte) *SelectInputReply { } // Write request to wire for SelectInput +// selectInputRequest writes a SelectInput request to a byte slice. func selectInputRequest(c *xgb.Conn, EventMask uint32) []byte { size := 8 b := 0 diff --git a/nexgb/xf86dri/xf86dri.go b/nexgb/xf86dri/xf86dri.go index ac87c0a..cd3ff35 100644 --- a/nexgb/xf86dri/xf86dri.go +++ b/nexgb/xf86dri/xf86dri.go @@ -2,7 +2,7 @@ package xf86dri /* - This file was generated by xf86dri.xml on May 10 2012 8:04:32pm EDT. + This file was generated by xf86dri.xml on May 10 2012 11:56:19pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,18 +40,6 @@ func init() { xgb.NewExtErrorFuncs["XFree86-DRI"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Int8' - -// Skipping definition for base type 'Card16' - -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - // Skipping definition for base type 'Float' // Skipping definition for base type 'Card8' @@ -64,8 +52,18 @@ func init() { // Skipping definition for base type 'Byte' -// 'DrmClipRect' struct definition -// Size: 8 +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Bool' + type DrmClipRect struct { X1 int16 Y1 int16 @@ -73,7 +71,7 @@ type DrmClipRect struct { X3 int16 } -// Struct read DrmClipRect +// DrmClipRectRead reads a byte slice into a DrmClipRect value. func DrmClipRectRead(buf []byte, v *DrmClipRect) int { b := 0 @@ -92,7 +90,7 @@ func DrmClipRectRead(buf []byte, v *DrmClipRect) int { return b } -// Struct list read DrmClipRect +// DrmClipRectReadList reads a byte slice into a list of DrmClipRect values. func DrmClipRectReadList(buf []byte, dest []DrmClipRect) int { b := 0 for i := 0; i < len(dest); i++ { @@ -102,7 +100,7 @@ func DrmClipRectReadList(buf []byte, dest []DrmClipRect) int { return xgb.Pad(b) } -// Struct write DrmClipRect +// Bytes writes a DrmClipRect value to a byte slice. func (v DrmClipRect) Bytes() []byte { buf := make([]byte, 8) b := 0 @@ -122,7 +120,7 @@ func (v DrmClipRect) Bytes() []byte { return buf } -// Write struct list DrmClipRect +// DrmClipRectListBytes writes a list of %s(MISSING) values to a byte slice. func DrmClipRectListBytes(buf []byte, list []DrmClipRect) int { b := 0 var structBytes []byte @@ -134,36 +132,38 @@ func DrmClipRectListBytes(buf []byte, list []DrmClipRect) int { return b } -// Request QueryVersion -// size: 4 +// QueryVersionCookie is a cookie used only for QueryVersion requests. type QueryVersionCookie struct { *xgb.Cookie } +// QueryVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() func QueryVersion(c *xgb.Conn) QueryVersionCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryVersionRequest(c), cookie) return QueryVersionCookie{cookie} } +// QueryVersionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryVersionUnchecked(c *xgb.Conn) QueryVersionCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryVersionRequest(c), cookie) return QueryVersionCookie{cookie} } -// Request reply for QueryVersion -// size: 16 +// QueryVersionReply represents the data returned from a QueryVersion request. type QueryVersionReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes DriMajorVersion uint16 DriMinorVersion uint16 DriMinorPatch uint32 } -// Waits and reads reply data from request QueryVersion +// Reply blocks and returns the reply data for a QueryVersion request. func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -175,7 +175,7 @@ func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { return queryVersionReply(buf), nil } -// Read reply into structure from buffer for QueryVersion +// queryVersionReply reads a byte slice into a QueryVersionReply value. func queryVersionReply(buf []byte) *QueryVersionReply { v := new(QueryVersionReply) b := 1 // skip reply determinant @@ -201,6 +201,7 @@ func queryVersionReply(buf []byte) *QueryVersionReply { } // Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. func queryVersionRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -218,34 +219,36 @@ func queryVersionRequest(c *xgb.Conn) []byte { return buf } -// Request QueryDirectRenderingCapable -// size: 8 +// QueryDirectRenderingCapableCookie is a cookie used only for QueryDirectRenderingCapable requests. type QueryDirectRenderingCapableCookie struct { *xgb.Cookie } +// QueryDirectRenderingCapable sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryDirectRenderingCapableCookie.Reply() func QueryDirectRenderingCapable(c *xgb.Conn, Screen uint32) QueryDirectRenderingCapableCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryDirectRenderingCapableRequest(c, Screen), cookie) return QueryDirectRenderingCapableCookie{cookie} } +// QueryDirectRenderingCapableUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryDirectRenderingCapableUnchecked(c *xgb.Conn, Screen uint32) QueryDirectRenderingCapableCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryDirectRenderingCapableRequest(c, Screen), cookie) return QueryDirectRenderingCapableCookie{cookie} } -// Request reply for QueryDirectRenderingCapable -// size: 9 +// QueryDirectRenderingCapableReply represents the data returned from a QueryDirectRenderingCapable request. type QueryDirectRenderingCapableReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes IsCapable bool } -// Waits and reads reply data from request QueryDirectRenderingCapable +// Reply blocks and returns the reply data for a QueryDirectRenderingCapable request. func (cook QueryDirectRenderingCapableCookie) Reply() (*QueryDirectRenderingCapableReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -257,7 +260,7 @@ func (cook QueryDirectRenderingCapableCookie) Reply() (*QueryDirectRenderingCapa return queryDirectRenderingCapableReply(buf), nil } -// Read reply into structure from buffer for QueryDirectRenderingCapable +// queryDirectRenderingCapableReply reads a byte slice into a QueryDirectRenderingCapableReply value. func queryDirectRenderingCapableReply(buf []byte) *QueryDirectRenderingCapableReply { v := new(QueryDirectRenderingCapableReply) b := 1 // skip reply determinant @@ -281,6 +284,7 @@ func queryDirectRenderingCapableReply(buf []byte) *QueryDirectRenderingCapableRe } // Write request to wire for QueryDirectRenderingCapable +// queryDirectRenderingCapableRequest writes a QueryDirectRenderingCapable request to a byte slice. func queryDirectRenderingCapableRequest(c *xgb.Conn, Screen uint32) []byte { size := 8 b := 0 @@ -301,29 +305,31 @@ func queryDirectRenderingCapableRequest(c *xgb.Conn, Screen uint32) []byte { return buf } -// Request OpenConnection -// size: 8 +// OpenConnectionCookie is a cookie used only for OpenConnection requests. type OpenConnectionCookie struct { *xgb.Cookie } +// OpenConnection sends a checked request. +// If an error occurs, it will be returned with the reply by calling OpenConnectionCookie.Reply() func OpenConnection(c *xgb.Conn, Screen uint32) OpenConnectionCookie { cookie := c.NewCookie(true, true) c.NewRequest(openConnectionRequest(c, Screen), cookie) return OpenConnectionCookie{cookie} } +// OpenConnectionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func OpenConnectionUnchecked(c *xgb.Conn, Screen uint32) OpenConnectionCookie { cookie := c.NewCookie(false, true) c.NewRequest(openConnectionRequest(c, Screen), cookie) return OpenConnectionCookie{cookie} } -// Request reply for OpenConnection -// size: (32 + xgb.Pad((int(BusIdLen) * 1))) +// OpenConnectionReply represents the data returned from a OpenConnection request. type OpenConnectionReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes SareaHandleLow uint32 SareaHandleHigh uint32 @@ -332,7 +338,7 @@ type OpenConnectionReply struct { BusId string // size: xgb.Pad((int(BusIdLen) * 1)) } -// Waits and reads reply data from request OpenConnection +// Reply blocks and returns the reply data for a OpenConnection request. func (cook OpenConnectionCookie) Reply() (*OpenConnectionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -344,7 +350,7 @@ func (cook OpenConnectionCookie) Reply() (*OpenConnectionReply, error) { return openConnectionReply(buf), nil } -// Read reply into structure from buffer for OpenConnection +// openConnectionReply reads a byte slice into a OpenConnectionReply value. func openConnectionReply(buf []byte) *OpenConnectionReply { v := new(OpenConnectionReply) b := 1 // skip reply determinant @@ -379,6 +385,7 @@ func openConnectionReply(buf []byte) *OpenConnectionReply { } // Write request to wire for OpenConnection +// openConnectionRequest writes a OpenConnection request to a byte slice. func openConnectionRequest(c *xgb.Conn, Screen uint32) []byte { size := 8 b := 0 @@ -399,30 +406,35 @@ func openConnectionRequest(c *xgb.Conn, Screen uint32) []byte { return buf } -// Request CloseConnection -// size: 8 +// CloseConnectionCookie is a cookie used only for CloseConnection requests. type CloseConnectionCookie struct { *xgb.Cookie } -// Write request to wire for CloseConnection +// CloseConnection sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CloseConnection(c *xgb.Conn, Screen uint32) CloseConnectionCookie { cookie := c.NewCookie(false, false) c.NewRequest(closeConnectionRequest(c, Screen), cookie) return CloseConnectionCookie{cookie} } +// CloseConnectionChecked sends a checked request. +// If an error occurs, it can be retrieved using CloseConnectionCookie.Check() func CloseConnectionChecked(c *xgb.Conn, Screen uint32) CloseConnectionCookie { cookie := c.NewCookie(true, false) c.NewRequest(closeConnectionRequest(c, Screen), cookie) return CloseConnectionCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CloseConnectionCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CloseConnection +// closeConnectionRequest writes a CloseConnection request to a byte slice. func closeConnectionRequest(c *xgb.Conn, Screen uint32) []byte { size := 8 b := 0 @@ -443,29 +455,31 @@ func closeConnectionRequest(c *xgb.Conn, Screen uint32) []byte { return buf } -// Request GetClientDriverName -// size: 8 +// GetClientDriverNameCookie is a cookie used only for GetClientDriverName requests. type GetClientDriverNameCookie struct { *xgb.Cookie } +// GetClientDriverName sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetClientDriverNameCookie.Reply() func GetClientDriverName(c *xgb.Conn, Screen uint32) GetClientDriverNameCookie { cookie := c.NewCookie(true, true) c.NewRequest(getClientDriverNameRequest(c, Screen), cookie) return GetClientDriverNameCookie{cookie} } +// GetClientDriverNameUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetClientDriverNameUnchecked(c *xgb.Conn, Screen uint32) GetClientDriverNameCookie { cookie := c.NewCookie(false, true) c.NewRequest(getClientDriverNameRequest(c, Screen), cookie) return GetClientDriverNameCookie{cookie} } -// Request reply for GetClientDriverName -// size: (32 + xgb.Pad((int(ClientDriverNameLen) * 1))) +// GetClientDriverNameReply represents the data returned from a GetClientDriverName request. type GetClientDriverNameReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes ClientDriverMajorVersion uint32 ClientDriverMinorVersion uint32 @@ -475,7 +489,7 @@ type GetClientDriverNameReply struct { ClientDriverName string // size: xgb.Pad((int(ClientDriverNameLen) * 1)) } -// Waits and reads reply data from request GetClientDriverName +// Reply blocks and returns the reply data for a GetClientDriverName request. func (cook GetClientDriverNameCookie) Reply() (*GetClientDriverNameReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -487,7 +501,7 @@ func (cook GetClientDriverNameCookie) Reply() (*GetClientDriverNameReply, error) return getClientDriverNameReply(buf), nil } -// Read reply into structure from buffer for GetClientDriverName +// getClientDriverNameReply reads a byte slice into a GetClientDriverNameReply value. func getClientDriverNameReply(buf []byte) *GetClientDriverNameReply { v := new(GetClientDriverNameReply) b := 1 // skip reply determinant @@ -525,6 +539,7 @@ func getClientDriverNameReply(buf []byte) *GetClientDriverNameReply { } // Write request to wire for GetClientDriverName +// getClientDriverNameRequest writes a GetClientDriverName request to a byte slice. func getClientDriverNameRequest(c *xgb.Conn, Screen uint32) []byte { size := 8 b := 0 @@ -545,34 +560,36 @@ func getClientDriverNameRequest(c *xgb.Conn, Screen uint32) []byte { return buf } -// Request CreateContext -// size: 16 +// CreateContextCookie is a cookie used only for CreateContext requests. type CreateContextCookie struct { *xgb.Cookie } +// CreateContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling CreateContextCookie.Reply() func CreateContext(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) CreateContextCookie { cookie := c.NewCookie(true, true) c.NewRequest(createContextRequest(c, Screen, Visual, Context), cookie) return CreateContextCookie{cookie} } +// CreateContextUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreateContextUnchecked(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) CreateContextCookie { cookie := c.NewCookie(false, true) c.NewRequest(createContextRequest(c, Screen, Visual, Context), cookie) return CreateContextCookie{cookie} } -// Request reply for CreateContext -// size: 12 +// CreateContextReply represents the data returned from a CreateContext request. type CreateContextReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes HwContext uint32 } -// Waits and reads reply data from request CreateContext +// Reply blocks and returns the reply data for a CreateContext request. func (cook CreateContextCookie) Reply() (*CreateContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -584,7 +601,7 @@ func (cook CreateContextCookie) Reply() (*CreateContextReply, error) { return createContextReply(buf), nil } -// Read reply into structure from buffer for CreateContext +// createContextReply reads a byte slice into a CreateContextReply value. func createContextReply(buf []byte) *CreateContextReply { v := new(CreateContextReply) b := 1 // skip reply determinant @@ -604,6 +621,7 @@ func createContextReply(buf []byte) *CreateContextReply { } // Write request to wire for CreateContext +// createContextRequest writes a CreateContext request to a byte slice. func createContextRequest(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) []byte { size := 16 b := 0 @@ -630,30 +648,35 @@ func createContextRequest(c *xgb.Conn, Screen uint32, Visual uint32, Context uin return buf } -// Request DestroyContext -// size: 12 +// DestroyContextCookie is a cookie used only for DestroyContext requests. type DestroyContextCookie struct { *xgb.Cookie } -// Write request to wire for DestroyContext +// DestroyContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func DestroyContext(c *xgb.Conn, Screen uint32, Context uint32) DestroyContextCookie { cookie := c.NewCookie(false, false) c.NewRequest(destroyContextRequest(c, Screen, Context), cookie) return DestroyContextCookie{cookie} } +// DestroyContextChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroyContextCookie.Check() func DestroyContextChecked(c *xgb.Conn, Screen uint32, Context uint32) DestroyContextCookie { cookie := c.NewCookie(true, false) c.NewRequest(destroyContextRequest(c, Screen, Context), cookie) return DestroyContextCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook DestroyContextCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for DestroyContext +// destroyContextRequest writes a DestroyContext request to a byte slice. func destroyContextRequest(c *xgb.Conn, Screen uint32, Context uint32) []byte { size := 12 b := 0 @@ -677,34 +700,36 @@ func destroyContextRequest(c *xgb.Conn, Screen uint32, Context uint32) []byte { return buf } -// Request CreateDrawable -// size: 12 +// CreateDrawableCookie is a cookie used only for CreateDrawable requests. type CreateDrawableCookie struct { *xgb.Cookie } +// CreateDrawable sends a checked request. +// If an error occurs, it will be returned with the reply by calling CreateDrawableCookie.Reply() func CreateDrawable(c *xgb.Conn, Screen uint32, Drawable uint32) CreateDrawableCookie { cookie := c.NewCookie(true, true) c.NewRequest(createDrawableRequest(c, Screen, Drawable), cookie) return CreateDrawableCookie{cookie} } +// CreateDrawableUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreateDrawableUnchecked(c *xgb.Conn, Screen uint32, Drawable uint32) CreateDrawableCookie { cookie := c.NewCookie(false, true) c.NewRequest(createDrawableRequest(c, Screen, Drawable), cookie) return CreateDrawableCookie{cookie} } -// Request reply for CreateDrawable -// size: 12 +// CreateDrawableReply represents the data returned from a CreateDrawable request. type CreateDrawableReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes HwDrawableHandle uint32 } -// Waits and reads reply data from request CreateDrawable +// Reply blocks and returns the reply data for a CreateDrawable request. func (cook CreateDrawableCookie) Reply() (*CreateDrawableReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -716,7 +741,7 @@ func (cook CreateDrawableCookie) Reply() (*CreateDrawableReply, error) { return createDrawableReply(buf), nil } -// Read reply into structure from buffer for CreateDrawable +// createDrawableReply reads a byte slice into a CreateDrawableReply value. func createDrawableReply(buf []byte) *CreateDrawableReply { v := new(CreateDrawableReply) b := 1 // skip reply determinant @@ -736,6 +761,7 @@ func createDrawableReply(buf []byte) *CreateDrawableReply { } // Write request to wire for CreateDrawable +// createDrawableRequest writes a CreateDrawable request to a byte slice. func createDrawableRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte { size := 12 b := 0 @@ -759,30 +785,35 @@ func createDrawableRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte { return buf } -// Request DestroyDrawable -// size: 12 +// DestroyDrawableCookie is a cookie used only for DestroyDrawable requests. type DestroyDrawableCookie struct { *xgb.Cookie } -// Write request to wire for DestroyDrawable +// DestroyDrawable sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func DestroyDrawable(c *xgb.Conn, Screen uint32, Drawable uint32) DestroyDrawableCookie { cookie := c.NewCookie(false, false) c.NewRequest(destroyDrawableRequest(c, Screen, Drawable), cookie) return DestroyDrawableCookie{cookie} } +// DestroyDrawableChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroyDrawableCookie.Check() func DestroyDrawableChecked(c *xgb.Conn, Screen uint32, Drawable uint32) DestroyDrawableCookie { cookie := c.NewCookie(true, false) c.NewRequest(destroyDrawableRequest(c, Screen, Drawable), cookie) return DestroyDrawableCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook DestroyDrawableCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for DestroyDrawable +// destroyDrawableRequest writes a DestroyDrawable request to a byte slice. func destroyDrawableRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte { size := 12 b := 0 @@ -806,29 +837,31 @@ func destroyDrawableRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte return buf } -// Request GetDrawableInfo -// size: 12 +// GetDrawableInfoCookie is a cookie used only for GetDrawableInfo requests. type GetDrawableInfoCookie struct { *xgb.Cookie } +// GetDrawableInfo sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetDrawableInfoCookie.Reply() func GetDrawableInfo(c *xgb.Conn, Screen uint32, Drawable uint32) GetDrawableInfoCookie { cookie := c.NewCookie(true, true) c.NewRequest(getDrawableInfoRequest(c, Screen, Drawable), cookie) return GetDrawableInfoCookie{cookie} } +// GetDrawableInfoUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetDrawableInfoUnchecked(c *xgb.Conn, Screen uint32, Drawable uint32) GetDrawableInfoCookie { cookie := c.NewCookie(false, true) c.NewRequest(getDrawableInfoRequest(c, Screen, Drawable), cookie) return GetDrawableInfoCookie{cookie} } -// Request reply for GetDrawableInfo -// size: ((36 + xgb.Pad((int(NumClipRects) * 8))) + xgb.Pad((int(NumBackClipRects) * 8))) +// GetDrawableInfoReply represents the data returned from a GetDrawableInfo request. type GetDrawableInfoReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes DrawableTableIndex uint32 DrawableTableStamp uint32 @@ -844,7 +877,7 @@ type GetDrawableInfoReply struct { BackClipRects []DrmClipRect // size: xgb.Pad((int(NumBackClipRects) * 8)) } -// Waits and reads reply data from request GetDrawableInfo +// Reply blocks and returns the reply data for a GetDrawableInfo request. func (cook GetDrawableInfoCookie) Reply() (*GetDrawableInfoReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -856,7 +889,7 @@ func (cook GetDrawableInfoCookie) Reply() (*GetDrawableInfoReply, error) { return getDrawableInfoReply(buf), nil } -// Read reply into structure from buffer for GetDrawableInfo +// getDrawableInfoReply reads a byte slice into a GetDrawableInfoReply value. func getDrawableInfoReply(buf []byte) *GetDrawableInfoReply { v := new(GetDrawableInfoReply) b := 1 // skip reply determinant @@ -909,6 +942,7 @@ func getDrawableInfoReply(buf []byte) *GetDrawableInfoReply { } // Write request to wire for GetDrawableInfo +// getDrawableInfoRequest writes a GetDrawableInfo request to a byte slice. func getDrawableInfoRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte { size := 12 b := 0 @@ -932,29 +966,31 @@ func getDrawableInfoRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte return buf } -// Request GetDeviceInfo -// size: 8 +// GetDeviceInfoCookie is a cookie used only for GetDeviceInfo requests. type GetDeviceInfoCookie struct { *xgb.Cookie } +// GetDeviceInfo sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetDeviceInfoCookie.Reply() func GetDeviceInfo(c *xgb.Conn, Screen uint32) GetDeviceInfoCookie { cookie := c.NewCookie(true, true) c.NewRequest(getDeviceInfoRequest(c, Screen), cookie) return GetDeviceInfoCookie{cookie} } +// GetDeviceInfoUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetDeviceInfoUnchecked(c *xgb.Conn, Screen uint32) GetDeviceInfoCookie { cookie := c.NewCookie(false, true) c.NewRequest(getDeviceInfoRequest(c, Screen), cookie) return GetDeviceInfoCookie{cookie} } -// Request reply for GetDeviceInfo -// size: (32 + xgb.Pad((int(DevicePrivateSize) * 4))) +// GetDeviceInfoReply represents the data returned from a GetDeviceInfo request. type GetDeviceInfoReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes FramebufferHandleLow uint32 FramebufferHandleHigh uint32 @@ -965,7 +1001,7 @@ type GetDeviceInfoReply struct { DevicePrivate []uint32 // size: xgb.Pad((int(DevicePrivateSize) * 4)) } -// Waits and reads reply data from request GetDeviceInfo +// Reply blocks and returns the reply data for a GetDeviceInfo request. func (cook GetDeviceInfoCookie) Reply() (*GetDeviceInfoReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -977,7 +1013,7 @@ func (cook GetDeviceInfoCookie) Reply() (*GetDeviceInfoReply, error) { return getDeviceInfoReply(buf), nil } -// Read reply into structure from buffer for GetDeviceInfo +// getDeviceInfoReply reads a byte slice into a GetDeviceInfoReply value. func getDeviceInfoReply(buf []byte) *GetDeviceInfoReply { v := new(GetDeviceInfoReply) b := 1 // skip reply determinant @@ -1019,6 +1055,7 @@ func getDeviceInfoReply(buf []byte) *GetDeviceInfoReply { } // Write request to wire for GetDeviceInfo +// getDeviceInfoRequest writes a GetDeviceInfo request to a byte slice. func getDeviceInfoRequest(c *xgb.Conn, Screen uint32) []byte { size := 8 b := 0 @@ -1039,34 +1076,36 @@ func getDeviceInfoRequest(c *xgb.Conn, Screen uint32) []byte { return buf } -// Request AuthConnection -// size: 12 +// AuthConnectionCookie is a cookie used only for AuthConnection requests. type AuthConnectionCookie struct { *xgb.Cookie } +// AuthConnection sends a checked request. +// If an error occurs, it will be returned with the reply by calling AuthConnectionCookie.Reply() func AuthConnection(c *xgb.Conn, Screen uint32, Magic uint32) AuthConnectionCookie { cookie := c.NewCookie(true, true) c.NewRequest(authConnectionRequest(c, Screen, Magic), cookie) return AuthConnectionCookie{cookie} } +// AuthConnectionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func AuthConnectionUnchecked(c *xgb.Conn, Screen uint32, Magic uint32) AuthConnectionCookie { cookie := c.NewCookie(false, true) c.NewRequest(authConnectionRequest(c, Screen, Magic), cookie) return AuthConnectionCookie{cookie} } -// Request reply for AuthConnection -// size: 12 +// AuthConnectionReply represents the data returned from a AuthConnection request. type AuthConnectionReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Authenticated uint32 } -// Waits and reads reply data from request AuthConnection +// Reply blocks and returns the reply data for a AuthConnection request. func (cook AuthConnectionCookie) Reply() (*AuthConnectionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1078,7 +1117,7 @@ func (cook AuthConnectionCookie) Reply() (*AuthConnectionReply, error) { return authConnectionReply(buf), nil } -// Read reply into structure from buffer for AuthConnection +// authConnectionReply reads a byte slice into a AuthConnectionReply value. func authConnectionReply(buf []byte) *AuthConnectionReply { v := new(AuthConnectionReply) b := 1 // skip reply determinant @@ -1098,6 +1137,7 @@ func authConnectionReply(buf []byte) *AuthConnectionReply { } // Write request to wire for AuthConnection +// authConnectionRequest writes a AuthConnection request to a byte slice. func authConnectionRequest(c *xgb.Conn, Screen uint32, Magic uint32) []byte { size := 12 b := 0 diff --git a/nexgb/xf86vidmode/xf86vidmode.go b/nexgb/xf86vidmode/xf86vidmode.go index d32f601..15daeb2 100644 --- a/nexgb/xf86vidmode/xf86vidmode.go +++ b/nexgb/xf86vidmode/xf86vidmode.go @@ -2,7 +2,7 @@ package xf86vidmode /* - This file was generated by xf86vidmode.xml on May 10 2012 8:04:32pm EDT. + This file was generated by xf86vidmode.xml on May 10 2012 11:56:19pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,18 +40,6 @@ func init() { xgb.NewExtErrorFuncs["XFree86-VidModeExtension"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - -// Skipping definition for base type 'Int8' - // Skipping definition for base type 'Card16' // Skipping definition for base type 'Char' @@ -64,6 +52,18 @@ func init() { // Skipping definition for base type 'Float' +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + +// Skipping definition for base type 'Int8' + const ( ModeFlagPositiveHsync = 1 ModeFlagNegativeHsync = 2 @@ -93,8 +93,6 @@ type Syncrange uint32 type Dotclock uint32 -// 'ModeInfo' struct definition -// Size: 48 type ModeInfo struct { Dotclock Dotclock Hdisplay uint16 @@ -112,7 +110,7 @@ type ModeInfo struct { Privsize uint32 } -// Struct read ModeInfo +// ModeInfoRead reads a byte slice into a ModeInfo value. func ModeInfoRead(buf []byte, v *ModeInfo) int { b := 0 @@ -159,7 +157,7 @@ func ModeInfoRead(buf []byte, v *ModeInfo) int { return b } -// Struct list read ModeInfo +// ModeInfoReadList reads a byte slice into a list of ModeInfo values. func ModeInfoReadList(buf []byte, dest []ModeInfo) int { b := 0 for i := 0; i < len(dest); i++ { @@ -169,7 +167,7 @@ func ModeInfoReadList(buf []byte, dest []ModeInfo) int { return xgb.Pad(b) } -// Struct write ModeInfo +// Bytes writes a ModeInfo value to a byte slice. func (v ModeInfo) Bytes() []byte { buf := make([]byte, 48) b := 0 @@ -217,7 +215,7 @@ func (v ModeInfo) Bytes() []byte { return buf } -// Write struct list ModeInfo +// ModeInfoListBytes writes a list of %s(MISSING) values to a byte slice. func ModeInfoListBytes(buf []byte, list []ModeInfo) int { b := 0 var structBytes []byte @@ -229,9 +227,7 @@ func ModeInfoListBytes(buf []byte, list []ModeInfo) int { return b } -// Error definition BadClock (0) -// Size: 32 - +// BadBadClock is the error number for a BadBadClock. const BadBadClock = 0 type BadClockError struct { @@ -239,7 +235,7 @@ type BadClockError struct { NiceName string } -// Error read BadClock +// BadClockErrorNew constructs a BadClockError value that implements xgb.Error from a byte slice. func BadClockErrorNew(buf []byte) xgb.Error { v := BadClockError{} v.NiceName = "BadClock" @@ -253,8 +249,8 @@ func BadClockErrorNew(buf []byte) xgb.Error { return v } -func (err BadClockError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadBadClock error. +// This is mostly used internally. func (err BadClockError) SequenceId() uint16 { return err.Sequence } @@ -274,9 +270,7 @@ func init() { xgb.NewExtErrorFuncs["XFree86-VidModeExtension"][0] = BadClockErrorNew } -// Error definition BadHTimings (1) -// Size: 32 - +// BadBadHTimings is the error number for a BadBadHTimings. const BadBadHTimings = 1 type BadHTimingsError struct { @@ -284,7 +278,7 @@ type BadHTimingsError struct { NiceName string } -// Error read BadHTimings +// BadHTimingsErrorNew constructs a BadHTimingsError value that implements xgb.Error from a byte slice. func BadHTimingsErrorNew(buf []byte) xgb.Error { v := BadHTimingsError{} v.NiceName = "BadHTimings" @@ -298,8 +292,8 @@ func BadHTimingsErrorNew(buf []byte) xgb.Error { return v } -func (err BadHTimingsError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadBadHTimings error. +// This is mostly used internally. func (err BadHTimingsError) SequenceId() uint16 { return err.Sequence } @@ -319,9 +313,7 @@ func init() { xgb.NewExtErrorFuncs["XFree86-VidModeExtension"][1] = BadHTimingsErrorNew } -// Error definition BadVTimings (2) -// Size: 32 - +// BadBadVTimings is the error number for a BadBadVTimings. const BadBadVTimings = 2 type BadVTimingsError struct { @@ -329,7 +321,7 @@ type BadVTimingsError struct { NiceName string } -// Error read BadVTimings +// BadVTimingsErrorNew constructs a BadVTimingsError value that implements xgb.Error from a byte slice. func BadVTimingsErrorNew(buf []byte) xgb.Error { v := BadVTimingsError{} v.NiceName = "BadVTimings" @@ -343,8 +335,8 @@ func BadVTimingsErrorNew(buf []byte) xgb.Error { return v } -func (err BadVTimingsError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadBadVTimings error. +// This is mostly used internally. func (err BadVTimingsError) SequenceId() uint16 { return err.Sequence } @@ -364,9 +356,7 @@ func init() { xgb.NewExtErrorFuncs["XFree86-VidModeExtension"][2] = BadVTimingsErrorNew } -// Error definition ModeUnsuitable (3) -// Size: 32 - +// BadModeUnsuitable is the error number for a BadModeUnsuitable. const BadModeUnsuitable = 3 type ModeUnsuitableError struct { @@ -374,7 +364,7 @@ type ModeUnsuitableError struct { NiceName string } -// Error read ModeUnsuitable +// ModeUnsuitableErrorNew constructs a ModeUnsuitableError value that implements xgb.Error from a byte slice. func ModeUnsuitableErrorNew(buf []byte) xgb.Error { v := ModeUnsuitableError{} v.NiceName = "ModeUnsuitable" @@ -388,8 +378,8 @@ func ModeUnsuitableErrorNew(buf []byte) xgb.Error { return v } -func (err ModeUnsuitableError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadModeUnsuitable error. +// This is mostly used internally. func (err ModeUnsuitableError) SequenceId() uint16 { return err.Sequence } @@ -409,9 +399,7 @@ func init() { xgb.NewExtErrorFuncs["XFree86-VidModeExtension"][3] = ModeUnsuitableErrorNew } -// Error definition ExtensionDisabled (4) -// Size: 32 - +// BadExtensionDisabled is the error number for a BadExtensionDisabled. const BadExtensionDisabled = 4 type ExtensionDisabledError struct { @@ -419,7 +407,7 @@ type ExtensionDisabledError struct { NiceName string } -// Error read ExtensionDisabled +// ExtensionDisabledErrorNew constructs a ExtensionDisabledError value that implements xgb.Error from a byte slice. func ExtensionDisabledErrorNew(buf []byte) xgb.Error { v := ExtensionDisabledError{} v.NiceName = "ExtensionDisabled" @@ -433,8 +421,8 @@ func ExtensionDisabledErrorNew(buf []byte) xgb.Error { return v } -func (err ExtensionDisabledError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadExtensionDisabled error. +// This is mostly used internally. func (err ExtensionDisabledError) SequenceId() uint16 { return err.Sequence } @@ -454,9 +442,7 @@ func init() { xgb.NewExtErrorFuncs["XFree86-VidModeExtension"][4] = ExtensionDisabledErrorNew } -// Error definition ClientNotLocal (5) -// Size: 32 - +// BadClientNotLocal is the error number for a BadClientNotLocal. const BadClientNotLocal = 5 type ClientNotLocalError struct { @@ -464,7 +450,7 @@ type ClientNotLocalError struct { NiceName string } -// Error read ClientNotLocal +// ClientNotLocalErrorNew constructs a ClientNotLocalError value that implements xgb.Error from a byte slice. func ClientNotLocalErrorNew(buf []byte) xgb.Error { v := ClientNotLocalError{} v.NiceName = "ClientNotLocal" @@ -478,8 +464,8 @@ func ClientNotLocalErrorNew(buf []byte) xgb.Error { return v } -func (err ClientNotLocalError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadClientNotLocal error. +// This is mostly used internally. func (err ClientNotLocalError) SequenceId() uint16 { return err.Sequence } @@ -499,9 +485,7 @@ func init() { xgb.NewExtErrorFuncs["XFree86-VidModeExtension"][5] = ClientNotLocalErrorNew } -// Error definition ZoomLocked (6) -// Size: 32 - +// BadZoomLocked is the error number for a BadZoomLocked. const BadZoomLocked = 6 type ZoomLockedError struct { @@ -509,7 +493,7 @@ type ZoomLockedError struct { NiceName string } -// Error read ZoomLocked +// ZoomLockedErrorNew constructs a ZoomLockedError value that implements xgb.Error from a byte slice. func ZoomLockedErrorNew(buf []byte) xgb.Error { v := ZoomLockedError{} v.NiceName = "ZoomLocked" @@ -523,8 +507,8 @@ func ZoomLockedErrorNew(buf []byte) xgb.Error { return v } -func (err ZoomLockedError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadZoomLocked error. +// This is mostly used internally. func (err ZoomLockedError) SequenceId() uint16 { return err.Sequence } @@ -544,35 +528,37 @@ func init() { xgb.NewExtErrorFuncs["XFree86-VidModeExtension"][6] = ZoomLockedErrorNew } -// Request QueryVersion -// size: 4 +// QueryVersionCookie is a cookie used only for QueryVersion requests. type QueryVersionCookie struct { *xgb.Cookie } +// QueryVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() func QueryVersion(c *xgb.Conn) QueryVersionCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryVersionRequest(c), cookie) return QueryVersionCookie{cookie} } +// QueryVersionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryVersionUnchecked(c *xgb.Conn) QueryVersionCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryVersionRequest(c), cookie) return QueryVersionCookie{cookie} } -// Request reply for QueryVersion -// size: 12 +// QueryVersionReply represents the data returned from a QueryVersion request. type QueryVersionReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes MajorVersion uint16 MinorVersion uint16 } -// Waits and reads reply data from request QueryVersion +// Reply blocks and returns the reply data for a QueryVersion request. func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -584,7 +570,7 @@ func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { return queryVersionReply(buf), nil } -// Read reply into structure from buffer for QueryVersion +// queryVersionReply reads a byte slice into a QueryVersionReply value. func queryVersionReply(buf []byte) *QueryVersionReply { v := new(QueryVersionReply) b := 1 // skip reply determinant @@ -607,6 +593,7 @@ func queryVersionReply(buf []byte) *QueryVersionReply { } // Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. func queryVersionRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -624,29 +611,31 @@ func queryVersionRequest(c *xgb.Conn) []byte { return buf } -// Request GetModeLine -// size: 8 +// GetModeLineCookie is a cookie used only for GetModeLine requests. type GetModeLineCookie struct { *xgb.Cookie } +// GetModeLine sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetModeLineCookie.Reply() func GetModeLine(c *xgb.Conn, Screen uint16) GetModeLineCookie { cookie := c.NewCookie(true, true) c.NewRequest(getModeLineRequest(c, Screen), cookie) return GetModeLineCookie{cookie} } +// GetModeLineUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetModeLineUnchecked(c *xgb.Conn, Screen uint16) GetModeLineCookie { cookie := c.NewCookie(false, true) c.NewRequest(getModeLineRequest(c, Screen), cookie) return GetModeLineCookie{cookie} } -// Request reply for GetModeLine -// size: (52 + xgb.Pad((int(Privsize) * 1))) +// GetModeLineReply represents the data returned from a GetModeLine request. type GetModeLineReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Dotclock Dotclock Hdisplay uint16 @@ -665,7 +654,7 @@ type GetModeLineReply struct { Private []byte // size: xgb.Pad((int(Privsize) * 1)) } -// Waits and reads reply data from request GetModeLine +// Reply blocks and returns the reply data for a GetModeLine request. func (cook GetModeLineCookie) Reply() (*GetModeLineReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -677,7 +666,7 @@ func (cook GetModeLineCookie) Reply() (*GetModeLineReply, error) { return getModeLineReply(buf), nil } -// Read reply into structure from buffer for GetModeLine +// getModeLineReply reads a byte slice into a GetModeLineReply value. func getModeLineReply(buf []byte) *GetModeLineReply { v := new(GetModeLineReply) b := 1 // skip reply determinant @@ -738,6 +727,7 @@ func getModeLineReply(buf []byte) *GetModeLineReply { } // Write request to wire for GetModeLine +// getModeLineRequest writes a GetModeLine request to a byte slice. func getModeLineRequest(c *xgb.Conn, Screen uint16) []byte { size := 8 b := 0 @@ -760,30 +750,35 @@ func getModeLineRequest(c *xgb.Conn, Screen uint16) []byte { return buf } -// Request ModModeLine -// size: xgb.Pad((48 + xgb.Pad((int(Privsize) * 1)))) +// ModModeLineCookie is a cookie used only for ModModeLine requests. type ModModeLineCookie struct { *xgb.Cookie } -// Write request to wire for ModModeLine +// ModModeLine sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ModModeLine(c *xgb.Conn, Screen uint32, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) ModModeLineCookie { cookie := c.NewCookie(false, false) c.NewRequest(modModeLineRequest(c, Screen, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) return ModModeLineCookie{cookie} } +// ModModeLineChecked sends a checked request. +// If an error occurs, it can be retrieved using ModModeLineCookie.Check() func ModModeLineChecked(c *xgb.Conn, Screen uint32, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) ModModeLineCookie { cookie := c.NewCookie(true, false) c.NewRequest(modModeLineRequest(c, Screen, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) return ModModeLineCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook ModModeLineCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ModModeLine +// modModeLineRequest writes a ModModeLine request to a byte slice. func modModeLineRequest(c *xgb.Conn, Screen uint32, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) []byte { size := xgb.Pad((48 + xgb.Pad((int(Privsize) * 1)))) b := 0 @@ -844,30 +839,35 @@ func modModeLineRequest(c *xgb.Conn, Screen uint32, Hdisplay uint16, Hsyncstart return buf } -// Request SwitchMode -// size: 8 +// SwitchModeCookie is a cookie used only for SwitchMode requests. type SwitchModeCookie struct { *xgb.Cookie } -// Write request to wire for SwitchMode +// SwitchMode sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SwitchMode(c *xgb.Conn, Screen uint16, Zoom uint16) SwitchModeCookie { cookie := c.NewCookie(false, false) c.NewRequest(switchModeRequest(c, Screen, Zoom), cookie) return SwitchModeCookie{cookie} } +// SwitchModeChecked sends a checked request. +// If an error occurs, it can be retrieved using SwitchModeCookie.Check() func SwitchModeChecked(c *xgb.Conn, Screen uint16, Zoom uint16) SwitchModeCookie { cookie := c.NewCookie(true, false) c.NewRequest(switchModeRequest(c, Screen, Zoom), cookie) return SwitchModeCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SwitchModeCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SwitchMode +// switchModeRequest writes a SwitchMode request to a byte slice. func switchModeRequest(c *xgb.Conn, Screen uint16, Zoom uint16) []byte { size := 8 b := 0 @@ -891,29 +891,31 @@ func switchModeRequest(c *xgb.Conn, Screen uint16, Zoom uint16) []byte { return buf } -// Request GetMonitor -// size: 8 +// GetMonitorCookie is a cookie used only for GetMonitor requests. type GetMonitorCookie struct { *xgb.Cookie } +// GetMonitor sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetMonitorCookie.Reply() func GetMonitor(c *xgb.Conn, Screen uint16) GetMonitorCookie { cookie := c.NewCookie(true, true) c.NewRequest(getMonitorRequest(c, Screen), cookie) return GetMonitorCookie{cookie} } +// GetMonitorUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetMonitorUnchecked(c *xgb.Conn, Screen uint16) GetMonitorCookie { cookie := c.NewCookie(false, true) c.NewRequest(getMonitorRequest(c, Screen), cookie) return GetMonitorCookie{cookie} } -// Request reply for GetMonitor -// size: (((((32 + xgb.Pad((int(NumHsync) * 4))) + xgb.Pad((int(NumVsync) * 4))) + xgb.Pad((int(VendorLength) * 1))) + xgb.Pad(((((int(VendorLength) + 3) & -4) - int(VendorLength)) * 1))) + xgb.Pad((int(ModelLength) * 1))) +// GetMonitorReply represents the data returned from a GetMonitor request. type GetMonitorReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes VendorLength byte ModelLength byte @@ -927,7 +929,7 @@ type GetMonitorReply struct { Model string // size: xgb.Pad((int(ModelLength) * 1)) } -// Waits and reads reply data from request GetMonitor +// Reply blocks and returns the reply data for a GetMonitor request. func (cook GetMonitorCookie) Reply() (*GetMonitorReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -939,7 +941,7 @@ func (cook GetMonitorCookie) Reply() (*GetMonitorReply, error) { return getMonitorReply(buf), nil } -// Read reply into structure from buffer for GetMonitor +// getMonitorReply reads a byte slice into a GetMonitorReply value. func getMonitorReply(buf []byte) *GetMonitorReply { v := new(GetMonitorReply) b := 1 // skip reply determinant @@ -1002,6 +1004,7 @@ func getMonitorReply(buf []byte) *GetMonitorReply { } // Write request to wire for GetMonitor +// getMonitorRequest writes a GetMonitor request to a byte slice. func getMonitorRequest(c *xgb.Conn, Screen uint16) []byte { size := 8 b := 0 @@ -1024,30 +1027,35 @@ func getMonitorRequest(c *xgb.Conn, Screen uint16) []byte { return buf } -// Request LockModeSwitch -// size: 8 +// LockModeSwitchCookie is a cookie used only for LockModeSwitch requests. type LockModeSwitchCookie struct { *xgb.Cookie } -// Write request to wire for LockModeSwitch +// LockModeSwitch sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func LockModeSwitch(c *xgb.Conn, Screen uint16, Lock uint16) LockModeSwitchCookie { cookie := c.NewCookie(false, false) c.NewRequest(lockModeSwitchRequest(c, Screen, Lock), cookie) return LockModeSwitchCookie{cookie} } +// LockModeSwitchChecked sends a checked request. +// If an error occurs, it can be retrieved using LockModeSwitchCookie.Check() func LockModeSwitchChecked(c *xgb.Conn, Screen uint16, Lock uint16) LockModeSwitchCookie { cookie := c.NewCookie(true, false) c.NewRequest(lockModeSwitchRequest(c, Screen, Lock), cookie) return LockModeSwitchCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook LockModeSwitchCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for LockModeSwitch +// lockModeSwitchRequest writes a LockModeSwitch request to a byte slice. func lockModeSwitchRequest(c *xgb.Conn, Screen uint16, Lock uint16) []byte { size := 8 b := 0 @@ -1071,36 +1079,38 @@ func lockModeSwitchRequest(c *xgb.Conn, Screen uint16, Lock uint16) []byte { return buf } -// Request GetAllModeLines -// size: 8 +// GetAllModeLinesCookie is a cookie used only for GetAllModeLines requests. type GetAllModeLinesCookie struct { *xgb.Cookie } +// GetAllModeLines sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetAllModeLinesCookie.Reply() func GetAllModeLines(c *xgb.Conn, Screen uint16) GetAllModeLinesCookie { cookie := c.NewCookie(true, true) c.NewRequest(getAllModeLinesRequest(c, Screen), cookie) return GetAllModeLinesCookie{cookie} } +// GetAllModeLinesUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetAllModeLinesUnchecked(c *xgb.Conn, Screen uint16) GetAllModeLinesCookie { cookie := c.NewCookie(false, true) c.NewRequest(getAllModeLinesRequest(c, Screen), cookie) return GetAllModeLinesCookie{cookie} } -// Request reply for GetAllModeLines -// size: (32 + xgb.Pad((int(Modecount) * 48))) +// GetAllModeLinesReply represents the data returned from a GetAllModeLines request. type GetAllModeLinesReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Modecount uint32 // padding: 20 bytes Modeinfo []ModeInfo // size: xgb.Pad((int(Modecount) * 48)) } -// Waits and reads reply data from request GetAllModeLines +// Reply blocks and returns the reply data for a GetAllModeLines request. func (cook GetAllModeLinesCookie) Reply() (*GetAllModeLinesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1112,7 +1122,7 @@ func (cook GetAllModeLinesCookie) Reply() (*GetAllModeLinesReply, error) { return getAllModeLinesReply(buf), nil } -// Read reply into structure from buffer for GetAllModeLines +// getAllModeLinesReply reads a byte slice into a GetAllModeLinesReply value. func getAllModeLinesReply(buf []byte) *GetAllModeLinesReply { v := new(GetAllModeLinesReply) b := 1 // skip reply determinant @@ -1137,6 +1147,7 @@ func getAllModeLinesReply(buf []byte) *GetAllModeLinesReply { } // Write request to wire for GetAllModeLines +// getAllModeLinesRequest writes a GetAllModeLines request to a byte slice. func getAllModeLinesRequest(c *xgb.Conn, Screen uint16) []byte { size := 8 b := 0 @@ -1159,30 +1170,35 @@ func getAllModeLinesRequest(c *xgb.Conn, Screen uint16) []byte { return buf } -// Request AddModeLine -// size: xgb.Pad((92 + xgb.Pad((int(Privsize) * 1)))) +// AddModeLineCookie is a cookie used only for AddModeLine requests. type AddModeLineCookie struct { *xgb.Cookie } -// Write request to wire for AddModeLine +// AddModeLine sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func AddModeLine(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, AfterDotclock Dotclock, AfterHdisplay uint16, AfterHsyncstart uint16, AfterHsyncend uint16, AfterHtotal uint16, AfterHskew uint16, AfterVdisplay uint16, AfterVsyncstart uint16, AfterVsyncend uint16, AfterVtotal uint16, AfterFlags uint32, Private []byte) AddModeLineCookie { cookie := c.NewCookie(false, false) c.NewRequest(addModeLineRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, AfterDotclock, AfterHdisplay, AfterHsyncstart, AfterHsyncend, AfterHtotal, AfterHskew, AfterVdisplay, AfterVsyncstart, AfterVsyncend, AfterVtotal, AfterFlags, Private), cookie) return AddModeLineCookie{cookie} } +// AddModeLineChecked sends a checked request. +// If an error occurs, it can be retrieved using AddModeLineCookie.Check() func AddModeLineChecked(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, AfterDotclock Dotclock, AfterHdisplay uint16, AfterHsyncstart uint16, AfterHsyncend uint16, AfterHtotal uint16, AfterHskew uint16, AfterVdisplay uint16, AfterVsyncstart uint16, AfterVsyncend uint16, AfterVtotal uint16, AfterFlags uint32, Private []byte) AddModeLineCookie { cookie := c.NewCookie(true, false) c.NewRequest(addModeLineRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, AfterDotclock, AfterHdisplay, AfterHsyncstart, AfterHsyncend, AfterHtotal, AfterHskew, AfterVdisplay, AfterVsyncstart, AfterVsyncend, AfterVtotal, AfterFlags, Private), cookie) return AddModeLineCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook AddModeLineCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for AddModeLine +// addModeLineRequest writes a AddModeLine request to a byte slice. func addModeLineRequest(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, AfterDotclock Dotclock, AfterHdisplay uint16, AfterHsyncstart uint16, AfterHsyncend uint16, AfterHtotal uint16, AfterHskew uint16, AfterVdisplay uint16, AfterVsyncstart uint16, AfterVsyncend uint16, AfterVtotal uint16, AfterFlags uint32, Private []byte) []byte { size := xgb.Pad((92 + xgb.Pad((int(Privsize) * 1)))) b := 0 @@ -1283,30 +1299,35 @@ func addModeLineRequest(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay return buf } -// Request DeleteModeLine -// size: xgb.Pad((52 + xgb.Pad((int(Privsize) * 1)))) +// DeleteModeLineCookie is a cookie used only for DeleteModeLine requests. type DeleteModeLineCookie struct { *xgb.Cookie } -// Write request to wire for DeleteModeLine +// DeleteModeLine sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func DeleteModeLine(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) DeleteModeLineCookie { cookie := c.NewCookie(false, false) c.NewRequest(deleteModeLineRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) return DeleteModeLineCookie{cookie} } +// DeleteModeLineChecked sends a checked request. +// If an error occurs, it can be retrieved using DeleteModeLineCookie.Check() func DeleteModeLineChecked(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) DeleteModeLineCookie { cookie := c.NewCookie(true, false) c.NewRequest(deleteModeLineRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) return DeleteModeLineCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook DeleteModeLineCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for DeleteModeLine +// deleteModeLineRequest writes a DeleteModeLine request to a byte slice. func deleteModeLineRequest(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) []byte { size := xgb.Pad((52 + xgb.Pad((int(Privsize) * 1)))) b := 0 @@ -1370,35 +1391,37 @@ func deleteModeLineRequest(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdispl return buf } -// Request ValidateModeLine -// size: xgb.Pad((52 + xgb.Pad((int(Privsize) * 1)))) +// ValidateModeLineCookie is a cookie used only for ValidateModeLine requests. type ValidateModeLineCookie struct { *xgb.Cookie } +// ValidateModeLine sends a checked request. +// If an error occurs, it will be returned with the reply by calling ValidateModeLineCookie.Reply() func ValidateModeLine(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) ValidateModeLineCookie { cookie := c.NewCookie(true, true) c.NewRequest(validateModeLineRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) return ValidateModeLineCookie{cookie} } +// ValidateModeLineUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ValidateModeLineUnchecked(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) ValidateModeLineCookie { cookie := c.NewCookie(false, true) c.NewRequest(validateModeLineRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) return ValidateModeLineCookie{cookie} } -// Request reply for ValidateModeLine -// size: 32 +// ValidateModeLineReply represents the data returned from a ValidateModeLine request. type ValidateModeLineReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Status uint32 // padding: 20 bytes } -// Waits and reads reply data from request ValidateModeLine +// Reply blocks and returns the reply data for a ValidateModeLine request. func (cook ValidateModeLineCookie) Reply() (*ValidateModeLineReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1410,7 +1433,7 @@ func (cook ValidateModeLineCookie) Reply() (*ValidateModeLineReply, error) { return validateModeLineReply(buf), nil } -// Read reply into structure from buffer for ValidateModeLine +// validateModeLineReply reads a byte slice into a ValidateModeLineReply value. func validateModeLineReply(buf []byte) *ValidateModeLineReply { v := new(ValidateModeLineReply) b := 1 // skip reply determinant @@ -1432,6 +1455,7 @@ func validateModeLineReply(buf []byte) *ValidateModeLineReply { } // Write request to wire for ValidateModeLine +// validateModeLineRequest writes a ValidateModeLine request to a byte slice. func validateModeLineRequest(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) []byte { size := xgb.Pad((52 + xgb.Pad((int(Privsize) * 1)))) b := 0 @@ -1495,30 +1519,35 @@ func validateModeLineRequest(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdis return buf } -// Request SwitchToMode -// size: xgb.Pad((52 + xgb.Pad((int(Privsize) * 1)))) +// SwitchToModeCookie is a cookie used only for SwitchToMode requests. type SwitchToModeCookie struct { *xgb.Cookie } -// Write request to wire for SwitchToMode +// SwitchToMode sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SwitchToMode(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) SwitchToModeCookie { cookie := c.NewCookie(false, false) c.NewRequest(switchToModeRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) return SwitchToModeCookie{cookie} } +// SwitchToModeChecked sends a checked request. +// If an error occurs, it can be retrieved using SwitchToModeCookie.Check() func SwitchToModeChecked(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) SwitchToModeCookie { cookie := c.NewCookie(true, false) c.NewRequest(switchToModeRequest(c, Screen, Dotclock, Hdisplay, Hsyncstart, Hsyncend, Htotal, Hskew, Vdisplay, Vsyncstart, Vsyncend, Vtotal, Flags, Privsize, Private), cookie) return SwitchToModeCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SwitchToModeCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SwitchToMode +// switchToModeRequest writes a SwitchToMode request to a byte slice. func switchToModeRequest(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay uint16, Hsyncstart uint16, Hsyncend uint16, Htotal uint16, Hskew uint16, Vdisplay uint16, Vsyncstart uint16, Vsyncend uint16, Vtotal uint16, Flags uint32, Privsize uint32, Private []byte) []byte { size := xgb.Pad((52 + xgb.Pad((int(Privsize) * 1)))) b := 0 @@ -1582,36 +1611,38 @@ func switchToModeRequest(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay return buf } -// Request GetViewPort -// size: 8 +// GetViewPortCookie is a cookie used only for GetViewPort requests. type GetViewPortCookie struct { *xgb.Cookie } +// GetViewPort sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetViewPortCookie.Reply() func GetViewPort(c *xgb.Conn, Screen uint16) GetViewPortCookie { cookie := c.NewCookie(true, true) c.NewRequest(getViewPortRequest(c, Screen), cookie) return GetViewPortCookie{cookie} } +// GetViewPortUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetViewPortUnchecked(c *xgb.Conn, Screen uint16) GetViewPortCookie { cookie := c.NewCookie(false, true) c.NewRequest(getViewPortRequest(c, Screen), cookie) return GetViewPortCookie{cookie} } -// Request reply for GetViewPort -// size: 32 +// GetViewPortReply represents the data returned from a GetViewPort request. type GetViewPortReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes X uint32 Y uint32 // padding: 16 bytes } -// Waits and reads reply data from request GetViewPort +// Reply blocks and returns the reply data for a GetViewPort request. func (cook GetViewPortCookie) Reply() (*GetViewPortReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1623,7 +1654,7 @@ func (cook GetViewPortCookie) Reply() (*GetViewPortReply, error) { return getViewPortReply(buf), nil } -// Read reply into structure from buffer for GetViewPort +// getViewPortReply reads a byte slice into a GetViewPortReply value. func getViewPortReply(buf []byte) *GetViewPortReply { v := new(GetViewPortReply) b := 1 // skip reply determinant @@ -1648,6 +1679,7 @@ func getViewPortReply(buf []byte) *GetViewPortReply { } // Write request to wire for GetViewPort +// getViewPortRequest writes a GetViewPort request to a byte slice. func getViewPortRequest(c *xgb.Conn, Screen uint16) []byte { size := 8 b := 0 @@ -1670,30 +1702,35 @@ func getViewPortRequest(c *xgb.Conn, Screen uint16) []byte { return buf } -// Request SetViewPort -// size: 16 +// SetViewPortCookie is a cookie used only for SetViewPort requests. type SetViewPortCookie struct { *xgb.Cookie } -// Write request to wire for SetViewPort +// SetViewPort sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetViewPort(c *xgb.Conn, Screen uint16, X uint32, Y uint32) SetViewPortCookie { cookie := c.NewCookie(false, false) c.NewRequest(setViewPortRequest(c, Screen, X, Y), cookie) return SetViewPortCookie{cookie} } +// SetViewPortChecked sends a checked request. +// If an error occurs, it can be retrieved using SetViewPortCookie.Check() func SetViewPortChecked(c *xgb.Conn, Screen uint16, X uint32, Y uint32) SetViewPortCookie { cookie := c.NewCookie(true, false) c.NewRequest(setViewPortRequest(c, Screen, X, Y), cookie) return SetViewPortCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetViewPortCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetViewPort +// setViewPortRequest writes a SetViewPort request to a byte slice. func setViewPortRequest(c *xgb.Conn, Screen uint16, X uint32, Y uint32) []byte { size := 16 b := 0 @@ -1722,29 +1759,31 @@ func setViewPortRequest(c *xgb.Conn, Screen uint16, X uint32, Y uint32) []byte { return buf } -// Request GetDotClocks -// size: 8 +// GetDotClocksCookie is a cookie used only for GetDotClocks requests. type GetDotClocksCookie struct { *xgb.Cookie } +// GetDotClocks sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetDotClocksCookie.Reply() func GetDotClocks(c *xgb.Conn, Screen uint16) GetDotClocksCookie { cookie := c.NewCookie(true, true) c.NewRequest(getDotClocksRequest(c, Screen), cookie) return GetDotClocksCookie{cookie} } +// GetDotClocksUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetDotClocksUnchecked(c *xgb.Conn, Screen uint16) GetDotClocksCookie { cookie := c.NewCookie(false, true) c.NewRequest(getDotClocksRequest(c, Screen), cookie) return GetDotClocksCookie{cookie} } -// Request reply for GetDotClocks -// size: (32 + xgb.Pad((((1 - (int(Flags) & 1)) * int(Clocks)) * 4))) +// GetDotClocksReply represents the data returned from a GetDotClocks request. type GetDotClocksReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Flags uint32 Clocks uint32 @@ -1753,7 +1792,7 @@ type GetDotClocksReply struct { Clock []uint32 // size: xgb.Pad((((1 - (int(Flags) & 1)) * int(Clocks)) * 4)) } -// Waits and reads reply data from request GetDotClocks +// Reply blocks and returns the reply data for a GetDotClocks request. func (cook GetDotClocksCookie) Reply() (*GetDotClocksReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1765,7 +1804,7 @@ func (cook GetDotClocksCookie) Reply() (*GetDotClocksReply, error) { return getDotClocksReply(buf), nil } -// Read reply into structure from buffer for GetDotClocks +// getDotClocksReply reads a byte slice into a GetDotClocksReply value. func getDotClocksReply(buf []byte) *GetDotClocksReply { v := new(GetDotClocksReply) b := 1 // skip reply determinant @@ -1800,6 +1839,7 @@ func getDotClocksReply(buf []byte) *GetDotClocksReply { } // Write request to wire for GetDotClocks +// getDotClocksRequest writes a GetDotClocks request to a byte slice. func getDotClocksRequest(c *xgb.Conn, Screen uint16) []byte { size := 8 b := 0 @@ -1822,30 +1862,35 @@ func getDotClocksRequest(c *xgb.Conn, Screen uint16) []byte { return buf } -// Request SetClientVersion -// size: 8 +// SetClientVersionCookie is a cookie used only for SetClientVersion requests. type SetClientVersionCookie struct { *xgb.Cookie } -// Write request to wire for SetClientVersion +// SetClientVersion sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetClientVersion(c *xgb.Conn, Major uint16, Minor uint16) SetClientVersionCookie { cookie := c.NewCookie(false, false) c.NewRequest(setClientVersionRequest(c, Major, Minor), cookie) return SetClientVersionCookie{cookie} } +// SetClientVersionChecked sends a checked request. +// If an error occurs, it can be retrieved using SetClientVersionCookie.Check() func SetClientVersionChecked(c *xgb.Conn, Major uint16, Minor uint16) SetClientVersionCookie { cookie := c.NewCookie(true, false) c.NewRequest(setClientVersionRequest(c, Major, Minor), cookie) return SetClientVersionCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetClientVersionCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetClientVersion +// setClientVersionRequest writes a SetClientVersion request to a byte slice. func setClientVersionRequest(c *xgb.Conn, Major uint16, Minor uint16) []byte { size := 8 b := 0 @@ -1869,30 +1914,35 @@ func setClientVersionRequest(c *xgb.Conn, Major uint16, Minor uint16) []byte { return buf } -// Request SetGamma -// size: 32 +// SetGammaCookie is a cookie used only for SetGamma requests. type SetGammaCookie struct { *xgb.Cookie } -// Write request to wire for SetGamma +// SetGamma sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetGamma(c *xgb.Conn, Screen uint16, Red uint32, Green uint32, Blue uint32) SetGammaCookie { cookie := c.NewCookie(false, false) c.NewRequest(setGammaRequest(c, Screen, Red, Green, Blue), cookie) return SetGammaCookie{cookie} } +// SetGammaChecked sends a checked request. +// If an error occurs, it can be retrieved using SetGammaCookie.Check() func SetGammaChecked(c *xgb.Conn, Screen uint16, Red uint32, Green uint32, Blue uint32) SetGammaCookie { cookie := c.NewCookie(true, false) c.NewRequest(setGammaRequest(c, Screen, Red, Green, Blue), cookie) return SetGammaCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetGammaCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetGamma +// setGammaRequest writes a SetGamma request to a byte slice. func setGammaRequest(c *xgb.Conn, Screen uint16, Red uint32, Green uint32, Blue uint32) []byte { size := 32 b := 0 @@ -1926,29 +1976,31 @@ func setGammaRequest(c *xgb.Conn, Screen uint16, Red uint32, Green uint32, Blue return buf } -// Request GetGamma -// size: 32 +// GetGammaCookie is a cookie used only for GetGamma requests. type GetGammaCookie struct { *xgb.Cookie } +// GetGamma sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetGammaCookie.Reply() func GetGamma(c *xgb.Conn, Screen uint16) GetGammaCookie { cookie := c.NewCookie(true, true) c.NewRequest(getGammaRequest(c, Screen), cookie) return GetGammaCookie{cookie} } +// GetGammaUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetGammaUnchecked(c *xgb.Conn, Screen uint16) GetGammaCookie { cookie := c.NewCookie(false, true) c.NewRequest(getGammaRequest(c, Screen), cookie) return GetGammaCookie{cookie} } -// Request reply for GetGamma -// size: 32 +// GetGammaReply represents the data returned from a GetGamma request. type GetGammaReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Red uint32 Green uint32 @@ -1956,7 +2008,7 @@ type GetGammaReply struct { // padding: 12 bytes } -// Waits and reads reply data from request GetGamma +// Reply blocks and returns the reply data for a GetGamma request. func (cook GetGammaCookie) Reply() (*GetGammaReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1968,7 +2020,7 @@ func (cook GetGammaCookie) Reply() (*GetGammaReply, error) { return getGammaReply(buf), nil } -// Read reply into structure from buffer for GetGamma +// getGammaReply reads a byte slice into a GetGammaReply value. func getGammaReply(buf []byte) *GetGammaReply { v := new(GetGammaReply) b := 1 // skip reply determinant @@ -1996,6 +2048,7 @@ func getGammaReply(buf []byte) *GetGammaReply { } // Write request to wire for GetGamma +// getGammaRequest writes a GetGamma request to a byte slice. func getGammaRequest(c *xgb.Conn, Screen uint16) []byte { size := 32 b := 0 @@ -2018,29 +2071,31 @@ func getGammaRequest(c *xgb.Conn, Screen uint16) []byte { return buf } -// Request GetGammaRamp -// size: 8 +// GetGammaRampCookie is a cookie used only for GetGammaRamp requests. type GetGammaRampCookie struct { *xgb.Cookie } +// GetGammaRamp sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetGammaRampCookie.Reply() func GetGammaRamp(c *xgb.Conn, Screen uint16, Size uint16) GetGammaRampCookie { cookie := c.NewCookie(true, true) c.NewRequest(getGammaRampRequest(c, Screen, Size), cookie) return GetGammaRampCookie{cookie} } +// GetGammaRampUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetGammaRampUnchecked(c *xgb.Conn, Screen uint16, Size uint16) GetGammaRampCookie { cookie := c.NewCookie(false, true) c.NewRequest(getGammaRampRequest(c, Screen, Size), cookie) return GetGammaRampCookie{cookie} } -// Request reply for GetGammaRamp -// size: (((32 + xgb.Pad((((int(Size) + 1) & -2) * 2))) + xgb.Pad((((int(Size) + 1) & -2) * 2))) + xgb.Pad((((int(Size) + 1) & -2) * 2))) +// GetGammaRampReply represents the data returned from a GetGammaRamp request. type GetGammaRampReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Size uint16 // padding: 22 bytes @@ -2049,7 +2104,7 @@ type GetGammaRampReply struct { Blue []uint16 // size: xgb.Pad((((int(Size) + 1) & -2) * 2)) } -// Waits and reads reply data from request GetGammaRamp +// Reply blocks and returns the reply data for a GetGammaRamp request. func (cook GetGammaRampCookie) Reply() (*GetGammaRampReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -2061,7 +2116,7 @@ func (cook GetGammaRampCookie) Reply() (*GetGammaRampReply, error) { return getGammaRampReply(buf), nil } -// Read reply into structure from buffer for GetGammaRamp +// getGammaRampReply reads a byte slice into a GetGammaRampReply value. func getGammaRampReply(buf []byte) *GetGammaRampReply { v := new(GetGammaRampReply) b := 1 // skip reply determinant @@ -2104,6 +2159,7 @@ func getGammaRampReply(buf []byte) *GetGammaRampReply { } // Write request to wire for GetGammaRamp +// getGammaRampRequest writes a GetGammaRamp request to a byte slice. func getGammaRampRequest(c *xgb.Conn, Screen uint16, Size uint16) []byte { size := 8 b := 0 @@ -2127,30 +2183,35 @@ func getGammaRampRequest(c *xgb.Conn, Screen uint16, Size uint16) []byte { return buf } -// Request SetGammaRamp -// size: xgb.Pad((((8 + xgb.Pad((((int(Size) + 1) & -2) * 2))) + xgb.Pad((((int(Size) + 1) & -2) * 2))) + xgb.Pad((((int(Size) + 1) & -2) * 2)))) +// SetGammaRampCookie is a cookie used only for SetGammaRamp requests. type SetGammaRampCookie struct { *xgb.Cookie } -// Write request to wire for SetGammaRamp +// SetGammaRamp sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetGammaRamp(c *xgb.Conn, Screen uint16, Size uint16, Red []uint16, Green []uint16, Blue []uint16) SetGammaRampCookie { cookie := c.NewCookie(false, false) c.NewRequest(setGammaRampRequest(c, Screen, Size, Red, Green, Blue), cookie) return SetGammaRampCookie{cookie} } +// SetGammaRampChecked sends a checked request. +// If an error occurs, it can be retrieved using SetGammaRampCookie.Check() func SetGammaRampChecked(c *xgb.Conn, Screen uint16, Size uint16, Red []uint16, Green []uint16, Blue []uint16) SetGammaRampCookie { cookie := c.NewCookie(true, false) c.NewRequest(setGammaRampRequest(c, Screen, Size, Red, Green, Blue), cookie) return SetGammaRampCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetGammaRampCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetGammaRamp +// setGammaRampRequest writes a SetGammaRamp request to a byte slice. func setGammaRampRequest(c *xgb.Conn, Screen uint16, Size uint16, Red []uint16, Green []uint16, Blue []uint16) []byte { size := xgb.Pad((((8 + xgb.Pad((((int(Size) + 1) & -2) * 2))) + xgb.Pad((((int(Size) + 1) & -2) * 2))) + xgb.Pad((((int(Size) + 1) & -2) * 2)))) b := 0 @@ -2192,35 +2253,37 @@ func setGammaRampRequest(c *xgb.Conn, Screen uint16, Size uint16, Red []uint16, return buf } -// Request GetGammaRampSize -// size: 8 +// GetGammaRampSizeCookie is a cookie used only for GetGammaRampSize requests. type GetGammaRampSizeCookie struct { *xgb.Cookie } +// GetGammaRampSize sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetGammaRampSizeCookie.Reply() func GetGammaRampSize(c *xgb.Conn, Screen uint16) GetGammaRampSizeCookie { cookie := c.NewCookie(true, true) c.NewRequest(getGammaRampSizeRequest(c, Screen), cookie) return GetGammaRampSizeCookie{cookie} } +// GetGammaRampSizeUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetGammaRampSizeUnchecked(c *xgb.Conn, Screen uint16) GetGammaRampSizeCookie { cookie := c.NewCookie(false, true) c.NewRequest(getGammaRampSizeRequest(c, Screen), cookie) return GetGammaRampSizeCookie{cookie} } -// Request reply for GetGammaRampSize -// size: 32 +// GetGammaRampSizeReply represents the data returned from a GetGammaRampSize request. type GetGammaRampSizeReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Size uint16 // padding: 22 bytes } -// Waits and reads reply data from request GetGammaRampSize +// Reply blocks and returns the reply data for a GetGammaRampSize request. func (cook GetGammaRampSizeCookie) Reply() (*GetGammaRampSizeReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -2232,7 +2295,7 @@ func (cook GetGammaRampSizeCookie) Reply() (*GetGammaRampSizeReply, error) { return getGammaRampSizeReply(buf), nil } -// Read reply into structure from buffer for GetGammaRampSize +// getGammaRampSizeReply reads a byte slice into a GetGammaRampSizeReply value. func getGammaRampSizeReply(buf []byte) *GetGammaRampSizeReply { v := new(GetGammaRampSizeReply) b := 1 // skip reply determinant @@ -2254,6 +2317,7 @@ func getGammaRampSizeReply(buf []byte) *GetGammaRampSizeReply { } // Write request to wire for GetGammaRampSize +// getGammaRampSizeRequest writes a GetGammaRampSize request to a byte slice. func getGammaRampSizeRequest(c *xgb.Conn, Screen uint16) []byte { size := 8 b := 0 @@ -2276,35 +2340,37 @@ func getGammaRampSizeRequest(c *xgb.Conn, Screen uint16) []byte { return buf } -// Request GetPermissions -// size: 8 +// GetPermissionsCookie is a cookie used only for GetPermissions requests. type GetPermissionsCookie struct { *xgb.Cookie } +// GetPermissions sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPermissionsCookie.Reply() func GetPermissions(c *xgb.Conn, Screen uint16) GetPermissionsCookie { cookie := c.NewCookie(true, true) c.NewRequest(getPermissionsRequest(c, Screen), cookie) return GetPermissionsCookie{cookie} } +// GetPermissionsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetPermissionsUnchecked(c *xgb.Conn, Screen uint16) GetPermissionsCookie { cookie := c.NewCookie(false, true) c.NewRequest(getPermissionsRequest(c, Screen), cookie) return GetPermissionsCookie{cookie} } -// Request reply for GetPermissions -// size: 32 +// GetPermissionsReply represents the data returned from a GetPermissions request. type GetPermissionsReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Permissions uint32 // padding: 20 bytes } -// Waits and reads reply data from request GetPermissions +// Reply blocks and returns the reply data for a GetPermissions request. func (cook GetPermissionsCookie) Reply() (*GetPermissionsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -2316,7 +2382,7 @@ func (cook GetPermissionsCookie) Reply() (*GetPermissionsReply, error) { return getPermissionsReply(buf), nil } -// Read reply into structure from buffer for GetPermissions +// getPermissionsReply reads a byte slice into a GetPermissionsReply value. func getPermissionsReply(buf []byte) *GetPermissionsReply { v := new(GetPermissionsReply) b := 1 // skip reply determinant @@ -2338,6 +2404,7 @@ func getPermissionsReply(buf []byte) *GetPermissionsReply { } // Write request to wire for GetPermissions +// getPermissionsRequest writes a GetPermissions request to a byte slice. func getPermissionsRequest(c *xgb.Conn, Screen uint16) []byte { size := 8 b := 0 diff --git a/nexgb/xfixes/xfixes.go b/nexgb/xfixes/xfixes.go index 3b6bbea..b5d9c14 100644 --- a/nexgb/xfixes/xfixes.go +++ b/nexgb/xfixes/xfixes.go @@ -2,7 +2,7 @@ package xfixes /* - This file was generated by xfixes.xml on May 10 2012 8:04:32pm EDT. + This file was generated by xfixes.xml on May 10 2012 11:56:19pm EDT. This file is automatically generated. Edit at your peril! */ @@ -42,16 +42,6 @@ func init() { xgb.NewExtErrorFuncs["XFIXES"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - // Skipping definition for base type 'Int8' // Skipping definition for base type 'Card16' @@ -66,6 +56,16 @@ func init() { // Skipping definition for base type 'Float' +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + const ( SaveSetModeInsert = 0 SaveSetModeDelete = 1 @@ -115,9 +115,7 @@ func NewRegionId(c *xgb.Conn) (Region, error) { return Region(id), nil } -// Event definition SelectionNotify (0) -// Size: 32 - +// SelectionNotify is the event number for a SelectionNotifyEvent. const SelectionNotify = 0 type SelectionNotifyEvent struct { @@ -131,7 +129,7 @@ type SelectionNotifyEvent struct { // padding: 8 bytes } -// Event read SelectionNotify +// SelectionNotifyEventNew constructs a SelectionNotifyEvent value that implements xgb.Event from a byte slice. func SelectionNotifyEventNew(buf []byte) xgb.Event { v := SelectionNotifyEvent{} b := 1 // don't read event number @@ -162,7 +160,7 @@ func SelectionNotifyEventNew(buf []byte) xgb.Event { return v } -// Event write SelectionNotify +// Bytes writes a SelectionNotifyEvent value to a byte slice. func (v SelectionNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -196,12 +194,14 @@ func (v SelectionNotifyEvent) Bytes() []byte { return buf } -func (v SelectionNotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the SelectionNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v SelectionNotifyEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of SelectionNotifyEvent. func (v SelectionNotifyEvent) String() string { fieldVals := make([]string, 0, 7) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -218,9 +218,7 @@ func init() { xgb.NewExtEventFuncs["XFIXES"][0] = SelectionNotifyEventNew } -// Event definition CursorNotify (1) -// Size: 32 - +// CursorNotify is the event number for a CursorNotifyEvent. const CursorNotify = 1 type CursorNotifyEvent struct { @@ -233,7 +231,7 @@ type CursorNotifyEvent struct { // padding: 12 bytes } -// Event read CursorNotify +// CursorNotifyEventNew constructs a CursorNotifyEvent value that implements xgb.Event from a byte slice. func CursorNotifyEventNew(buf []byte) xgb.Event { v := CursorNotifyEvent{} b := 1 // don't read event number @@ -261,7 +259,7 @@ func CursorNotifyEventNew(buf []byte) xgb.Event { return v } -// Event write CursorNotify +// Bytes writes a CursorNotifyEvent value to a byte slice. func (v CursorNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -292,12 +290,14 @@ func (v CursorNotifyEvent) Bytes() []byte { return buf } -func (v CursorNotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the CursorNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v CursorNotifyEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of CursorNotifyEvent. func (v CursorNotifyEvent) String() string { fieldVals := make([]string, 0, 6) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -313,9 +313,7 @@ func init() { xgb.NewExtEventFuncs["XFIXES"][1] = CursorNotifyEventNew } -// Error definition BadRegion (0) -// Size: 32 - +// BadBadRegion is the error number for a BadBadRegion. const BadBadRegion = 0 type BadRegionError struct { @@ -323,7 +321,7 @@ type BadRegionError struct { NiceName string } -// Error read BadRegion +// BadRegionErrorNew constructs a BadRegionError value that implements xgb.Error from a byte slice. func BadRegionErrorNew(buf []byte) xgb.Error { v := BadRegionError{} v.NiceName = "BadRegion" @@ -337,8 +335,8 @@ func BadRegionErrorNew(buf []byte) xgb.Error { return v } -func (err BadRegionError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadBadRegion error. +// This is mostly used internally. func (err BadRegionError) SequenceId() uint16 { return err.Sequence } @@ -358,36 +356,38 @@ func init() { xgb.NewExtErrorFuncs["XFIXES"][0] = BadRegionErrorNew } -// Request QueryVersion -// size: 12 +// QueryVersionCookie is a cookie used only for QueryVersion requests. type QueryVersionCookie struct { *xgb.Cookie } +// QueryVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() func QueryVersion(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) return QueryVersionCookie{cookie} } +// QueryVersionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) return QueryVersionCookie{cookie} } -// Request reply for QueryVersion -// size: 32 +// QueryVersionReply represents the data returned from a QueryVersion request. type QueryVersionReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes MajorVersion uint32 MinorVersion uint32 // padding: 16 bytes } -// Waits and reads reply data from request QueryVersion +// Reply blocks and returns the reply data for a QueryVersion request. func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -399,7 +399,7 @@ func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { return queryVersionReply(buf), nil } -// Read reply into structure from buffer for QueryVersion +// queryVersionReply reads a byte slice into a QueryVersionReply value. func queryVersionReply(buf []byte) *QueryVersionReply { v := new(QueryVersionReply) b := 1 // skip reply determinant @@ -424,6 +424,7 @@ func queryVersionReply(buf []byte) *QueryVersionReply { } // Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) []byte { size := 12 b := 0 @@ -447,30 +448,35 @@ func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVers return buf } -// Request ChangeSaveSet -// size: 12 +// ChangeSaveSetCookie is a cookie used only for ChangeSaveSet requests. type ChangeSaveSetCookie struct { *xgb.Cookie } -// Write request to wire for ChangeSaveSet +// ChangeSaveSet sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ChangeSaveSet(c *xgb.Conn, Mode byte, Target byte, Map byte, Window xproto.Window) ChangeSaveSetCookie { cookie := c.NewCookie(false, false) c.NewRequest(changeSaveSetRequest(c, Mode, Target, Map, Window), cookie) return ChangeSaveSetCookie{cookie} } +// ChangeSaveSetChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeSaveSetCookie.Check() func ChangeSaveSetChecked(c *xgb.Conn, Mode byte, Target byte, Map byte, Window xproto.Window) ChangeSaveSetCookie { cookie := c.NewCookie(true, false) c.NewRequest(changeSaveSetRequest(c, Mode, Target, Map, Window), cookie) return ChangeSaveSetCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook ChangeSaveSetCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ChangeSaveSet +// changeSaveSetRequest writes a ChangeSaveSet request to a byte slice. func changeSaveSetRequest(c *xgb.Conn, Mode byte, Target byte, Map byte, Window xproto.Window) []byte { size := 12 b := 0 @@ -502,30 +508,35 @@ func changeSaveSetRequest(c *xgb.Conn, Mode byte, Target byte, Map byte, Window return buf } -// Request SelectSelectionInput -// size: 16 +// SelectSelectionInputCookie is a cookie used only for SelectSelectionInput requests. type SelectSelectionInputCookie struct { *xgb.Cookie } -// Write request to wire for SelectSelectionInput +// SelectSelectionInput sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SelectSelectionInput(c *xgb.Conn, Window xproto.Window, Selection xproto.Atom, EventMask uint32) SelectSelectionInputCookie { cookie := c.NewCookie(false, false) c.NewRequest(selectSelectionInputRequest(c, Window, Selection, EventMask), cookie) return SelectSelectionInputCookie{cookie} } +// SelectSelectionInputChecked sends a checked request. +// If an error occurs, it can be retrieved using SelectSelectionInputCookie.Check() func SelectSelectionInputChecked(c *xgb.Conn, Window xproto.Window, Selection xproto.Atom, EventMask uint32) SelectSelectionInputCookie { cookie := c.NewCookie(true, false) c.NewRequest(selectSelectionInputRequest(c, Window, Selection, EventMask), cookie) return SelectSelectionInputCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SelectSelectionInputCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SelectSelectionInput +// selectSelectionInputRequest writes a SelectSelectionInput request to a byte slice. func selectSelectionInputRequest(c *xgb.Conn, Window xproto.Window, Selection xproto.Atom, EventMask uint32) []byte { size := 16 b := 0 @@ -552,30 +563,35 @@ func selectSelectionInputRequest(c *xgb.Conn, Window xproto.Window, Selection xp return buf } -// Request SelectCursorInput -// size: 12 +// SelectCursorInputCookie is a cookie used only for SelectCursorInput requests. type SelectCursorInputCookie struct { *xgb.Cookie } -// Write request to wire for SelectCursorInput +// SelectCursorInput sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SelectCursorInput(c *xgb.Conn, Window xproto.Window, EventMask uint32) SelectCursorInputCookie { cookie := c.NewCookie(false, false) c.NewRequest(selectCursorInputRequest(c, Window, EventMask), cookie) return SelectCursorInputCookie{cookie} } +// SelectCursorInputChecked sends a checked request. +// If an error occurs, it can be retrieved using SelectCursorInputCookie.Check() func SelectCursorInputChecked(c *xgb.Conn, Window xproto.Window, EventMask uint32) SelectCursorInputCookie { cookie := c.NewCookie(true, false) c.NewRequest(selectCursorInputRequest(c, Window, EventMask), cookie) return SelectCursorInputCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SelectCursorInputCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SelectCursorInput +// selectCursorInputRequest writes a SelectCursorInput request to a byte slice. func selectCursorInputRequest(c *xgb.Conn, Window xproto.Window, EventMask uint32) []byte { size := 12 b := 0 @@ -599,29 +615,31 @@ func selectCursorInputRequest(c *xgb.Conn, Window xproto.Window, EventMask uint3 return buf } -// Request GetCursorImage -// size: 4 +// GetCursorImageCookie is a cookie used only for GetCursorImage requests. type GetCursorImageCookie struct { *xgb.Cookie } +// GetCursorImage sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetCursorImageCookie.Reply() func GetCursorImage(c *xgb.Conn) GetCursorImageCookie { cookie := c.NewCookie(true, true) c.NewRequest(getCursorImageRequest(c), cookie) return GetCursorImageCookie{cookie} } +// GetCursorImageUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetCursorImageUnchecked(c *xgb.Conn) GetCursorImageCookie { cookie := c.NewCookie(false, true) c.NewRequest(getCursorImageRequest(c), cookie) return GetCursorImageCookie{cookie} } -// Request reply for GetCursorImage -// size: (32 + xgb.Pad(((int(Width) * int(Height)) * 4))) +// GetCursorImageReply represents the data returned from a GetCursorImage request. type GetCursorImageReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes X int16 Y int16 @@ -634,7 +652,7 @@ type GetCursorImageReply struct { CursorImage []uint32 // size: xgb.Pad(((int(Width) * int(Height)) * 4)) } -// Waits and reads reply data from request GetCursorImage +// Reply blocks and returns the reply data for a GetCursorImage request. func (cook GetCursorImageCookie) Reply() (*GetCursorImageReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -646,7 +664,7 @@ func (cook GetCursorImageCookie) Reply() (*GetCursorImageReply, error) { return getCursorImageReply(buf), nil } -// Read reply into structure from buffer for GetCursorImage +// getCursorImageReply reads a byte slice into a GetCursorImageReply value. func getCursorImageReply(buf []byte) *GetCursorImageReply { v := new(GetCursorImageReply) b := 1 // skip reply determinant @@ -693,6 +711,7 @@ func getCursorImageReply(buf []byte) *GetCursorImageReply { } // Write request to wire for GetCursorImage +// getCursorImageRequest writes a GetCursorImage request to a byte slice. func getCursorImageRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -710,30 +729,35 @@ func getCursorImageRequest(c *xgb.Conn) []byte { return buf } -// Request CreateRegion -// size: xgb.Pad((8 + xgb.Pad((len(Rectangles) * 8)))) +// CreateRegionCookie is a cookie used only for CreateRegion requests. type CreateRegionCookie struct { *xgb.Cookie } -// Write request to wire for CreateRegion +// CreateRegion sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreateRegion(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) CreateRegionCookie { cookie := c.NewCookie(false, false) c.NewRequest(createRegionRequest(c, Region, Rectangles), cookie) return CreateRegionCookie{cookie} } +// CreateRegionChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateRegionCookie.Check() func CreateRegionChecked(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) CreateRegionCookie { cookie := c.NewCookie(true, false) c.NewRequest(createRegionRequest(c, Region, Rectangles), cookie) return CreateRegionCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CreateRegionCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreateRegion +// createRegionRequest writes a CreateRegion request to a byte slice. func createRegionRequest(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) []byte { size := xgb.Pad((8 + xgb.Pad((len(Rectangles) * 8)))) b := 0 @@ -756,30 +780,35 @@ func createRegionRequest(c *xgb.Conn, Region Region, Rectangles []xproto.Rectang return buf } -// Request CreateRegionFromBitmap -// size: 12 +// CreateRegionFromBitmapCookie is a cookie used only for CreateRegionFromBitmap requests. type CreateRegionFromBitmapCookie struct { *xgb.Cookie } -// Write request to wire for CreateRegionFromBitmap +// CreateRegionFromBitmap sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreateRegionFromBitmap(c *xgb.Conn, Region Region, Bitmap xproto.Pixmap) CreateRegionFromBitmapCookie { cookie := c.NewCookie(false, false) c.NewRequest(createRegionFromBitmapRequest(c, Region, Bitmap), cookie) return CreateRegionFromBitmapCookie{cookie} } +// CreateRegionFromBitmapChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateRegionFromBitmapCookie.Check() func CreateRegionFromBitmapChecked(c *xgb.Conn, Region Region, Bitmap xproto.Pixmap) CreateRegionFromBitmapCookie { cookie := c.NewCookie(true, false) c.NewRequest(createRegionFromBitmapRequest(c, Region, Bitmap), cookie) return CreateRegionFromBitmapCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CreateRegionFromBitmapCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreateRegionFromBitmap +// createRegionFromBitmapRequest writes a CreateRegionFromBitmap request to a byte slice. func createRegionFromBitmapRequest(c *xgb.Conn, Region Region, Bitmap xproto.Pixmap) []byte { size := 12 b := 0 @@ -803,30 +832,35 @@ func createRegionFromBitmapRequest(c *xgb.Conn, Region Region, Bitmap xproto.Pix return buf } -// Request CreateRegionFromWindow -// size: 16 +// CreateRegionFromWindowCookie is a cookie used only for CreateRegionFromWindow requests. type CreateRegionFromWindowCookie struct { *xgb.Cookie } -// Write request to wire for CreateRegionFromWindow +// CreateRegionFromWindow sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreateRegionFromWindow(c *xgb.Conn, Region Region, Window xproto.Window, Kind shape.Kind) CreateRegionFromWindowCookie { cookie := c.NewCookie(false, false) c.NewRequest(createRegionFromWindowRequest(c, Region, Window, Kind), cookie) return CreateRegionFromWindowCookie{cookie} } +// CreateRegionFromWindowChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateRegionFromWindowCookie.Check() func CreateRegionFromWindowChecked(c *xgb.Conn, Region Region, Window xproto.Window, Kind shape.Kind) CreateRegionFromWindowCookie { cookie := c.NewCookie(true, false) c.NewRequest(createRegionFromWindowRequest(c, Region, Window, Kind), cookie) return CreateRegionFromWindowCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CreateRegionFromWindowCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreateRegionFromWindow +// createRegionFromWindowRequest writes a CreateRegionFromWindow request to a byte slice. func createRegionFromWindowRequest(c *xgb.Conn, Region Region, Window xproto.Window, Kind shape.Kind) []byte { size := 16 b := 0 @@ -855,30 +889,35 @@ func createRegionFromWindowRequest(c *xgb.Conn, Region Region, Window xproto.Win return buf } -// Request CreateRegionFromGC -// size: 12 +// CreateRegionFromGCCookie is a cookie used only for CreateRegionFromGC requests. type CreateRegionFromGCCookie struct { *xgb.Cookie } -// Write request to wire for CreateRegionFromGC +// CreateRegionFromGC sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreateRegionFromGC(c *xgb.Conn, Region Region, Gc xproto.Gcontext) CreateRegionFromGCCookie { cookie := c.NewCookie(false, false) c.NewRequest(createRegionFromGCRequest(c, Region, Gc), cookie) return CreateRegionFromGCCookie{cookie} } +// CreateRegionFromGCChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateRegionFromGCCookie.Check() func CreateRegionFromGCChecked(c *xgb.Conn, Region Region, Gc xproto.Gcontext) CreateRegionFromGCCookie { cookie := c.NewCookie(true, false) c.NewRequest(createRegionFromGCRequest(c, Region, Gc), cookie) return CreateRegionFromGCCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CreateRegionFromGCCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreateRegionFromGC +// createRegionFromGCRequest writes a CreateRegionFromGC request to a byte slice. func createRegionFromGCRequest(c *xgb.Conn, Region Region, Gc xproto.Gcontext) []byte { size := 12 b := 0 @@ -902,30 +941,35 @@ func createRegionFromGCRequest(c *xgb.Conn, Region Region, Gc xproto.Gcontext) [ return buf } -// Request CreateRegionFromPicture -// size: 12 +// CreateRegionFromPictureCookie is a cookie used only for CreateRegionFromPicture requests. type CreateRegionFromPictureCookie struct { *xgb.Cookie } -// Write request to wire for CreateRegionFromPicture +// CreateRegionFromPicture sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreateRegionFromPicture(c *xgb.Conn, Region Region, Picture render.Picture) CreateRegionFromPictureCookie { cookie := c.NewCookie(false, false) c.NewRequest(createRegionFromPictureRequest(c, Region, Picture), cookie) return CreateRegionFromPictureCookie{cookie} } +// CreateRegionFromPictureChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateRegionFromPictureCookie.Check() func CreateRegionFromPictureChecked(c *xgb.Conn, Region Region, Picture render.Picture) CreateRegionFromPictureCookie { cookie := c.NewCookie(true, false) c.NewRequest(createRegionFromPictureRequest(c, Region, Picture), cookie) return CreateRegionFromPictureCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CreateRegionFromPictureCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreateRegionFromPicture +// createRegionFromPictureRequest writes a CreateRegionFromPicture request to a byte slice. func createRegionFromPictureRequest(c *xgb.Conn, Region Region, Picture render.Picture) []byte { size := 12 b := 0 @@ -949,30 +993,35 @@ func createRegionFromPictureRequest(c *xgb.Conn, Region Region, Picture render.P return buf } -// Request DestroyRegion -// size: 8 +// DestroyRegionCookie is a cookie used only for DestroyRegion requests. type DestroyRegionCookie struct { *xgb.Cookie } -// Write request to wire for DestroyRegion +// DestroyRegion sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func DestroyRegion(c *xgb.Conn, Region Region) DestroyRegionCookie { cookie := c.NewCookie(false, false) c.NewRequest(destroyRegionRequest(c, Region), cookie) return DestroyRegionCookie{cookie} } +// DestroyRegionChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroyRegionCookie.Check() func DestroyRegionChecked(c *xgb.Conn, Region Region) DestroyRegionCookie { cookie := c.NewCookie(true, false) c.NewRequest(destroyRegionRequest(c, Region), cookie) return DestroyRegionCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook DestroyRegionCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for DestroyRegion +// destroyRegionRequest writes a DestroyRegion request to a byte slice. func destroyRegionRequest(c *xgb.Conn, Region Region) []byte { size := 8 b := 0 @@ -993,30 +1042,35 @@ func destroyRegionRequest(c *xgb.Conn, Region Region) []byte { return buf } -// Request SetRegion -// size: xgb.Pad((8 + xgb.Pad((len(Rectangles) * 8)))) +// SetRegionCookie is a cookie used only for SetRegion requests. type SetRegionCookie struct { *xgb.Cookie } -// Write request to wire for SetRegion +// SetRegion sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetRegion(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) SetRegionCookie { cookie := c.NewCookie(false, false) c.NewRequest(setRegionRequest(c, Region, Rectangles), cookie) return SetRegionCookie{cookie} } +// SetRegionChecked sends a checked request. +// If an error occurs, it can be retrieved using SetRegionCookie.Check() func SetRegionChecked(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) SetRegionCookie { cookie := c.NewCookie(true, false) c.NewRequest(setRegionRequest(c, Region, Rectangles), cookie) return SetRegionCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetRegionCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetRegion +// setRegionRequest writes a SetRegion request to a byte slice. func setRegionRequest(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) []byte { size := xgb.Pad((8 + xgb.Pad((len(Rectangles) * 8)))) b := 0 @@ -1039,30 +1093,35 @@ func setRegionRequest(c *xgb.Conn, Region Region, Rectangles []xproto.Rectangle) return buf } -// Request CopyRegion -// size: 12 +// CopyRegionCookie is a cookie used only for CopyRegion requests. type CopyRegionCookie struct { *xgb.Cookie } -// Write request to wire for CopyRegion +// CopyRegion sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CopyRegion(c *xgb.Conn, Source Region, Destination Region) CopyRegionCookie { cookie := c.NewCookie(false, false) c.NewRequest(copyRegionRequest(c, Source, Destination), cookie) return CopyRegionCookie{cookie} } +// CopyRegionChecked sends a checked request. +// If an error occurs, it can be retrieved using CopyRegionCookie.Check() func CopyRegionChecked(c *xgb.Conn, Source Region, Destination Region) CopyRegionCookie { cookie := c.NewCookie(true, false) c.NewRequest(copyRegionRequest(c, Source, Destination), cookie) return CopyRegionCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CopyRegionCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CopyRegion +// copyRegionRequest writes a CopyRegion request to a byte slice. func copyRegionRequest(c *xgb.Conn, Source Region, Destination Region) []byte { size := 12 b := 0 @@ -1086,30 +1145,35 @@ func copyRegionRequest(c *xgb.Conn, Source Region, Destination Region) []byte { return buf } -// Request UnionRegion -// size: 16 +// UnionRegionCookie is a cookie used only for UnionRegion requests. type UnionRegionCookie struct { *xgb.Cookie } -// Write request to wire for UnionRegion +// UnionRegion sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func UnionRegion(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) UnionRegionCookie { cookie := c.NewCookie(false, false) c.NewRequest(unionRegionRequest(c, Source1, Source2, Destination), cookie) return UnionRegionCookie{cookie} } +// UnionRegionChecked sends a checked request. +// If an error occurs, it can be retrieved using UnionRegionCookie.Check() func UnionRegionChecked(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) UnionRegionCookie { cookie := c.NewCookie(true, false) c.NewRequest(unionRegionRequest(c, Source1, Source2, Destination), cookie) return UnionRegionCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook UnionRegionCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for UnionRegion +// unionRegionRequest writes a UnionRegion request to a byte slice. func unionRegionRequest(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) []byte { size := 16 b := 0 @@ -1136,30 +1200,35 @@ func unionRegionRequest(c *xgb.Conn, Source1 Region, Source2 Region, Destination return buf } -// Request IntersectRegion -// size: 16 +// IntersectRegionCookie is a cookie used only for IntersectRegion requests. type IntersectRegionCookie struct { *xgb.Cookie } -// Write request to wire for IntersectRegion +// IntersectRegion sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func IntersectRegion(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) IntersectRegionCookie { cookie := c.NewCookie(false, false) c.NewRequest(intersectRegionRequest(c, Source1, Source2, Destination), cookie) return IntersectRegionCookie{cookie} } +// IntersectRegionChecked sends a checked request. +// If an error occurs, it can be retrieved using IntersectRegionCookie.Check() func IntersectRegionChecked(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) IntersectRegionCookie { cookie := c.NewCookie(true, false) c.NewRequest(intersectRegionRequest(c, Source1, Source2, Destination), cookie) return IntersectRegionCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook IntersectRegionCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for IntersectRegion +// intersectRegionRequest writes a IntersectRegion request to a byte slice. func intersectRegionRequest(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) []byte { size := 16 b := 0 @@ -1186,30 +1255,35 @@ func intersectRegionRequest(c *xgb.Conn, Source1 Region, Source2 Region, Destina return buf } -// Request SubtractRegion -// size: 16 +// SubtractRegionCookie is a cookie used only for SubtractRegion requests. type SubtractRegionCookie struct { *xgb.Cookie } -// Write request to wire for SubtractRegion +// SubtractRegion sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SubtractRegion(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) SubtractRegionCookie { cookie := c.NewCookie(false, false) c.NewRequest(subtractRegionRequest(c, Source1, Source2, Destination), cookie) return SubtractRegionCookie{cookie} } +// SubtractRegionChecked sends a checked request. +// If an error occurs, it can be retrieved using SubtractRegionCookie.Check() func SubtractRegionChecked(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) SubtractRegionCookie { cookie := c.NewCookie(true, false) c.NewRequest(subtractRegionRequest(c, Source1, Source2, Destination), cookie) return SubtractRegionCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SubtractRegionCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SubtractRegion +// subtractRegionRequest writes a SubtractRegion request to a byte slice. func subtractRegionRequest(c *xgb.Conn, Source1 Region, Source2 Region, Destination Region) []byte { size := 16 b := 0 @@ -1236,30 +1310,35 @@ func subtractRegionRequest(c *xgb.Conn, Source1 Region, Source2 Region, Destinat return buf } -// Request InvertRegion -// size: 20 +// InvertRegionCookie is a cookie used only for InvertRegion requests. type InvertRegionCookie struct { *xgb.Cookie } -// Write request to wire for InvertRegion +// InvertRegion sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func InvertRegion(c *xgb.Conn, Source Region, Bounds xproto.Rectangle, Destination Region) InvertRegionCookie { cookie := c.NewCookie(false, false) c.NewRequest(invertRegionRequest(c, Source, Bounds, Destination), cookie) return InvertRegionCookie{cookie} } +// InvertRegionChecked sends a checked request. +// If an error occurs, it can be retrieved using InvertRegionCookie.Check() func InvertRegionChecked(c *xgb.Conn, Source Region, Bounds xproto.Rectangle, Destination Region) InvertRegionCookie { cookie := c.NewCookie(true, false) c.NewRequest(invertRegionRequest(c, Source, Bounds, Destination), cookie) return InvertRegionCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook InvertRegionCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for InvertRegion +// invertRegionRequest writes a InvertRegion request to a byte slice. func invertRegionRequest(c *xgb.Conn, Source Region, Bounds xproto.Rectangle, Destination Region) []byte { size := 20 b := 0 @@ -1289,30 +1368,35 @@ func invertRegionRequest(c *xgb.Conn, Source Region, Bounds xproto.Rectangle, De return buf } -// Request TranslateRegion -// size: 12 +// TranslateRegionCookie is a cookie used only for TranslateRegion requests. type TranslateRegionCookie struct { *xgb.Cookie } -// Write request to wire for TranslateRegion +// TranslateRegion sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func TranslateRegion(c *xgb.Conn, Region Region, Dx int16, Dy int16) TranslateRegionCookie { cookie := c.NewCookie(false, false) c.NewRequest(translateRegionRequest(c, Region, Dx, Dy), cookie) return TranslateRegionCookie{cookie} } +// TranslateRegionChecked sends a checked request. +// If an error occurs, it can be retrieved using TranslateRegionCookie.Check() func TranslateRegionChecked(c *xgb.Conn, Region Region, Dx int16, Dy int16) TranslateRegionCookie { cookie := c.NewCookie(true, false) c.NewRequest(translateRegionRequest(c, Region, Dx, Dy), cookie) return TranslateRegionCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook TranslateRegionCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for TranslateRegion +// translateRegionRequest writes a TranslateRegion request to a byte slice. func translateRegionRequest(c *xgb.Conn, Region Region, Dx int16, Dy int16) []byte { size := 12 b := 0 @@ -1339,30 +1423,35 @@ func translateRegionRequest(c *xgb.Conn, Region Region, Dx int16, Dy int16) []by return buf } -// Request RegionExtents -// size: 12 +// RegionExtentsCookie is a cookie used only for RegionExtents requests. type RegionExtentsCookie struct { *xgb.Cookie } -// Write request to wire for RegionExtents +// RegionExtents sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func RegionExtents(c *xgb.Conn, Source Region, Destination Region) RegionExtentsCookie { cookie := c.NewCookie(false, false) c.NewRequest(regionExtentsRequest(c, Source, Destination), cookie) return RegionExtentsCookie{cookie} } +// RegionExtentsChecked sends a checked request. +// If an error occurs, it can be retrieved using RegionExtentsCookie.Check() func RegionExtentsChecked(c *xgb.Conn, Source Region, Destination Region) RegionExtentsCookie { cookie := c.NewCookie(true, false) c.NewRequest(regionExtentsRequest(c, Source, Destination), cookie) return RegionExtentsCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook RegionExtentsCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for RegionExtents +// regionExtentsRequest writes a RegionExtents request to a byte slice. func regionExtentsRequest(c *xgb.Conn, Source Region, Destination Region) []byte { size := 12 b := 0 @@ -1386,36 +1475,38 @@ func regionExtentsRequest(c *xgb.Conn, Source Region, Destination Region) []byte return buf } -// Request FetchRegion -// size: 8 +// FetchRegionCookie is a cookie used only for FetchRegion requests. type FetchRegionCookie struct { *xgb.Cookie } +// FetchRegion sends a checked request. +// If an error occurs, it will be returned with the reply by calling FetchRegionCookie.Reply() func FetchRegion(c *xgb.Conn, Region Region) FetchRegionCookie { cookie := c.NewCookie(true, true) c.NewRequest(fetchRegionRequest(c, Region), cookie) return FetchRegionCookie{cookie} } +// FetchRegionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func FetchRegionUnchecked(c *xgb.Conn, Region Region) FetchRegionCookie { cookie := c.NewCookie(false, true) c.NewRequest(fetchRegionRequest(c, Region), cookie) return FetchRegionCookie{cookie} } -// Request reply for FetchRegion -// size: (32 + xgb.Pad(((int(Length) / 2) * 8))) +// FetchRegionReply represents the data returned from a FetchRegion request. type FetchRegionReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Extents xproto.Rectangle // padding: 16 bytes Rectangles []xproto.Rectangle // size: xgb.Pad(((int(Length) / 2) * 8)) } -// Waits and reads reply data from request FetchRegion +// Reply blocks and returns the reply data for a FetchRegion request. func (cook FetchRegionCookie) Reply() (*FetchRegionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1427,7 +1518,7 @@ func (cook FetchRegionCookie) Reply() (*FetchRegionReply, error) { return fetchRegionReply(buf), nil } -// Read reply into structure from buffer for FetchRegion +// fetchRegionReply reads a byte slice into a FetchRegionReply value. func fetchRegionReply(buf []byte) *FetchRegionReply { v := new(FetchRegionReply) b := 1 // skip reply determinant @@ -1452,6 +1543,7 @@ func fetchRegionReply(buf []byte) *FetchRegionReply { } // Write request to wire for FetchRegion +// fetchRegionRequest writes a FetchRegion request to a byte slice. func fetchRegionRequest(c *xgb.Conn, Region Region) []byte { size := 8 b := 0 @@ -1472,30 +1564,35 @@ func fetchRegionRequest(c *xgb.Conn, Region Region) []byte { return buf } -// Request SetGCClipRegion -// size: 16 +// SetGCClipRegionCookie is a cookie used only for SetGCClipRegion requests. type SetGCClipRegionCookie struct { *xgb.Cookie } -// Write request to wire for SetGCClipRegion +// SetGCClipRegion sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetGCClipRegion(c *xgb.Conn, Gc xproto.Gcontext, Region Region, XOrigin int16, YOrigin int16) SetGCClipRegionCookie { cookie := c.NewCookie(false, false) c.NewRequest(setGCClipRegionRequest(c, Gc, Region, XOrigin, YOrigin), cookie) return SetGCClipRegionCookie{cookie} } +// SetGCClipRegionChecked sends a checked request. +// If an error occurs, it can be retrieved using SetGCClipRegionCookie.Check() func SetGCClipRegionChecked(c *xgb.Conn, Gc xproto.Gcontext, Region Region, XOrigin int16, YOrigin int16) SetGCClipRegionCookie { cookie := c.NewCookie(true, false) c.NewRequest(setGCClipRegionRequest(c, Gc, Region, XOrigin, YOrigin), cookie) return SetGCClipRegionCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetGCClipRegionCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetGCClipRegion +// setGCClipRegionRequest writes a SetGCClipRegion request to a byte slice. func setGCClipRegionRequest(c *xgb.Conn, Gc xproto.Gcontext, Region Region, XOrigin int16, YOrigin int16) []byte { size := 16 b := 0 @@ -1525,30 +1622,35 @@ func setGCClipRegionRequest(c *xgb.Conn, Gc xproto.Gcontext, Region Region, XOri return buf } -// Request SetWindowShapeRegion -// size: 20 +// SetWindowShapeRegionCookie is a cookie used only for SetWindowShapeRegion requests. type SetWindowShapeRegionCookie struct { *xgb.Cookie } -// Write request to wire for SetWindowShapeRegion +// SetWindowShapeRegion sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetWindowShapeRegion(c *xgb.Conn, Dest xproto.Window, DestKind shape.Kind, XOffset int16, YOffset int16, Region Region) SetWindowShapeRegionCookie { cookie := c.NewCookie(false, false) c.NewRequest(setWindowShapeRegionRequest(c, Dest, DestKind, XOffset, YOffset, Region), cookie) return SetWindowShapeRegionCookie{cookie} } +// SetWindowShapeRegionChecked sends a checked request. +// If an error occurs, it can be retrieved using SetWindowShapeRegionCookie.Check() func SetWindowShapeRegionChecked(c *xgb.Conn, Dest xproto.Window, DestKind shape.Kind, XOffset int16, YOffset int16, Region Region) SetWindowShapeRegionCookie { cookie := c.NewCookie(true, false) c.NewRequest(setWindowShapeRegionRequest(c, Dest, DestKind, XOffset, YOffset, Region), cookie) return SetWindowShapeRegionCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetWindowShapeRegionCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetWindowShapeRegion +// setWindowShapeRegionRequest writes a SetWindowShapeRegion request to a byte slice. func setWindowShapeRegionRequest(c *xgb.Conn, Dest xproto.Window, DestKind shape.Kind, XOffset int16, YOffset int16, Region Region) []byte { size := 20 b := 0 @@ -1583,30 +1685,35 @@ func setWindowShapeRegionRequest(c *xgb.Conn, Dest xproto.Window, DestKind shape return buf } -// Request SetPictureClipRegion -// size: 16 +// SetPictureClipRegionCookie is a cookie used only for SetPictureClipRegion requests. type SetPictureClipRegionCookie struct { *xgb.Cookie } -// Write request to wire for SetPictureClipRegion +// SetPictureClipRegion sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetPictureClipRegion(c *xgb.Conn, Picture render.Picture, Region Region, XOrigin int16, YOrigin int16) SetPictureClipRegionCookie { cookie := c.NewCookie(false, false) c.NewRequest(setPictureClipRegionRequest(c, Picture, Region, XOrigin, YOrigin), cookie) return SetPictureClipRegionCookie{cookie} } +// SetPictureClipRegionChecked sends a checked request. +// If an error occurs, it can be retrieved using SetPictureClipRegionCookie.Check() func SetPictureClipRegionChecked(c *xgb.Conn, Picture render.Picture, Region Region, XOrigin int16, YOrigin int16) SetPictureClipRegionCookie { cookie := c.NewCookie(true, false) c.NewRequest(setPictureClipRegionRequest(c, Picture, Region, XOrigin, YOrigin), cookie) return SetPictureClipRegionCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetPictureClipRegionCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetPictureClipRegion +// setPictureClipRegionRequest writes a SetPictureClipRegion request to a byte slice. func setPictureClipRegionRequest(c *xgb.Conn, Picture render.Picture, Region Region, XOrigin int16, YOrigin int16) []byte { size := 16 b := 0 @@ -1636,30 +1743,35 @@ func setPictureClipRegionRequest(c *xgb.Conn, Picture render.Picture, Region Reg return buf } -// Request SetCursorName -// size: xgb.Pad((12 + xgb.Pad((int(Nbytes) * 1)))) +// SetCursorNameCookie is a cookie used only for SetCursorName requests. type SetCursorNameCookie struct { *xgb.Cookie } -// Write request to wire for SetCursorName +// SetCursorName sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetCursorName(c *xgb.Conn, Cursor xproto.Cursor, Nbytes uint16, Name string) SetCursorNameCookie { cookie := c.NewCookie(false, false) c.NewRequest(setCursorNameRequest(c, Cursor, Nbytes, Name), cookie) return SetCursorNameCookie{cookie} } +// SetCursorNameChecked sends a checked request. +// If an error occurs, it can be retrieved using SetCursorNameCookie.Check() func SetCursorNameChecked(c *xgb.Conn, Cursor xproto.Cursor, Nbytes uint16, Name string) SetCursorNameCookie { cookie := c.NewCookie(true, false) c.NewRequest(setCursorNameRequest(c, Cursor, Nbytes, Name), cookie) return SetCursorNameCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetCursorNameCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetCursorName +// setCursorNameRequest writes a SetCursorName request to a byte slice. func setCursorNameRequest(c *xgb.Conn, Cursor xproto.Cursor, Nbytes uint16, Name string) []byte { size := xgb.Pad((12 + xgb.Pad((int(Nbytes) * 1)))) b := 0 @@ -1688,29 +1800,31 @@ func setCursorNameRequest(c *xgb.Conn, Cursor xproto.Cursor, Nbytes uint16, Name return buf } -// Request GetCursorName -// size: 8 +// GetCursorNameCookie is a cookie used only for GetCursorName requests. type GetCursorNameCookie struct { *xgb.Cookie } +// GetCursorName sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetCursorNameCookie.Reply() func GetCursorName(c *xgb.Conn, Cursor xproto.Cursor) GetCursorNameCookie { cookie := c.NewCookie(true, true) c.NewRequest(getCursorNameRequest(c, Cursor), cookie) return GetCursorNameCookie{cookie} } +// GetCursorNameUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetCursorNameUnchecked(c *xgb.Conn, Cursor xproto.Cursor) GetCursorNameCookie { cookie := c.NewCookie(false, true) c.NewRequest(getCursorNameRequest(c, Cursor), cookie) return GetCursorNameCookie{cookie} } -// Request reply for GetCursorName -// size: (32 + xgb.Pad((int(Nbytes) * 1))) +// GetCursorNameReply represents the data returned from a GetCursorName request. type GetCursorNameReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Atom xproto.Atom Nbytes uint16 @@ -1718,7 +1832,7 @@ type GetCursorNameReply struct { Name string // size: xgb.Pad((int(Nbytes) * 1)) } -// Waits and reads reply data from request GetCursorName +// Reply blocks and returns the reply data for a GetCursorName request. func (cook GetCursorNameCookie) Reply() (*GetCursorNameReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1730,7 +1844,7 @@ func (cook GetCursorNameCookie) Reply() (*GetCursorNameReply, error) { return getCursorNameReply(buf), nil } -// Read reply into structure from buffer for GetCursorName +// getCursorNameReply reads a byte slice into a GetCursorNameReply value. func getCursorNameReply(buf []byte) *GetCursorNameReply { v := new(GetCursorNameReply) b := 1 // skip reply determinant @@ -1762,6 +1876,7 @@ func getCursorNameReply(buf []byte) *GetCursorNameReply { } // Write request to wire for GetCursorName +// getCursorNameRequest writes a GetCursorName request to a byte slice. func getCursorNameRequest(c *xgb.Conn, Cursor xproto.Cursor) []byte { size := 8 b := 0 @@ -1782,29 +1897,31 @@ func getCursorNameRequest(c *xgb.Conn, Cursor xproto.Cursor) []byte { return buf } -// Request GetCursorImageAndName -// size: 4 +// GetCursorImageAndNameCookie is a cookie used only for GetCursorImageAndName requests. type GetCursorImageAndNameCookie struct { *xgb.Cookie } +// GetCursorImageAndName sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetCursorImageAndNameCookie.Reply() func GetCursorImageAndName(c *xgb.Conn) GetCursorImageAndNameCookie { cookie := c.NewCookie(true, true) c.NewRequest(getCursorImageAndNameRequest(c), cookie) return GetCursorImageAndNameCookie{cookie} } +// GetCursorImageAndNameUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetCursorImageAndNameUnchecked(c *xgb.Conn) GetCursorImageAndNameCookie { cookie := c.NewCookie(false, true) c.NewRequest(getCursorImageAndNameRequest(c), cookie) return GetCursorImageAndNameCookie{cookie} } -// Request reply for GetCursorImageAndName -// size: ((32 + xgb.Pad((int(Nbytes) * 1))) + xgb.Pad(((int(Width) * int(Height)) * 4))) +// GetCursorImageAndNameReply represents the data returned from a GetCursorImageAndName request. type GetCursorImageAndNameReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes X int16 Y int16 @@ -1820,7 +1937,7 @@ type GetCursorImageAndNameReply struct { CursorImage []uint32 // size: xgb.Pad(((int(Width) * int(Height)) * 4)) } -// Waits and reads reply data from request GetCursorImageAndName +// Reply blocks and returns the reply data for a GetCursorImageAndName request. func (cook GetCursorImageAndNameCookie) Reply() (*GetCursorImageAndNameReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1832,7 +1949,7 @@ func (cook GetCursorImageAndNameCookie) Reply() (*GetCursorImageAndNameReply, er return getCursorImageAndNameReply(buf), nil } -// Read reply into structure from buffer for GetCursorImageAndName +// getCursorImageAndNameReply reads a byte slice into a GetCursorImageAndNameReply value. func getCursorImageAndNameReply(buf []byte) *GetCursorImageAndNameReply { v := new(GetCursorImageAndNameReply) b := 1 // skip reply determinant @@ -1892,6 +2009,7 @@ func getCursorImageAndNameReply(buf []byte) *GetCursorImageAndNameReply { } // Write request to wire for GetCursorImageAndName +// getCursorImageAndNameRequest writes a GetCursorImageAndName request to a byte slice. func getCursorImageAndNameRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -1909,30 +2027,35 @@ func getCursorImageAndNameRequest(c *xgb.Conn) []byte { return buf } -// Request ChangeCursor -// size: 12 +// ChangeCursorCookie is a cookie used only for ChangeCursor requests. type ChangeCursorCookie struct { *xgb.Cookie } -// Write request to wire for ChangeCursor +// ChangeCursor sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ChangeCursor(c *xgb.Conn, Source xproto.Cursor, Destination xproto.Cursor) ChangeCursorCookie { cookie := c.NewCookie(false, false) c.NewRequest(changeCursorRequest(c, Source, Destination), cookie) return ChangeCursorCookie{cookie} } +// ChangeCursorChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeCursorCookie.Check() func ChangeCursorChecked(c *xgb.Conn, Source xproto.Cursor, Destination xproto.Cursor) ChangeCursorCookie { cookie := c.NewCookie(true, false) c.NewRequest(changeCursorRequest(c, Source, Destination), cookie) return ChangeCursorCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook ChangeCursorCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ChangeCursor +// changeCursorRequest writes a ChangeCursor request to a byte slice. func changeCursorRequest(c *xgb.Conn, Source xproto.Cursor, Destination xproto.Cursor) []byte { size := 12 b := 0 @@ -1956,30 +2079,35 @@ func changeCursorRequest(c *xgb.Conn, Source xproto.Cursor, Destination xproto.C return buf } -// Request ChangeCursorByName -// size: xgb.Pad((12 + xgb.Pad((int(Nbytes) * 1)))) +// ChangeCursorByNameCookie is a cookie used only for ChangeCursorByName requests. type ChangeCursorByNameCookie struct { *xgb.Cookie } -// Write request to wire for ChangeCursorByName +// ChangeCursorByName sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ChangeCursorByName(c *xgb.Conn, Src xproto.Cursor, Nbytes uint16, Name string) ChangeCursorByNameCookie { cookie := c.NewCookie(false, false) c.NewRequest(changeCursorByNameRequest(c, Src, Nbytes, Name), cookie) return ChangeCursorByNameCookie{cookie} } +// ChangeCursorByNameChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeCursorByNameCookie.Check() func ChangeCursorByNameChecked(c *xgb.Conn, Src xproto.Cursor, Nbytes uint16, Name string) ChangeCursorByNameCookie { cookie := c.NewCookie(true, false) c.NewRequest(changeCursorByNameRequest(c, Src, Nbytes, Name), cookie) return ChangeCursorByNameCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook ChangeCursorByNameCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ChangeCursorByName +// changeCursorByNameRequest writes a ChangeCursorByName request to a byte slice. func changeCursorByNameRequest(c *xgb.Conn, Src xproto.Cursor, Nbytes uint16, Name string) []byte { size := xgb.Pad((12 + xgb.Pad((int(Nbytes) * 1)))) b := 0 @@ -2008,30 +2136,35 @@ func changeCursorByNameRequest(c *xgb.Conn, Src xproto.Cursor, Nbytes uint16, Na return buf } -// Request ExpandRegion -// size: 20 +// ExpandRegionCookie is a cookie used only for ExpandRegion requests. type ExpandRegionCookie struct { *xgb.Cookie } -// Write request to wire for ExpandRegion +// ExpandRegion sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ExpandRegion(c *xgb.Conn, Source Region, Destination Region, Left uint16, Right uint16, Top uint16, Bottom uint16) ExpandRegionCookie { cookie := c.NewCookie(false, false) c.NewRequest(expandRegionRequest(c, Source, Destination, Left, Right, Top, Bottom), cookie) return ExpandRegionCookie{cookie} } +// ExpandRegionChecked sends a checked request. +// If an error occurs, it can be retrieved using ExpandRegionCookie.Check() func ExpandRegionChecked(c *xgb.Conn, Source Region, Destination Region, Left uint16, Right uint16, Top uint16, Bottom uint16) ExpandRegionCookie { cookie := c.NewCookie(true, false) c.NewRequest(expandRegionRequest(c, Source, Destination, Left, Right, Top, Bottom), cookie) return ExpandRegionCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook ExpandRegionCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ExpandRegion +// expandRegionRequest writes a ExpandRegion request to a byte slice. func expandRegionRequest(c *xgb.Conn, Source Region, Destination Region, Left uint16, Right uint16, Top uint16, Bottom uint16) []byte { size := 20 b := 0 @@ -2067,30 +2200,35 @@ func expandRegionRequest(c *xgb.Conn, Source Region, Destination Region, Left ui return buf } -// Request HideCursor -// size: 8 +// HideCursorCookie is a cookie used only for HideCursor requests. type HideCursorCookie struct { *xgb.Cookie } -// Write request to wire for HideCursor +// HideCursor sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func HideCursor(c *xgb.Conn, Window xproto.Window) HideCursorCookie { cookie := c.NewCookie(false, false) c.NewRequest(hideCursorRequest(c, Window), cookie) return HideCursorCookie{cookie} } +// HideCursorChecked sends a checked request. +// If an error occurs, it can be retrieved using HideCursorCookie.Check() func HideCursorChecked(c *xgb.Conn, Window xproto.Window) HideCursorCookie { cookie := c.NewCookie(true, false) c.NewRequest(hideCursorRequest(c, Window), cookie) return HideCursorCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook HideCursorCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for HideCursor +// hideCursorRequest writes a HideCursor request to a byte slice. func hideCursorRequest(c *xgb.Conn, Window xproto.Window) []byte { size := 8 b := 0 @@ -2111,30 +2249,35 @@ func hideCursorRequest(c *xgb.Conn, Window xproto.Window) []byte { return buf } -// Request ShowCursor -// size: 8 +// ShowCursorCookie is a cookie used only for ShowCursor requests. type ShowCursorCookie struct { *xgb.Cookie } -// Write request to wire for ShowCursor +// ShowCursor sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ShowCursor(c *xgb.Conn, Window xproto.Window) ShowCursorCookie { cookie := c.NewCookie(false, false) c.NewRequest(showCursorRequest(c, Window), cookie) return ShowCursorCookie{cookie} } +// ShowCursorChecked sends a checked request. +// If an error occurs, it can be retrieved using ShowCursorCookie.Check() func ShowCursorChecked(c *xgb.Conn, Window xproto.Window) ShowCursorCookie { cookie := c.NewCookie(true, false) c.NewRequest(showCursorRequest(c, Window), cookie) return ShowCursorCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook ShowCursorCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ShowCursor +// showCursorRequest writes a ShowCursor request to a byte slice. func showCursorRequest(c *xgb.Conn, Window xproto.Window) []byte { size := 8 b := 0 diff --git a/nexgb/xgb.go b/nexgb/xgb.go index 75af854..50cfdba 100644 --- a/nexgb/xgb.go +++ b/nexgb/xgb.go @@ -118,7 +118,6 @@ func (c *Conn) Close() { // Event is an interface that can contain any of the events returned by the // server. Use a type assertion switch to extract the Event structs. type Event interface { - ImplementsEvent() Bytes() []byte String() string } @@ -141,7 +140,6 @@ var NewExtEventFuncs = make(map[string]map[int]NewEventFun) // Error is an interface that can contain any of the errors returned by // the server. Use a type assertion switch to extract the Error structs. type Error interface { - ImplementsError() SequenceId() uint16 BadId() uint32 Error() string diff --git a/nexgb/xgbgen/go_error.go b/nexgb/xgbgen/go_error.go index b7721be..81a017b 100644 --- a/nexgb/xgbgen/go_error.go +++ b/nexgb/xgbgen/go_error.go @@ -6,9 +6,7 @@ import ( // Error types func (e *Error) Define(c *Context) { - c.Putln("// Error definition %s (%d)", e.SrcName(), e.Number) - c.Putln("// Size: %s", e.Size()) - c.Putln("") + c.Putln("// %s is the error number for a %s.", e.ErrConst(), e.ErrConst()) c.Putln("const %s = %d", e.ErrConst(), e.Number) c.Putln("") c.Putln("type %s struct {", e.ErrType()) @@ -40,7 +38,8 @@ func (e *Error) Define(c *Context) { } func (e *Error) Read(c *Context) { - c.Putln("// Error read %s", e.SrcName()) + c.Putln("// %sNew constructs a %s value that implements xgb.Error from "+ + "a byte slice.", e.ErrType(), e.ErrType()) c.Putln("func %sNew(buf []byte) xgb.Error {", e.ErrType()) c.Putln("v := %s{}", e.ErrType()) c.Putln("v.NiceName = \"%s\"", e.SrcName()) @@ -62,8 +61,9 @@ func (e *Error) Read(c *Context) { // ImplementsError writes functions to implement the XGB Error interface. func (e *Error) ImplementsError(c *Context) { - c.Putln("func (err %s) ImplementsError() { }", e.ErrType()) - c.Putln("") + c.Putln("// SequenceId returns the sequence id attached to the %s error.", + e.ErrConst()) + c.Putln("// This is mostly used internally.") c.Putln("func (err %s) SequenceId() uint16 {", e.ErrType()) c.Putln("return err.Sequence") c.Putln("}") @@ -84,8 +84,7 @@ func (e *Error) ImplementsError(c *Context) { // ErrorCopy types func (e *ErrorCopy) Define(c *Context) { - c.Putln("// ErrorCopy definition %s (%d)", e.SrcName(), e.Number) - c.Putln("") + c.Putln("// %s is the error number for a %s.", e.ErrConst(), e.ErrConst()) c.Putln("const %s = %d", e.ErrConst(), e.Number) c.Putln("") c.Putln("type %s %s", e.ErrType(), e.Old.(*Error).ErrType()) @@ -111,6 +110,8 @@ func (e *ErrorCopy) Define(c *Context) { } func (e *ErrorCopy) Read(c *Context) { + c.Putln("// %sNew constructs a %s value that implements xgb.Error from "+ + "a byte slice.", e.ErrType(), e.ErrType()) c.Putln("func %sNew(buf []byte) xgb.Error {", e.ErrType()) c.Putln("v := %s(%sNew(buf).(%s))", e.ErrType(), e.Old.(*Error).ErrType(), e.Old.(*Error).ErrType()) @@ -122,8 +123,9 @@ func (e *ErrorCopy) Read(c *Context) { // ImplementsError writes functions to implement the XGB Error interface. func (e *ErrorCopy) ImplementsError(c *Context) { - c.Putln("func (err %s) ImplementsError() { }", e.ErrType()) - c.Putln("") + c.Putln("// SequenceId returns the sequence id attached to the %s error.", + e.ErrConst()) + c.Putln("// This is mostly used internally.") c.Putln("func (err %s) SequenceId() uint16 {", e.ErrType()) c.Putln("return err.Sequence") c.Putln("}") diff --git a/nexgb/xgbgen/go_event.go b/nexgb/xgbgen/go_event.go index d7ef109..9b5e748 100644 --- a/nexgb/xgbgen/go_event.go +++ b/nexgb/xgbgen/go_event.go @@ -6,9 +6,7 @@ import ( // Event types func (e *Event) Define(c *Context) { - c.Putln("// Event definition %s (%d)", e.SrcName(), e.Number) - c.Putln("// Size: %s", e.Size()) - c.Putln("") + c.Putln("// %s is the event number for a %s.", e.SrcName(), e.EvType()) c.Putln("const %s = %d", e.SrcName(), e.Number) c.Putln("") c.Putln("type %s struct {", e.EvType()) @@ -30,8 +28,10 @@ func (e *Event) Define(c *Context) { e.Write(c) // Makes sure that this event type is an Event interface. - c.Putln("func (v %s) ImplementsEvent() { }", e.EvType()) - c.Putln("") + c.Putln("// SequenceId returns the sequence id attached to the %s event.", + e.SrcName()) + c.Putln("// Events without a sequence number (KeymapNotify) return 0.") + c.Putln("// This is mostly used internally.") c.Putln("func (v %s) SequenceId() uint16 {", e.EvType()) if e.NoSequence { c.Putln("return uint16(0)") @@ -40,6 +40,8 @@ func (e *Event) Define(c *Context) { } c.Putln("}") c.Putln("") + c.Putln("// String is a rudimentary string representation of %s.", + e.EvType()) c.Putln("func (v %s) String() string {", e.EvType()) EventFieldString(c, e.Fields, e.SrcName()) c.Putln("}") @@ -58,7 +60,8 @@ func (e *Event) Define(c *Context) { } func (e *Event) Read(c *Context) { - c.Putln("// Event read %s", e.SrcName()) + c.Putln("// %sNew constructs a %s value that implements xgb.Event from "+ + "a byte slice.", e.EvType(), e.EvType()) c.Putln("func %sNew(buf []byte) xgb.Event {", e.EvType()) c.Putln("v := %s{}", e.EvType()) c.Putln("b := 1 // don't read event number") @@ -78,7 +81,7 @@ func (e *Event) Read(c *Context) { } func (e *Event) Write(c *Context) { - c.Putln("// Event write %s", e.SrcName()) + c.Putln("// Bytes writes a %s value to a byte slice.", e.EvType()) c.Putln("func (v %s) Bytes() []byte {", e.EvType()) c.Putln("buf := make([]byte, %s)", e.Size()) c.Putln("b := 0") @@ -102,8 +105,7 @@ func (e *Event) Write(c *Context) { // EventCopy types func (e *EventCopy) Define(c *Context) { - c.Putln("// EventCopy definition %s (%d)", e.SrcName(), e.Number) - c.Putln("") + c.Putln("// %s is the event number for a %s.", e.SrcName(), e.EvType()) c.Putln("const %s = %d", e.SrcName(), e.Number) c.Putln("") c.Putln("type %s %s", e.EvType(), e.Old.(*Event).EvType()) @@ -118,8 +120,10 @@ func (e *EventCopy) Define(c *Context) { e.Write(c) // Makes sure that this event type is an Event interface. - c.Putln("func (v %s) ImplementsEvent() { }", e.EvType()) - c.Putln("") + c.Putln("// SequenceId returns the sequence id attached to the %s event.", + e.SrcName()) + c.Putln("// Events without a sequence number (KeymapNotify) return 0.") + c.Putln("// This is mostly used internally.") c.Putln("func (v %s) SequenceId() uint16 {", e.EvType()) if e.Old.(*Event).NoSequence { c.Putln("return uint16(0)") @@ -146,6 +150,8 @@ func (e *EventCopy) Define(c *Context) { } func (e *EventCopy) Read(c *Context) { + c.Putln("// %sNew constructs a %s value that implements xgb.Event from "+ + "a byte slice.", e.EvType(), e.EvType()) c.Putln("func %sNew(buf []byte) xgb.Event {", e.EvType()) c.Putln("return %s(%sNew(buf).(%s))", e.EvType(), e.Old.(*Event).EvType(), e.Old.(*Event).EvType()) @@ -154,6 +160,7 @@ func (e *EventCopy) Read(c *Context) { } func (e *EventCopy) Write(c *Context) { + c.Putln("// Bytes writes a %s value to a byte slice.", e.EvType()) c.Putln("func (v %s) Bytes() []byte {", e.EvType()) c.Putln("return %s(v).Bytes()", e.Old.(*Event).EvType()) c.Putln("}") diff --git a/nexgb/xgbgen/go_request_reply.go b/nexgb/xgbgen/go_request_reply.go index 200260c..eca0c10 100644 --- a/nexgb/xgbgen/go_request_reply.go +++ b/nexgb/xgbgen/go_request_reply.go @@ -6,13 +6,16 @@ import ( ) func (r *Request) Define(c *Context) { - c.Putln("// Request %s", r.SrcName()) - c.Putln("// size: %s", r.Size(c)) + c.Putln("// %s is a cookie used only for %s requests.", + r.CookieName(), r.SrcName()) c.Putln("type %s struct {", r.CookieName()) c.Putln("*xgb.Cookie") c.Putln("}") c.Putln("") if r.Reply != nil { + c.Putln("// %s sends a checked request.", r.SrcName()) + c.Putln("// If an error occurs, it will be returned with the reply "+ + "by calling %s.Reply()", r.CookieName()) c.Putln("func %s(c *xgb.Conn, %s) %s {", r.SrcName(), r.ParamNameTypes(), r.CookieName()) c.Putln("cookie := c.NewCookie(true, true)") @@ -21,6 +24,9 @@ func (r *Request) Define(c *Context) { c.Putln("}") c.Putln("") + c.Putln("// %sUnchecked sends an unchecked request.", r.SrcName()) + c.Putln("// If an error occurs, it can only be retrieved using " + + "xgb.WaitForEvent or xgb.PollForEvent.") c.Putln("func %sUnchecked(c *xgb.Conn, %s) %s {", r.SrcName(), r.ParamNameTypes(), r.CookieName()) c.Putln("cookie := c.NewCookie(false, true)") @@ -31,7 +37,9 @@ func (r *Request) Define(c *Context) { r.ReadReply(c) } else { - c.Putln("// Write request to wire for %s", r.SrcName()) + c.Putln("// %s sends an unchecked request.", r.SrcName()) + c.Putln("// If an error occurs, it can only be retrieved using " + + "xgb.WaitForEvent or xgb.PollForEvent.") c.Putln("func %s(c *xgb.Conn, %s) %s {", r.SrcName(), r.ParamNameTypes(), r.CookieName()) c.Putln("cookie := c.NewCookie(false, false)") @@ -40,6 +48,9 @@ func (r *Request) Define(c *Context) { c.Putln("}") c.Putln("") + c.Putln("// %sChecked sends a checked request.", r.SrcName()) + c.Putln("// If an error occurs, it can be retrieved using "+ + "%s.Check()", r.CookieName()) c.Putln("func %sChecked(c *xgb.Conn, %s) %s {", r.SrcName(), r.ParamNameTypes(), r.CookieName()) c.Putln("cookie := c.NewCookie(true, false)") @@ -48,6 +59,10 @@ func (r *Request) Define(c *Context) { c.Putln("}") c.Putln("") + c.Putln("// Check returns an error if one occurred for checked " + + "requests that are not expecting a reply.") + c.Putln("// This cannot be called for requests expecting a reply, " + + "nor for unchecked requests.") c.Putln("func (cook %s) Check() error {", r.CookieName()) c.Putln("return cook.Cookie.Check()") c.Putln("}") @@ -57,18 +72,19 @@ func (r *Request) Define(c *Context) { } func (r *Request) ReadReply(c *Context) { - c.Putln("// Request reply for %s", r.SrcName()) - c.Putln("// size: %s", r.Reply.Size()) + c.Putln("// %s represents the data returned from a %s request.", + r.ReplyTypeName(), r.SrcName()) c.Putln("type %s struct {", r.ReplyTypeName()) - c.Putln("Sequence uint16") - c.Putln("Length uint32") + c.Putln("Sequence uint16 // sequence number of the request for this reply") + c.Putln("Length uint32 // number of bytes in this reply") for _, field := range r.Reply.Fields { field.Define(c) } c.Putln("}") c.Putln("") - c.Putln("// Waits and reads reply data from request %s", r.SrcName()) + c.Putln("// Reply blocks and returns the reply data for a %s request.", + r.SrcName()) c.Putln("func (cook %s) Reply() (*%s, error) {", r.CookieName(), r.ReplyTypeName()) c.Putln("buf, err := cook.Cookie.Reply()") @@ -82,7 +98,8 @@ func (r *Request) ReadReply(c *Context) { c.Putln("}") c.Putln("") - c.Putln("// Read reply into structure from buffer for %s", r.SrcName()) + c.Putln("// %s reads a byte slice into a %s value.", + r.ReplyName(), r.ReplyTypeName()) c.Putln("func %s(buf []byte) *%s {", r.ReplyName(), r.ReplyTypeName()) c.Putln("v := new(%s)", r.ReplyTypeName()) @@ -113,6 +130,8 @@ func (r *Request) WriteRequest(c *Context) { c.Putln("") } c.Putln("// Write request to wire for %s", r.SrcName()) + c.Putln("// %s writes a %s request to a byte slice.", + r.ReqName(), r.SrcName()) c.Putln("func %s(c *xgb.Conn, %s) []byte {", r.ReqName(), r.ParamNameTypes()) c.Putln("size := %s", r.Size(c)) diff --git a/nexgb/xgbgen/go_struct.go b/nexgb/xgbgen/go_struct.go index 7f33b21..a988893 100644 --- a/nexgb/xgbgen/go_struct.go +++ b/nexgb/xgbgen/go_struct.go @@ -1,8 +1,6 @@ package main func (s *Struct) Define(c *Context) { - c.Putln("// '%s' struct definition", s.SrcName()) - c.Putln("// Size: %s", s.Size()) c.Putln("type %s struct {", s.SrcName()) for _, field := range s.Fields { field.Define(c) @@ -34,7 +32,8 @@ func (s *Struct) Define(c *Context) { // the number of bytes read off the buffer. // 'ReadStructName' should only be used to read raw reply data from the wire. func (s *Struct) Read(c *Context) { - c.Putln("// Struct read %s", s.SrcName()) + c.Putln("// %sRead reads a byte slice into a %s value.", + s.SrcName(), s.SrcName()) c.Putln("func %sRead(buf []byte, v *%s) int {", s.SrcName(), s.SrcName()) c.Putln("b := 0") @@ -53,10 +52,10 @@ func (s *Struct) Read(c *Context) { // a source (i.e., the buffer) byte slice, and a destination slice and returns // the number of bytes read from the byte slice. func (s *Struct) ReadList(c *Context) { - c.Putln("// Struct list read %s", s.SrcName()) + c.Putln("// %sReadList reads a byte slice into a list of %s values.", + s.SrcName(), s.SrcName()) c.Putln("func %sReadList(buf []byte, dest []%s) int {", s.SrcName(), s.SrcName()) - c.Putln("b := 0") c.Putln("for i := 0; i < len(dest); i++ {") c.Putln("dest[i] = %s{}", s.SrcName()) @@ -70,7 +69,7 @@ func (s *Struct) ReadList(c *Context) { } func (s *Struct) Write(c *Context) { - c.Putln("// Struct write %s", s.SrcName()) + c.Putln("// Bytes writes a %s value to a byte slice.", s.SrcName()) c.Putln("func (v %s) Bytes() []byte {", s.SrcName()) c.Putln("buf := make([]byte, %s)", s.Size().Reduce("v.")) c.Putln("b := 0") @@ -85,7 +84,8 @@ func (s *Struct) Write(c *Context) { } func (s *Struct) WriteList(c *Context) { - c.Putln("// Write struct list %s", s.SrcName()) + c.Putln("// %sListBytes writes a list of %s values to a byte slice.", + s.SrcName()) c.Putln("func %sListBytes(buf []byte, list []%s) int {", s.SrcName(), s.SrcName()) c.Putln("b := 0") @@ -101,7 +101,8 @@ func (s *Struct) WriteList(c *Context) { } func (s *Struct) WriteListSize(c *Context) { - c.Putln("// Struct list size %s", s.SrcName()) + c.Putln("// %sListSize computes the size (bytes) of a list of %s values.", + s.SrcName(), s.SrcName()) c.Putln("func %sListSize(list []%s) int {", s.SrcName(), s.SrcName()) c.Putln("size := 0") if s.Size().Expression.Concrete() { diff --git a/nexgb/xgbgen/go_union.go b/nexgb/xgbgen/go_union.go index 91300a2..1a8684c 100644 --- a/nexgb/xgbgen/go_union.go +++ b/nexgb/xgbgen/go_union.go @@ -2,7 +2,8 @@ package main // Union types func (u *Union) Define(c *Context) { - c.Putln("// Union definition %s", u.SrcName()) + c.Putln("// %s is a represention of the %s union type.", + u.SrcName(), u.SrcName()) c.Putln("// Note that to *create* a Union, you should *never* create") c.Putln("// this struct directly (unless you know what you're doing).") c.Putln("// Instead use one of the following constructors for '%s':", @@ -38,8 +39,8 @@ func (u *Union) Define(c *Context) { func (u *Union) New(c *Context) { for _, field := range u.Fields { - c.Putln("// Union constructor for %s for field %s.", - u.SrcName(), field.SrcName()) + c.Putln("// %s%sNew constructs a new %s union type with the %s field.", + u.SrcName(), field.SrcName(), u.SrcName(), field.SrcName()) c.Putln("func %s%sNew(%s %s) %s {", u.SrcName(), field.SrcName(), field.SrcName(), field.SrcType(), u.SrcName()) @@ -65,7 +66,8 @@ func (u *Union) New(c *Context) { } func (u *Union) Read(c *Context) { - c.Putln("// Union read %s", u.SrcName()) + c.Putln("// %sRead reads a byte slice into a %s value.", + u.SrcName(), u.SrcName()) c.Putln("func %sRead(buf []byte, v *%s) int {", u.SrcName(), u.SrcName()) c.Putln("var b int") c.Putln("") @@ -80,7 +82,8 @@ func (u *Union) Read(c *Context) { } func (u *Union) ReadList(c *Context) { - c.Putln("// Union list read %s", u.SrcName()) + c.Putln("// %sReadList reads a byte slice into a list of %s values.", + u.SrcName(), u.SrcName()) c.Putln("func %sReadList(buf []byte, dest []%s) int {", u.SrcName(), u.SrcName()) c.Putln("b := 0") @@ -99,7 +102,7 @@ func (u *Union) ReadList(c *Context) { // *same* *fixed* size. Thus, we make sure to always read bytes into // every field which allows us to simply pick the first field and write it. func (u *Union) Write(c *Context) { - c.Putln("// Union write %s", u.SrcName()) + c.Putln("// Bytes writes a %s value to a byte slice.", u.SrcName()) c.Putln("// Each field in a union must contain the same data.") c.Putln("// So simply pick the first field and write that to the wire.") c.Putln("func (v %s) Bytes() []byte {", u.SrcName()) @@ -113,7 +116,8 @@ func (u *Union) Write(c *Context) { } func (u *Union) WriteList(c *Context) { - c.Putln("// Union list write %s", u.SrcName()) + c.Putln("// %sListBytes writes a list of %s values to a byte slice.", + u.SrcName()) c.Putln("func %sListBytes(buf []byte, list []%s) int {", u.SrcName(), u.SrcName()) c.Putln("b := 0") @@ -130,6 +134,8 @@ func (u *Union) WriteList(c *Context) { func (u *Union) WriteListSize(c *Context) { c.Putln("// Union list size %s", u.SrcName()) + c.Putln("// %sListSize computes the size (bytes) of a list of %s values.", + u.SrcName()) c.Putln("func %sListSize(list []%s) int {", u.SrcName(), u.SrcName()) c.Putln("size := 0") c.Putln("for _, item := range list {") diff --git a/nexgb/xinerama/xinerama.go b/nexgb/xinerama/xinerama.go index 587b628..cc4eaaa 100644 --- a/nexgb/xinerama/xinerama.go +++ b/nexgb/xinerama/xinerama.go @@ -2,7 +2,7 @@ package xinerama /* - This file was generated by xinerama.xml on May 10 2012 8:04:32pm EDT. + This file was generated by xinerama.xml on May 10 2012 11:56:19pm EDT. This file is automatically generated. Edit at your peril! */ @@ -64,8 +64,6 @@ func init() { // Skipping definition for base type 'Card8' -// 'ScreenInfo' struct definition -// Size: 8 type ScreenInfo struct { XOrg int16 YOrg int16 @@ -73,7 +71,7 @@ type ScreenInfo struct { Height uint16 } -// Struct read ScreenInfo +// ScreenInfoRead reads a byte slice into a ScreenInfo value. func ScreenInfoRead(buf []byte, v *ScreenInfo) int { b := 0 @@ -92,7 +90,7 @@ func ScreenInfoRead(buf []byte, v *ScreenInfo) int { return b } -// Struct list read ScreenInfo +// ScreenInfoReadList reads a byte slice into a list of ScreenInfo values. func ScreenInfoReadList(buf []byte, dest []ScreenInfo) int { b := 0 for i := 0; i < len(dest); i++ { @@ -102,7 +100,7 @@ func ScreenInfoReadList(buf []byte, dest []ScreenInfo) int { return xgb.Pad(b) } -// Struct write ScreenInfo +// Bytes writes a ScreenInfo value to a byte slice. func (v ScreenInfo) Bytes() []byte { buf := make([]byte, 8) b := 0 @@ -122,7 +120,7 @@ func (v ScreenInfo) Bytes() []byte { return buf } -// Write struct list ScreenInfo +// ScreenInfoListBytes writes a list of %s(MISSING) values to a byte slice. func ScreenInfoListBytes(buf []byte, list []ScreenInfo) int { b := 0 var structBytes []byte @@ -134,35 +132,37 @@ func ScreenInfoListBytes(buf []byte, list []ScreenInfo) int { return b } -// Request QueryVersion -// size: 8 +// QueryVersionCookie is a cookie used only for QueryVersion requests. type QueryVersionCookie struct { *xgb.Cookie } +// QueryVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() func QueryVersion(c *xgb.Conn, Major byte, Minor byte) QueryVersionCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryVersionRequest(c, Major, Minor), cookie) return QueryVersionCookie{cookie} } +// QueryVersionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryVersionUnchecked(c *xgb.Conn, Major byte, Minor byte) QueryVersionCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryVersionRequest(c, Major, Minor), cookie) return QueryVersionCookie{cookie} } -// Request reply for QueryVersion -// size: 12 +// QueryVersionReply represents the data returned from a QueryVersion request. type QueryVersionReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Major uint16 Minor uint16 } -// Waits and reads reply data from request QueryVersion +// Reply blocks and returns the reply data for a QueryVersion request. func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -174,7 +174,7 @@ func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { return queryVersionReply(buf), nil } -// Read reply into structure from buffer for QueryVersion +// queryVersionReply reads a byte slice into a QueryVersionReply value. func queryVersionReply(buf []byte) *QueryVersionReply { v := new(QueryVersionReply) b := 1 // skip reply determinant @@ -197,6 +197,7 @@ func queryVersionReply(buf []byte) *QueryVersionReply { } // Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. func queryVersionRequest(c *xgb.Conn, Major byte, Minor byte) []byte { size := 8 b := 0 @@ -220,34 +221,36 @@ func queryVersionRequest(c *xgb.Conn, Major byte, Minor byte) []byte { return buf } -// Request GetState -// size: 8 +// GetStateCookie is a cookie used only for GetState requests. type GetStateCookie struct { *xgb.Cookie } +// GetState sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetStateCookie.Reply() func GetState(c *xgb.Conn, Window xproto.Window) GetStateCookie { cookie := c.NewCookie(true, true) c.NewRequest(getStateRequest(c, Window), cookie) return GetStateCookie{cookie} } +// GetStateUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetStateUnchecked(c *xgb.Conn, Window xproto.Window) GetStateCookie { cookie := c.NewCookie(false, true) c.NewRequest(getStateRequest(c, Window), cookie) return GetStateCookie{cookie} } -// Request reply for GetState -// size: 12 +// GetStateReply represents the data returned from a GetState request. type GetStateReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply State byte Window xproto.Window } -// Waits and reads reply data from request GetState +// Reply blocks and returns the reply data for a GetState request. func (cook GetStateCookie) Reply() (*GetStateReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -259,7 +262,7 @@ func (cook GetStateCookie) Reply() (*GetStateReply, error) { return getStateReply(buf), nil } -// Read reply into structure from buffer for GetState +// getStateReply reads a byte slice into a GetStateReply value. func getStateReply(buf []byte) *GetStateReply { v := new(GetStateReply) b := 1 // skip reply determinant @@ -280,6 +283,7 @@ func getStateReply(buf []byte) *GetStateReply { } // Write request to wire for GetState +// getStateRequest writes a GetState request to a byte slice. func getStateRequest(c *xgb.Conn, Window xproto.Window) []byte { size := 8 b := 0 @@ -300,34 +304,36 @@ func getStateRequest(c *xgb.Conn, Window xproto.Window) []byte { return buf } -// Request GetScreenCount -// size: 8 +// GetScreenCountCookie is a cookie used only for GetScreenCount requests. type GetScreenCountCookie struct { *xgb.Cookie } +// GetScreenCount sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetScreenCountCookie.Reply() func GetScreenCount(c *xgb.Conn, Window xproto.Window) GetScreenCountCookie { cookie := c.NewCookie(true, true) c.NewRequest(getScreenCountRequest(c, Window), cookie) return GetScreenCountCookie{cookie} } +// GetScreenCountUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetScreenCountUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenCountCookie { cookie := c.NewCookie(false, true) c.NewRequest(getScreenCountRequest(c, Window), cookie) return GetScreenCountCookie{cookie} } -// Request reply for GetScreenCount -// size: 12 +// GetScreenCountReply represents the data returned from a GetScreenCount request. type GetScreenCountReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply ScreenCount byte Window xproto.Window } -// Waits and reads reply data from request GetScreenCount +// Reply blocks and returns the reply data for a GetScreenCount request. func (cook GetScreenCountCookie) Reply() (*GetScreenCountReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -339,7 +345,7 @@ func (cook GetScreenCountCookie) Reply() (*GetScreenCountReply, error) { return getScreenCountReply(buf), nil } -// Read reply into structure from buffer for GetScreenCount +// getScreenCountReply reads a byte slice into a GetScreenCountReply value. func getScreenCountReply(buf []byte) *GetScreenCountReply { v := new(GetScreenCountReply) b := 1 // skip reply determinant @@ -360,6 +366,7 @@ func getScreenCountReply(buf []byte) *GetScreenCountReply { } // Write request to wire for GetScreenCount +// getScreenCountRequest writes a GetScreenCount request to a byte slice. func getScreenCountRequest(c *xgb.Conn, Window xproto.Window) []byte { size := 8 b := 0 @@ -380,29 +387,31 @@ func getScreenCountRequest(c *xgb.Conn, Window xproto.Window) []byte { return buf } -// Request GetScreenSize -// size: 12 +// GetScreenSizeCookie is a cookie used only for GetScreenSize requests. type GetScreenSizeCookie struct { *xgb.Cookie } +// GetScreenSize sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetScreenSizeCookie.Reply() func GetScreenSize(c *xgb.Conn, Window xproto.Window, Screen uint32) GetScreenSizeCookie { cookie := c.NewCookie(true, true) c.NewRequest(getScreenSizeRequest(c, Window, Screen), cookie) return GetScreenSizeCookie{cookie} } +// GetScreenSizeUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetScreenSizeUnchecked(c *xgb.Conn, Window xproto.Window, Screen uint32) GetScreenSizeCookie { cookie := c.NewCookie(false, true) c.NewRequest(getScreenSizeRequest(c, Window, Screen), cookie) return GetScreenSizeCookie{cookie} } -// Request reply for GetScreenSize -// size: 24 +// GetScreenSizeReply represents the data returned from a GetScreenSize request. type GetScreenSizeReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Width uint32 Height uint32 @@ -410,7 +419,7 @@ type GetScreenSizeReply struct { Screen uint32 } -// Waits and reads reply data from request GetScreenSize +// Reply blocks and returns the reply data for a GetScreenSize request. func (cook GetScreenSizeCookie) Reply() (*GetScreenSizeReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -422,7 +431,7 @@ func (cook GetScreenSizeCookie) Reply() (*GetScreenSizeReply, error) { return getScreenSizeReply(buf), nil } -// Read reply into structure from buffer for GetScreenSize +// getScreenSizeReply reads a byte slice into a GetScreenSizeReply value. func getScreenSizeReply(buf []byte) *GetScreenSizeReply { v := new(GetScreenSizeReply) b := 1 // skip reply determinant @@ -451,6 +460,7 @@ func getScreenSizeReply(buf []byte) *GetScreenSizeReply { } // Write request to wire for GetScreenSize +// getScreenSizeRequest writes a GetScreenSize request to a byte slice. func getScreenSizeRequest(c *xgb.Conn, Window xproto.Window, Screen uint32) []byte { size := 12 b := 0 @@ -474,34 +484,36 @@ func getScreenSizeRequest(c *xgb.Conn, Window xproto.Window, Screen uint32) []by return buf } -// Request IsActive -// size: 4 +// IsActiveCookie is a cookie used only for IsActive requests. type IsActiveCookie struct { *xgb.Cookie } +// IsActive sends a checked request. +// If an error occurs, it will be returned with the reply by calling IsActiveCookie.Reply() func IsActive(c *xgb.Conn) IsActiveCookie { cookie := c.NewCookie(true, true) c.NewRequest(isActiveRequest(c), cookie) return IsActiveCookie{cookie} } +// IsActiveUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func IsActiveUnchecked(c *xgb.Conn) IsActiveCookie { cookie := c.NewCookie(false, true) c.NewRequest(isActiveRequest(c), cookie) return IsActiveCookie{cookie} } -// Request reply for IsActive -// size: 12 +// IsActiveReply represents the data returned from a IsActive request. type IsActiveReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes State uint32 } -// Waits and reads reply data from request IsActive +// Reply blocks and returns the reply data for a IsActive request. func (cook IsActiveCookie) Reply() (*IsActiveReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -513,7 +525,7 @@ func (cook IsActiveCookie) Reply() (*IsActiveReply, error) { return isActiveReply(buf), nil } -// Read reply into structure from buffer for IsActive +// isActiveReply reads a byte slice into a IsActiveReply value. func isActiveReply(buf []byte) *IsActiveReply { v := new(IsActiveReply) b := 1 // skip reply determinant @@ -533,6 +545,7 @@ func isActiveReply(buf []byte) *IsActiveReply { } // Write request to wire for IsActive +// isActiveRequest writes a IsActive request to a byte slice. func isActiveRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -550,36 +563,38 @@ func isActiveRequest(c *xgb.Conn) []byte { return buf } -// Request QueryScreens -// size: 4 +// QueryScreensCookie is a cookie used only for QueryScreens requests. type QueryScreensCookie struct { *xgb.Cookie } +// QueryScreens sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryScreensCookie.Reply() func QueryScreens(c *xgb.Conn) QueryScreensCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryScreensRequest(c), cookie) return QueryScreensCookie{cookie} } +// QueryScreensUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryScreensUnchecked(c *xgb.Conn) QueryScreensCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryScreensRequest(c), cookie) return QueryScreensCookie{cookie} } -// Request reply for QueryScreens -// size: (32 + xgb.Pad((int(Number) * 8))) +// QueryScreensReply represents the data returned from a QueryScreens request. type QueryScreensReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Number uint32 // padding: 20 bytes ScreenInfo []ScreenInfo // size: xgb.Pad((int(Number) * 8)) } -// Waits and reads reply data from request QueryScreens +// Reply blocks and returns the reply data for a QueryScreens request. func (cook QueryScreensCookie) Reply() (*QueryScreensReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -591,7 +606,7 @@ func (cook QueryScreensCookie) Reply() (*QueryScreensReply, error) { return queryScreensReply(buf), nil } -// Read reply into structure from buffer for QueryScreens +// queryScreensReply reads a byte slice into a QueryScreensReply value. func queryScreensReply(buf []byte) *QueryScreensReply { v := new(QueryScreensReply) b := 1 // skip reply determinant @@ -616,6 +631,7 @@ func queryScreensReply(buf []byte) *QueryScreensReply { } // Write request to wire for QueryScreens +// queryScreensRequest writes a QueryScreens request to a byte slice. func queryScreensRequest(c *xgb.Conn) []byte { size := 4 b := 0 diff --git a/nexgb/xinput/xinput.go b/nexgb/xinput/xinput.go index cdb0fec..2c2247c 100644 --- a/nexgb/xinput/xinput.go +++ b/nexgb/xinput/xinput.go @@ -2,7 +2,7 @@ package xinput /* - This file was generated by xinput.xml on May 10 2012 8:04:32pm EDT. + This file was generated by xinput.xml on May 10 2012 11:56:19pm EDT. This file is automatically generated. Edit at your peril! */ @@ -114,8 +114,6 @@ type KeyCode byte type EventClass uint32 -// 'DeviceInfo' struct definition -// Size: 8 type DeviceInfo struct { DeviceType xproto.Atom DeviceId byte @@ -124,7 +122,7 @@ type DeviceInfo struct { // padding: 1 bytes } -// Struct read DeviceInfo +// DeviceInfoRead reads a byte slice into a DeviceInfo value. func DeviceInfoRead(buf []byte, v *DeviceInfo) int { b := 0 @@ -145,7 +143,7 @@ func DeviceInfoRead(buf []byte, v *DeviceInfo) int { return b } -// Struct list read DeviceInfo +// DeviceInfoReadList reads a byte slice into a list of DeviceInfo values. func DeviceInfoReadList(buf []byte, dest []DeviceInfo) int { b := 0 for i := 0; i < len(dest); i++ { @@ -155,7 +153,7 @@ func DeviceInfoReadList(buf []byte, dest []DeviceInfo) int { return xgb.Pad(b) } -// Struct write DeviceInfo +// Bytes writes a DeviceInfo value to a byte slice. func (v DeviceInfo) Bytes() []byte { buf := make([]byte, 8) b := 0 @@ -177,7 +175,7 @@ func (v DeviceInfo) Bytes() []byte { return buf } -// Write struct list DeviceInfo +// DeviceInfoListBytes writes a list of %s(MISSING) values to a byte slice. func DeviceInfoListBytes(buf []byte, list []DeviceInfo) int { b := 0 var structBytes []byte @@ -189,14 +187,12 @@ func DeviceInfoListBytes(buf []byte, list []DeviceInfo) int { return b } -// 'InputInfo' struct definition -// Size: 2 type InputInfo struct { ClassId byte Len byte } -// Struct read InputInfo +// InputInfoRead reads a byte slice into a InputInfo value. func InputInfoRead(buf []byte, v *InputInfo) int { b := 0 @@ -209,7 +205,7 @@ func InputInfoRead(buf []byte, v *InputInfo) int { return b } -// Struct list read InputInfo +// InputInfoReadList reads a byte slice into a list of InputInfo values. func InputInfoReadList(buf []byte, dest []InputInfo) int { b := 0 for i := 0; i < len(dest); i++ { @@ -219,7 +215,7 @@ func InputInfoReadList(buf []byte, dest []InputInfo) int { return xgb.Pad(b) } -// Struct write InputInfo +// Bytes writes a InputInfo value to a byte slice. func (v InputInfo) Bytes() []byte { buf := make([]byte, 2) b := 0 @@ -233,7 +229,7 @@ func (v InputInfo) Bytes() []byte { return buf } -// Write struct list InputInfo +// InputInfoListBytes writes a list of %s(MISSING) values to a byte slice. func InputInfoListBytes(buf []byte, list []InputInfo) int { b := 0 var structBytes []byte @@ -245,8 +241,6 @@ func InputInfoListBytes(buf []byte, list []InputInfo) int { return b } -// 'KeyInfo' struct definition -// Size: 8 type KeyInfo struct { ClassId byte Len byte @@ -256,7 +250,7 @@ type KeyInfo struct { // padding: 2 bytes } -// Struct read KeyInfo +// KeyInfoRead reads a byte slice into a KeyInfo value. func KeyInfoRead(buf []byte, v *KeyInfo) int { b := 0 @@ -280,7 +274,7 @@ func KeyInfoRead(buf []byte, v *KeyInfo) int { return b } -// Struct list read KeyInfo +// KeyInfoReadList reads a byte slice into a list of KeyInfo values. func KeyInfoReadList(buf []byte, dest []KeyInfo) int { b := 0 for i := 0; i < len(dest); i++ { @@ -290,7 +284,7 @@ func KeyInfoReadList(buf []byte, dest []KeyInfo) int { return xgb.Pad(b) } -// Struct write KeyInfo +// Bytes writes a KeyInfo value to a byte slice. func (v KeyInfo) Bytes() []byte { buf := make([]byte, 8) b := 0 @@ -315,7 +309,7 @@ func (v KeyInfo) Bytes() []byte { return buf } -// Write struct list KeyInfo +// KeyInfoListBytes writes a list of %s(MISSING) values to a byte slice. func KeyInfoListBytes(buf []byte, list []KeyInfo) int { b := 0 var structBytes []byte @@ -327,15 +321,13 @@ func KeyInfoListBytes(buf []byte, list []KeyInfo) int { return b } -// 'ButtonInfo' struct definition -// Size: 4 type ButtonInfo struct { ClassId byte Len byte NumButtons uint16 } -// Struct read ButtonInfo +// ButtonInfoRead reads a byte slice into a ButtonInfo value. func ButtonInfoRead(buf []byte, v *ButtonInfo) int { b := 0 @@ -351,7 +343,7 @@ func ButtonInfoRead(buf []byte, v *ButtonInfo) int { return b } -// Struct list read ButtonInfo +// ButtonInfoReadList reads a byte slice into a list of ButtonInfo values. func ButtonInfoReadList(buf []byte, dest []ButtonInfo) int { b := 0 for i := 0; i < len(dest); i++ { @@ -361,7 +353,7 @@ func ButtonInfoReadList(buf []byte, dest []ButtonInfo) int { return xgb.Pad(b) } -// Struct write ButtonInfo +// Bytes writes a ButtonInfo value to a byte slice. func (v ButtonInfo) Bytes() []byte { buf := make([]byte, 4) b := 0 @@ -378,7 +370,7 @@ func (v ButtonInfo) Bytes() []byte { return buf } -// Write struct list ButtonInfo +// ButtonInfoListBytes writes a list of %s(MISSING) values to a byte slice. func ButtonInfoListBytes(buf []byte, list []ButtonInfo) int { b := 0 var structBytes []byte @@ -390,15 +382,13 @@ func ButtonInfoListBytes(buf []byte, list []ButtonInfo) int { return b } -// 'AxisInfo' struct definition -// Size: 12 type AxisInfo struct { Resolution uint32 Minimum int32 Maximum int32 } -// Struct read AxisInfo +// AxisInfoRead reads a byte slice into a AxisInfo value. func AxisInfoRead(buf []byte, v *AxisInfo) int { b := 0 @@ -414,7 +404,7 @@ func AxisInfoRead(buf []byte, v *AxisInfo) int { return b } -// Struct list read AxisInfo +// AxisInfoReadList reads a byte slice into a list of AxisInfo values. func AxisInfoReadList(buf []byte, dest []AxisInfo) int { b := 0 for i := 0; i < len(dest); i++ { @@ -424,7 +414,7 @@ func AxisInfoReadList(buf []byte, dest []AxisInfo) int { return xgb.Pad(b) } -// Struct write AxisInfo +// Bytes writes a AxisInfo value to a byte slice. func (v AxisInfo) Bytes() []byte { buf := make([]byte, 12) b := 0 @@ -441,7 +431,7 @@ func (v AxisInfo) Bytes() []byte { return buf } -// Write struct list AxisInfo +// AxisInfoListBytes writes a list of %s(MISSING) values to a byte slice. func AxisInfoListBytes(buf []byte, list []AxisInfo) int { b := 0 var structBytes []byte @@ -453,8 +443,6 @@ func AxisInfoListBytes(buf []byte, list []AxisInfo) int { return b } -// 'ValuatorInfo' struct definition -// Size: (8 + xgb.Pad((int(AxesLen) * 12))) type ValuatorInfo struct { ClassId byte Len byte @@ -464,7 +452,7 @@ type ValuatorInfo struct { Axes []AxisInfo // size: xgb.Pad((int(AxesLen) * 12)) } -// Struct read ValuatorInfo +// ValuatorInfoRead reads a byte slice into a ValuatorInfo value. func ValuatorInfoRead(buf []byte, v *ValuatorInfo) int { b := 0 @@ -489,7 +477,7 @@ func ValuatorInfoRead(buf []byte, v *ValuatorInfo) int { return b } -// Struct list read ValuatorInfo +// ValuatorInfoReadList reads a byte slice into a list of ValuatorInfo values. func ValuatorInfoReadList(buf []byte, dest []ValuatorInfo) int { b := 0 for i := 0; i < len(dest); i++ { @@ -499,7 +487,7 @@ func ValuatorInfoReadList(buf []byte, dest []ValuatorInfo) int { return xgb.Pad(b) } -// Struct write ValuatorInfo +// Bytes writes a ValuatorInfo value to a byte slice. func (v ValuatorInfo) Bytes() []byte { buf := make([]byte, (8 + xgb.Pad((int(v.AxesLen) * 12)))) b := 0 @@ -524,7 +512,7 @@ func (v ValuatorInfo) Bytes() []byte { return buf } -// Write struct list ValuatorInfo +// ValuatorInfoListBytes writes a list of %s(MISSING) values to a byte slice. func ValuatorInfoListBytes(buf []byte, list []ValuatorInfo) int { b := 0 var structBytes []byte @@ -536,7 +524,7 @@ func ValuatorInfoListBytes(buf []byte, list []ValuatorInfo) int { return b } -// Struct list size ValuatorInfo +// ValuatorInfoListSize computes the size (bytes) of a list of ValuatorInfo values. func ValuatorInfoListSize(list []ValuatorInfo) int { size := 0 for _, item := range list { @@ -545,14 +533,12 @@ func ValuatorInfoListSize(list []ValuatorInfo) int { return size } -// 'InputClassInfo' struct definition -// Size: 2 type InputClassInfo struct { ClassId byte EventTypeBase byte } -// Struct read InputClassInfo +// InputClassInfoRead reads a byte slice into a InputClassInfo value. func InputClassInfoRead(buf []byte, v *InputClassInfo) int { b := 0 @@ -565,7 +551,7 @@ func InputClassInfoRead(buf []byte, v *InputClassInfo) int { return b } -// Struct list read InputClassInfo +// InputClassInfoReadList reads a byte slice into a list of InputClassInfo values. func InputClassInfoReadList(buf []byte, dest []InputClassInfo) int { b := 0 for i := 0; i < len(dest); i++ { @@ -575,7 +561,7 @@ func InputClassInfoReadList(buf []byte, dest []InputClassInfo) int { return xgb.Pad(b) } -// Struct write InputClassInfo +// Bytes writes a InputClassInfo value to a byte slice. func (v InputClassInfo) Bytes() []byte { buf := make([]byte, 2) b := 0 @@ -589,7 +575,7 @@ func (v InputClassInfo) Bytes() []byte { return buf } -// Write struct list InputClassInfo +// InputClassInfoListBytes writes a list of %s(MISSING) values to a byte slice. func InputClassInfoListBytes(buf []byte, list []InputClassInfo) int { b := 0 var structBytes []byte @@ -601,13 +587,11 @@ func InputClassInfoListBytes(buf []byte, list []InputClassInfo) int { return b } -// 'DeviceTimeCoord' struct definition -// Size: 4 type DeviceTimeCoord struct { Time xproto.Timestamp } -// Struct read DeviceTimeCoord +// DeviceTimeCoordRead reads a byte slice into a DeviceTimeCoord value. func DeviceTimeCoordRead(buf []byte, v *DeviceTimeCoord) int { b := 0 @@ -617,7 +601,7 @@ func DeviceTimeCoordRead(buf []byte, v *DeviceTimeCoord) int { return b } -// Struct list read DeviceTimeCoord +// DeviceTimeCoordReadList reads a byte slice into a list of DeviceTimeCoord values. func DeviceTimeCoordReadList(buf []byte, dest []DeviceTimeCoord) int { b := 0 for i := 0; i < len(dest); i++ { @@ -627,7 +611,7 @@ func DeviceTimeCoordReadList(buf []byte, dest []DeviceTimeCoord) int { return xgb.Pad(b) } -// Struct write DeviceTimeCoord +// Bytes writes a DeviceTimeCoord value to a byte slice. func (v DeviceTimeCoord) Bytes() []byte { buf := make([]byte, 4) b := 0 @@ -638,7 +622,7 @@ func (v DeviceTimeCoord) Bytes() []byte { return buf } -// Write struct list DeviceTimeCoord +// DeviceTimeCoordListBytes writes a list of %s(MISSING) values to a byte slice. func DeviceTimeCoordListBytes(buf []byte, list []DeviceTimeCoord) int { b := 0 var structBytes []byte @@ -650,15 +634,13 @@ func DeviceTimeCoordListBytes(buf []byte, list []DeviceTimeCoord) int { return b } -// 'FeedbackState' struct definition -// Size: 4 type FeedbackState struct { ClassId byte Id byte Len uint16 } -// Struct read FeedbackState +// FeedbackStateRead reads a byte slice into a FeedbackState value. func FeedbackStateRead(buf []byte, v *FeedbackState) int { b := 0 @@ -674,7 +656,7 @@ func FeedbackStateRead(buf []byte, v *FeedbackState) int { return b } -// Struct list read FeedbackState +// FeedbackStateReadList reads a byte slice into a list of FeedbackState values. func FeedbackStateReadList(buf []byte, dest []FeedbackState) int { b := 0 for i := 0; i < len(dest); i++ { @@ -684,7 +666,7 @@ func FeedbackStateReadList(buf []byte, dest []FeedbackState) int { return xgb.Pad(b) } -// Struct write FeedbackState +// Bytes writes a FeedbackState value to a byte slice. func (v FeedbackState) Bytes() []byte { buf := make([]byte, 4) b := 0 @@ -701,7 +683,7 @@ func (v FeedbackState) Bytes() []byte { return buf } -// Write struct list FeedbackState +// FeedbackStateListBytes writes a list of %s(MISSING) values to a byte slice. func FeedbackStateListBytes(buf []byte, list []FeedbackState) int { b := 0 var structBytes []byte @@ -713,8 +695,6 @@ func FeedbackStateListBytes(buf []byte, list []FeedbackState) int { return b } -// 'KbdFeedbackState' struct definition -// Size: 52 type KbdFeedbackState struct { ClassId byte Id byte @@ -730,7 +710,7 @@ type KbdFeedbackState struct { AutoRepeats []byte // size: 32 } -// Struct read KbdFeedbackState +// KbdFeedbackStateRead reads a byte slice into a KbdFeedbackState value. func KbdFeedbackStateRead(buf []byte, v *KbdFeedbackState) int { b := 0 @@ -777,7 +757,7 @@ func KbdFeedbackStateRead(buf []byte, v *KbdFeedbackState) int { return b } -// Struct list read KbdFeedbackState +// KbdFeedbackStateReadList reads a byte slice into a list of KbdFeedbackState values. func KbdFeedbackStateReadList(buf []byte, dest []KbdFeedbackState) int { b := 0 for i := 0; i < len(dest); i++ { @@ -787,7 +767,7 @@ func KbdFeedbackStateReadList(buf []byte, dest []KbdFeedbackState) int { return xgb.Pad(b) } -// Struct write KbdFeedbackState +// Bytes writes a KbdFeedbackState value to a byte slice. func (v KbdFeedbackState) Bytes() []byte { buf := make([]byte, 52) b := 0 @@ -834,7 +814,7 @@ func (v KbdFeedbackState) Bytes() []byte { return buf } -// Write struct list KbdFeedbackState +// KbdFeedbackStateListBytes writes a list of %s(MISSING) values to a byte slice. func KbdFeedbackStateListBytes(buf []byte, list []KbdFeedbackState) int { b := 0 var structBytes []byte @@ -846,7 +826,7 @@ func KbdFeedbackStateListBytes(buf []byte, list []KbdFeedbackState) int { return b } -// Struct list size KbdFeedbackState +// KbdFeedbackStateListSize computes the size (bytes) of a list of KbdFeedbackState values. func KbdFeedbackStateListSize(list []KbdFeedbackState) int { size := 0 for _ = range list { @@ -855,8 +835,6 @@ func KbdFeedbackStateListSize(list []KbdFeedbackState) int { return size } -// 'PtrFeedbackState' struct definition -// Size: 12 type PtrFeedbackState struct { ClassId byte Id byte @@ -867,7 +845,7 @@ type PtrFeedbackState struct { Threshold uint16 } -// Struct read PtrFeedbackState +// PtrFeedbackStateRead reads a byte slice into a PtrFeedbackState value. func PtrFeedbackStateRead(buf []byte, v *PtrFeedbackState) int { b := 0 @@ -894,7 +872,7 @@ func PtrFeedbackStateRead(buf []byte, v *PtrFeedbackState) int { return b } -// Struct list read PtrFeedbackState +// PtrFeedbackStateReadList reads a byte slice into a list of PtrFeedbackState values. func PtrFeedbackStateReadList(buf []byte, dest []PtrFeedbackState) int { b := 0 for i := 0; i < len(dest); i++ { @@ -904,7 +882,7 @@ func PtrFeedbackStateReadList(buf []byte, dest []PtrFeedbackState) int { return xgb.Pad(b) } -// Struct write PtrFeedbackState +// Bytes writes a PtrFeedbackState value to a byte slice. func (v PtrFeedbackState) Bytes() []byte { buf := make([]byte, 12) b := 0 @@ -932,7 +910,7 @@ func (v PtrFeedbackState) Bytes() []byte { return buf } -// Write struct list PtrFeedbackState +// PtrFeedbackStateListBytes writes a list of %s(MISSING) values to a byte slice. func PtrFeedbackStateListBytes(buf []byte, list []PtrFeedbackState) int { b := 0 var structBytes []byte @@ -944,8 +922,6 @@ func PtrFeedbackStateListBytes(buf []byte, list []PtrFeedbackState) int { return b } -// 'IntegerFeedbackState' struct definition -// Size: 16 type IntegerFeedbackState struct { ClassId byte Id byte @@ -955,7 +931,7 @@ type IntegerFeedbackState struct { MaxValue int32 } -// Struct read IntegerFeedbackState +// IntegerFeedbackStateRead reads a byte slice into a IntegerFeedbackState value. func IntegerFeedbackStateRead(buf []byte, v *IntegerFeedbackState) int { b := 0 @@ -980,7 +956,7 @@ func IntegerFeedbackStateRead(buf []byte, v *IntegerFeedbackState) int { return b } -// Struct list read IntegerFeedbackState +// IntegerFeedbackStateReadList reads a byte slice into a list of IntegerFeedbackState values. func IntegerFeedbackStateReadList(buf []byte, dest []IntegerFeedbackState) int { b := 0 for i := 0; i < len(dest); i++ { @@ -990,7 +966,7 @@ func IntegerFeedbackStateReadList(buf []byte, dest []IntegerFeedbackState) int { return xgb.Pad(b) } -// Struct write IntegerFeedbackState +// Bytes writes a IntegerFeedbackState value to a byte slice. func (v IntegerFeedbackState) Bytes() []byte { buf := make([]byte, 16) b := 0 @@ -1016,7 +992,7 @@ func (v IntegerFeedbackState) Bytes() []byte { return buf } -// Write struct list IntegerFeedbackState +// IntegerFeedbackStateListBytes writes a list of %s(MISSING) values to a byte slice. func IntegerFeedbackStateListBytes(buf []byte, list []IntegerFeedbackState) int { b := 0 var structBytes []byte @@ -1028,8 +1004,6 @@ func IntegerFeedbackStateListBytes(buf []byte, list []IntegerFeedbackState) int return b } -// 'StringFeedbackState' struct definition -// Size: (8 + xgb.Pad((int(NumKeysyms) * 4))) type StringFeedbackState struct { ClassId byte Id byte @@ -1039,7 +1013,7 @@ type StringFeedbackState struct { Keysyms []xproto.Keysym // size: xgb.Pad((int(NumKeysyms) * 4)) } -// Struct read StringFeedbackState +// StringFeedbackStateRead reads a byte slice into a StringFeedbackState value. func StringFeedbackStateRead(buf []byte, v *StringFeedbackState) int { b := 0 @@ -1068,7 +1042,7 @@ func StringFeedbackStateRead(buf []byte, v *StringFeedbackState) int { return b } -// Struct list read StringFeedbackState +// StringFeedbackStateReadList reads a byte slice into a list of StringFeedbackState values. func StringFeedbackStateReadList(buf []byte, dest []StringFeedbackState) int { b := 0 for i := 0; i < len(dest); i++ { @@ -1078,7 +1052,7 @@ func StringFeedbackStateReadList(buf []byte, dest []StringFeedbackState) int { return xgb.Pad(b) } -// Struct write StringFeedbackState +// Bytes writes a StringFeedbackState value to a byte slice. func (v StringFeedbackState) Bytes() []byte { buf := make([]byte, (8 + xgb.Pad((int(v.NumKeysyms) * 4)))) b := 0 @@ -1107,7 +1081,7 @@ func (v StringFeedbackState) Bytes() []byte { return buf } -// Write struct list StringFeedbackState +// StringFeedbackStateListBytes writes a list of %s(MISSING) values to a byte slice. func StringFeedbackStateListBytes(buf []byte, list []StringFeedbackState) int { b := 0 var structBytes []byte @@ -1119,7 +1093,7 @@ func StringFeedbackStateListBytes(buf []byte, list []StringFeedbackState) int { return b } -// Struct list size StringFeedbackState +// StringFeedbackStateListSize computes the size (bytes) of a list of StringFeedbackState values. func StringFeedbackStateListSize(list []StringFeedbackState) int { size := 0 for _, item := range list { @@ -1128,8 +1102,6 @@ func StringFeedbackStateListSize(list []StringFeedbackState) int { return size } -// 'BellFeedbackState' struct definition -// Size: 12 type BellFeedbackState struct { ClassId byte Id byte @@ -1140,7 +1112,7 @@ type BellFeedbackState struct { Duration uint16 } -// Struct read BellFeedbackState +// BellFeedbackStateRead reads a byte slice into a BellFeedbackState value. func BellFeedbackStateRead(buf []byte, v *BellFeedbackState) int { b := 0 @@ -1167,7 +1139,7 @@ func BellFeedbackStateRead(buf []byte, v *BellFeedbackState) int { return b } -// Struct list read BellFeedbackState +// BellFeedbackStateReadList reads a byte slice into a list of BellFeedbackState values. func BellFeedbackStateReadList(buf []byte, dest []BellFeedbackState) int { b := 0 for i := 0; i < len(dest); i++ { @@ -1177,7 +1149,7 @@ func BellFeedbackStateReadList(buf []byte, dest []BellFeedbackState) int { return xgb.Pad(b) } -// Struct write BellFeedbackState +// Bytes writes a BellFeedbackState value to a byte slice. func (v BellFeedbackState) Bytes() []byte { buf := make([]byte, 12) b := 0 @@ -1205,7 +1177,7 @@ func (v BellFeedbackState) Bytes() []byte { return buf } -// Write struct list BellFeedbackState +// BellFeedbackStateListBytes writes a list of %s(MISSING) values to a byte slice. func BellFeedbackStateListBytes(buf []byte, list []BellFeedbackState) int { b := 0 var structBytes []byte @@ -1217,8 +1189,6 @@ func BellFeedbackStateListBytes(buf []byte, list []BellFeedbackState) int { return b } -// 'LedFeedbackState' struct definition -// Size: 12 type LedFeedbackState struct { ClassId byte Id byte @@ -1227,7 +1197,7 @@ type LedFeedbackState struct { LedValues uint32 } -// Struct read LedFeedbackState +// LedFeedbackStateRead reads a byte slice into a LedFeedbackState value. func LedFeedbackStateRead(buf []byte, v *LedFeedbackState) int { b := 0 @@ -1249,7 +1219,7 @@ func LedFeedbackStateRead(buf []byte, v *LedFeedbackState) int { return b } -// Struct list read LedFeedbackState +// LedFeedbackStateReadList reads a byte slice into a list of LedFeedbackState values. func LedFeedbackStateReadList(buf []byte, dest []LedFeedbackState) int { b := 0 for i := 0; i < len(dest); i++ { @@ -1259,7 +1229,7 @@ func LedFeedbackStateReadList(buf []byte, dest []LedFeedbackState) int { return xgb.Pad(b) } -// Struct write LedFeedbackState +// Bytes writes a LedFeedbackState value to a byte slice. func (v LedFeedbackState) Bytes() []byte { buf := make([]byte, 12) b := 0 @@ -1282,7 +1252,7 @@ func (v LedFeedbackState) Bytes() []byte { return buf } -// Write struct list LedFeedbackState +// LedFeedbackStateListBytes writes a list of %s(MISSING) values to a byte slice. func LedFeedbackStateListBytes(buf []byte, list []LedFeedbackState) int { b := 0 var structBytes []byte @@ -1294,15 +1264,13 @@ func LedFeedbackStateListBytes(buf []byte, list []LedFeedbackState) int { return b } -// 'FeedbackCtl' struct definition -// Size: 4 type FeedbackCtl struct { ClassId byte Id byte Len uint16 } -// Struct read FeedbackCtl +// FeedbackCtlRead reads a byte slice into a FeedbackCtl value. func FeedbackCtlRead(buf []byte, v *FeedbackCtl) int { b := 0 @@ -1318,7 +1286,7 @@ func FeedbackCtlRead(buf []byte, v *FeedbackCtl) int { return b } -// Struct list read FeedbackCtl +// FeedbackCtlReadList reads a byte slice into a list of FeedbackCtl values. func FeedbackCtlReadList(buf []byte, dest []FeedbackCtl) int { b := 0 for i := 0; i < len(dest); i++ { @@ -1328,7 +1296,7 @@ func FeedbackCtlReadList(buf []byte, dest []FeedbackCtl) int { return xgb.Pad(b) } -// Struct write FeedbackCtl +// Bytes writes a FeedbackCtl value to a byte slice. func (v FeedbackCtl) Bytes() []byte { buf := make([]byte, 4) b := 0 @@ -1345,7 +1313,7 @@ func (v FeedbackCtl) Bytes() []byte { return buf } -// Write struct list FeedbackCtl +// FeedbackCtlListBytes writes a list of %s(MISSING) values to a byte slice. func FeedbackCtlListBytes(buf []byte, list []FeedbackCtl) int { b := 0 var structBytes []byte @@ -1357,8 +1325,6 @@ func FeedbackCtlListBytes(buf []byte, list []FeedbackCtl) int { return b } -// 'KbdFeedbackCtl' struct definition -// Size: 20 type KbdFeedbackCtl struct { ClassId byte Id byte @@ -1373,7 +1339,7 @@ type KbdFeedbackCtl struct { LedValues uint32 } -// Struct read KbdFeedbackCtl +// KbdFeedbackCtlRead reads a byte slice into a KbdFeedbackCtl value. func KbdFeedbackCtlRead(buf []byte, v *KbdFeedbackCtl) int { b := 0 @@ -1413,7 +1379,7 @@ func KbdFeedbackCtlRead(buf []byte, v *KbdFeedbackCtl) int { return b } -// Struct list read KbdFeedbackCtl +// KbdFeedbackCtlReadList reads a byte slice into a list of KbdFeedbackCtl values. func KbdFeedbackCtlReadList(buf []byte, dest []KbdFeedbackCtl) int { b := 0 for i := 0; i < len(dest); i++ { @@ -1423,7 +1389,7 @@ func KbdFeedbackCtlReadList(buf []byte, dest []KbdFeedbackCtl) int { return xgb.Pad(b) } -// Struct write KbdFeedbackCtl +// Bytes writes a KbdFeedbackCtl value to a byte slice. func (v KbdFeedbackCtl) Bytes() []byte { buf := make([]byte, 20) b := 0 @@ -1464,7 +1430,7 @@ func (v KbdFeedbackCtl) Bytes() []byte { return buf } -// Write struct list KbdFeedbackCtl +// KbdFeedbackCtlListBytes writes a list of %s(MISSING) values to a byte slice. func KbdFeedbackCtlListBytes(buf []byte, list []KbdFeedbackCtl) int { b := 0 var structBytes []byte @@ -1476,8 +1442,6 @@ func KbdFeedbackCtlListBytes(buf []byte, list []KbdFeedbackCtl) int { return b } -// 'PtrFeedbackCtl' struct definition -// Size: 12 type PtrFeedbackCtl struct { ClassId byte Id byte @@ -1488,7 +1452,7 @@ type PtrFeedbackCtl struct { Threshold int16 } -// Struct read PtrFeedbackCtl +// PtrFeedbackCtlRead reads a byte slice into a PtrFeedbackCtl value. func PtrFeedbackCtlRead(buf []byte, v *PtrFeedbackCtl) int { b := 0 @@ -1515,7 +1479,7 @@ func PtrFeedbackCtlRead(buf []byte, v *PtrFeedbackCtl) int { return b } -// Struct list read PtrFeedbackCtl +// PtrFeedbackCtlReadList reads a byte slice into a list of PtrFeedbackCtl values. func PtrFeedbackCtlReadList(buf []byte, dest []PtrFeedbackCtl) int { b := 0 for i := 0; i < len(dest); i++ { @@ -1525,7 +1489,7 @@ func PtrFeedbackCtlReadList(buf []byte, dest []PtrFeedbackCtl) int { return xgb.Pad(b) } -// Struct write PtrFeedbackCtl +// Bytes writes a PtrFeedbackCtl value to a byte slice. func (v PtrFeedbackCtl) Bytes() []byte { buf := make([]byte, 12) b := 0 @@ -1553,7 +1517,7 @@ func (v PtrFeedbackCtl) Bytes() []byte { return buf } -// Write struct list PtrFeedbackCtl +// PtrFeedbackCtlListBytes writes a list of %s(MISSING) values to a byte slice. func PtrFeedbackCtlListBytes(buf []byte, list []PtrFeedbackCtl) int { b := 0 var structBytes []byte @@ -1565,8 +1529,6 @@ func PtrFeedbackCtlListBytes(buf []byte, list []PtrFeedbackCtl) int { return b } -// 'IntegerFeedbackCtl' struct definition -// Size: 8 type IntegerFeedbackCtl struct { ClassId byte Id byte @@ -1574,7 +1536,7 @@ type IntegerFeedbackCtl struct { IntToDisplay int32 } -// Struct read IntegerFeedbackCtl +// IntegerFeedbackCtlRead reads a byte slice into a IntegerFeedbackCtl value. func IntegerFeedbackCtlRead(buf []byte, v *IntegerFeedbackCtl) int { b := 0 @@ -1593,7 +1555,7 @@ func IntegerFeedbackCtlRead(buf []byte, v *IntegerFeedbackCtl) int { return b } -// Struct list read IntegerFeedbackCtl +// IntegerFeedbackCtlReadList reads a byte slice into a list of IntegerFeedbackCtl values. func IntegerFeedbackCtlReadList(buf []byte, dest []IntegerFeedbackCtl) int { b := 0 for i := 0; i < len(dest); i++ { @@ -1603,7 +1565,7 @@ func IntegerFeedbackCtlReadList(buf []byte, dest []IntegerFeedbackCtl) int { return xgb.Pad(b) } -// Struct write IntegerFeedbackCtl +// Bytes writes a IntegerFeedbackCtl value to a byte slice. func (v IntegerFeedbackCtl) Bytes() []byte { buf := make([]byte, 8) b := 0 @@ -1623,7 +1585,7 @@ func (v IntegerFeedbackCtl) Bytes() []byte { return buf } -// Write struct list IntegerFeedbackCtl +// IntegerFeedbackCtlListBytes writes a list of %s(MISSING) values to a byte slice. func IntegerFeedbackCtlListBytes(buf []byte, list []IntegerFeedbackCtl) int { b := 0 var structBytes []byte @@ -1635,8 +1597,6 @@ func IntegerFeedbackCtlListBytes(buf []byte, list []IntegerFeedbackCtl) int { return b } -// 'StringFeedbackCtl' struct definition -// Size: (8 + xgb.Pad((int(NumKeysyms) * 4))) type StringFeedbackCtl struct { ClassId byte Id byte @@ -1646,7 +1606,7 @@ type StringFeedbackCtl struct { Keysyms []xproto.Keysym // size: xgb.Pad((int(NumKeysyms) * 4)) } -// Struct read StringFeedbackCtl +// StringFeedbackCtlRead reads a byte slice into a StringFeedbackCtl value. func StringFeedbackCtlRead(buf []byte, v *StringFeedbackCtl) int { b := 0 @@ -1674,7 +1634,7 @@ func StringFeedbackCtlRead(buf []byte, v *StringFeedbackCtl) int { return b } -// Struct list read StringFeedbackCtl +// StringFeedbackCtlReadList reads a byte slice into a list of StringFeedbackCtl values. func StringFeedbackCtlReadList(buf []byte, dest []StringFeedbackCtl) int { b := 0 for i := 0; i < len(dest); i++ { @@ -1684,7 +1644,7 @@ func StringFeedbackCtlReadList(buf []byte, dest []StringFeedbackCtl) int { return xgb.Pad(b) } -// Struct write StringFeedbackCtl +// Bytes writes a StringFeedbackCtl value to a byte slice. func (v StringFeedbackCtl) Bytes() []byte { buf := make([]byte, (8 + xgb.Pad((int(v.NumKeysyms) * 4)))) b := 0 @@ -1712,7 +1672,7 @@ func (v StringFeedbackCtl) Bytes() []byte { return buf } -// Write struct list StringFeedbackCtl +// StringFeedbackCtlListBytes writes a list of %s(MISSING) values to a byte slice. func StringFeedbackCtlListBytes(buf []byte, list []StringFeedbackCtl) int { b := 0 var structBytes []byte @@ -1724,7 +1684,7 @@ func StringFeedbackCtlListBytes(buf []byte, list []StringFeedbackCtl) int { return b } -// Struct list size StringFeedbackCtl +// StringFeedbackCtlListSize computes the size (bytes) of a list of StringFeedbackCtl values. func StringFeedbackCtlListSize(list []StringFeedbackCtl) int { size := 0 for _, item := range list { @@ -1733,8 +1693,6 @@ func StringFeedbackCtlListSize(list []StringFeedbackCtl) int { return size } -// 'BellFeedbackCtl' struct definition -// Size: 12 type BellFeedbackCtl struct { ClassId byte Id byte @@ -1745,7 +1703,7 @@ type BellFeedbackCtl struct { Duration int16 } -// Struct read BellFeedbackCtl +// BellFeedbackCtlRead reads a byte slice into a BellFeedbackCtl value. func BellFeedbackCtlRead(buf []byte, v *BellFeedbackCtl) int { b := 0 @@ -1772,7 +1730,7 @@ func BellFeedbackCtlRead(buf []byte, v *BellFeedbackCtl) int { return b } -// Struct list read BellFeedbackCtl +// BellFeedbackCtlReadList reads a byte slice into a list of BellFeedbackCtl values. func BellFeedbackCtlReadList(buf []byte, dest []BellFeedbackCtl) int { b := 0 for i := 0; i < len(dest); i++ { @@ -1782,7 +1740,7 @@ func BellFeedbackCtlReadList(buf []byte, dest []BellFeedbackCtl) int { return xgb.Pad(b) } -// Struct write BellFeedbackCtl +// Bytes writes a BellFeedbackCtl value to a byte slice. func (v BellFeedbackCtl) Bytes() []byte { buf := make([]byte, 12) b := 0 @@ -1810,7 +1768,7 @@ func (v BellFeedbackCtl) Bytes() []byte { return buf } -// Write struct list BellFeedbackCtl +// BellFeedbackCtlListBytes writes a list of %s(MISSING) values to a byte slice. func BellFeedbackCtlListBytes(buf []byte, list []BellFeedbackCtl) int { b := 0 var structBytes []byte @@ -1822,8 +1780,6 @@ func BellFeedbackCtlListBytes(buf []byte, list []BellFeedbackCtl) int { return b } -// 'LedFeedbackCtl' struct definition -// Size: 12 type LedFeedbackCtl struct { ClassId byte Id byte @@ -1832,7 +1788,7 @@ type LedFeedbackCtl struct { LedValues uint32 } -// Struct read LedFeedbackCtl +// LedFeedbackCtlRead reads a byte slice into a LedFeedbackCtl value. func LedFeedbackCtlRead(buf []byte, v *LedFeedbackCtl) int { b := 0 @@ -1854,7 +1810,7 @@ func LedFeedbackCtlRead(buf []byte, v *LedFeedbackCtl) int { return b } -// Struct list read LedFeedbackCtl +// LedFeedbackCtlReadList reads a byte slice into a list of LedFeedbackCtl values. func LedFeedbackCtlReadList(buf []byte, dest []LedFeedbackCtl) int { b := 0 for i := 0; i < len(dest); i++ { @@ -1864,7 +1820,7 @@ func LedFeedbackCtlReadList(buf []byte, dest []LedFeedbackCtl) int { return xgb.Pad(b) } -// Struct write LedFeedbackCtl +// Bytes writes a LedFeedbackCtl value to a byte slice. func (v LedFeedbackCtl) Bytes() []byte { buf := make([]byte, 12) b := 0 @@ -1887,7 +1843,7 @@ func (v LedFeedbackCtl) Bytes() []byte { return buf } -// Write struct list LedFeedbackCtl +// LedFeedbackCtlListBytes writes a list of %s(MISSING) values to a byte slice. func LedFeedbackCtlListBytes(buf []byte, list []LedFeedbackCtl) int { b := 0 var structBytes []byte @@ -1899,15 +1855,13 @@ func LedFeedbackCtlListBytes(buf []byte, list []LedFeedbackCtl) int { return b } -// 'InputState' struct definition -// Size: 3 type InputState struct { ClassId byte Len byte NumItems byte } -// Struct read InputState +// InputStateRead reads a byte slice into a InputState value. func InputStateRead(buf []byte, v *InputState) int { b := 0 @@ -1923,7 +1877,7 @@ func InputStateRead(buf []byte, v *InputState) int { return b } -// Struct list read InputState +// InputStateReadList reads a byte slice into a list of InputState values. func InputStateReadList(buf []byte, dest []InputState) int { b := 0 for i := 0; i < len(dest); i++ { @@ -1933,7 +1887,7 @@ func InputStateReadList(buf []byte, dest []InputState) int { return xgb.Pad(b) } -// Struct write InputState +// Bytes writes a InputState value to a byte slice. func (v InputState) Bytes() []byte { buf := make([]byte, 3) b := 0 @@ -1950,7 +1904,7 @@ func (v InputState) Bytes() []byte { return buf } -// Write struct list InputState +// InputStateListBytes writes a list of %s(MISSING) values to a byte slice. func InputStateListBytes(buf []byte, list []InputState) int { b := 0 var structBytes []byte @@ -1962,8 +1916,6 @@ func InputStateListBytes(buf []byte, list []InputState) int { return b } -// 'KeyState' struct definition -// Size: 36 type KeyState struct { ClassId byte Len byte @@ -1972,7 +1924,7 @@ type KeyState struct { Keys []byte // size: 32 } -// Struct read KeyState +// KeyStateRead reads a byte slice into a KeyState value. func KeyStateRead(buf []byte, v *KeyState) int { b := 0 @@ -1994,7 +1946,7 @@ func KeyStateRead(buf []byte, v *KeyState) int { return b } -// Struct list read KeyState +// KeyStateReadList reads a byte slice into a list of KeyState values. func KeyStateReadList(buf []byte, dest []KeyState) int { b := 0 for i := 0; i < len(dest); i++ { @@ -2004,7 +1956,7 @@ func KeyStateReadList(buf []byte, dest []KeyState) int { return xgb.Pad(b) } -// Struct write KeyState +// Bytes writes a KeyState value to a byte slice. func (v KeyState) Bytes() []byte { buf := make([]byte, 36) b := 0 @@ -2026,7 +1978,7 @@ func (v KeyState) Bytes() []byte { return buf } -// Write struct list KeyState +// KeyStateListBytes writes a list of %s(MISSING) values to a byte slice. func KeyStateListBytes(buf []byte, list []KeyState) int { b := 0 var structBytes []byte @@ -2038,7 +1990,7 @@ func KeyStateListBytes(buf []byte, list []KeyState) int { return b } -// Struct list size KeyState +// KeyStateListSize computes the size (bytes) of a list of KeyState values. func KeyStateListSize(list []KeyState) int { size := 0 for _ = range list { @@ -2047,8 +1999,6 @@ func KeyStateListSize(list []KeyState) int { return size } -// 'ButtonState' struct definition -// Size: 36 type ButtonState struct { ClassId byte Len byte @@ -2057,7 +2007,7 @@ type ButtonState struct { Buttons []byte // size: 32 } -// Struct read ButtonState +// ButtonStateRead reads a byte slice into a ButtonState value. func ButtonStateRead(buf []byte, v *ButtonState) int { b := 0 @@ -2079,7 +2029,7 @@ func ButtonStateRead(buf []byte, v *ButtonState) int { return b } -// Struct list read ButtonState +// ButtonStateReadList reads a byte slice into a list of ButtonState values. func ButtonStateReadList(buf []byte, dest []ButtonState) int { b := 0 for i := 0; i < len(dest); i++ { @@ -2089,7 +2039,7 @@ func ButtonStateReadList(buf []byte, dest []ButtonState) int { return xgb.Pad(b) } -// Struct write ButtonState +// Bytes writes a ButtonState value to a byte slice. func (v ButtonState) Bytes() []byte { buf := make([]byte, 36) b := 0 @@ -2111,7 +2061,7 @@ func (v ButtonState) Bytes() []byte { return buf } -// Write struct list ButtonState +// ButtonStateListBytes writes a list of %s(MISSING) values to a byte slice. func ButtonStateListBytes(buf []byte, list []ButtonState) int { b := 0 var structBytes []byte @@ -2123,7 +2073,7 @@ func ButtonStateListBytes(buf []byte, list []ButtonState) int { return b } -// Struct list size ButtonState +// ButtonStateListSize computes the size (bytes) of a list of ButtonState values. func ButtonStateListSize(list []ButtonState) int { size := 0 for _ = range list { @@ -2132,8 +2082,6 @@ func ButtonStateListSize(list []ButtonState) int { return size } -// 'ValuatorState' struct definition -// Size: (4 + xgb.Pad((int(NumValuators) * 4))) type ValuatorState struct { ClassId byte Len byte @@ -2142,7 +2090,7 @@ type ValuatorState struct { Valuators []uint32 // size: xgb.Pad((int(NumValuators) * 4)) } -// Struct read ValuatorState +// ValuatorStateRead reads a byte slice into a ValuatorState value. func ValuatorStateRead(buf []byte, v *ValuatorState) int { b := 0 @@ -2168,7 +2116,7 @@ func ValuatorStateRead(buf []byte, v *ValuatorState) int { return b } -// Struct list read ValuatorState +// ValuatorStateReadList reads a byte slice into a list of ValuatorState values. func ValuatorStateReadList(buf []byte, dest []ValuatorState) int { b := 0 for i := 0; i < len(dest); i++ { @@ -2178,7 +2126,7 @@ func ValuatorStateReadList(buf []byte, dest []ValuatorState) int { return xgb.Pad(b) } -// Struct write ValuatorState +// Bytes writes a ValuatorState value to a byte slice. func (v ValuatorState) Bytes() []byte { buf := make([]byte, (4 + xgb.Pad((int(v.NumValuators) * 4)))) b := 0 @@ -2204,7 +2152,7 @@ func (v ValuatorState) Bytes() []byte { return buf } -// Write struct list ValuatorState +// ValuatorStateListBytes writes a list of %s(MISSING) values to a byte slice. func ValuatorStateListBytes(buf []byte, list []ValuatorState) int { b := 0 var structBytes []byte @@ -2216,7 +2164,7 @@ func ValuatorStateListBytes(buf []byte, list []ValuatorState) int { return b } -// Struct list size ValuatorState +// ValuatorStateListSize computes the size (bytes) of a list of ValuatorState values. func ValuatorStateListSize(list []ValuatorState) int { size := 0 for _, item := range list { @@ -2225,14 +2173,12 @@ func ValuatorStateListSize(list []ValuatorState) int { return size } -// 'DeviceState' struct definition -// Size: 4 type DeviceState struct { ControlId uint16 Len uint16 } -// Struct read DeviceState +// DeviceStateRead reads a byte slice into a DeviceState value. func DeviceStateRead(buf []byte, v *DeviceState) int { b := 0 @@ -2245,7 +2191,7 @@ func DeviceStateRead(buf []byte, v *DeviceState) int { return b } -// Struct list read DeviceState +// DeviceStateReadList reads a byte slice into a list of DeviceState values. func DeviceStateReadList(buf []byte, dest []DeviceState) int { b := 0 for i := 0; i < len(dest); i++ { @@ -2255,7 +2201,7 @@ func DeviceStateReadList(buf []byte, dest []DeviceState) int { return xgb.Pad(b) } -// Struct write DeviceState +// Bytes writes a DeviceState value to a byte slice. func (v DeviceState) Bytes() []byte { buf := make([]byte, 4) b := 0 @@ -2269,7 +2215,7 @@ func (v DeviceState) Bytes() []byte { return buf } -// Write struct list DeviceState +// DeviceStateListBytes writes a list of %s(MISSING) values to a byte slice. func DeviceStateListBytes(buf []byte, list []DeviceState) int { b := 0 var structBytes []byte @@ -2281,8 +2227,6 @@ func DeviceStateListBytes(buf []byte, list []DeviceState) int { return b } -// 'DeviceResolutionState' struct definition -// Size: (((8 + xgb.Pad((int(NumValuators) * 4))) + xgb.Pad((int(NumValuators) * 4))) + xgb.Pad((int(NumValuators) * 4))) type DeviceResolutionState struct { ControlId uint16 Len uint16 @@ -2292,7 +2236,7 @@ type DeviceResolutionState struct { ResolutionMax []uint32 // size: xgb.Pad((int(NumValuators) * 4)) } -// Struct read DeviceResolutionState +// DeviceResolutionStateRead reads a byte slice into a DeviceResolutionState value. func DeviceResolutionStateRead(buf []byte, v *DeviceResolutionState) int { b := 0 @@ -2329,7 +2273,7 @@ func DeviceResolutionStateRead(buf []byte, v *DeviceResolutionState) int { return b } -// Struct list read DeviceResolutionState +// DeviceResolutionStateReadList reads a byte slice into a list of DeviceResolutionState values. func DeviceResolutionStateReadList(buf []byte, dest []DeviceResolutionState) int { b := 0 for i := 0; i < len(dest); i++ { @@ -2339,7 +2283,7 @@ func DeviceResolutionStateReadList(buf []byte, dest []DeviceResolutionState) int return xgb.Pad(b) } -// Struct write DeviceResolutionState +// Bytes writes a DeviceResolutionState value to a byte slice. func (v DeviceResolutionState) Bytes() []byte { buf := make([]byte, (((8 + xgb.Pad((int(v.NumValuators) * 4))) + xgb.Pad((int(v.NumValuators) * 4))) + xgb.Pad((int(v.NumValuators) * 4)))) b := 0 @@ -2374,7 +2318,7 @@ func (v DeviceResolutionState) Bytes() []byte { return buf } -// Write struct list DeviceResolutionState +// DeviceResolutionStateListBytes writes a list of %s(MISSING) values to a byte slice. func DeviceResolutionStateListBytes(buf []byte, list []DeviceResolutionState) int { b := 0 var structBytes []byte @@ -2386,7 +2330,7 @@ func DeviceResolutionStateListBytes(buf []byte, list []DeviceResolutionState) in return b } -// Struct list size DeviceResolutionState +// DeviceResolutionStateListSize computes the size (bytes) of a list of DeviceResolutionState values. func DeviceResolutionStateListSize(list []DeviceResolutionState) int { size := 0 for _, item := range list { @@ -2395,8 +2339,6 @@ func DeviceResolutionStateListSize(list []DeviceResolutionState) int { return size } -// 'DeviceAbsCalibState' struct definition -// Size: 36 type DeviceAbsCalibState struct { ControlId uint16 Len uint16 @@ -2410,7 +2352,7 @@ type DeviceAbsCalibState struct { ButtonThreshold uint32 } -// Struct read DeviceAbsCalibState +// DeviceAbsCalibStateRead reads a byte slice into a DeviceAbsCalibState value. func DeviceAbsCalibStateRead(buf []byte, v *DeviceAbsCalibState) int { b := 0 @@ -2447,7 +2389,7 @@ func DeviceAbsCalibStateRead(buf []byte, v *DeviceAbsCalibState) int { return b } -// Struct list read DeviceAbsCalibState +// DeviceAbsCalibStateReadList reads a byte slice into a list of DeviceAbsCalibState values. func DeviceAbsCalibStateReadList(buf []byte, dest []DeviceAbsCalibState) int { b := 0 for i := 0; i < len(dest); i++ { @@ -2457,7 +2399,7 @@ func DeviceAbsCalibStateReadList(buf []byte, dest []DeviceAbsCalibState) int { return xgb.Pad(b) } -// Struct write DeviceAbsCalibState +// Bytes writes a DeviceAbsCalibState value to a byte slice. func (v DeviceAbsCalibState) Bytes() []byte { buf := make([]byte, 36) b := 0 @@ -2495,7 +2437,7 @@ func (v DeviceAbsCalibState) Bytes() []byte { return buf } -// Write struct list DeviceAbsCalibState +// DeviceAbsCalibStateListBytes writes a list of %s(MISSING) values to a byte slice. func DeviceAbsCalibStateListBytes(buf []byte, list []DeviceAbsCalibState) int { b := 0 var structBytes []byte @@ -2507,8 +2449,6 @@ func DeviceAbsCalibStateListBytes(buf []byte, list []DeviceAbsCalibState) int { return b } -// 'DeviceAbsAreaState' struct definition -// Size: 28 type DeviceAbsAreaState struct { ControlId uint16 Len uint16 @@ -2520,7 +2460,7 @@ type DeviceAbsAreaState struct { Following uint32 } -// Struct read DeviceAbsAreaState +// DeviceAbsAreaStateRead reads a byte slice into a DeviceAbsAreaState value. func DeviceAbsAreaStateRead(buf []byte, v *DeviceAbsAreaState) int { b := 0 @@ -2551,7 +2491,7 @@ func DeviceAbsAreaStateRead(buf []byte, v *DeviceAbsAreaState) int { return b } -// Struct list read DeviceAbsAreaState +// DeviceAbsAreaStateReadList reads a byte slice into a list of DeviceAbsAreaState values. func DeviceAbsAreaStateReadList(buf []byte, dest []DeviceAbsAreaState) int { b := 0 for i := 0; i < len(dest); i++ { @@ -2561,7 +2501,7 @@ func DeviceAbsAreaStateReadList(buf []byte, dest []DeviceAbsAreaState) int { return xgb.Pad(b) } -// Struct write DeviceAbsAreaState +// Bytes writes a DeviceAbsAreaState value to a byte slice. func (v DeviceAbsAreaState) Bytes() []byte { buf := make([]byte, 28) b := 0 @@ -2593,7 +2533,7 @@ func (v DeviceAbsAreaState) Bytes() []byte { return buf } -// Write struct list DeviceAbsAreaState +// DeviceAbsAreaStateListBytes writes a list of %s(MISSING) values to a byte slice. func DeviceAbsAreaStateListBytes(buf []byte, list []DeviceAbsAreaState) int { b := 0 var structBytes []byte @@ -2605,8 +2545,6 @@ func DeviceAbsAreaStateListBytes(buf []byte, list []DeviceAbsAreaState) int { return b } -// 'DeviceCoreState' struct definition -// Size: 8 type DeviceCoreState struct { ControlId uint16 Len uint16 @@ -2615,7 +2553,7 @@ type DeviceCoreState struct { // padding: 2 bytes } -// Struct read DeviceCoreState +// DeviceCoreStateRead reads a byte slice into a DeviceCoreState value. func DeviceCoreStateRead(buf []byte, v *DeviceCoreState) int { b := 0 @@ -2636,7 +2574,7 @@ func DeviceCoreStateRead(buf []byte, v *DeviceCoreState) int { return b } -// Struct list read DeviceCoreState +// DeviceCoreStateReadList reads a byte slice into a list of DeviceCoreState values. func DeviceCoreStateReadList(buf []byte, dest []DeviceCoreState) int { b := 0 for i := 0; i < len(dest); i++ { @@ -2646,7 +2584,7 @@ func DeviceCoreStateReadList(buf []byte, dest []DeviceCoreState) int { return xgb.Pad(b) } -// Struct write DeviceCoreState +// Bytes writes a DeviceCoreState value to a byte slice. func (v DeviceCoreState) Bytes() []byte { buf := make([]byte, 8) b := 0 @@ -2668,7 +2606,7 @@ func (v DeviceCoreState) Bytes() []byte { return buf } -// Write struct list DeviceCoreState +// DeviceCoreStateListBytes writes a list of %s(MISSING) values to a byte slice. func DeviceCoreStateListBytes(buf []byte, list []DeviceCoreState) int { b := 0 var structBytes []byte @@ -2680,8 +2618,6 @@ func DeviceCoreStateListBytes(buf []byte, list []DeviceCoreState) int { return b } -// 'DeviceEnableState' struct definition -// Size: 8 type DeviceEnableState struct { ControlId uint16 Len uint16 @@ -2689,7 +2625,7 @@ type DeviceEnableState struct { // padding: 3 bytes } -// Struct read DeviceEnableState +// DeviceEnableStateRead reads a byte slice into a DeviceEnableState value. func DeviceEnableStateRead(buf []byte, v *DeviceEnableState) int { b := 0 @@ -2707,7 +2643,7 @@ func DeviceEnableStateRead(buf []byte, v *DeviceEnableState) int { return b } -// Struct list read DeviceEnableState +// DeviceEnableStateReadList reads a byte slice into a list of DeviceEnableState values. func DeviceEnableStateReadList(buf []byte, dest []DeviceEnableState) int { b := 0 for i := 0; i < len(dest); i++ { @@ -2717,7 +2653,7 @@ func DeviceEnableStateReadList(buf []byte, dest []DeviceEnableState) int { return xgb.Pad(b) } -// Struct write DeviceEnableState +// Bytes writes a DeviceEnableState value to a byte slice. func (v DeviceEnableState) Bytes() []byte { buf := make([]byte, 8) b := 0 @@ -2736,7 +2672,7 @@ func (v DeviceEnableState) Bytes() []byte { return buf } -// Write struct list DeviceEnableState +// DeviceEnableStateListBytes writes a list of %s(MISSING) values to a byte slice. func DeviceEnableStateListBytes(buf []byte, list []DeviceEnableState) int { b := 0 var structBytes []byte @@ -2748,14 +2684,12 @@ func DeviceEnableStateListBytes(buf []byte, list []DeviceEnableState) int { return b } -// 'DeviceCtl' struct definition -// Size: 4 type DeviceCtl struct { ControlId uint16 Len uint16 } -// Struct read DeviceCtl +// DeviceCtlRead reads a byte slice into a DeviceCtl value. func DeviceCtlRead(buf []byte, v *DeviceCtl) int { b := 0 @@ -2768,7 +2702,7 @@ func DeviceCtlRead(buf []byte, v *DeviceCtl) int { return b } -// Struct list read DeviceCtl +// DeviceCtlReadList reads a byte slice into a list of DeviceCtl values. func DeviceCtlReadList(buf []byte, dest []DeviceCtl) int { b := 0 for i := 0; i < len(dest); i++ { @@ -2778,7 +2712,7 @@ func DeviceCtlReadList(buf []byte, dest []DeviceCtl) int { return xgb.Pad(b) } -// Struct write DeviceCtl +// Bytes writes a DeviceCtl value to a byte slice. func (v DeviceCtl) Bytes() []byte { buf := make([]byte, 4) b := 0 @@ -2792,7 +2726,7 @@ func (v DeviceCtl) Bytes() []byte { return buf } -// Write struct list DeviceCtl +// DeviceCtlListBytes writes a list of %s(MISSING) values to a byte slice. func DeviceCtlListBytes(buf []byte, list []DeviceCtl) int { b := 0 var structBytes []byte @@ -2804,8 +2738,6 @@ func DeviceCtlListBytes(buf []byte, list []DeviceCtl) int { return b } -// 'DeviceResolutionCtl' struct definition -// Size: (6 + xgb.Pad((int(NumValuators) * 4))) type DeviceResolutionCtl struct { ControlId uint16 Len uint16 @@ -2814,7 +2746,7 @@ type DeviceResolutionCtl struct { ResolutionValues []uint32 // size: xgb.Pad((int(NumValuators) * 4)) } -// Struct read DeviceResolutionCtl +// DeviceResolutionCtlRead reads a byte slice into a DeviceResolutionCtl value. func DeviceResolutionCtlRead(buf []byte, v *DeviceResolutionCtl) int { b := 0 @@ -2840,7 +2772,7 @@ func DeviceResolutionCtlRead(buf []byte, v *DeviceResolutionCtl) int { return b } -// Struct list read DeviceResolutionCtl +// DeviceResolutionCtlReadList reads a byte slice into a list of DeviceResolutionCtl values. func DeviceResolutionCtlReadList(buf []byte, dest []DeviceResolutionCtl) int { b := 0 for i := 0; i < len(dest); i++ { @@ -2850,7 +2782,7 @@ func DeviceResolutionCtlReadList(buf []byte, dest []DeviceResolutionCtl) int { return xgb.Pad(b) } -// Struct write DeviceResolutionCtl +// Bytes writes a DeviceResolutionCtl value to a byte slice. func (v DeviceResolutionCtl) Bytes() []byte { buf := make([]byte, (6 + xgb.Pad((int(v.NumValuators) * 4)))) b := 0 @@ -2876,7 +2808,7 @@ func (v DeviceResolutionCtl) Bytes() []byte { return buf } -// Write struct list DeviceResolutionCtl +// DeviceResolutionCtlListBytes writes a list of %s(MISSING) values to a byte slice. func DeviceResolutionCtlListBytes(buf []byte, list []DeviceResolutionCtl) int { b := 0 var structBytes []byte @@ -2888,7 +2820,7 @@ func DeviceResolutionCtlListBytes(buf []byte, list []DeviceResolutionCtl) int { return b } -// Struct list size DeviceResolutionCtl +// DeviceResolutionCtlListSize computes the size (bytes) of a list of DeviceResolutionCtl values. func DeviceResolutionCtlListSize(list []DeviceResolutionCtl) int { size := 0 for _, item := range list { @@ -2897,8 +2829,6 @@ func DeviceResolutionCtlListSize(list []DeviceResolutionCtl) int { return size } -// 'DeviceAbsCalibCtl' struct definition -// Size: 36 type DeviceAbsCalibCtl struct { ControlId uint16 Len uint16 @@ -2912,7 +2842,7 @@ type DeviceAbsCalibCtl struct { ButtonThreshold uint32 } -// Struct read DeviceAbsCalibCtl +// DeviceAbsCalibCtlRead reads a byte slice into a DeviceAbsCalibCtl value. func DeviceAbsCalibCtlRead(buf []byte, v *DeviceAbsCalibCtl) int { b := 0 @@ -2949,7 +2879,7 @@ func DeviceAbsCalibCtlRead(buf []byte, v *DeviceAbsCalibCtl) int { return b } -// Struct list read DeviceAbsCalibCtl +// DeviceAbsCalibCtlReadList reads a byte slice into a list of DeviceAbsCalibCtl values. func DeviceAbsCalibCtlReadList(buf []byte, dest []DeviceAbsCalibCtl) int { b := 0 for i := 0; i < len(dest); i++ { @@ -2959,7 +2889,7 @@ func DeviceAbsCalibCtlReadList(buf []byte, dest []DeviceAbsCalibCtl) int { return xgb.Pad(b) } -// Struct write DeviceAbsCalibCtl +// Bytes writes a DeviceAbsCalibCtl value to a byte slice. func (v DeviceAbsCalibCtl) Bytes() []byte { buf := make([]byte, 36) b := 0 @@ -2997,7 +2927,7 @@ func (v DeviceAbsCalibCtl) Bytes() []byte { return buf } -// Write struct list DeviceAbsCalibCtl +// DeviceAbsCalibCtlListBytes writes a list of %s(MISSING) values to a byte slice. func DeviceAbsCalibCtlListBytes(buf []byte, list []DeviceAbsCalibCtl) int { b := 0 var structBytes []byte @@ -3009,8 +2939,6 @@ func DeviceAbsCalibCtlListBytes(buf []byte, list []DeviceAbsCalibCtl) int { return b } -// 'DeviceAbsAreaCtrl' struct definition -// Size: 28 type DeviceAbsAreaCtrl struct { ControlId uint16 Len uint16 @@ -3022,7 +2950,7 @@ type DeviceAbsAreaCtrl struct { Following uint32 } -// Struct read DeviceAbsAreaCtrl +// DeviceAbsAreaCtrlRead reads a byte slice into a DeviceAbsAreaCtrl value. func DeviceAbsAreaCtrlRead(buf []byte, v *DeviceAbsAreaCtrl) int { b := 0 @@ -3053,7 +2981,7 @@ func DeviceAbsAreaCtrlRead(buf []byte, v *DeviceAbsAreaCtrl) int { return b } -// Struct list read DeviceAbsAreaCtrl +// DeviceAbsAreaCtrlReadList reads a byte slice into a list of DeviceAbsAreaCtrl values. func DeviceAbsAreaCtrlReadList(buf []byte, dest []DeviceAbsAreaCtrl) int { b := 0 for i := 0; i < len(dest); i++ { @@ -3063,7 +2991,7 @@ func DeviceAbsAreaCtrlReadList(buf []byte, dest []DeviceAbsAreaCtrl) int { return xgb.Pad(b) } -// Struct write DeviceAbsAreaCtrl +// Bytes writes a DeviceAbsAreaCtrl value to a byte slice. func (v DeviceAbsAreaCtrl) Bytes() []byte { buf := make([]byte, 28) b := 0 @@ -3095,7 +3023,7 @@ func (v DeviceAbsAreaCtrl) Bytes() []byte { return buf } -// Write struct list DeviceAbsAreaCtrl +// DeviceAbsAreaCtrlListBytes writes a list of %s(MISSING) values to a byte slice. func DeviceAbsAreaCtrlListBytes(buf []byte, list []DeviceAbsAreaCtrl) int { b := 0 var structBytes []byte @@ -3107,8 +3035,6 @@ func DeviceAbsAreaCtrlListBytes(buf []byte, list []DeviceAbsAreaCtrl) int { return b } -// 'DeviceCoreCtrl' struct definition -// Size: 8 type DeviceCoreCtrl struct { ControlId uint16 Len uint16 @@ -3116,7 +3042,7 @@ type DeviceCoreCtrl struct { // padding: 3 bytes } -// Struct read DeviceCoreCtrl +// DeviceCoreCtrlRead reads a byte slice into a DeviceCoreCtrl value. func DeviceCoreCtrlRead(buf []byte, v *DeviceCoreCtrl) int { b := 0 @@ -3134,7 +3060,7 @@ func DeviceCoreCtrlRead(buf []byte, v *DeviceCoreCtrl) int { return b } -// Struct list read DeviceCoreCtrl +// DeviceCoreCtrlReadList reads a byte slice into a list of DeviceCoreCtrl values. func DeviceCoreCtrlReadList(buf []byte, dest []DeviceCoreCtrl) int { b := 0 for i := 0; i < len(dest); i++ { @@ -3144,7 +3070,7 @@ func DeviceCoreCtrlReadList(buf []byte, dest []DeviceCoreCtrl) int { return xgb.Pad(b) } -// Struct write DeviceCoreCtrl +// Bytes writes a DeviceCoreCtrl value to a byte slice. func (v DeviceCoreCtrl) Bytes() []byte { buf := make([]byte, 8) b := 0 @@ -3163,7 +3089,7 @@ func (v DeviceCoreCtrl) Bytes() []byte { return buf } -// Write struct list DeviceCoreCtrl +// DeviceCoreCtrlListBytes writes a list of %s(MISSING) values to a byte slice. func DeviceCoreCtrlListBytes(buf []byte, list []DeviceCoreCtrl) int { b := 0 var structBytes []byte @@ -3175,8 +3101,6 @@ func DeviceCoreCtrlListBytes(buf []byte, list []DeviceCoreCtrl) int { return b } -// 'DeviceEnableCtrl' struct definition -// Size: 8 type DeviceEnableCtrl struct { ControlId uint16 Len uint16 @@ -3184,7 +3108,7 @@ type DeviceEnableCtrl struct { // padding: 3 bytes } -// Struct read DeviceEnableCtrl +// DeviceEnableCtrlRead reads a byte slice into a DeviceEnableCtrl value. func DeviceEnableCtrlRead(buf []byte, v *DeviceEnableCtrl) int { b := 0 @@ -3202,7 +3126,7 @@ func DeviceEnableCtrlRead(buf []byte, v *DeviceEnableCtrl) int { return b } -// Struct list read DeviceEnableCtrl +// DeviceEnableCtrlReadList reads a byte slice into a list of DeviceEnableCtrl values. func DeviceEnableCtrlReadList(buf []byte, dest []DeviceEnableCtrl) int { b := 0 for i := 0; i < len(dest); i++ { @@ -3212,7 +3136,7 @@ func DeviceEnableCtrlReadList(buf []byte, dest []DeviceEnableCtrl) int { return xgb.Pad(b) } -// Struct write DeviceEnableCtrl +// Bytes writes a DeviceEnableCtrl value to a byte slice. func (v DeviceEnableCtrl) Bytes() []byte { buf := make([]byte, 8) b := 0 @@ -3231,7 +3155,7 @@ func (v DeviceEnableCtrl) Bytes() []byte { return buf } -// Write struct list DeviceEnableCtrl +// DeviceEnableCtrlListBytes writes a list of %s(MISSING) values to a byte slice. func DeviceEnableCtrlListBytes(buf []byte, list []DeviceEnableCtrl) int { b := 0 var structBytes []byte @@ -3243,9 +3167,7 @@ func DeviceEnableCtrlListBytes(buf []byte, list []DeviceEnableCtrl) int { return b } -// Event definition DeviceValuator (0) -// Size: 32 - +// DeviceValuator is the event number for a DeviceValuatorEvent. const DeviceValuator = 0 type DeviceValuatorEvent struct { @@ -3257,7 +3179,7 @@ type DeviceValuatorEvent struct { Valuators []int32 // size: 24 } -// Event read DeviceValuator +// DeviceValuatorEventNew constructs a DeviceValuatorEvent value that implements xgb.Event from a byte slice. func DeviceValuatorEventNew(buf []byte) xgb.Event { v := DeviceValuatorEvent{} b := 1 // don't read event number @@ -3287,7 +3209,7 @@ func DeviceValuatorEventNew(buf []byte) xgb.Event { return v } -// Event write DeviceValuator +// Bytes writes a DeviceValuatorEvent value to a byte slice. func (v DeviceValuatorEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -3319,12 +3241,14 @@ func (v DeviceValuatorEvent) Bytes() []byte { return buf } -func (v DeviceValuatorEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the DeviceValuator event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v DeviceValuatorEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of DeviceValuatorEvent. func (v DeviceValuatorEvent) String() string { fieldVals := make([]string, 0, 5) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -3339,9 +3263,7 @@ func init() { xgb.NewExtEventFuncs["XInputExtension"][0] = DeviceValuatorEventNew } -// Event definition DeviceKeyPress (1) -// Size: 32 - +// DeviceKeyPress is the event number for a DeviceKeyPressEvent. const DeviceKeyPress = 1 type DeviceKeyPressEvent struct { @@ -3360,7 +3282,7 @@ type DeviceKeyPressEvent struct { DeviceId byte } -// Event read DeviceKeyPress +// DeviceKeyPressEventNew constructs a DeviceKeyPressEvent value that implements xgb.Event from a byte slice. func DeviceKeyPressEventNew(buf []byte) xgb.Event { v := DeviceKeyPressEvent{} b := 1 // don't read event number @@ -3411,7 +3333,7 @@ func DeviceKeyPressEventNew(buf []byte) xgb.Event { return v } -// Event write DeviceKeyPress +// Bytes writes a DeviceKeyPressEvent value to a byte slice. func (v DeviceKeyPressEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -3465,12 +3387,14 @@ func (v DeviceKeyPressEvent) Bytes() []byte { return buf } -func (v DeviceKeyPressEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the DeviceKeyPress event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v DeviceKeyPressEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of DeviceKeyPressEvent. func (v DeviceKeyPressEvent) String() string { fieldVals := make([]string, 0, 12) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -3493,9 +3417,7 @@ func init() { xgb.NewExtEventFuncs["XInputExtension"][1] = DeviceKeyPressEventNew } -// Event definition FocusIn (6) -// Size: 32 - +// FocusIn is the event number for a FocusInEvent. const FocusIn = 6 type FocusInEvent struct { @@ -3508,7 +3430,7 @@ type FocusInEvent struct { // padding: 18 bytes } -// Event read FocusIn +// FocusInEventNew constructs a FocusInEvent value that implements xgb.Event from a byte slice. func FocusInEventNew(buf []byte) xgb.Event { v := FocusInEvent{} b := 1 // don't read event number @@ -3536,7 +3458,7 @@ func FocusInEventNew(buf []byte) xgb.Event { return v } -// Event write FocusIn +// Bytes writes a FocusInEvent value to a byte slice. func (v FocusInEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -3567,12 +3489,14 @@ func (v FocusInEvent) Bytes() []byte { return buf } -func (v FocusInEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the FocusIn event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v FocusInEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of FocusInEvent. func (v FocusInEvent) String() string { fieldVals := make([]string, 0, 6) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -3588,9 +3512,7 @@ func init() { xgb.NewExtEventFuncs["XInputExtension"][6] = FocusInEventNew } -// Event definition DeviceStateNotify (10) -// Size: 32 - +// DeviceStateNotify is the event number for a DeviceStateNotifyEvent. const DeviceStateNotify = 10 type DeviceStateNotifyEvent struct { @@ -3606,7 +3528,7 @@ type DeviceStateNotifyEvent struct { Valuators []uint32 // size: 12 } -// Event read DeviceStateNotify +// DeviceStateNotifyEventNew constructs a DeviceStateNotifyEvent value that implements xgb.Event from a byte slice. func DeviceStateNotifyEventNew(buf []byte) xgb.Event { v := DeviceStateNotifyEvent{} b := 1 // don't read event number @@ -3650,7 +3572,7 @@ func DeviceStateNotifyEventNew(buf []byte) xgb.Event { return v } -// Event write DeviceStateNotify +// Bytes writes a DeviceStateNotifyEvent value to a byte slice. func (v DeviceStateNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -3694,12 +3616,14 @@ func (v DeviceStateNotifyEvent) Bytes() []byte { return buf } -func (v DeviceStateNotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the DeviceStateNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v DeviceStateNotifyEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of DeviceStateNotifyEvent. func (v DeviceStateNotifyEvent) String() string { fieldVals := make([]string, 0, 9) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -3716,9 +3640,7 @@ func init() { xgb.NewExtEventFuncs["XInputExtension"][10] = DeviceStateNotifyEventNew } -// Event definition DeviceMappingNotify (11) -// Size: 32 - +// DeviceMappingNotify is the event number for a DeviceMappingNotifyEvent. const DeviceMappingNotify = 11 type DeviceMappingNotifyEvent struct { @@ -3732,7 +3654,7 @@ type DeviceMappingNotifyEvent struct { // padding: 20 bytes } -// Event read DeviceMappingNotify +// DeviceMappingNotifyEventNew constructs a DeviceMappingNotifyEvent value that implements xgb.Event from a byte slice. func DeviceMappingNotifyEventNew(buf []byte) xgb.Event { v := DeviceMappingNotifyEvent{} b := 1 // don't read event number @@ -3762,7 +3684,7 @@ func DeviceMappingNotifyEventNew(buf []byte) xgb.Event { return v } -// Event write DeviceMappingNotify +// Bytes writes a DeviceMappingNotifyEvent value to a byte slice. func (v DeviceMappingNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -3795,12 +3717,14 @@ func (v DeviceMappingNotifyEvent) Bytes() []byte { return buf } -func (v DeviceMappingNotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the DeviceMappingNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v DeviceMappingNotifyEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of DeviceMappingNotifyEvent. func (v DeviceMappingNotifyEvent) String() string { fieldVals := make([]string, 0, 7) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -3816,9 +3740,7 @@ func init() { xgb.NewExtEventFuncs["XInputExtension"][11] = DeviceMappingNotifyEventNew } -// Event definition ChangeDeviceNotify (12) -// Size: 32 - +// ChangeDeviceNotify is the event number for a ChangeDeviceNotifyEvent. const ChangeDeviceNotify = 12 type ChangeDeviceNotifyEvent struct { @@ -3829,7 +3751,7 @@ type ChangeDeviceNotifyEvent struct { // padding: 23 bytes } -// Event read ChangeDeviceNotify +// ChangeDeviceNotifyEventNew constructs a ChangeDeviceNotifyEvent value that implements xgb.Event from a byte slice. func ChangeDeviceNotifyEventNew(buf []byte) xgb.Event { v := ChangeDeviceNotifyEvent{} b := 1 // don't read event number @@ -3851,7 +3773,7 @@ func ChangeDeviceNotifyEventNew(buf []byte) xgb.Event { return v } -// Event write ChangeDeviceNotify +// Bytes writes a ChangeDeviceNotifyEvent value to a byte slice. func (v ChangeDeviceNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -3876,12 +3798,14 @@ func (v ChangeDeviceNotifyEvent) Bytes() []byte { return buf } -func (v ChangeDeviceNotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the ChangeDeviceNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v ChangeDeviceNotifyEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of ChangeDeviceNotifyEvent. func (v ChangeDeviceNotifyEvent) String() string { fieldVals := make([]string, 0, 4) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -3895,9 +3819,7 @@ func init() { xgb.NewExtEventFuncs["XInputExtension"][12] = ChangeDeviceNotifyEventNew } -// Event definition DeviceKeyStateNotify (13) -// Size: 32 - +// DeviceKeyStateNotify is the event number for a DeviceKeyStateNotifyEvent. const DeviceKeyStateNotify = 13 type DeviceKeyStateNotifyEvent struct { @@ -3906,7 +3828,7 @@ type DeviceKeyStateNotifyEvent struct { Keys []byte // size: 28 } -// Event read DeviceKeyStateNotify +// DeviceKeyStateNotifyEventNew constructs a DeviceKeyStateNotifyEvent value that implements xgb.Event from a byte slice. func DeviceKeyStateNotifyEventNew(buf []byte) xgb.Event { v := DeviceKeyStateNotifyEvent{} b := 1 // don't read event number @@ -3924,7 +3846,7 @@ func DeviceKeyStateNotifyEventNew(buf []byte) xgb.Event { return v } -// Event write DeviceKeyStateNotify +// Bytes writes a DeviceKeyStateNotifyEvent value to a byte slice. func (v DeviceKeyStateNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -3944,12 +3866,14 @@ func (v DeviceKeyStateNotifyEvent) Bytes() []byte { return buf } -func (v DeviceKeyStateNotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the DeviceKeyStateNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v DeviceKeyStateNotifyEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of DeviceKeyStateNotifyEvent. func (v DeviceKeyStateNotifyEvent) String() string { fieldVals := make([]string, 0, 2) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -3961,9 +3885,7 @@ func init() { xgb.NewExtEventFuncs["XInputExtension"][13] = DeviceKeyStateNotifyEventNew } -// Event definition DeviceButtonStateNotify (14) -// Size: 32 - +// DeviceButtonStateNotify is the event number for a DeviceButtonStateNotifyEvent. const DeviceButtonStateNotify = 14 type DeviceButtonStateNotifyEvent struct { @@ -3972,7 +3894,7 @@ type DeviceButtonStateNotifyEvent struct { Buttons []byte // size: 28 } -// Event read DeviceButtonStateNotify +// DeviceButtonStateNotifyEventNew constructs a DeviceButtonStateNotifyEvent value that implements xgb.Event from a byte slice. func DeviceButtonStateNotifyEventNew(buf []byte) xgb.Event { v := DeviceButtonStateNotifyEvent{} b := 1 // don't read event number @@ -3990,7 +3912,7 @@ func DeviceButtonStateNotifyEventNew(buf []byte) xgb.Event { return v } -// Event write DeviceButtonStateNotify +// Bytes writes a DeviceButtonStateNotifyEvent value to a byte slice. func (v DeviceButtonStateNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -4010,12 +3932,14 @@ func (v DeviceButtonStateNotifyEvent) Bytes() []byte { return buf } -func (v DeviceButtonStateNotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the DeviceButtonStateNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v DeviceButtonStateNotifyEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of DeviceButtonStateNotifyEvent. func (v DeviceButtonStateNotifyEvent) String() string { fieldVals := make([]string, 0, 2) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -4027,9 +3951,7 @@ func init() { xgb.NewExtEventFuncs["XInputExtension"][14] = DeviceButtonStateNotifyEventNew } -// Event definition DevicePresenceNotify (15) -// Size: 32 - +// DevicePresenceNotify is the event number for a DevicePresenceNotifyEvent. const DevicePresenceNotify = 15 type DevicePresenceNotifyEvent struct { @@ -4042,7 +3964,7 @@ type DevicePresenceNotifyEvent struct { // padding: 20 bytes } -// Event read DevicePresenceNotify +// DevicePresenceNotifyEventNew constructs a DevicePresenceNotifyEvent value that implements xgb.Event from a byte slice. func DevicePresenceNotifyEventNew(buf []byte) xgb.Event { v := DevicePresenceNotifyEvent{} b := 1 // don't read event number @@ -4069,7 +3991,7 @@ func DevicePresenceNotifyEventNew(buf []byte) xgb.Event { return v } -// Event write DevicePresenceNotify +// Bytes writes a DevicePresenceNotifyEvent value to a byte slice. func (v DevicePresenceNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -4099,12 +4021,14 @@ func (v DevicePresenceNotifyEvent) Bytes() []byte { return buf } -func (v DevicePresenceNotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the DevicePresenceNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v DevicePresenceNotifyEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of DevicePresenceNotifyEvent. func (v DevicePresenceNotifyEvent) String() string { fieldVals := make([]string, 0, 6) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -4119,22 +4043,24 @@ func init() { xgb.NewExtEventFuncs["XInputExtension"][15] = DevicePresenceNotifyEventNew } -// EventCopy definition DeviceKeyRelease (2) - +// DeviceKeyRelease is the event number for a DeviceKeyReleaseEvent. const DeviceKeyRelease = 2 type DeviceKeyReleaseEvent DeviceKeyPressEvent +// DeviceKeyReleaseEventNew constructs a DeviceKeyReleaseEvent value that implements xgb.Event from a byte slice. func DeviceKeyReleaseEventNew(buf []byte) xgb.Event { return DeviceKeyReleaseEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) } +// Bytes writes a DeviceKeyReleaseEvent value to a byte slice. func (v DeviceKeyReleaseEvent) Bytes() []byte { return DeviceKeyPressEvent(v).Bytes() } -func (v DeviceKeyReleaseEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the DeviceKeyRelease event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v DeviceKeyReleaseEvent) SequenceId() uint16 { return v.Sequence } @@ -4161,22 +4087,24 @@ func init() { xgb.NewExtEventFuncs["XInputExtension"][2] = DeviceKeyReleaseEventNew } -// EventCopy definition DeviceButtonPress (3) - +// DeviceButtonPress is the event number for a DeviceButtonPressEvent. const DeviceButtonPress = 3 type DeviceButtonPressEvent DeviceKeyPressEvent +// DeviceButtonPressEventNew constructs a DeviceButtonPressEvent value that implements xgb.Event from a byte slice. func DeviceButtonPressEventNew(buf []byte) xgb.Event { return DeviceButtonPressEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) } +// Bytes writes a DeviceButtonPressEvent value to a byte slice. func (v DeviceButtonPressEvent) Bytes() []byte { return DeviceKeyPressEvent(v).Bytes() } -func (v DeviceButtonPressEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the DeviceButtonPress event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v DeviceButtonPressEvent) SequenceId() uint16 { return v.Sequence } @@ -4203,22 +4131,24 @@ func init() { xgb.NewExtEventFuncs["XInputExtension"][3] = DeviceButtonPressEventNew } -// EventCopy definition DeviceButtonRelease (4) - +// DeviceButtonRelease is the event number for a DeviceButtonReleaseEvent. const DeviceButtonRelease = 4 type DeviceButtonReleaseEvent DeviceKeyPressEvent +// DeviceButtonReleaseEventNew constructs a DeviceButtonReleaseEvent value that implements xgb.Event from a byte slice. func DeviceButtonReleaseEventNew(buf []byte) xgb.Event { return DeviceButtonReleaseEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) } +// Bytes writes a DeviceButtonReleaseEvent value to a byte slice. func (v DeviceButtonReleaseEvent) Bytes() []byte { return DeviceKeyPressEvent(v).Bytes() } -func (v DeviceButtonReleaseEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the DeviceButtonRelease event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v DeviceButtonReleaseEvent) SequenceId() uint16 { return v.Sequence } @@ -4245,22 +4175,24 @@ func init() { xgb.NewExtEventFuncs["XInputExtension"][4] = DeviceButtonReleaseEventNew } -// EventCopy definition DeviceMotionNotify (5) - +// DeviceMotionNotify is the event number for a DeviceMotionNotifyEvent. const DeviceMotionNotify = 5 type DeviceMotionNotifyEvent DeviceKeyPressEvent +// DeviceMotionNotifyEventNew constructs a DeviceMotionNotifyEvent value that implements xgb.Event from a byte slice. func DeviceMotionNotifyEventNew(buf []byte) xgb.Event { return DeviceMotionNotifyEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) } +// Bytes writes a DeviceMotionNotifyEvent value to a byte slice. func (v DeviceMotionNotifyEvent) Bytes() []byte { return DeviceKeyPressEvent(v).Bytes() } -func (v DeviceMotionNotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the DeviceMotionNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v DeviceMotionNotifyEvent) SequenceId() uint16 { return v.Sequence } @@ -4287,22 +4219,24 @@ func init() { xgb.NewExtEventFuncs["XInputExtension"][5] = DeviceMotionNotifyEventNew } -// EventCopy definition ProximityIn (8) - +// ProximityIn is the event number for a ProximityInEvent. const ProximityIn = 8 type ProximityInEvent DeviceKeyPressEvent +// ProximityInEventNew constructs a ProximityInEvent value that implements xgb.Event from a byte slice. func ProximityInEventNew(buf []byte) xgb.Event { return ProximityInEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) } +// Bytes writes a ProximityInEvent value to a byte slice. func (v ProximityInEvent) Bytes() []byte { return DeviceKeyPressEvent(v).Bytes() } -func (v ProximityInEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the ProximityIn event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v ProximityInEvent) SequenceId() uint16 { return v.Sequence } @@ -4329,22 +4263,24 @@ func init() { xgb.NewExtEventFuncs["XInputExtension"][8] = ProximityInEventNew } -// EventCopy definition ProximityOut (9) - +// ProximityOut is the event number for a ProximityOutEvent. const ProximityOut = 9 type ProximityOutEvent DeviceKeyPressEvent +// ProximityOutEventNew constructs a ProximityOutEvent value that implements xgb.Event from a byte slice. func ProximityOutEventNew(buf []byte) xgb.Event { return ProximityOutEvent(DeviceKeyPressEventNew(buf).(DeviceKeyPressEvent)) } +// Bytes writes a ProximityOutEvent value to a byte slice. func (v ProximityOutEvent) Bytes() []byte { return DeviceKeyPressEvent(v).Bytes() } -func (v ProximityOutEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the ProximityOut event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v ProximityOutEvent) SequenceId() uint16 { return v.Sequence } @@ -4371,22 +4307,24 @@ func init() { xgb.NewExtEventFuncs["XInputExtension"][9] = ProximityOutEventNew } -// EventCopy definition FocusOut (7) - +// FocusOut is the event number for a FocusOutEvent. const FocusOut = 7 type FocusOutEvent FocusInEvent +// FocusOutEventNew constructs a FocusOutEvent value that implements xgb.Event from a byte slice. func FocusOutEventNew(buf []byte) xgb.Event { return FocusOutEvent(FocusInEventNew(buf).(FocusInEvent)) } +// Bytes writes a FocusOutEvent value to a byte slice. func (v FocusOutEvent) Bytes() []byte { return FocusInEvent(v).Bytes() } -func (v FocusOutEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the FocusOut event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v FocusOutEvent) SequenceId() uint16 { return v.Sequence } @@ -4406,9 +4344,7 @@ func init() { xgb.NewExtEventFuncs["XInputExtension"][7] = FocusOutEventNew } -// Error definition Device (0) -// Size: 32 - +// BadDevice is the error number for a BadDevice. const BadDevice = 0 type DeviceError struct { @@ -4416,7 +4352,7 @@ type DeviceError struct { NiceName string } -// Error read Device +// DeviceErrorNew constructs a DeviceError value that implements xgb.Error from a byte slice. func DeviceErrorNew(buf []byte) xgb.Error { v := DeviceError{} v.NiceName = "Device" @@ -4430,8 +4366,8 @@ func DeviceErrorNew(buf []byte) xgb.Error { return v } -func (err DeviceError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadDevice error. +// This is mostly used internally. func (err DeviceError) SequenceId() uint16 { return err.Sequence } @@ -4451,9 +4387,7 @@ func init() { xgb.NewExtErrorFuncs["XInputExtension"][0] = DeviceErrorNew } -// Error definition Event (1) -// Size: 32 - +// BadEvent is the error number for a BadEvent. const BadEvent = 1 type EventError struct { @@ -4461,7 +4395,7 @@ type EventError struct { NiceName string } -// Error read Event +// EventErrorNew constructs a EventError value that implements xgb.Error from a byte slice. func EventErrorNew(buf []byte) xgb.Error { v := EventError{} v.NiceName = "Event" @@ -4475,8 +4409,8 @@ func EventErrorNew(buf []byte) xgb.Error { return v } -func (err EventError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadEvent error. +// This is mostly used internally. func (err EventError) SequenceId() uint16 { return err.Sequence } @@ -4496,9 +4430,7 @@ func init() { xgb.NewExtErrorFuncs["XInputExtension"][1] = EventErrorNew } -// Error definition Mode (2) -// Size: 32 - +// BadMode is the error number for a BadMode. const BadMode = 2 type ModeError struct { @@ -4506,7 +4438,7 @@ type ModeError struct { NiceName string } -// Error read Mode +// ModeErrorNew constructs a ModeError value that implements xgb.Error from a byte slice. func ModeErrorNew(buf []byte) xgb.Error { v := ModeError{} v.NiceName = "Mode" @@ -4520,8 +4452,8 @@ func ModeErrorNew(buf []byte) xgb.Error { return v } -func (err ModeError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadMode error. +// This is mostly used internally. func (err ModeError) SequenceId() uint16 { return err.Sequence } @@ -4541,9 +4473,7 @@ func init() { xgb.NewExtErrorFuncs["XInputExtension"][2] = ModeErrorNew } -// Error definition DeviceBusy (3) -// Size: 32 - +// BadDeviceBusy is the error number for a BadDeviceBusy. const BadDeviceBusy = 3 type DeviceBusyError struct { @@ -4551,7 +4481,7 @@ type DeviceBusyError struct { NiceName string } -// Error read DeviceBusy +// DeviceBusyErrorNew constructs a DeviceBusyError value that implements xgb.Error from a byte slice. func DeviceBusyErrorNew(buf []byte) xgb.Error { v := DeviceBusyError{} v.NiceName = "DeviceBusy" @@ -4565,8 +4495,8 @@ func DeviceBusyErrorNew(buf []byte) xgb.Error { return v } -func (err DeviceBusyError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadDeviceBusy error. +// This is mostly used internally. func (err DeviceBusyError) SequenceId() uint16 { return err.Sequence } @@ -4586,9 +4516,7 @@ func init() { xgb.NewExtErrorFuncs["XInputExtension"][3] = DeviceBusyErrorNew } -// Error definition Class (4) -// Size: 32 - +// BadClass is the error number for a BadClass. const BadClass = 4 type ClassError struct { @@ -4596,7 +4524,7 @@ type ClassError struct { NiceName string } -// Error read Class +// ClassErrorNew constructs a ClassError value that implements xgb.Error from a byte slice. func ClassErrorNew(buf []byte) xgb.Error { v := ClassError{} v.NiceName = "Class" @@ -4610,8 +4538,8 @@ func ClassErrorNew(buf []byte) xgb.Error { return v } -func (err ClassError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadClass error. +// This is mostly used internally. func (err ClassError) SequenceId() uint16 { return err.Sequence } @@ -4631,29 +4559,31 @@ func init() { xgb.NewExtErrorFuncs["XInputExtension"][4] = ClassErrorNew } -// Request GetExtensionVersion -// size: xgb.Pad((8 + xgb.Pad((int(NameLen) * 1)))) +// GetExtensionVersionCookie is a cookie used only for GetExtensionVersion requests. type GetExtensionVersionCookie struct { *xgb.Cookie } +// GetExtensionVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetExtensionVersionCookie.Reply() func GetExtensionVersion(c *xgb.Conn, NameLen uint16, Name string) GetExtensionVersionCookie { cookie := c.NewCookie(true, true) c.NewRequest(getExtensionVersionRequest(c, NameLen, Name), cookie) return GetExtensionVersionCookie{cookie} } +// GetExtensionVersionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetExtensionVersionUnchecked(c *xgb.Conn, NameLen uint16, Name string) GetExtensionVersionCookie { cookie := c.NewCookie(false, true) c.NewRequest(getExtensionVersionRequest(c, NameLen, Name), cookie) return GetExtensionVersionCookie{cookie} } -// Request reply for GetExtensionVersion -// size: 32 +// GetExtensionVersionReply represents the data returned from a GetExtensionVersion request. type GetExtensionVersionReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes ServerMajor uint16 ServerMinor uint16 @@ -4661,7 +4591,7 @@ type GetExtensionVersionReply struct { // padding: 19 bytes } -// Waits and reads reply data from request GetExtensionVersion +// Reply blocks and returns the reply data for a GetExtensionVersion request. func (cook GetExtensionVersionCookie) Reply() (*GetExtensionVersionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -4673,7 +4603,7 @@ func (cook GetExtensionVersionCookie) Reply() (*GetExtensionVersionReply, error) return getExtensionVersionReply(buf), nil } -// Read reply into structure from buffer for GetExtensionVersion +// getExtensionVersionReply reads a byte slice into a GetExtensionVersionReply value. func getExtensionVersionReply(buf []byte) *GetExtensionVersionReply { v := new(GetExtensionVersionReply) b := 1 // skip reply determinant @@ -4705,6 +4635,7 @@ func getExtensionVersionReply(buf []byte) *GetExtensionVersionReply { } // Write request to wire for GetExtensionVersion +// getExtensionVersionRequest writes a GetExtensionVersion request to a byte slice. func getExtensionVersionRequest(c *xgb.Conn, NameLen uint16, Name string) []byte { size := xgb.Pad((8 + xgb.Pad((int(NameLen) * 1)))) b := 0 @@ -4730,36 +4661,38 @@ func getExtensionVersionRequest(c *xgb.Conn, NameLen uint16, Name string) []byte return buf } -// Request ListInputDevices -// size: 4 +// ListInputDevicesCookie is a cookie used only for ListInputDevices requests. type ListInputDevicesCookie struct { *xgb.Cookie } +// ListInputDevices sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListInputDevicesCookie.Reply() func ListInputDevices(c *xgb.Conn) ListInputDevicesCookie { cookie := c.NewCookie(true, true) c.NewRequest(listInputDevicesRequest(c), cookie) return ListInputDevicesCookie{cookie} } +// ListInputDevicesUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ListInputDevicesUnchecked(c *xgb.Conn) ListInputDevicesCookie { cookie := c.NewCookie(false, true) c.NewRequest(listInputDevicesRequest(c), cookie) return ListInputDevicesCookie{cookie} } -// Request reply for ListInputDevices -// size: (32 + xgb.Pad((int(DevicesLen) * 8))) +// ListInputDevicesReply represents the data returned from a ListInputDevices request. type ListInputDevicesReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes DevicesLen byte // padding: 23 bytes Devices []DeviceInfo // size: xgb.Pad((int(DevicesLen) * 8)) } -// Waits and reads reply data from request ListInputDevices +// Reply blocks and returns the reply data for a ListInputDevices request. func (cook ListInputDevicesCookie) Reply() (*ListInputDevicesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -4771,7 +4704,7 @@ func (cook ListInputDevicesCookie) Reply() (*ListInputDevicesReply, error) { return listInputDevicesReply(buf), nil } -// Read reply into structure from buffer for ListInputDevices +// listInputDevicesReply reads a byte slice into a ListInputDevicesReply value. func listInputDevicesReply(buf []byte) *ListInputDevicesReply { v := new(ListInputDevicesReply) b := 1 // skip reply determinant @@ -4796,6 +4729,7 @@ func listInputDevicesReply(buf []byte) *ListInputDevicesReply { } // Write request to wire for ListInputDevices +// listInputDevicesRequest writes a ListInputDevices request to a byte slice. func listInputDevicesRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -4813,36 +4747,38 @@ func listInputDevicesRequest(c *xgb.Conn) []byte { return buf } -// Request OpenDevice -// size: 8 +// OpenDeviceCookie is a cookie used only for OpenDevice requests. type OpenDeviceCookie struct { *xgb.Cookie } +// OpenDevice sends a checked request. +// If an error occurs, it will be returned with the reply by calling OpenDeviceCookie.Reply() func OpenDevice(c *xgb.Conn, DeviceId byte) OpenDeviceCookie { cookie := c.NewCookie(true, true) c.NewRequest(openDeviceRequest(c, DeviceId), cookie) return OpenDeviceCookie{cookie} } +// OpenDeviceUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func OpenDeviceUnchecked(c *xgb.Conn, DeviceId byte) OpenDeviceCookie { cookie := c.NewCookie(false, true) c.NewRequest(openDeviceRequest(c, DeviceId), cookie) return OpenDeviceCookie{cookie} } -// Request reply for OpenDevice -// size: (32 + xgb.Pad((int(NumClasses) * 2))) +// OpenDeviceReply represents the data returned from a OpenDevice request. type OpenDeviceReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes NumClasses byte // padding: 23 bytes ClassInfo []InputClassInfo // size: xgb.Pad((int(NumClasses) * 2)) } -// Waits and reads reply data from request OpenDevice +// Reply blocks and returns the reply data for a OpenDevice request. func (cook OpenDeviceCookie) Reply() (*OpenDeviceReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -4854,7 +4790,7 @@ func (cook OpenDeviceCookie) Reply() (*OpenDeviceReply, error) { return openDeviceReply(buf), nil } -// Read reply into structure from buffer for OpenDevice +// openDeviceReply reads a byte slice into a OpenDeviceReply value. func openDeviceReply(buf []byte) *OpenDeviceReply { v := new(OpenDeviceReply) b := 1 // skip reply determinant @@ -4879,6 +4815,7 @@ func openDeviceReply(buf []byte) *OpenDeviceReply { } // Write request to wire for OpenDevice +// openDeviceRequest writes a OpenDevice request to a byte slice. func openDeviceRequest(c *xgb.Conn, DeviceId byte) []byte { size := 8 b := 0 @@ -4901,30 +4838,35 @@ func openDeviceRequest(c *xgb.Conn, DeviceId byte) []byte { return buf } -// Request CloseDevice -// size: 8 +// CloseDeviceCookie is a cookie used only for CloseDevice requests. type CloseDeviceCookie struct { *xgb.Cookie } -// Write request to wire for CloseDevice +// CloseDevice sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CloseDevice(c *xgb.Conn, DeviceId byte) CloseDeviceCookie { cookie := c.NewCookie(false, false) c.NewRequest(closeDeviceRequest(c, DeviceId), cookie) return CloseDeviceCookie{cookie} } +// CloseDeviceChecked sends a checked request. +// If an error occurs, it can be retrieved using CloseDeviceCookie.Check() func CloseDeviceChecked(c *xgb.Conn, DeviceId byte) CloseDeviceCookie { cookie := c.NewCookie(true, false) c.NewRequest(closeDeviceRequest(c, DeviceId), cookie) return CloseDeviceCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CloseDeviceCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CloseDevice +// closeDeviceRequest writes a CloseDevice request to a byte slice. func closeDeviceRequest(c *xgb.Conn, DeviceId byte) []byte { size := 8 b := 0 @@ -4947,35 +4889,37 @@ func closeDeviceRequest(c *xgb.Conn, DeviceId byte) []byte { return buf } -// Request SetDeviceMode -// size: 8 +// SetDeviceModeCookie is a cookie used only for SetDeviceMode requests. type SetDeviceModeCookie struct { *xgb.Cookie } +// SetDeviceMode sends a checked request. +// If an error occurs, it will be returned with the reply by calling SetDeviceModeCookie.Reply() func SetDeviceMode(c *xgb.Conn, DeviceId byte, Mode byte) SetDeviceModeCookie { cookie := c.NewCookie(true, true) c.NewRequest(setDeviceModeRequest(c, DeviceId, Mode), cookie) return SetDeviceModeCookie{cookie} } +// SetDeviceModeUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetDeviceModeUnchecked(c *xgb.Conn, DeviceId byte, Mode byte) SetDeviceModeCookie { cookie := c.NewCookie(false, true) c.NewRequest(setDeviceModeRequest(c, DeviceId, Mode), cookie) return SetDeviceModeCookie{cookie} } -// Request reply for SetDeviceMode -// size: 32 +// SetDeviceModeReply represents the data returned from a SetDeviceMode request. type SetDeviceModeReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Status byte // padding: 23 bytes } -// Waits and reads reply data from request SetDeviceMode +// Reply blocks and returns the reply data for a SetDeviceMode request. func (cook SetDeviceModeCookie) Reply() (*SetDeviceModeReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -4987,7 +4931,7 @@ func (cook SetDeviceModeCookie) Reply() (*SetDeviceModeReply, error) { return setDeviceModeReply(buf), nil } -// Read reply into structure from buffer for SetDeviceMode +// setDeviceModeReply reads a byte slice into a SetDeviceModeReply value. func setDeviceModeReply(buf []byte) *SetDeviceModeReply { v := new(SetDeviceModeReply) b := 1 // skip reply determinant @@ -5009,6 +4953,7 @@ func setDeviceModeReply(buf []byte) *SetDeviceModeReply { } // Write request to wire for SetDeviceMode +// setDeviceModeRequest writes a SetDeviceMode request to a byte slice. func setDeviceModeRequest(c *xgb.Conn, DeviceId byte, Mode byte) []byte { size := 8 b := 0 @@ -5034,30 +4979,35 @@ func setDeviceModeRequest(c *xgb.Conn, DeviceId byte, Mode byte) []byte { return buf } -// Request SelectExtensionEvent -// size: xgb.Pad((12 + xgb.Pad((int(NumClasses) * 4)))) +// SelectExtensionEventCookie is a cookie used only for SelectExtensionEvent requests. type SelectExtensionEventCookie struct { *xgb.Cookie } -// Write request to wire for SelectExtensionEvent +// SelectExtensionEvent sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SelectExtensionEvent(c *xgb.Conn, Window xproto.Window, NumClasses uint16, Classes []EventClass) SelectExtensionEventCookie { cookie := c.NewCookie(false, false) c.NewRequest(selectExtensionEventRequest(c, Window, NumClasses, Classes), cookie) return SelectExtensionEventCookie{cookie} } +// SelectExtensionEventChecked sends a checked request. +// If an error occurs, it can be retrieved using SelectExtensionEventCookie.Check() func SelectExtensionEventChecked(c *xgb.Conn, Window xproto.Window, NumClasses uint16, Classes []EventClass) SelectExtensionEventCookie { cookie := c.NewCookie(true, false) c.NewRequest(selectExtensionEventRequest(c, Window, NumClasses, Classes), cookie) return SelectExtensionEventCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SelectExtensionEventCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SelectExtensionEvent +// selectExtensionEventRequest writes a SelectExtensionEvent request to a byte slice. func selectExtensionEventRequest(c *xgb.Conn, Window xproto.Window, NumClasses uint16, Classes []EventClass) []byte { size := xgb.Pad((12 + xgb.Pad((int(NumClasses) * 4)))) b := 0 @@ -5089,29 +5039,31 @@ func selectExtensionEventRequest(c *xgb.Conn, Window xproto.Window, NumClasses u return buf } -// Request GetSelectedExtensionEvents -// size: 8 +// GetSelectedExtensionEventsCookie is a cookie used only for GetSelectedExtensionEvents requests. type GetSelectedExtensionEventsCookie struct { *xgb.Cookie } +// GetSelectedExtensionEvents sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetSelectedExtensionEventsCookie.Reply() func GetSelectedExtensionEvents(c *xgb.Conn, Window xproto.Window) GetSelectedExtensionEventsCookie { cookie := c.NewCookie(true, true) c.NewRequest(getSelectedExtensionEventsRequest(c, Window), cookie) return GetSelectedExtensionEventsCookie{cookie} } +// GetSelectedExtensionEventsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetSelectedExtensionEventsUnchecked(c *xgb.Conn, Window xproto.Window) GetSelectedExtensionEventsCookie { cookie := c.NewCookie(false, true) c.NewRequest(getSelectedExtensionEventsRequest(c, Window), cookie) return GetSelectedExtensionEventsCookie{cookie} } -// Request reply for GetSelectedExtensionEvents -// size: ((32 + xgb.Pad((int(NumThisClasses) * 4))) + xgb.Pad((int(NumAllClasses) * 4))) +// GetSelectedExtensionEventsReply represents the data returned from a GetSelectedExtensionEvents request. type GetSelectedExtensionEventsReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes NumThisClasses uint16 NumAllClasses uint16 @@ -5120,7 +5072,7 @@ type GetSelectedExtensionEventsReply struct { AllClasses []EventClass // size: xgb.Pad((int(NumAllClasses) * 4)) } -// Waits and reads reply data from request GetSelectedExtensionEvents +// Reply blocks and returns the reply data for a GetSelectedExtensionEvents request. func (cook GetSelectedExtensionEventsCookie) Reply() (*GetSelectedExtensionEventsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -5132,7 +5084,7 @@ func (cook GetSelectedExtensionEventsCookie) Reply() (*GetSelectedExtensionEvent return getSelectedExtensionEventsReply(buf), nil } -// Read reply into structure from buffer for GetSelectedExtensionEvents +// getSelectedExtensionEventsReply reads a byte slice into a GetSelectedExtensionEventsReply value. func getSelectedExtensionEventsReply(buf []byte) *GetSelectedExtensionEventsReply { v := new(GetSelectedExtensionEventsReply) b := 1 // skip reply determinant @@ -5171,6 +5123,7 @@ func getSelectedExtensionEventsReply(buf []byte) *GetSelectedExtensionEventsRepl } // Write request to wire for GetSelectedExtensionEvents +// getSelectedExtensionEventsRequest writes a GetSelectedExtensionEvents request to a byte slice. func getSelectedExtensionEventsRequest(c *xgb.Conn, Window xproto.Window) []byte { size := 8 b := 0 @@ -5191,30 +5144,35 @@ func getSelectedExtensionEventsRequest(c *xgb.Conn, Window xproto.Window) []byte return buf } -// Request ChangeDeviceDontPropagateList -// size: xgb.Pad((12 + xgb.Pad((int(NumClasses) * 4)))) +// ChangeDeviceDontPropagateListCookie is a cookie used only for ChangeDeviceDontPropagateList requests. type ChangeDeviceDontPropagateListCookie struct { *xgb.Cookie } -// Write request to wire for ChangeDeviceDontPropagateList +// ChangeDeviceDontPropagateList sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ChangeDeviceDontPropagateList(c *xgb.Conn, Window xproto.Window, NumClasses uint16, Mode byte, Classes []EventClass) ChangeDeviceDontPropagateListCookie { cookie := c.NewCookie(false, false) c.NewRequest(changeDeviceDontPropagateListRequest(c, Window, NumClasses, Mode, Classes), cookie) return ChangeDeviceDontPropagateListCookie{cookie} } +// ChangeDeviceDontPropagateListChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeDeviceDontPropagateListCookie.Check() func ChangeDeviceDontPropagateListChecked(c *xgb.Conn, Window xproto.Window, NumClasses uint16, Mode byte, Classes []EventClass) ChangeDeviceDontPropagateListCookie { cookie := c.NewCookie(true, false) c.NewRequest(changeDeviceDontPropagateListRequest(c, Window, NumClasses, Mode, Classes), cookie) return ChangeDeviceDontPropagateListCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook ChangeDeviceDontPropagateListCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ChangeDeviceDontPropagateList +// changeDeviceDontPropagateListRequest writes a ChangeDeviceDontPropagateList request to a byte slice. func changeDeviceDontPropagateListRequest(c *xgb.Conn, Window xproto.Window, NumClasses uint16, Mode byte, Classes []EventClass) []byte { size := xgb.Pad((12 + xgb.Pad((int(NumClasses) * 4)))) b := 0 @@ -5249,36 +5207,38 @@ func changeDeviceDontPropagateListRequest(c *xgb.Conn, Window xproto.Window, Num return buf } -// Request GetDeviceDontPropagateList -// size: 8 +// GetDeviceDontPropagateListCookie is a cookie used only for GetDeviceDontPropagateList requests. type GetDeviceDontPropagateListCookie struct { *xgb.Cookie } +// GetDeviceDontPropagateList sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetDeviceDontPropagateListCookie.Reply() func GetDeviceDontPropagateList(c *xgb.Conn, Window xproto.Window) GetDeviceDontPropagateListCookie { cookie := c.NewCookie(true, true) c.NewRequest(getDeviceDontPropagateListRequest(c, Window), cookie) return GetDeviceDontPropagateListCookie{cookie} } +// GetDeviceDontPropagateListUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetDeviceDontPropagateListUnchecked(c *xgb.Conn, Window xproto.Window) GetDeviceDontPropagateListCookie { cookie := c.NewCookie(false, true) c.NewRequest(getDeviceDontPropagateListRequest(c, Window), cookie) return GetDeviceDontPropagateListCookie{cookie} } -// Request reply for GetDeviceDontPropagateList -// size: (32 + xgb.Pad((int(NumClasses) * 4))) +// GetDeviceDontPropagateListReply represents the data returned from a GetDeviceDontPropagateList request. type GetDeviceDontPropagateListReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes NumClasses uint16 // padding: 22 bytes Classes []EventClass // size: xgb.Pad((int(NumClasses) * 4)) } -// Waits and reads reply data from request GetDeviceDontPropagateList +// Reply blocks and returns the reply data for a GetDeviceDontPropagateList request. func (cook GetDeviceDontPropagateListCookie) Reply() (*GetDeviceDontPropagateListReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -5290,7 +5250,7 @@ func (cook GetDeviceDontPropagateListCookie) Reply() (*GetDeviceDontPropagateLis return getDeviceDontPropagateListReply(buf), nil } -// Read reply into structure from buffer for GetDeviceDontPropagateList +// getDeviceDontPropagateListReply reads a byte slice into a GetDeviceDontPropagateListReply value. func getDeviceDontPropagateListReply(buf []byte) *GetDeviceDontPropagateListReply { v := new(GetDeviceDontPropagateListReply) b := 1 // skip reply determinant @@ -5319,6 +5279,7 @@ func getDeviceDontPropagateListReply(buf []byte) *GetDeviceDontPropagateListRepl } // Write request to wire for GetDeviceDontPropagateList +// getDeviceDontPropagateListRequest writes a GetDeviceDontPropagateList request to a byte slice. func getDeviceDontPropagateListRequest(c *xgb.Conn, Window xproto.Window) []byte { size := 8 b := 0 @@ -5339,29 +5300,31 @@ func getDeviceDontPropagateListRequest(c *xgb.Conn, Window xproto.Window) []byte return buf } -// Request GetDeviceMotionEvents -// size: 16 +// GetDeviceMotionEventsCookie is a cookie used only for GetDeviceMotionEvents requests. type GetDeviceMotionEventsCookie struct { *xgb.Cookie } +// GetDeviceMotionEvents sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetDeviceMotionEventsCookie.Reply() func GetDeviceMotionEvents(c *xgb.Conn, Start xproto.Timestamp, Stop xproto.Timestamp, DeviceId byte) GetDeviceMotionEventsCookie { cookie := c.NewCookie(true, true) c.NewRequest(getDeviceMotionEventsRequest(c, Start, Stop, DeviceId), cookie) return GetDeviceMotionEventsCookie{cookie} } +// GetDeviceMotionEventsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetDeviceMotionEventsUnchecked(c *xgb.Conn, Start xproto.Timestamp, Stop xproto.Timestamp, DeviceId byte) GetDeviceMotionEventsCookie { cookie := c.NewCookie(false, true) c.NewRequest(getDeviceMotionEventsRequest(c, Start, Stop, DeviceId), cookie) return GetDeviceMotionEventsCookie{cookie} } -// Request reply for GetDeviceMotionEvents -// size: 32 +// GetDeviceMotionEventsReply represents the data returned from a GetDeviceMotionEvents request. type GetDeviceMotionEventsReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes NumCoords uint32 NumAxes byte @@ -5369,7 +5332,7 @@ type GetDeviceMotionEventsReply struct { // padding: 18 bytes } -// Waits and reads reply data from request GetDeviceMotionEvents +// Reply blocks and returns the reply data for a GetDeviceMotionEvents request. func (cook GetDeviceMotionEventsCookie) Reply() (*GetDeviceMotionEventsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -5381,7 +5344,7 @@ func (cook GetDeviceMotionEventsCookie) Reply() (*GetDeviceMotionEventsReply, er return getDeviceMotionEventsReply(buf), nil } -// Read reply into structure from buffer for GetDeviceMotionEvents +// getDeviceMotionEventsReply reads a byte slice into a GetDeviceMotionEventsReply value. func getDeviceMotionEventsReply(buf []byte) *GetDeviceMotionEventsReply { v := new(GetDeviceMotionEventsReply) b := 1 // skip reply determinant @@ -5409,6 +5372,7 @@ func getDeviceMotionEventsReply(buf []byte) *GetDeviceMotionEventsReply { } // Write request to wire for GetDeviceMotionEvents +// getDeviceMotionEventsRequest writes a GetDeviceMotionEvents request to a byte slice. func getDeviceMotionEventsRequest(c *xgb.Conn, Start xproto.Timestamp, Stop xproto.Timestamp, DeviceId byte) []byte { size := 16 b := 0 @@ -5435,35 +5399,37 @@ func getDeviceMotionEventsRequest(c *xgb.Conn, Start xproto.Timestamp, Stop xpro return buf } -// Request ChangeKeyboardDevice -// size: 8 +// ChangeKeyboardDeviceCookie is a cookie used only for ChangeKeyboardDevice requests. type ChangeKeyboardDeviceCookie struct { *xgb.Cookie } +// ChangeKeyboardDevice sends a checked request. +// If an error occurs, it will be returned with the reply by calling ChangeKeyboardDeviceCookie.Reply() func ChangeKeyboardDevice(c *xgb.Conn, DeviceId byte) ChangeKeyboardDeviceCookie { cookie := c.NewCookie(true, true) c.NewRequest(changeKeyboardDeviceRequest(c, DeviceId), cookie) return ChangeKeyboardDeviceCookie{cookie} } +// ChangeKeyboardDeviceUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ChangeKeyboardDeviceUnchecked(c *xgb.Conn, DeviceId byte) ChangeKeyboardDeviceCookie { cookie := c.NewCookie(false, true) c.NewRequest(changeKeyboardDeviceRequest(c, DeviceId), cookie) return ChangeKeyboardDeviceCookie{cookie} } -// Request reply for ChangeKeyboardDevice -// size: 32 +// ChangeKeyboardDeviceReply represents the data returned from a ChangeKeyboardDevice request. type ChangeKeyboardDeviceReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Status byte // padding: 23 bytes } -// Waits and reads reply data from request ChangeKeyboardDevice +// Reply blocks and returns the reply data for a ChangeKeyboardDevice request. func (cook ChangeKeyboardDeviceCookie) Reply() (*ChangeKeyboardDeviceReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -5475,7 +5441,7 @@ func (cook ChangeKeyboardDeviceCookie) Reply() (*ChangeKeyboardDeviceReply, erro return changeKeyboardDeviceReply(buf), nil } -// Read reply into structure from buffer for ChangeKeyboardDevice +// changeKeyboardDeviceReply reads a byte slice into a ChangeKeyboardDeviceReply value. func changeKeyboardDeviceReply(buf []byte) *ChangeKeyboardDeviceReply { v := new(ChangeKeyboardDeviceReply) b := 1 // skip reply determinant @@ -5497,6 +5463,7 @@ func changeKeyboardDeviceReply(buf []byte) *ChangeKeyboardDeviceReply { } // Write request to wire for ChangeKeyboardDevice +// changeKeyboardDeviceRequest writes a ChangeKeyboardDevice request to a byte slice. func changeKeyboardDeviceRequest(c *xgb.Conn, DeviceId byte) []byte { size := 8 b := 0 @@ -5519,35 +5486,37 @@ func changeKeyboardDeviceRequest(c *xgb.Conn, DeviceId byte) []byte { return buf } -// Request ChangePointerDevice -// size: 8 +// ChangePointerDeviceCookie is a cookie used only for ChangePointerDevice requests. type ChangePointerDeviceCookie struct { *xgb.Cookie } +// ChangePointerDevice sends a checked request. +// If an error occurs, it will be returned with the reply by calling ChangePointerDeviceCookie.Reply() func ChangePointerDevice(c *xgb.Conn, XAxis byte, YAxis byte, DeviceId byte) ChangePointerDeviceCookie { cookie := c.NewCookie(true, true) c.NewRequest(changePointerDeviceRequest(c, XAxis, YAxis, DeviceId), cookie) return ChangePointerDeviceCookie{cookie} } +// ChangePointerDeviceUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ChangePointerDeviceUnchecked(c *xgb.Conn, XAxis byte, YAxis byte, DeviceId byte) ChangePointerDeviceCookie { cookie := c.NewCookie(false, true) c.NewRequest(changePointerDeviceRequest(c, XAxis, YAxis, DeviceId), cookie) return ChangePointerDeviceCookie{cookie} } -// Request reply for ChangePointerDevice -// size: 32 +// ChangePointerDeviceReply represents the data returned from a ChangePointerDevice request. type ChangePointerDeviceReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Status byte // padding: 23 bytes } -// Waits and reads reply data from request ChangePointerDevice +// Reply blocks and returns the reply data for a ChangePointerDevice request. func (cook ChangePointerDeviceCookie) Reply() (*ChangePointerDeviceReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -5559,7 +5528,7 @@ func (cook ChangePointerDeviceCookie) Reply() (*ChangePointerDeviceReply, error) return changePointerDeviceReply(buf), nil } -// Read reply into structure from buffer for ChangePointerDevice +// changePointerDeviceReply reads a byte slice into a ChangePointerDeviceReply value. func changePointerDeviceReply(buf []byte) *ChangePointerDeviceReply { v := new(ChangePointerDeviceReply) b := 1 // skip reply determinant @@ -5581,6 +5550,7 @@ func changePointerDeviceReply(buf []byte) *ChangePointerDeviceReply { } // Write request to wire for ChangePointerDevice +// changePointerDeviceRequest writes a ChangePointerDevice request to a byte slice. func changePointerDeviceRequest(c *xgb.Conn, XAxis byte, YAxis byte, DeviceId byte) []byte { size := 8 b := 0 @@ -5609,35 +5579,37 @@ func changePointerDeviceRequest(c *xgb.Conn, XAxis byte, YAxis byte, DeviceId by return buf } -// Request GrabDevice -// size: xgb.Pad((20 + xgb.Pad((int(NumClasses) * 4)))) +// GrabDeviceCookie is a cookie used only for GrabDevice requests. type GrabDeviceCookie struct { *xgb.Cookie } +// GrabDevice sends a checked request. +// If an error occurs, it will be returned with the reply by calling GrabDeviceCookie.Reply() func GrabDevice(c *xgb.Conn, GrabWindow xproto.Window, Time xproto.Timestamp, NumClasses uint16, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, DeviceId byte, Classes []EventClass) GrabDeviceCookie { cookie := c.NewCookie(true, true) c.NewRequest(grabDeviceRequest(c, GrabWindow, Time, NumClasses, ThisDeviceMode, OtherDeviceMode, OwnerEvents, DeviceId, Classes), cookie) return GrabDeviceCookie{cookie} } +// GrabDeviceUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GrabDeviceUnchecked(c *xgb.Conn, GrabWindow xproto.Window, Time xproto.Timestamp, NumClasses uint16, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, DeviceId byte, Classes []EventClass) GrabDeviceCookie { cookie := c.NewCookie(false, true) c.NewRequest(grabDeviceRequest(c, GrabWindow, Time, NumClasses, ThisDeviceMode, OtherDeviceMode, OwnerEvents, DeviceId, Classes), cookie) return GrabDeviceCookie{cookie} } -// Request reply for GrabDevice -// size: 32 +// GrabDeviceReply represents the data returned from a GrabDevice request. type GrabDeviceReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Status byte // padding: 23 bytes } -// Waits and reads reply data from request GrabDevice +// Reply blocks and returns the reply data for a GrabDevice request. func (cook GrabDeviceCookie) Reply() (*GrabDeviceReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -5649,7 +5621,7 @@ func (cook GrabDeviceCookie) Reply() (*GrabDeviceReply, error) { return grabDeviceReply(buf), nil } -// Read reply into structure from buffer for GrabDevice +// grabDeviceReply reads a byte slice into a GrabDeviceReply value. func grabDeviceReply(buf []byte) *GrabDeviceReply { v := new(GrabDeviceReply) b := 1 // skip reply determinant @@ -5671,6 +5643,7 @@ func grabDeviceReply(buf []byte) *GrabDeviceReply { } // Write request to wire for GrabDevice +// grabDeviceRequest writes a GrabDevice request to a byte slice. func grabDeviceRequest(c *xgb.Conn, GrabWindow xproto.Window, Time xproto.Timestamp, NumClasses uint16, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, DeviceId byte, Classes []EventClass) []byte { size := xgb.Pad((20 + xgb.Pad((int(NumClasses) * 4)))) b := 0 @@ -5721,30 +5694,35 @@ func grabDeviceRequest(c *xgb.Conn, GrabWindow xproto.Window, Time xproto.Timest return buf } -// Request UngrabDevice -// size: 12 +// UngrabDeviceCookie is a cookie used only for UngrabDevice requests. type UngrabDeviceCookie struct { *xgb.Cookie } -// Write request to wire for UngrabDevice +// UngrabDevice sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func UngrabDevice(c *xgb.Conn, Time xproto.Timestamp, DeviceId byte) UngrabDeviceCookie { cookie := c.NewCookie(false, false) c.NewRequest(ungrabDeviceRequest(c, Time, DeviceId), cookie) return UngrabDeviceCookie{cookie} } +// UngrabDeviceChecked sends a checked request. +// If an error occurs, it can be retrieved using UngrabDeviceCookie.Check() func UngrabDeviceChecked(c *xgb.Conn, Time xproto.Timestamp, DeviceId byte) UngrabDeviceCookie { cookie := c.NewCookie(true, false) c.NewRequest(ungrabDeviceRequest(c, Time, DeviceId), cookie) return UngrabDeviceCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook UngrabDeviceCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for UngrabDevice +// ungrabDeviceRequest writes a UngrabDevice request to a byte slice. func ungrabDeviceRequest(c *xgb.Conn, Time xproto.Timestamp, DeviceId byte) []byte { size := 12 b := 0 @@ -5768,30 +5746,35 @@ func ungrabDeviceRequest(c *xgb.Conn, Time xproto.Timestamp, DeviceId byte) []by return buf } -// Request GrabDeviceKey -// size: xgb.Pad((20 + xgb.Pad((int(NumClasses) * 4)))) +// GrabDeviceKeyCookie is a cookie used only for GrabDeviceKey requests. type GrabDeviceKeyCookie struct { *xgb.Cookie } -// Write request to wire for GrabDeviceKey +// GrabDeviceKey sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GrabDeviceKey(c *xgb.Conn, GrabWindow xproto.Window, NumClasses uint16, Modifiers uint16, ModifierDevice byte, GrabbedDevice byte, Key byte, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, Classes []EventClass) GrabDeviceKeyCookie { cookie := c.NewCookie(false, false) c.NewRequest(grabDeviceKeyRequest(c, GrabWindow, NumClasses, Modifiers, ModifierDevice, GrabbedDevice, Key, ThisDeviceMode, OtherDeviceMode, OwnerEvents, Classes), cookie) return GrabDeviceKeyCookie{cookie} } +// GrabDeviceKeyChecked sends a checked request. +// If an error occurs, it can be retrieved using GrabDeviceKeyCookie.Check() func GrabDeviceKeyChecked(c *xgb.Conn, GrabWindow xproto.Window, NumClasses uint16, Modifiers uint16, ModifierDevice byte, GrabbedDevice byte, Key byte, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, Classes []EventClass) GrabDeviceKeyCookie { cookie := c.NewCookie(true, false) c.NewRequest(grabDeviceKeyRequest(c, GrabWindow, NumClasses, Modifiers, ModifierDevice, GrabbedDevice, Key, ThisDeviceMode, OtherDeviceMode, OwnerEvents, Classes), cookie) return GrabDeviceKeyCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook GrabDeviceKeyCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for GrabDeviceKey +// grabDeviceKeyRequest writes a GrabDeviceKey request to a byte slice. func grabDeviceKeyRequest(c *xgb.Conn, GrabWindow xproto.Window, NumClasses uint16, Modifiers uint16, ModifierDevice byte, GrabbedDevice byte, Key byte, ThisDeviceMode byte, OtherDeviceMode byte, OwnerEvents bool, Classes []EventClass) []byte { size := xgb.Pad((20 + xgb.Pad((int(NumClasses) * 4)))) b := 0 @@ -5848,30 +5831,35 @@ func grabDeviceKeyRequest(c *xgb.Conn, GrabWindow xproto.Window, NumClasses uint return buf } -// Request UngrabDeviceKey -// size: 16 +// UngrabDeviceKeyCookie is a cookie used only for UngrabDeviceKey requests. type UngrabDeviceKeyCookie struct { *xgb.Cookie } -// Write request to wire for UngrabDeviceKey +// UngrabDeviceKey sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func UngrabDeviceKey(c *xgb.Conn, GrabWindow xproto.Window, Modifiers uint16, ModifierDevice byte, Key byte, GrabbedDevice byte) UngrabDeviceKeyCookie { cookie := c.NewCookie(false, false) c.NewRequest(ungrabDeviceKeyRequest(c, GrabWindow, Modifiers, ModifierDevice, Key, GrabbedDevice), cookie) return UngrabDeviceKeyCookie{cookie} } +// UngrabDeviceKeyChecked sends a checked request. +// If an error occurs, it can be retrieved using UngrabDeviceKeyCookie.Check() func UngrabDeviceKeyChecked(c *xgb.Conn, GrabWindow xproto.Window, Modifiers uint16, ModifierDevice byte, Key byte, GrabbedDevice byte) UngrabDeviceKeyCookie { cookie := c.NewCookie(true, false) c.NewRequest(ungrabDeviceKeyRequest(c, GrabWindow, Modifiers, ModifierDevice, Key, GrabbedDevice), cookie) return UngrabDeviceKeyCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook UngrabDeviceKeyCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for UngrabDeviceKey +// ungrabDeviceKeyRequest writes a UngrabDeviceKey request to a byte slice. func ungrabDeviceKeyRequest(c *xgb.Conn, GrabWindow xproto.Window, Modifiers uint16, ModifierDevice byte, Key byte, GrabbedDevice byte) []byte { size := 16 b := 0 @@ -5904,30 +5892,35 @@ func ungrabDeviceKeyRequest(c *xgb.Conn, GrabWindow xproto.Window, Modifiers uin return buf } -// Request GrabDeviceButton -// size: xgb.Pad((20 + xgb.Pad((int(NumClasses) * 4)))) +// GrabDeviceButtonCookie is a cookie used only for GrabDeviceButton requests. type GrabDeviceButtonCookie struct { *xgb.Cookie } -// Write request to wire for GrabDeviceButton +// GrabDeviceButton sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GrabDeviceButton(c *xgb.Conn, GrabWindow xproto.Window, GrabbedDevice byte, ModifierDevice byte, NumClasses uint16, Modifiers uint16, ThisDeviceMode byte, OtherDeviceMode byte, Button byte, OwnerEvents byte, Classes []EventClass) GrabDeviceButtonCookie { cookie := c.NewCookie(false, false) c.NewRequest(grabDeviceButtonRequest(c, GrabWindow, GrabbedDevice, ModifierDevice, NumClasses, Modifiers, ThisDeviceMode, OtherDeviceMode, Button, OwnerEvents, Classes), cookie) return GrabDeviceButtonCookie{cookie} } +// GrabDeviceButtonChecked sends a checked request. +// If an error occurs, it can be retrieved using GrabDeviceButtonCookie.Check() func GrabDeviceButtonChecked(c *xgb.Conn, GrabWindow xproto.Window, GrabbedDevice byte, ModifierDevice byte, NumClasses uint16, Modifiers uint16, ThisDeviceMode byte, OtherDeviceMode byte, Button byte, OwnerEvents byte, Classes []EventClass) GrabDeviceButtonCookie { cookie := c.NewCookie(true, false) c.NewRequest(grabDeviceButtonRequest(c, GrabWindow, GrabbedDevice, ModifierDevice, NumClasses, Modifiers, ThisDeviceMode, OtherDeviceMode, Button, OwnerEvents, Classes), cookie) return GrabDeviceButtonCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook GrabDeviceButtonCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for GrabDeviceButton +// grabDeviceButtonRequest writes a GrabDeviceButton request to a byte slice. func grabDeviceButtonRequest(c *xgb.Conn, GrabWindow xproto.Window, GrabbedDevice byte, ModifierDevice byte, NumClasses uint16, Modifiers uint16, ThisDeviceMode byte, OtherDeviceMode byte, Button byte, OwnerEvents byte, Classes []EventClass) []byte { size := xgb.Pad((20 + xgb.Pad((int(NumClasses) * 4)))) b := 0 @@ -5980,30 +5973,35 @@ func grabDeviceButtonRequest(c *xgb.Conn, GrabWindow xproto.Window, GrabbedDevic return buf } -// Request UngrabDeviceButton -// size: 16 +// UngrabDeviceButtonCookie is a cookie used only for UngrabDeviceButton requests. type UngrabDeviceButtonCookie struct { *xgb.Cookie } -// Write request to wire for UngrabDeviceButton +// UngrabDeviceButton sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func UngrabDeviceButton(c *xgb.Conn, GrabWindow xproto.Window, Modifiers uint16, ModifierDevice byte, Button byte, GrabbedDevice byte) UngrabDeviceButtonCookie { cookie := c.NewCookie(false, false) c.NewRequest(ungrabDeviceButtonRequest(c, GrabWindow, Modifiers, ModifierDevice, Button, GrabbedDevice), cookie) return UngrabDeviceButtonCookie{cookie} } +// UngrabDeviceButtonChecked sends a checked request. +// If an error occurs, it can be retrieved using UngrabDeviceButtonCookie.Check() func UngrabDeviceButtonChecked(c *xgb.Conn, GrabWindow xproto.Window, Modifiers uint16, ModifierDevice byte, Button byte, GrabbedDevice byte) UngrabDeviceButtonCookie { cookie := c.NewCookie(true, false) c.NewRequest(ungrabDeviceButtonRequest(c, GrabWindow, Modifiers, ModifierDevice, Button, GrabbedDevice), cookie) return UngrabDeviceButtonCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook UngrabDeviceButtonCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for UngrabDeviceButton +// ungrabDeviceButtonRequest writes a UngrabDeviceButton request to a byte slice. func ungrabDeviceButtonRequest(c *xgb.Conn, GrabWindow xproto.Window, Modifiers uint16, ModifierDevice byte, Button byte, GrabbedDevice byte) []byte { size := 16 b := 0 @@ -6036,30 +6034,35 @@ func ungrabDeviceButtonRequest(c *xgb.Conn, GrabWindow xproto.Window, Modifiers return buf } -// Request AllowDeviceEvents -// size: 12 +// AllowDeviceEventsCookie is a cookie used only for AllowDeviceEvents requests. type AllowDeviceEventsCookie struct { *xgb.Cookie } -// Write request to wire for AllowDeviceEvents +// AllowDeviceEvents sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func AllowDeviceEvents(c *xgb.Conn, Time xproto.Timestamp, Mode byte, DeviceId byte) AllowDeviceEventsCookie { cookie := c.NewCookie(false, false) c.NewRequest(allowDeviceEventsRequest(c, Time, Mode, DeviceId), cookie) return AllowDeviceEventsCookie{cookie} } +// AllowDeviceEventsChecked sends a checked request. +// If an error occurs, it can be retrieved using AllowDeviceEventsCookie.Check() func AllowDeviceEventsChecked(c *xgb.Conn, Time xproto.Timestamp, Mode byte, DeviceId byte) AllowDeviceEventsCookie { cookie := c.NewCookie(true, false) c.NewRequest(allowDeviceEventsRequest(c, Time, Mode, DeviceId), cookie) return AllowDeviceEventsCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook AllowDeviceEventsCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for AllowDeviceEvents +// allowDeviceEventsRequest writes a AllowDeviceEvents request to a byte slice. func allowDeviceEventsRequest(c *xgb.Conn, Time xproto.Timestamp, Mode byte, DeviceId byte) []byte { size := 12 b := 0 @@ -6086,29 +6089,31 @@ func allowDeviceEventsRequest(c *xgb.Conn, Time xproto.Timestamp, Mode byte, Dev return buf } -// Request GetDeviceFocus -// size: 8 +// GetDeviceFocusCookie is a cookie used only for GetDeviceFocus requests. type GetDeviceFocusCookie struct { *xgb.Cookie } +// GetDeviceFocus sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetDeviceFocusCookie.Reply() func GetDeviceFocus(c *xgb.Conn, DeviceId byte) GetDeviceFocusCookie { cookie := c.NewCookie(true, true) c.NewRequest(getDeviceFocusRequest(c, DeviceId), cookie) return GetDeviceFocusCookie{cookie} } +// GetDeviceFocusUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetDeviceFocusUnchecked(c *xgb.Conn, DeviceId byte) GetDeviceFocusCookie { cookie := c.NewCookie(false, true) c.NewRequest(getDeviceFocusRequest(c, DeviceId), cookie) return GetDeviceFocusCookie{cookie} } -// Request reply for GetDeviceFocus -// size: 32 +// GetDeviceFocusReply represents the data returned from a GetDeviceFocus request. type GetDeviceFocusReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Focus xproto.Window Time xproto.Timestamp @@ -6116,7 +6121,7 @@ type GetDeviceFocusReply struct { // padding: 15 bytes } -// Waits and reads reply data from request GetDeviceFocus +// Reply blocks and returns the reply data for a GetDeviceFocus request. func (cook GetDeviceFocusCookie) Reply() (*GetDeviceFocusReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -6128,7 +6133,7 @@ func (cook GetDeviceFocusCookie) Reply() (*GetDeviceFocusReply, error) { return getDeviceFocusReply(buf), nil } -// Read reply into structure from buffer for GetDeviceFocus +// getDeviceFocusReply reads a byte slice into a GetDeviceFocusReply value. func getDeviceFocusReply(buf []byte) *GetDeviceFocusReply { v := new(GetDeviceFocusReply) b := 1 // skip reply determinant @@ -6156,6 +6161,7 @@ func getDeviceFocusReply(buf []byte) *GetDeviceFocusReply { } // Write request to wire for GetDeviceFocus +// getDeviceFocusRequest writes a GetDeviceFocus request to a byte slice. func getDeviceFocusRequest(c *xgb.Conn, DeviceId byte) []byte { size := 8 b := 0 @@ -6178,30 +6184,35 @@ func getDeviceFocusRequest(c *xgb.Conn, DeviceId byte) []byte { return buf } -// Request SetDeviceFocus -// size: 16 +// SetDeviceFocusCookie is a cookie used only for SetDeviceFocus requests. type SetDeviceFocusCookie struct { *xgb.Cookie } -// Write request to wire for SetDeviceFocus +// SetDeviceFocus sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetDeviceFocus(c *xgb.Conn, Focus xproto.Window, Time xproto.Timestamp, RevertTo byte, DeviceId byte) SetDeviceFocusCookie { cookie := c.NewCookie(false, false) c.NewRequest(setDeviceFocusRequest(c, Focus, Time, RevertTo, DeviceId), cookie) return SetDeviceFocusCookie{cookie} } +// SetDeviceFocusChecked sends a checked request. +// If an error occurs, it can be retrieved using SetDeviceFocusCookie.Check() func SetDeviceFocusChecked(c *xgb.Conn, Focus xproto.Window, Time xproto.Timestamp, RevertTo byte, DeviceId byte) SetDeviceFocusCookie { cookie := c.NewCookie(true, false) c.NewRequest(setDeviceFocusRequest(c, Focus, Time, RevertTo, DeviceId), cookie) return SetDeviceFocusCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetDeviceFocusCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetDeviceFocus +// setDeviceFocusRequest writes a SetDeviceFocus request to a byte slice. func setDeviceFocusRequest(c *xgb.Conn, Focus xproto.Window, Time xproto.Timestamp, RevertTo byte, DeviceId byte) []byte { size := 16 b := 0 @@ -6231,35 +6242,37 @@ func setDeviceFocusRequest(c *xgb.Conn, Focus xproto.Window, Time xproto.Timesta return buf } -// Request GetFeedbackControl -// size: 8 +// GetFeedbackControlCookie is a cookie used only for GetFeedbackControl requests. type GetFeedbackControlCookie struct { *xgb.Cookie } +// GetFeedbackControl sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetFeedbackControlCookie.Reply() func GetFeedbackControl(c *xgb.Conn, DeviceId byte) GetFeedbackControlCookie { cookie := c.NewCookie(true, true) c.NewRequest(getFeedbackControlRequest(c, DeviceId), cookie) return GetFeedbackControlCookie{cookie} } +// GetFeedbackControlUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetFeedbackControlUnchecked(c *xgb.Conn, DeviceId byte) GetFeedbackControlCookie { cookie := c.NewCookie(false, true) c.NewRequest(getFeedbackControlRequest(c, DeviceId), cookie) return GetFeedbackControlCookie{cookie} } -// Request reply for GetFeedbackControl -// size: 32 +// GetFeedbackControlReply represents the data returned from a GetFeedbackControl request. type GetFeedbackControlReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes NumFeedback uint16 // padding: 22 bytes } -// Waits and reads reply data from request GetFeedbackControl +// Reply blocks and returns the reply data for a GetFeedbackControl request. func (cook GetFeedbackControlCookie) Reply() (*GetFeedbackControlReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -6271,7 +6284,7 @@ func (cook GetFeedbackControlCookie) Reply() (*GetFeedbackControlReply, error) { return getFeedbackControlReply(buf), nil } -// Read reply into structure from buffer for GetFeedbackControl +// getFeedbackControlReply reads a byte slice into a GetFeedbackControlReply value. func getFeedbackControlReply(buf []byte) *GetFeedbackControlReply { v := new(GetFeedbackControlReply) b := 1 // skip reply determinant @@ -6293,6 +6306,7 @@ func getFeedbackControlReply(buf []byte) *GetFeedbackControlReply { } // Write request to wire for GetFeedbackControl +// getFeedbackControlRequest writes a GetFeedbackControl request to a byte slice. func getFeedbackControlRequest(c *xgb.Conn, DeviceId byte) []byte { size := 8 b := 0 @@ -6315,36 +6329,38 @@ func getFeedbackControlRequest(c *xgb.Conn, DeviceId byte) []byte { return buf } -// Request GetDeviceKeyMapping -// size: 8 +// GetDeviceKeyMappingCookie is a cookie used only for GetDeviceKeyMapping requests. type GetDeviceKeyMappingCookie struct { *xgb.Cookie } +// GetDeviceKeyMapping sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetDeviceKeyMappingCookie.Reply() func GetDeviceKeyMapping(c *xgb.Conn, DeviceId byte, FirstKeycode KeyCode, Count byte) GetDeviceKeyMappingCookie { cookie := c.NewCookie(true, true) c.NewRequest(getDeviceKeyMappingRequest(c, DeviceId, FirstKeycode, Count), cookie) return GetDeviceKeyMappingCookie{cookie} } +// GetDeviceKeyMappingUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetDeviceKeyMappingUnchecked(c *xgb.Conn, DeviceId byte, FirstKeycode KeyCode, Count byte) GetDeviceKeyMappingCookie { cookie := c.NewCookie(false, true) c.NewRequest(getDeviceKeyMappingRequest(c, DeviceId, FirstKeycode, Count), cookie) return GetDeviceKeyMappingCookie{cookie} } -// Request reply for GetDeviceKeyMapping -// size: (32 + xgb.Pad((int(Length) * 4))) +// GetDeviceKeyMappingReply represents the data returned from a GetDeviceKeyMapping request. type GetDeviceKeyMappingReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes KeysymsPerKeycode byte // padding: 23 bytes Keysyms []xproto.Keysym // size: xgb.Pad((int(Length) * 4)) } -// Waits and reads reply data from request GetDeviceKeyMapping +// Reply blocks and returns the reply data for a GetDeviceKeyMapping request. func (cook GetDeviceKeyMappingCookie) Reply() (*GetDeviceKeyMappingReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -6356,7 +6372,7 @@ func (cook GetDeviceKeyMappingCookie) Reply() (*GetDeviceKeyMappingReply, error) return getDeviceKeyMappingReply(buf), nil } -// Read reply into structure from buffer for GetDeviceKeyMapping +// getDeviceKeyMappingReply reads a byte slice into a GetDeviceKeyMappingReply value. func getDeviceKeyMappingReply(buf []byte) *GetDeviceKeyMappingReply { v := new(GetDeviceKeyMappingReply) b := 1 // skip reply determinant @@ -6385,6 +6401,7 @@ func getDeviceKeyMappingReply(buf []byte) *GetDeviceKeyMappingReply { } // Write request to wire for GetDeviceKeyMapping +// getDeviceKeyMappingRequest writes a GetDeviceKeyMapping request to a byte slice. func getDeviceKeyMappingRequest(c *xgb.Conn, DeviceId byte, FirstKeycode KeyCode, Count byte) []byte { size := 8 b := 0 @@ -6411,30 +6428,35 @@ func getDeviceKeyMappingRequest(c *xgb.Conn, DeviceId byte, FirstKeycode KeyCode return buf } -// Request ChangeDeviceKeyMapping -// size: xgb.Pad((8 + xgb.Pad(((int(KeycodeCount) * int(KeysymsPerKeycode)) * 4)))) +// ChangeDeviceKeyMappingCookie is a cookie used only for ChangeDeviceKeyMapping requests. type ChangeDeviceKeyMappingCookie struct { *xgb.Cookie } -// Write request to wire for ChangeDeviceKeyMapping +// ChangeDeviceKeyMapping sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ChangeDeviceKeyMapping(c *xgb.Conn, DeviceId byte, FirstKeycode KeyCode, KeysymsPerKeycode byte, KeycodeCount byte, Keysyms []xproto.Keysym) ChangeDeviceKeyMappingCookie { cookie := c.NewCookie(false, false) c.NewRequest(changeDeviceKeyMappingRequest(c, DeviceId, FirstKeycode, KeysymsPerKeycode, KeycodeCount, Keysyms), cookie) return ChangeDeviceKeyMappingCookie{cookie} } +// ChangeDeviceKeyMappingChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeDeviceKeyMappingCookie.Check() func ChangeDeviceKeyMappingChecked(c *xgb.Conn, DeviceId byte, FirstKeycode KeyCode, KeysymsPerKeycode byte, KeycodeCount byte, Keysyms []xproto.Keysym) ChangeDeviceKeyMappingCookie { cookie := c.NewCookie(true, false) c.NewRequest(changeDeviceKeyMappingRequest(c, DeviceId, FirstKeycode, KeysymsPerKeycode, KeycodeCount, Keysyms), cookie) return ChangeDeviceKeyMappingCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook ChangeDeviceKeyMappingCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ChangeDeviceKeyMapping +// changeDeviceKeyMappingRequest writes a ChangeDeviceKeyMapping request to a byte slice. func changeDeviceKeyMappingRequest(c *xgb.Conn, DeviceId byte, FirstKeycode KeyCode, KeysymsPerKeycode byte, KeycodeCount byte, Keysyms []xproto.Keysym) []byte { size := xgb.Pad((8 + xgb.Pad(((int(KeycodeCount) * int(KeysymsPerKeycode)) * 4)))) b := 0 @@ -6470,36 +6492,38 @@ func changeDeviceKeyMappingRequest(c *xgb.Conn, DeviceId byte, FirstKeycode KeyC return buf } -// Request GetDeviceModifierMapping -// size: 8 +// GetDeviceModifierMappingCookie is a cookie used only for GetDeviceModifierMapping requests. type GetDeviceModifierMappingCookie struct { *xgb.Cookie } +// GetDeviceModifierMapping sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetDeviceModifierMappingCookie.Reply() func GetDeviceModifierMapping(c *xgb.Conn, DeviceId byte) GetDeviceModifierMappingCookie { cookie := c.NewCookie(true, true) c.NewRequest(getDeviceModifierMappingRequest(c, DeviceId), cookie) return GetDeviceModifierMappingCookie{cookie} } +// GetDeviceModifierMappingUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetDeviceModifierMappingUnchecked(c *xgb.Conn, DeviceId byte) GetDeviceModifierMappingCookie { cookie := c.NewCookie(false, true) c.NewRequest(getDeviceModifierMappingRequest(c, DeviceId), cookie) return GetDeviceModifierMappingCookie{cookie} } -// Request reply for GetDeviceModifierMapping -// size: (32 + xgb.Pad(((int(KeycodesPerModifier) * 8) * 1))) +// GetDeviceModifierMappingReply represents the data returned from a GetDeviceModifierMapping request. type GetDeviceModifierMappingReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes KeycodesPerModifier byte // padding: 23 bytes Keymaps []byte // size: xgb.Pad(((int(KeycodesPerModifier) * 8) * 1)) } -// Waits and reads reply data from request GetDeviceModifierMapping +// Reply blocks and returns the reply data for a GetDeviceModifierMapping request. func (cook GetDeviceModifierMappingCookie) Reply() (*GetDeviceModifierMappingReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -6511,7 +6535,7 @@ func (cook GetDeviceModifierMappingCookie) Reply() (*GetDeviceModifierMappingRep return getDeviceModifierMappingReply(buf), nil } -// Read reply into structure from buffer for GetDeviceModifierMapping +// getDeviceModifierMappingReply reads a byte slice into a GetDeviceModifierMappingReply value. func getDeviceModifierMappingReply(buf []byte) *GetDeviceModifierMappingReply { v := new(GetDeviceModifierMappingReply) b := 1 // skip reply determinant @@ -6537,6 +6561,7 @@ func getDeviceModifierMappingReply(buf []byte) *GetDeviceModifierMappingReply { } // Write request to wire for GetDeviceModifierMapping +// getDeviceModifierMappingRequest writes a GetDeviceModifierMapping request to a byte slice. func getDeviceModifierMappingRequest(c *xgb.Conn, DeviceId byte) []byte { size := 8 b := 0 @@ -6559,35 +6584,37 @@ func getDeviceModifierMappingRequest(c *xgb.Conn, DeviceId byte) []byte { return buf } -// Request SetDeviceModifierMapping -// size: xgb.Pad((7 + xgb.Pad(((int(KeycodesPerModifier) * 8) * 1)))) +// SetDeviceModifierMappingCookie is a cookie used only for SetDeviceModifierMapping requests. type SetDeviceModifierMappingCookie struct { *xgb.Cookie } +// SetDeviceModifierMapping sends a checked request. +// If an error occurs, it will be returned with the reply by calling SetDeviceModifierMappingCookie.Reply() func SetDeviceModifierMapping(c *xgb.Conn, DeviceId byte, KeycodesPerModifier byte, Keymaps []byte) SetDeviceModifierMappingCookie { cookie := c.NewCookie(true, true) c.NewRequest(setDeviceModifierMappingRequest(c, DeviceId, KeycodesPerModifier, Keymaps), cookie) return SetDeviceModifierMappingCookie{cookie} } +// SetDeviceModifierMappingUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetDeviceModifierMappingUnchecked(c *xgb.Conn, DeviceId byte, KeycodesPerModifier byte, Keymaps []byte) SetDeviceModifierMappingCookie { cookie := c.NewCookie(false, true) c.NewRequest(setDeviceModifierMappingRequest(c, DeviceId, KeycodesPerModifier, Keymaps), cookie) return SetDeviceModifierMappingCookie{cookie} } -// Request reply for SetDeviceModifierMapping -// size: 32 +// SetDeviceModifierMappingReply represents the data returned from a SetDeviceModifierMapping request. type SetDeviceModifierMappingReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Status byte // padding: 23 bytes } -// Waits and reads reply data from request SetDeviceModifierMapping +// Reply blocks and returns the reply data for a SetDeviceModifierMapping request. func (cook SetDeviceModifierMappingCookie) Reply() (*SetDeviceModifierMappingReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -6599,7 +6626,7 @@ func (cook SetDeviceModifierMappingCookie) Reply() (*SetDeviceModifierMappingRep return setDeviceModifierMappingReply(buf), nil } -// Read reply into structure from buffer for SetDeviceModifierMapping +// setDeviceModifierMappingReply reads a byte slice into a SetDeviceModifierMappingReply value. func setDeviceModifierMappingReply(buf []byte) *SetDeviceModifierMappingReply { v := new(SetDeviceModifierMappingReply) b := 1 // skip reply determinant @@ -6621,6 +6648,7 @@ func setDeviceModifierMappingReply(buf []byte) *SetDeviceModifierMappingReply { } // Write request to wire for SetDeviceModifierMapping +// setDeviceModifierMappingRequest writes a SetDeviceModifierMapping request to a byte slice. func setDeviceModifierMappingRequest(c *xgb.Conn, DeviceId byte, KeycodesPerModifier byte, Keymaps []byte) []byte { size := xgb.Pad((7 + xgb.Pad(((int(KeycodesPerModifier) * 8) * 1)))) b := 0 @@ -6649,36 +6677,38 @@ func setDeviceModifierMappingRequest(c *xgb.Conn, DeviceId byte, KeycodesPerModi return buf } -// Request GetDeviceButtonMapping -// size: 8 +// GetDeviceButtonMappingCookie is a cookie used only for GetDeviceButtonMapping requests. type GetDeviceButtonMappingCookie struct { *xgb.Cookie } +// GetDeviceButtonMapping sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetDeviceButtonMappingCookie.Reply() func GetDeviceButtonMapping(c *xgb.Conn, DeviceId byte) GetDeviceButtonMappingCookie { cookie := c.NewCookie(true, true) c.NewRequest(getDeviceButtonMappingRequest(c, DeviceId), cookie) return GetDeviceButtonMappingCookie{cookie} } +// GetDeviceButtonMappingUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetDeviceButtonMappingUnchecked(c *xgb.Conn, DeviceId byte) GetDeviceButtonMappingCookie { cookie := c.NewCookie(false, true) c.NewRequest(getDeviceButtonMappingRequest(c, DeviceId), cookie) return GetDeviceButtonMappingCookie{cookie} } -// Request reply for GetDeviceButtonMapping -// size: (32 + xgb.Pad((int(MapSize) * 1))) +// GetDeviceButtonMappingReply represents the data returned from a GetDeviceButtonMapping request. type GetDeviceButtonMappingReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes MapSize byte // padding: 23 bytes Map []byte // size: xgb.Pad((int(MapSize) * 1)) } -// Waits and reads reply data from request GetDeviceButtonMapping +// Reply blocks and returns the reply data for a GetDeviceButtonMapping request. func (cook GetDeviceButtonMappingCookie) Reply() (*GetDeviceButtonMappingReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -6690,7 +6720,7 @@ func (cook GetDeviceButtonMappingCookie) Reply() (*GetDeviceButtonMappingReply, return getDeviceButtonMappingReply(buf), nil } -// Read reply into structure from buffer for GetDeviceButtonMapping +// getDeviceButtonMappingReply reads a byte slice into a GetDeviceButtonMappingReply value. func getDeviceButtonMappingReply(buf []byte) *GetDeviceButtonMappingReply { v := new(GetDeviceButtonMappingReply) b := 1 // skip reply determinant @@ -6716,6 +6746,7 @@ func getDeviceButtonMappingReply(buf []byte) *GetDeviceButtonMappingReply { } // Write request to wire for GetDeviceButtonMapping +// getDeviceButtonMappingRequest writes a GetDeviceButtonMapping request to a byte slice. func getDeviceButtonMappingRequest(c *xgb.Conn, DeviceId byte) []byte { size := 8 b := 0 @@ -6738,35 +6769,37 @@ func getDeviceButtonMappingRequest(c *xgb.Conn, DeviceId byte) []byte { return buf } -// Request SetDeviceButtonMapping -// size: xgb.Pad((8 + xgb.Pad((int(MapSize) * 1)))) +// SetDeviceButtonMappingCookie is a cookie used only for SetDeviceButtonMapping requests. type SetDeviceButtonMappingCookie struct { *xgb.Cookie } +// SetDeviceButtonMapping sends a checked request. +// If an error occurs, it will be returned with the reply by calling SetDeviceButtonMappingCookie.Reply() func SetDeviceButtonMapping(c *xgb.Conn, DeviceId byte, MapSize byte, Map []byte) SetDeviceButtonMappingCookie { cookie := c.NewCookie(true, true) c.NewRequest(setDeviceButtonMappingRequest(c, DeviceId, MapSize, Map), cookie) return SetDeviceButtonMappingCookie{cookie} } +// SetDeviceButtonMappingUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetDeviceButtonMappingUnchecked(c *xgb.Conn, DeviceId byte, MapSize byte, Map []byte) SetDeviceButtonMappingCookie { cookie := c.NewCookie(false, true) c.NewRequest(setDeviceButtonMappingRequest(c, DeviceId, MapSize, Map), cookie) return SetDeviceButtonMappingCookie{cookie} } -// Request reply for SetDeviceButtonMapping -// size: 32 +// SetDeviceButtonMappingReply represents the data returned from a SetDeviceButtonMapping request. type SetDeviceButtonMappingReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Status byte // padding: 23 bytes } -// Waits and reads reply data from request SetDeviceButtonMapping +// Reply blocks and returns the reply data for a SetDeviceButtonMapping request. func (cook SetDeviceButtonMappingCookie) Reply() (*SetDeviceButtonMappingReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -6778,7 +6811,7 @@ func (cook SetDeviceButtonMappingCookie) Reply() (*SetDeviceButtonMappingReply, return setDeviceButtonMappingReply(buf), nil } -// Read reply into structure from buffer for SetDeviceButtonMapping +// setDeviceButtonMappingReply reads a byte slice into a SetDeviceButtonMappingReply value. func setDeviceButtonMappingReply(buf []byte) *SetDeviceButtonMappingReply { v := new(SetDeviceButtonMappingReply) b := 1 // skip reply determinant @@ -6800,6 +6833,7 @@ func setDeviceButtonMappingReply(buf []byte) *SetDeviceButtonMappingReply { } // Write request to wire for SetDeviceButtonMapping +// setDeviceButtonMappingRequest writes a SetDeviceButtonMapping request to a byte slice. func setDeviceButtonMappingRequest(c *xgb.Conn, DeviceId byte, MapSize byte, Map []byte) []byte { size := xgb.Pad((8 + xgb.Pad((int(MapSize) * 1)))) b := 0 @@ -6828,35 +6862,37 @@ func setDeviceButtonMappingRequest(c *xgb.Conn, DeviceId byte, MapSize byte, Map return buf } -// Request QueryDeviceState -// size: 8 +// QueryDeviceStateCookie is a cookie used only for QueryDeviceState requests. type QueryDeviceStateCookie struct { *xgb.Cookie } +// QueryDeviceState sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryDeviceStateCookie.Reply() func QueryDeviceState(c *xgb.Conn, DeviceId byte) QueryDeviceStateCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryDeviceStateRequest(c, DeviceId), cookie) return QueryDeviceStateCookie{cookie} } +// QueryDeviceStateUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryDeviceStateUnchecked(c *xgb.Conn, DeviceId byte) QueryDeviceStateCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryDeviceStateRequest(c, DeviceId), cookie) return QueryDeviceStateCookie{cookie} } -// Request reply for QueryDeviceState -// size: 32 +// QueryDeviceStateReply represents the data returned from a QueryDeviceState request. type QueryDeviceStateReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes NumClasses byte // padding: 23 bytes } -// Waits and reads reply data from request QueryDeviceState +// Reply blocks and returns the reply data for a QueryDeviceState request. func (cook QueryDeviceStateCookie) Reply() (*QueryDeviceStateReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -6868,7 +6904,7 @@ func (cook QueryDeviceStateCookie) Reply() (*QueryDeviceStateReply, error) { return queryDeviceStateReply(buf), nil } -// Read reply into structure from buffer for QueryDeviceState +// queryDeviceStateReply reads a byte slice into a QueryDeviceStateReply value. func queryDeviceStateReply(buf []byte) *QueryDeviceStateReply { v := new(QueryDeviceStateReply) b := 1 // skip reply determinant @@ -6890,6 +6926,7 @@ func queryDeviceStateReply(buf []byte) *QueryDeviceStateReply { } // Write request to wire for QueryDeviceState +// queryDeviceStateRequest writes a QueryDeviceState request to a byte slice. func queryDeviceStateRequest(c *xgb.Conn, DeviceId byte) []byte { size := 8 b := 0 @@ -6912,30 +6949,35 @@ func queryDeviceStateRequest(c *xgb.Conn, DeviceId byte) []byte { return buf } -// Request SendExtensionEvent -// size: xgb.Pad(((16 + xgb.Pad(((int(NumEvents) * 32) * 1))) + xgb.Pad((int(NumClasses) * 4)))) +// SendExtensionEventCookie is a cookie used only for SendExtensionEvent requests. type SendExtensionEventCookie struct { *xgb.Cookie } -// Write request to wire for SendExtensionEvent +// SendExtensionEvent sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SendExtensionEvent(c *xgb.Conn, Destination xproto.Window, DeviceId byte, Propagate bool, NumClasses uint16, NumEvents byte, Events string, Classes []EventClass) SendExtensionEventCookie { cookie := c.NewCookie(false, false) c.NewRequest(sendExtensionEventRequest(c, Destination, DeviceId, Propagate, NumClasses, NumEvents, Events, Classes), cookie) return SendExtensionEventCookie{cookie} } +// SendExtensionEventChecked sends a checked request. +// If an error occurs, it can be retrieved using SendExtensionEventCookie.Check() func SendExtensionEventChecked(c *xgb.Conn, Destination xproto.Window, DeviceId byte, Propagate bool, NumClasses uint16, NumEvents byte, Events string, Classes []EventClass) SendExtensionEventCookie { cookie := c.NewCookie(true, false) c.NewRequest(sendExtensionEventRequest(c, Destination, DeviceId, Propagate, NumClasses, NumEvents, Events, Classes), cookie) return SendExtensionEventCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SendExtensionEventCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SendExtensionEvent +// sendExtensionEventRequest writes a SendExtensionEvent request to a byte slice. func sendExtensionEventRequest(c *xgb.Conn, Destination xproto.Window, DeviceId byte, Propagate bool, NumClasses uint16, NumEvents byte, Events string, Classes []EventClass) []byte { size := xgb.Pad(((16 + xgb.Pad(((int(NumEvents) * 32) * 1))) + xgb.Pad((int(NumClasses) * 4)))) b := 0 @@ -6983,30 +7025,35 @@ func sendExtensionEventRequest(c *xgb.Conn, Destination xproto.Window, DeviceId return buf } -// Request DeviceBell -// size: 8 +// DeviceBellCookie is a cookie used only for DeviceBell requests. type DeviceBellCookie struct { *xgb.Cookie } -// Write request to wire for DeviceBell +// DeviceBell sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func DeviceBell(c *xgb.Conn, DeviceId byte, FeedbackId byte, FeedbackClass byte, Percent int8) DeviceBellCookie { cookie := c.NewCookie(false, false) c.NewRequest(deviceBellRequest(c, DeviceId, FeedbackId, FeedbackClass, Percent), cookie) return DeviceBellCookie{cookie} } +// DeviceBellChecked sends a checked request. +// If an error occurs, it can be retrieved using DeviceBellCookie.Check() func DeviceBellChecked(c *xgb.Conn, DeviceId byte, FeedbackId byte, FeedbackClass byte, Percent int8) DeviceBellCookie { cookie := c.NewCookie(true, false) c.NewRequest(deviceBellRequest(c, DeviceId, FeedbackId, FeedbackClass, Percent), cookie) return DeviceBellCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook DeviceBellCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for DeviceBell +// deviceBellRequest writes a DeviceBell request to a byte slice. func deviceBellRequest(c *xgb.Conn, DeviceId byte, FeedbackId byte, FeedbackClass byte, Percent int8) []byte { size := 8 b := 0 @@ -7036,35 +7083,37 @@ func deviceBellRequest(c *xgb.Conn, DeviceId byte, FeedbackId byte, FeedbackClas return buf } -// Request SetDeviceValuators -// size: xgb.Pad((8 + xgb.Pad((int(NumValuators) * 4)))) +// SetDeviceValuatorsCookie is a cookie used only for SetDeviceValuators requests. type SetDeviceValuatorsCookie struct { *xgb.Cookie } +// SetDeviceValuators sends a checked request. +// If an error occurs, it will be returned with the reply by calling SetDeviceValuatorsCookie.Reply() func SetDeviceValuators(c *xgb.Conn, DeviceId byte, FirstValuator byte, NumValuators byte, Valuators []int32) SetDeviceValuatorsCookie { cookie := c.NewCookie(true, true) c.NewRequest(setDeviceValuatorsRequest(c, DeviceId, FirstValuator, NumValuators, Valuators), cookie) return SetDeviceValuatorsCookie{cookie} } +// SetDeviceValuatorsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetDeviceValuatorsUnchecked(c *xgb.Conn, DeviceId byte, FirstValuator byte, NumValuators byte, Valuators []int32) SetDeviceValuatorsCookie { cookie := c.NewCookie(false, true) c.NewRequest(setDeviceValuatorsRequest(c, DeviceId, FirstValuator, NumValuators, Valuators), cookie) return SetDeviceValuatorsCookie{cookie} } -// Request reply for SetDeviceValuators -// size: 32 +// SetDeviceValuatorsReply represents the data returned from a SetDeviceValuators request. type SetDeviceValuatorsReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Status byte // padding: 23 bytes } -// Waits and reads reply data from request SetDeviceValuators +// Reply blocks and returns the reply data for a SetDeviceValuators request. func (cook SetDeviceValuatorsCookie) Reply() (*SetDeviceValuatorsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -7076,7 +7125,7 @@ func (cook SetDeviceValuatorsCookie) Reply() (*SetDeviceValuatorsReply, error) { return setDeviceValuatorsReply(buf), nil } -// Read reply into structure from buffer for SetDeviceValuators +// setDeviceValuatorsReply reads a byte slice into a SetDeviceValuatorsReply value. func setDeviceValuatorsReply(buf []byte) *SetDeviceValuatorsReply { v := new(SetDeviceValuatorsReply) b := 1 // skip reply determinant @@ -7098,6 +7147,7 @@ func setDeviceValuatorsReply(buf []byte) *SetDeviceValuatorsReply { } // Write request to wire for SetDeviceValuators +// setDeviceValuatorsRequest writes a SetDeviceValuators request to a byte slice. func setDeviceValuatorsRequest(c *xgb.Conn, DeviceId byte, FirstValuator byte, NumValuators byte, Valuators []int32) []byte { size := xgb.Pad((8 + xgb.Pad((int(NumValuators) * 4)))) b := 0 @@ -7132,35 +7182,37 @@ func setDeviceValuatorsRequest(c *xgb.Conn, DeviceId byte, FirstValuator byte, N return buf } -// Request GetDeviceControl -// size: 8 +// GetDeviceControlCookie is a cookie used only for GetDeviceControl requests. type GetDeviceControlCookie struct { *xgb.Cookie } +// GetDeviceControl sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetDeviceControlCookie.Reply() func GetDeviceControl(c *xgb.Conn, ControlId uint16, DeviceId byte) GetDeviceControlCookie { cookie := c.NewCookie(true, true) c.NewRequest(getDeviceControlRequest(c, ControlId, DeviceId), cookie) return GetDeviceControlCookie{cookie} } +// GetDeviceControlUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetDeviceControlUnchecked(c *xgb.Conn, ControlId uint16, DeviceId byte) GetDeviceControlCookie { cookie := c.NewCookie(false, true) c.NewRequest(getDeviceControlRequest(c, ControlId, DeviceId), cookie) return GetDeviceControlCookie{cookie} } -// Request reply for GetDeviceControl -// size: 32 +// GetDeviceControlReply represents the data returned from a GetDeviceControl request. type GetDeviceControlReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Status byte // padding: 23 bytes } -// Waits and reads reply data from request GetDeviceControl +// Reply blocks and returns the reply data for a GetDeviceControl request. func (cook GetDeviceControlCookie) Reply() (*GetDeviceControlReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -7172,7 +7224,7 @@ func (cook GetDeviceControlCookie) Reply() (*GetDeviceControlReply, error) { return getDeviceControlReply(buf), nil } -// Read reply into structure from buffer for GetDeviceControl +// getDeviceControlReply reads a byte slice into a GetDeviceControlReply value. func getDeviceControlReply(buf []byte) *GetDeviceControlReply { v := new(GetDeviceControlReply) b := 1 // skip reply determinant @@ -7194,6 +7246,7 @@ func getDeviceControlReply(buf []byte) *GetDeviceControlReply { } // Write request to wire for GetDeviceControl +// getDeviceControlRequest writes a GetDeviceControl request to a byte slice. func getDeviceControlRequest(c *xgb.Conn, ControlId uint16, DeviceId byte) []byte { size := 8 b := 0 diff --git a/nexgb/xprint/xprint.go b/nexgb/xprint/xprint.go index 0037a22..237b6b5 100644 --- a/nexgb/xprint/xprint.go +++ b/nexgb/xprint/xprint.go @@ -2,7 +2,7 @@ package xprint /* - This file was generated by xprint.xml on May 10 2012 8:04:32pm EDT. + This file was generated by xprint.xml on May 10 2012 11:56:19pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,8 +40,6 @@ func init() { xgb.NewExtErrorFuncs["XpExtension"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Int8' - // Skipping definition for base type 'Card16' // Skipping definition for base type 'Char' @@ -64,6 +62,8 @@ func init() { // Skipping definition for base type 'Byte' +// Skipping definition for base type 'Int8' + const ( GetDocFinished = 0 GetDocSecondConsumer = 1 @@ -106,8 +106,6 @@ func NewPcontextId(c *xgb.Conn) (Pcontext, error) { type String8 byte -// 'Printer' struct definition -// Size: (((4 + xgb.Pad((int(NameLen) * 1))) + 4) + xgb.Pad((int(DescLen) * 1))) type Printer struct { NameLen uint32 Name []String8 // size: xgb.Pad((int(NameLen) * 1)) @@ -115,7 +113,7 @@ type Printer struct { Description []String8 // size: xgb.Pad((int(DescLen) * 1)) } -// Struct read Printer +// PrinterRead reads a byte slice into a Printer value. func PrinterRead(buf []byte, v *Printer) int { b := 0 @@ -142,7 +140,7 @@ func PrinterRead(buf []byte, v *Printer) int { return b } -// Struct list read Printer +// PrinterReadList reads a byte slice into a list of Printer values. func PrinterReadList(buf []byte, dest []Printer) int { b := 0 for i := 0; i < len(dest); i++ { @@ -152,7 +150,7 @@ func PrinterReadList(buf []byte, dest []Printer) int { return xgb.Pad(b) } -// Struct write Printer +// Bytes writes a Printer value to a byte slice. func (v Printer) Bytes() []byte { buf := make([]byte, (((4 + xgb.Pad((int(v.NameLen) * 1))) + 4) + xgb.Pad((int(v.DescLen) * 1)))) b := 0 @@ -178,7 +176,7 @@ func (v Printer) Bytes() []byte { return buf } -// Write struct list Printer +// PrinterListBytes writes a list of %s(MISSING) values to a byte slice. func PrinterListBytes(buf []byte, list []Printer) int { b := 0 var structBytes []byte @@ -190,7 +188,7 @@ func PrinterListBytes(buf []byte, list []Printer) int { return b } -// Struct list size Printer +// PrinterListSize computes the size (bytes) of a list of Printer values. func PrinterListSize(list []Printer) int { size := 0 for _, item := range list { @@ -199,9 +197,7 @@ func PrinterListSize(list []Printer) int { return size } -// Event definition Notify (0) -// Size: 32 - +// Notify is the event number for a NotifyEvent. const Notify = 0 type NotifyEvent struct { @@ -211,7 +207,7 @@ type NotifyEvent struct { Cancel bool } -// Event read Notify +// NotifyEventNew constructs a NotifyEvent value that implements xgb.Event from a byte slice. func NotifyEventNew(buf []byte) xgb.Event { v := NotifyEvent{} b := 1 // don't read event number @@ -235,7 +231,7 @@ func NotifyEventNew(buf []byte) xgb.Event { return v } -// Event write Notify +// Bytes writes a NotifyEvent value to a byte slice. func (v NotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -262,12 +258,14 @@ func (v NotifyEvent) Bytes() []byte { return buf } -func (v NotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the Notify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v NotifyEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of NotifyEvent. func (v NotifyEvent) String() string { fieldVals := make([]string, 0, 3) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -281,9 +279,7 @@ func init() { xgb.NewExtEventFuncs["XpExtension"][0] = NotifyEventNew } -// Event definition AttributNotify (1) -// Size: 32 - +// AttributNotify is the event number for a AttributNotifyEvent. const AttributNotify = 1 type AttributNotifyEvent struct { @@ -292,7 +288,7 @@ type AttributNotifyEvent struct { Context Pcontext } -// Event read AttributNotify +// AttributNotifyEventNew constructs a AttributNotifyEvent value that implements xgb.Event from a byte slice. func AttributNotifyEventNew(buf []byte) xgb.Event { v := AttributNotifyEvent{} b := 1 // don't read event number @@ -309,7 +305,7 @@ func AttributNotifyEventNew(buf []byte) xgb.Event { return v } -// Event write AttributNotify +// Bytes writes a AttributNotifyEvent value to a byte slice. func (v AttributNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -329,12 +325,14 @@ func (v AttributNotifyEvent) Bytes() []byte { return buf } -func (v AttributNotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the AttributNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v AttributNotifyEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of AttributNotifyEvent. func (v AttributNotifyEvent) String() string { fieldVals := make([]string, 0, 2) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -347,9 +345,7 @@ func init() { xgb.NewExtEventFuncs["XpExtension"][1] = AttributNotifyEventNew } -// Error definition BadContext (0) -// Size: 32 - +// BadBadContext is the error number for a BadBadContext. const BadBadContext = 0 type BadContextError struct { @@ -357,7 +353,7 @@ type BadContextError struct { NiceName string } -// Error read BadContext +// BadContextErrorNew constructs a BadContextError value that implements xgb.Error from a byte slice. func BadContextErrorNew(buf []byte) xgb.Error { v := BadContextError{} v.NiceName = "BadContext" @@ -371,8 +367,8 @@ func BadContextErrorNew(buf []byte) xgb.Error { return v } -func (err BadContextError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadBadContext error. +// This is mostly used internally. func (err BadContextError) SequenceId() uint16 { return err.Sequence } @@ -392,9 +388,7 @@ func init() { xgb.NewExtErrorFuncs["XpExtension"][0] = BadContextErrorNew } -// Error definition BadSequence (1) -// Size: 32 - +// BadBadSequence is the error number for a BadBadSequence. const BadBadSequence = 1 type BadSequenceError struct { @@ -402,7 +396,7 @@ type BadSequenceError struct { NiceName string } -// Error read BadSequence +// BadSequenceErrorNew constructs a BadSequenceError value that implements xgb.Error from a byte slice. func BadSequenceErrorNew(buf []byte) xgb.Error { v := BadSequenceError{} v.NiceName = "BadSequence" @@ -416,8 +410,8 @@ func BadSequenceErrorNew(buf []byte) xgb.Error { return v } -func (err BadSequenceError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadBadSequence error. +// This is mostly used internally. func (err BadSequenceError) SequenceId() uint16 { return err.Sequence } @@ -437,35 +431,37 @@ func init() { xgb.NewExtErrorFuncs["XpExtension"][1] = BadSequenceErrorNew } -// Request PrintQueryVersion -// size: 4 +// PrintQueryVersionCookie is a cookie used only for PrintQueryVersion requests. type PrintQueryVersionCookie struct { *xgb.Cookie } +// PrintQueryVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling PrintQueryVersionCookie.Reply() func PrintQueryVersion(c *xgb.Conn) PrintQueryVersionCookie { cookie := c.NewCookie(true, true) c.NewRequest(printQueryVersionRequest(c), cookie) return PrintQueryVersionCookie{cookie} } +// PrintQueryVersionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PrintQueryVersionUnchecked(c *xgb.Conn) PrintQueryVersionCookie { cookie := c.NewCookie(false, true) c.NewRequest(printQueryVersionRequest(c), cookie) return PrintQueryVersionCookie{cookie} } -// Request reply for PrintQueryVersion -// size: 12 +// PrintQueryVersionReply represents the data returned from a PrintQueryVersion request. type PrintQueryVersionReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes MajorVersion uint16 MinorVersion uint16 } -// Waits and reads reply data from request PrintQueryVersion +// Reply blocks and returns the reply data for a PrintQueryVersion request. func (cook PrintQueryVersionCookie) Reply() (*PrintQueryVersionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -477,7 +473,7 @@ func (cook PrintQueryVersionCookie) Reply() (*PrintQueryVersionReply, error) { return printQueryVersionReply(buf), nil } -// Read reply into structure from buffer for PrintQueryVersion +// printQueryVersionReply reads a byte slice into a PrintQueryVersionReply value. func printQueryVersionReply(buf []byte) *PrintQueryVersionReply { v := new(PrintQueryVersionReply) b := 1 // skip reply determinant @@ -500,6 +496,7 @@ func printQueryVersionReply(buf []byte) *PrintQueryVersionReply { } // Write request to wire for PrintQueryVersion +// printQueryVersionRequest writes a PrintQueryVersion request to a byte slice. func printQueryVersionRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -517,36 +514,38 @@ func printQueryVersionRequest(c *xgb.Conn) []byte { return buf } -// Request PrintGetPrinterList -// size: xgb.Pad(((12 + xgb.Pad((int(PrinterNameLen) * 1))) + xgb.Pad((int(LocaleLen) * 1)))) +// PrintGetPrinterListCookie is a cookie used only for PrintGetPrinterList requests. type PrintGetPrinterListCookie struct { *xgb.Cookie } +// PrintGetPrinterList sends a checked request. +// If an error occurs, it will be returned with the reply by calling PrintGetPrinterListCookie.Reply() func PrintGetPrinterList(c *xgb.Conn, PrinterNameLen uint32, LocaleLen uint32, PrinterName []String8, Locale []String8) PrintGetPrinterListCookie { cookie := c.NewCookie(true, true) c.NewRequest(printGetPrinterListRequest(c, PrinterNameLen, LocaleLen, PrinterName, Locale), cookie) return PrintGetPrinterListCookie{cookie} } +// PrintGetPrinterListUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PrintGetPrinterListUnchecked(c *xgb.Conn, PrinterNameLen uint32, LocaleLen uint32, PrinterName []String8, Locale []String8) PrintGetPrinterListCookie { cookie := c.NewCookie(false, true) c.NewRequest(printGetPrinterListRequest(c, PrinterNameLen, LocaleLen, PrinterName, Locale), cookie) return PrintGetPrinterListCookie{cookie} } -// Request reply for PrintGetPrinterList -// size: (32 + PrinterListSize(Printers)) +// PrintGetPrinterListReply represents the data returned from a PrintGetPrinterList request. type PrintGetPrinterListReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes ListCount uint32 // padding: 20 bytes Printers []Printer // size: PrinterListSize(Printers) } -// Waits and reads reply data from request PrintGetPrinterList +// Reply blocks and returns the reply data for a PrintGetPrinterList request. func (cook PrintGetPrinterListCookie) Reply() (*PrintGetPrinterListReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -558,7 +557,7 @@ func (cook PrintGetPrinterListCookie) Reply() (*PrintGetPrinterListReply, error) return printGetPrinterListReply(buf), nil } -// Read reply into structure from buffer for PrintGetPrinterList +// printGetPrinterListReply reads a byte slice into a PrintGetPrinterListReply value. func printGetPrinterListReply(buf []byte) *PrintGetPrinterListReply { v := new(PrintGetPrinterListReply) b := 1 // skip reply determinant @@ -583,6 +582,7 @@ func printGetPrinterListReply(buf []byte) *PrintGetPrinterListReply { } // Write request to wire for PrintGetPrinterList +// printGetPrinterListRequest writes a PrintGetPrinterList request to a byte slice. func printGetPrinterListRequest(c *xgb.Conn, PrinterNameLen uint32, LocaleLen uint32, PrinterName []String8, Locale []String8) []byte { size := xgb.Pad(((12 + xgb.Pad((int(PrinterNameLen) * 1))) + xgb.Pad((int(LocaleLen) * 1)))) b := 0 @@ -618,30 +618,35 @@ func printGetPrinterListRequest(c *xgb.Conn, PrinterNameLen uint32, LocaleLen ui return buf } -// Request PrintRehashPrinterList -// size: 4 +// PrintRehashPrinterListCookie is a cookie used only for PrintRehashPrinterList requests. type PrintRehashPrinterListCookie struct { *xgb.Cookie } -// Write request to wire for PrintRehashPrinterList +// PrintRehashPrinterList sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PrintRehashPrinterList(c *xgb.Conn) PrintRehashPrinterListCookie { cookie := c.NewCookie(false, false) c.NewRequest(printRehashPrinterListRequest(c), cookie) return PrintRehashPrinterListCookie{cookie} } +// PrintRehashPrinterListChecked sends a checked request. +// If an error occurs, it can be retrieved using PrintRehashPrinterListCookie.Check() func PrintRehashPrinterListChecked(c *xgb.Conn) PrintRehashPrinterListCookie { cookie := c.NewCookie(true, false) c.NewRequest(printRehashPrinterListRequest(c), cookie) return PrintRehashPrinterListCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook PrintRehashPrinterListCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for PrintRehashPrinterList +// printRehashPrinterListRequest writes a PrintRehashPrinterList request to a byte slice. func printRehashPrinterListRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -659,30 +664,35 @@ func printRehashPrinterListRequest(c *xgb.Conn) []byte { return buf } -// Request CreateContext -// size: xgb.Pad(((16 + xgb.Pad((int(PrinterNameLen) * 1))) + xgb.Pad((int(LocaleLen) * 1)))) +// CreateContextCookie is a cookie used only for CreateContext requests. type CreateContextCookie struct { *xgb.Cookie } -// Write request to wire for CreateContext +// CreateContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreateContext(c *xgb.Conn, ContextId uint32, PrinterNameLen uint32, LocaleLen uint32, PrinterName []String8, Locale []String8) CreateContextCookie { cookie := c.NewCookie(false, false) c.NewRequest(createContextRequest(c, ContextId, PrinterNameLen, LocaleLen, PrinterName, Locale), cookie) return CreateContextCookie{cookie} } +// CreateContextChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateContextCookie.Check() func CreateContextChecked(c *xgb.Conn, ContextId uint32, PrinterNameLen uint32, LocaleLen uint32, PrinterName []String8, Locale []String8) CreateContextCookie { cookie := c.NewCookie(true, false) c.NewRequest(createContextRequest(c, ContextId, PrinterNameLen, LocaleLen, PrinterName, Locale), cookie) return CreateContextCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CreateContextCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreateContext +// createContextRequest writes a CreateContext request to a byte slice. func createContextRequest(c *xgb.Conn, ContextId uint32, PrinterNameLen uint32, LocaleLen uint32, PrinterName []String8, Locale []String8) []byte { size := xgb.Pad(((16 + xgb.Pad((int(PrinterNameLen) * 1))) + xgb.Pad((int(LocaleLen) * 1)))) b := 0 @@ -721,30 +731,35 @@ func createContextRequest(c *xgb.Conn, ContextId uint32, PrinterNameLen uint32, return buf } -// Request PrintSetContext -// size: 8 +// PrintSetContextCookie is a cookie used only for PrintSetContext requests. type PrintSetContextCookie struct { *xgb.Cookie } -// Write request to wire for PrintSetContext +// PrintSetContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PrintSetContext(c *xgb.Conn, Context uint32) PrintSetContextCookie { cookie := c.NewCookie(false, false) c.NewRequest(printSetContextRequest(c, Context), cookie) return PrintSetContextCookie{cookie} } +// PrintSetContextChecked sends a checked request. +// If an error occurs, it can be retrieved using PrintSetContextCookie.Check() func PrintSetContextChecked(c *xgb.Conn, Context uint32) PrintSetContextCookie { cookie := c.NewCookie(true, false) c.NewRequest(printSetContextRequest(c, Context), cookie) return PrintSetContextCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook PrintSetContextCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for PrintSetContext +// printSetContextRequest writes a PrintSetContext request to a byte slice. func printSetContextRequest(c *xgb.Conn, Context uint32) []byte { size := 8 b := 0 @@ -765,34 +780,36 @@ func printSetContextRequest(c *xgb.Conn, Context uint32) []byte { return buf } -// Request PrintGetContext -// size: 4 +// PrintGetContextCookie is a cookie used only for PrintGetContext requests. type PrintGetContextCookie struct { *xgb.Cookie } +// PrintGetContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling PrintGetContextCookie.Reply() func PrintGetContext(c *xgb.Conn) PrintGetContextCookie { cookie := c.NewCookie(true, true) c.NewRequest(printGetContextRequest(c), cookie) return PrintGetContextCookie{cookie} } +// PrintGetContextUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PrintGetContextUnchecked(c *xgb.Conn) PrintGetContextCookie { cookie := c.NewCookie(false, true) c.NewRequest(printGetContextRequest(c), cookie) return PrintGetContextCookie{cookie} } -// Request reply for PrintGetContext -// size: 12 +// PrintGetContextReply represents the data returned from a PrintGetContext request. type PrintGetContextReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Context uint32 } -// Waits and reads reply data from request PrintGetContext +// Reply blocks and returns the reply data for a PrintGetContext request. func (cook PrintGetContextCookie) Reply() (*PrintGetContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -804,7 +821,7 @@ func (cook PrintGetContextCookie) Reply() (*PrintGetContextReply, error) { return printGetContextReply(buf), nil } -// Read reply into structure from buffer for PrintGetContext +// printGetContextReply reads a byte slice into a PrintGetContextReply value. func printGetContextReply(buf []byte) *PrintGetContextReply { v := new(PrintGetContextReply) b := 1 // skip reply determinant @@ -824,6 +841,7 @@ func printGetContextReply(buf []byte) *PrintGetContextReply { } // Write request to wire for PrintGetContext +// printGetContextRequest writes a PrintGetContext request to a byte slice. func printGetContextRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -841,30 +859,35 @@ func printGetContextRequest(c *xgb.Conn) []byte { return buf } -// Request PrintDestroyContext -// size: 8 +// PrintDestroyContextCookie is a cookie used only for PrintDestroyContext requests. type PrintDestroyContextCookie struct { *xgb.Cookie } -// Write request to wire for PrintDestroyContext +// PrintDestroyContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PrintDestroyContext(c *xgb.Conn, Context uint32) PrintDestroyContextCookie { cookie := c.NewCookie(false, false) c.NewRequest(printDestroyContextRequest(c, Context), cookie) return PrintDestroyContextCookie{cookie} } +// PrintDestroyContextChecked sends a checked request. +// If an error occurs, it can be retrieved using PrintDestroyContextCookie.Check() func PrintDestroyContextChecked(c *xgb.Conn, Context uint32) PrintDestroyContextCookie { cookie := c.NewCookie(true, false) c.NewRequest(printDestroyContextRequest(c, Context), cookie) return PrintDestroyContextCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook PrintDestroyContextCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for PrintDestroyContext +// printDestroyContextRequest writes a PrintDestroyContext request to a byte slice. func printDestroyContextRequest(c *xgb.Conn, Context uint32) []byte { size := 8 b := 0 @@ -885,34 +908,36 @@ func printDestroyContextRequest(c *xgb.Conn, Context uint32) []byte { return buf } -// Request PrintGetScreenOfContext -// size: 4 +// PrintGetScreenOfContextCookie is a cookie used only for PrintGetScreenOfContext requests. type PrintGetScreenOfContextCookie struct { *xgb.Cookie } +// PrintGetScreenOfContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling PrintGetScreenOfContextCookie.Reply() func PrintGetScreenOfContext(c *xgb.Conn) PrintGetScreenOfContextCookie { cookie := c.NewCookie(true, true) c.NewRequest(printGetScreenOfContextRequest(c), cookie) return PrintGetScreenOfContextCookie{cookie} } +// PrintGetScreenOfContextUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PrintGetScreenOfContextUnchecked(c *xgb.Conn) PrintGetScreenOfContextCookie { cookie := c.NewCookie(false, true) c.NewRequest(printGetScreenOfContextRequest(c), cookie) return PrintGetScreenOfContextCookie{cookie} } -// Request reply for PrintGetScreenOfContext -// size: 12 +// PrintGetScreenOfContextReply represents the data returned from a PrintGetScreenOfContext request. type PrintGetScreenOfContextReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Root xproto.Window } -// Waits and reads reply data from request PrintGetScreenOfContext +// Reply blocks and returns the reply data for a PrintGetScreenOfContext request. func (cook PrintGetScreenOfContextCookie) Reply() (*PrintGetScreenOfContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -924,7 +949,7 @@ func (cook PrintGetScreenOfContextCookie) Reply() (*PrintGetScreenOfContextReply return printGetScreenOfContextReply(buf), nil } -// Read reply into structure from buffer for PrintGetScreenOfContext +// printGetScreenOfContextReply reads a byte slice into a PrintGetScreenOfContextReply value. func printGetScreenOfContextReply(buf []byte) *PrintGetScreenOfContextReply { v := new(PrintGetScreenOfContextReply) b := 1 // skip reply determinant @@ -944,6 +969,7 @@ func printGetScreenOfContextReply(buf []byte) *PrintGetScreenOfContextReply { } // Write request to wire for PrintGetScreenOfContext +// printGetScreenOfContextRequest writes a PrintGetScreenOfContext request to a byte slice. func printGetScreenOfContextRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -961,30 +987,35 @@ func printGetScreenOfContextRequest(c *xgb.Conn) []byte { return buf } -// Request PrintStartJob -// size: 8 +// PrintStartJobCookie is a cookie used only for PrintStartJob requests. type PrintStartJobCookie struct { *xgb.Cookie } -// Write request to wire for PrintStartJob +// PrintStartJob sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PrintStartJob(c *xgb.Conn, OutputMode byte) PrintStartJobCookie { cookie := c.NewCookie(false, false) c.NewRequest(printStartJobRequest(c, OutputMode), cookie) return PrintStartJobCookie{cookie} } +// PrintStartJobChecked sends a checked request. +// If an error occurs, it can be retrieved using PrintStartJobCookie.Check() func PrintStartJobChecked(c *xgb.Conn, OutputMode byte) PrintStartJobCookie { cookie := c.NewCookie(true, false) c.NewRequest(printStartJobRequest(c, OutputMode), cookie) return PrintStartJobCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook PrintStartJobCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for PrintStartJob +// printStartJobRequest writes a PrintStartJob request to a byte slice. func printStartJobRequest(c *xgb.Conn, OutputMode byte) []byte { size := 8 b := 0 @@ -1005,30 +1036,35 @@ func printStartJobRequest(c *xgb.Conn, OutputMode byte) []byte { return buf } -// Request PrintEndJob -// size: 8 +// PrintEndJobCookie is a cookie used only for PrintEndJob requests. type PrintEndJobCookie struct { *xgb.Cookie } -// Write request to wire for PrintEndJob +// PrintEndJob sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PrintEndJob(c *xgb.Conn, Cancel bool) PrintEndJobCookie { cookie := c.NewCookie(false, false) c.NewRequest(printEndJobRequest(c, Cancel), cookie) return PrintEndJobCookie{cookie} } +// PrintEndJobChecked sends a checked request. +// If an error occurs, it can be retrieved using PrintEndJobCookie.Check() func PrintEndJobChecked(c *xgb.Conn, Cancel bool) PrintEndJobCookie { cookie := c.NewCookie(true, false) c.NewRequest(printEndJobRequest(c, Cancel), cookie) return PrintEndJobCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook PrintEndJobCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for PrintEndJob +// printEndJobRequest writes a PrintEndJob request to a byte slice. func printEndJobRequest(c *xgb.Conn, Cancel bool) []byte { size := 8 b := 0 @@ -1053,30 +1089,35 @@ func printEndJobRequest(c *xgb.Conn, Cancel bool) []byte { return buf } -// Request PrintStartDoc -// size: 8 +// PrintStartDocCookie is a cookie used only for PrintStartDoc requests. type PrintStartDocCookie struct { *xgb.Cookie } -// Write request to wire for PrintStartDoc +// PrintStartDoc sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PrintStartDoc(c *xgb.Conn, DriverMode byte) PrintStartDocCookie { cookie := c.NewCookie(false, false) c.NewRequest(printStartDocRequest(c, DriverMode), cookie) return PrintStartDocCookie{cookie} } +// PrintStartDocChecked sends a checked request. +// If an error occurs, it can be retrieved using PrintStartDocCookie.Check() func PrintStartDocChecked(c *xgb.Conn, DriverMode byte) PrintStartDocCookie { cookie := c.NewCookie(true, false) c.NewRequest(printStartDocRequest(c, DriverMode), cookie) return PrintStartDocCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook PrintStartDocCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for PrintStartDoc +// printStartDocRequest writes a PrintStartDoc request to a byte slice. func printStartDocRequest(c *xgb.Conn, DriverMode byte) []byte { size := 8 b := 0 @@ -1097,30 +1138,35 @@ func printStartDocRequest(c *xgb.Conn, DriverMode byte) []byte { return buf } -// Request PrintEndDoc -// size: 8 +// PrintEndDocCookie is a cookie used only for PrintEndDoc requests. type PrintEndDocCookie struct { *xgb.Cookie } -// Write request to wire for PrintEndDoc +// PrintEndDoc sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PrintEndDoc(c *xgb.Conn, Cancel bool) PrintEndDocCookie { cookie := c.NewCookie(false, false) c.NewRequest(printEndDocRequest(c, Cancel), cookie) return PrintEndDocCookie{cookie} } +// PrintEndDocChecked sends a checked request. +// If an error occurs, it can be retrieved using PrintEndDocCookie.Check() func PrintEndDocChecked(c *xgb.Conn, Cancel bool) PrintEndDocCookie { cookie := c.NewCookie(true, false) c.NewRequest(printEndDocRequest(c, Cancel), cookie) return PrintEndDocCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook PrintEndDocCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for PrintEndDoc +// printEndDocRequest writes a PrintEndDoc request to a byte slice. func printEndDocRequest(c *xgb.Conn, Cancel bool) []byte { size := 8 b := 0 @@ -1145,30 +1191,35 @@ func printEndDocRequest(c *xgb.Conn, Cancel bool) []byte { return buf } -// Request PrintPutDocumentData -// size: xgb.Pad((((16 + xgb.Pad((int(LenData) * 1))) + xgb.Pad((len(DocFormat) * 1))) + xgb.Pad((len(Options) * 1)))) +// PrintPutDocumentDataCookie is a cookie used only for PrintPutDocumentData requests. type PrintPutDocumentDataCookie struct { *xgb.Cookie } -// Write request to wire for PrintPutDocumentData +// PrintPutDocumentData sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PrintPutDocumentData(c *xgb.Conn, Drawable xproto.Drawable, LenData uint32, LenFmt uint16, LenOptions uint16, Data []byte, DocFormat []String8, Options []String8) PrintPutDocumentDataCookie { cookie := c.NewCookie(false, false) c.NewRequest(printPutDocumentDataRequest(c, Drawable, LenData, LenFmt, LenOptions, Data, DocFormat, Options), cookie) return PrintPutDocumentDataCookie{cookie} } +// PrintPutDocumentDataChecked sends a checked request. +// If an error occurs, it can be retrieved using PrintPutDocumentDataCookie.Check() func PrintPutDocumentDataChecked(c *xgb.Conn, Drawable xproto.Drawable, LenData uint32, LenFmt uint16, LenOptions uint16, Data []byte, DocFormat []String8, Options []String8) PrintPutDocumentDataCookie { cookie := c.NewCookie(true, false) c.NewRequest(printPutDocumentDataRequest(c, Drawable, LenData, LenFmt, LenOptions, Data, DocFormat, Options), cookie) return PrintPutDocumentDataCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook PrintPutDocumentDataCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for PrintPutDocumentData +// printPutDocumentDataRequest writes a PrintPutDocumentData request to a byte slice. func printPutDocumentDataRequest(c *xgb.Conn, Drawable xproto.Drawable, LenData uint32, LenFmt uint16, LenOptions uint16, Data []byte, DocFormat []String8, Options []String8) []byte { size := xgb.Pad((((16 + xgb.Pad((int(LenData) * 1))) + xgb.Pad((len(DocFormat) * 1))) + xgb.Pad((len(Options) * 1)))) b := 0 @@ -1213,29 +1264,31 @@ func printPutDocumentDataRequest(c *xgb.Conn, Drawable xproto.Drawable, LenData return buf } -// Request PrintGetDocumentData -// size: 12 +// PrintGetDocumentDataCookie is a cookie used only for PrintGetDocumentData requests. type PrintGetDocumentDataCookie struct { *xgb.Cookie } +// PrintGetDocumentData sends a checked request. +// If an error occurs, it will be returned with the reply by calling PrintGetDocumentDataCookie.Reply() func PrintGetDocumentData(c *xgb.Conn, Context Pcontext, MaxBytes uint32) PrintGetDocumentDataCookie { cookie := c.NewCookie(true, true) c.NewRequest(printGetDocumentDataRequest(c, Context, MaxBytes), cookie) return PrintGetDocumentDataCookie{cookie} } +// PrintGetDocumentDataUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PrintGetDocumentDataUnchecked(c *xgb.Conn, Context Pcontext, MaxBytes uint32) PrintGetDocumentDataCookie { cookie := c.NewCookie(false, true) c.NewRequest(printGetDocumentDataRequest(c, Context, MaxBytes), cookie) return PrintGetDocumentDataCookie{cookie} } -// Request reply for PrintGetDocumentData -// size: (32 + xgb.Pad((int(DataLen) * 1))) +// PrintGetDocumentDataReply represents the data returned from a PrintGetDocumentData request. type PrintGetDocumentDataReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes StatusCode uint32 FinishedFlag uint32 @@ -1244,7 +1297,7 @@ type PrintGetDocumentDataReply struct { Data []byte // size: xgb.Pad((int(DataLen) * 1)) } -// Waits and reads reply data from request PrintGetDocumentData +// Reply blocks and returns the reply data for a PrintGetDocumentData request. func (cook PrintGetDocumentDataCookie) Reply() (*PrintGetDocumentDataReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1256,7 +1309,7 @@ func (cook PrintGetDocumentDataCookie) Reply() (*PrintGetDocumentDataReply, erro return printGetDocumentDataReply(buf), nil } -// Read reply into structure from buffer for PrintGetDocumentData +// printGetDocumentDataReply reads a byte slice into a PrintGetDocumentDataReply value. func printGetDocumentDataReply(buf []byte) *PrintGetDocumentDataReply { v := new(PrintGetDocumentDataReply) b := 1 // skip reply determinant @@ -1288,6 +1341,7 @@ func printGetDocumentDataReply(buf []byte) *PrintGetDocumentDataReply { } // Write request to wire for PrintGetDocumentData +// printGetDocumentDataRequest writes a PrintGetDocumentData request to a byte slice. func printGetDocumentDataRequest(c *xgb.Conn, Context Pcontext, MaxBytes uint32) []byte { size := 12 b := 0 @@ -1311,30 +1365,35 @@ func printGetDocumentDataRequest(c *xgb.Conn, Context Pcontext, MaxBytes uint32) return buf } -// Request PrintStartPage -// size: 8 +// PrintStartPageCookie is a cookie used only for PrintStartPage requests. type PrintStartPageCookie struct { *xgb.Cookie } -// Write request to wire for PrintStartPage +// PrintStartPage sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PrintStartPage(c *xgb.Conn, Window xproto.Window) PrintStartPageCookie { cookie := c.NewCookie(false, false) c.NewRequest(printStartPageRequest(c, Window), cookie) return PrintStartPageCookie{cookie} } +// PrintStartPageChecked sends a checked request. +// If an error occurs, it can be retrieved using PrintStartPageCookie.Check() func PrintStartPageChecked(c *xgb.Conn, Window xproto.Window) PrintStartPageCookie { cookie := c.NewCookie(true, false) c.NewRequest(printStartPageRequest(c, Window), cookie) return PrintStartPageCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook PrintStartPageCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for PrintStartPage +// printStartPageRequest writes a PrintStartPage request to a byte slice. func printStartPageRequest(c *xgb.Conn, Window xproto.Window) []byte { size := 8 b := 0 @@ -1355,30 +1414,35 @@ func printStartPageRequest(c *xgb.Conn, Window xproto.Window) []byte { return buf } -// Request PrintEndPage -// size: 8 +// PrintEndPageCookie is a cookie used only for PrintEndPage requests. type PrintEndPageCookie struct { *xgb.Cookie } -// Write request to wire for PrintEndPage +// PrintEndPage sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PrintEndPage(c *xgb.Conn, Cancel bool) PrintEndPageCookie { cookie := c.NewCookie(false, false) c.NewRequest(printEndPageRequest(c, Cancel), cookie) return PrintEndPageCookie{cookie} } +// PrintEndPageChecked sends a checked request. +// If an error occurs, it can be retrieved using PrintEndPageCookie.Check() func PrintEndPageChecked(c *xgb.Conn, Cancel bool) PrintEndPageCookie { cookie := c.NewCookie(true, false) c.NewRequest(printEndPageRequest(c, Cancel), cookie) return PrintEndPageCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook PrintEndPageCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for PrintEndPage +// printEndPageRequest writes a PrintEndPage request to a byte slice. func printEndPageRequest(c *xgb.Conn, Cancel bool) []byte { size := 8 b := 0 @@ -1405,30 +1469,35 @@ func printEndPageRequest(c *xgb.Conn, Cancel bool) []byte { return buf } -// Request PrintSelectInput -// size: xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(EventMask))))))) +// PrintSelectInputCookie is a cookie used only for PrintSelectInput requests. type PrintSelectInputCookie struct { *xgb.Cookie } -// Write request to wire for PrintSelectInput +// PrintSelectInput sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PrintSelectInput(c *xgb.Conn, Context Pcontext, EventMask uint32, EventList []uint32) PrintSelectInputCookie { cookie := c.NewCookie(false, false) c.NewRequest(printSelectInputRequest(c, Context, EventMask, EventList), cookie) return PrintSelectInputCookie{cookie} } +// PrintSelectInputChecked sends a checked request. +// If an error occurs, it can be retrieved using PrintSelectInputCookie.Check() func PrintSelectInputChecked(c *xgb.Conn, Context Pcontext, EventMask uint32, EventList []uint32) PrintSelectInputCookie { cookie := c.NewCookie(true, false) c.NewRequest(printSelectInputRequest(c, Context, EventMask, EventList), cookie) return PrintSelectInputCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook PrintSelectInputCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for PrintSelectInput +// printSelectInputRequest writes a PrintSelectInput request to a byte slice. func printSelectInputRequest(c *xgb.Conn, Context Pcontext, EventMask uint32, EventList []uint32) []byte { size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(EventMask))))))) b := 0 @@ -1457,29 +1526,31 @@ func printSelectInputRequest(c *xgb.Conn, Context Pcontext, EventMask uint32, Ev return buf } -// Request PrintInputSelected -// size: 8 +// PrintInputSelectedCookie is a cookie used only for PrintInputSelected requests. type PrintInputSelectedCookie struct { *xgb.Cookie } +// PrintInputSelected sends a checked request. +// If an error occurs, it will be returned with the reply by calling PrintInputSelectedCookie.Reply() func PrintInputSelected(c *xgb.Conn, Context Pcontext) PrintInputSelectedCookie { cookie := c.NewCookie(true, true) c.NewRequest(printInputSelectedRequest(c, Context), cookie) return PrintInputSelectedCookie{cookie} } +// PrintInputSelectedUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PrintInputSelectedUnchecked(c *xgb.Conn, Context Pcontext) PrintInputSelectedCookie { cookie := c.NewCookie(false, true) c.NewRequest(printInputSelectedRequest(c, Context), cookie) return PrintInputSelectedCookie{cookie} } -// Request reply for PrintInputSelected -// size: ((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(EventMask)))))) + (4 + xgb.Pad((4 * xgb.PopCount(int(AllEventsMask)))))) +// PrintInputSelectedReply represents the data returned from a PrintInputSelected request. type PrintInputSelectedReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes EventMask uint32 EventList []uint32 @@ -1487,7 +1558,7 @@ type PrintInputSelectedReply struct { AllEventsList []uint32 } -// Waits and reads reply data from request PrintInputSelected +// Reply blocks and returns the reply data for a PrintInputSelected request. func (cook PrintInputSelectedCookie) Reply() (*PrintInputSelectedReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1499,7 +1570,7 @@ func (cook PrintInputSelectedCookie) Reply() (*PrintInputSelectedReply, error) { return printInputSelectedReply(buf), nil } -// Read reply into structure from buffer for PrintInputSelected +// printInputSelectedReply reads a byte slice into a PrintInputSelectedReply value. func printInputSelectedReply(buf []byte) *PrintInputSelectedReply { v := new(PrintInputSelectedReply) b := 1 // skip reply determinant @@ -1536,6 +1607,7 @@ func printInputSelectedReply(buf []byte) *PrintInputSelectedReply { } // Write request to wire for PrintInputSelected +// printInputSelectedRequest writes a PrintInputSelected request to a byte slice. func printInputSelectedRequest(c *xgb.Conn, Context Pcontext) []byte { size := 8 b := 0 @@ -1556,36 +1628,38 @@ func printInputSelectedRequest(c *xgb.Conn, Context Pcontext) []byte { return buf } -// Request PrintGetAttributes -// size: 12 +// PrintGetAttributesCookie is a cookie used only for PrintGetAttributes requests. type PrintGetAttributesCookie struct { *xgb.Cookie } +// PrintGetAttributes sends a checked request. +// If an error occurs, it will be returned with the reply by calling PrintGetAttributesCookie.Reply() func PrintGetAttributes(c *xgb.Conn, Context Pcontext, Pool byte) PrintGetAttributesCookie { cookie := c.NewCookie(true, true) c.NewRequest(printGetAttributesRequest(c, Context, Pool), cookie) return PrintGetAttributesCookie{cookie} } +// PrintGetAttributesUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PrintGetAttributesUnchecked(c *xgb.Conn, Context Pcontext, Pool byte) PrintGetAttributesCookie { cookie := c.NewCookie(false, true) c.NewRequest(printGetAttributesRequest(c, Context, Pool), cookie) return PrintGetAttributesCookie{cookie} } -// Request reply for PrintGetAttributes -// size: 33 +// PrintGetAttributesReply represents the data returned from a PrintGetAttributes request. type PrintGetAttributesReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes StringLen uint32 // padding: 20 bytes Attributes String8 } -// Waits and reads reply data from request PrintGetAttributes +// Reply blocks and returns the reply data for a PrintGetAttributes request. func (cook PrintGetAttributesCookie) Reply() (*PrintGetAttributesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1597,7 +1671,7 @@ func (cook PrintGetAttributesCookie) Reply() (*PrintGetAttributesReply, error) { return printGetAttributesReply(buf), nil } -// Read reply into structure from buffer for PrintGetAttributes +// printGetAttributesReply reads a byte slice into a PrintGetAttributesReply value. func printGetAttributesReply(buf []byte) *PrintGetAttributesReply { v := new(PrintGetAttributesReply) b := 1 // skip reply determinant @@ -1622,6 +1696,7 @@ func printGetAttributesReply(buf []byte) *PrintGetAttributesReply { } // Write request to wire for PrintGetAttributes +// printGetAttributesRequest writes a PrintGetAttributes request to a byte slice. func printGetAttributesRequest(c *xgb.Conn, Context Pcontext, Pool byte) []byte { size := 12 b := 0 @@ -1647,36 +1722,38 @@ func printGetAttributesRequest(c *xgb.Conn, Context Pcontext, Pool byte) []byte return buf } -// Request PrintGetOneAttributes -// size: xgb.Pad((16 + xgb.Pad((int(NameLen) * 1)))) +// PrintGetOneAttributesCookie is a cookie used only for PrintGetOneAttributes requests. type PrintGetOneAttributesCookie struct { *xgb.Cookie } +// PrintGetOneAttributes sends a checked request. +// If an error occurs, it will be returned with the reply by calling PrintGetOneAttributesCookie.Reply() func PrintGetOneAttributes(c *xgb.Conn, Context Pcontext, NameLen uint32, Pool byte, Name []String8) PrintGetOneAttributesCookie { cookie := c.NewCookie(true, true) c.NewRequest(printGetOneAttributesRequest(c, Context, NameLen, Pool, Name), cookie) return PrintGetOneAttributesCookie{cookie} } +// PrintGetOneAttributesUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PrintGetOneAttributesUnchecked(c *xgb.Conn, Context Pcontext, NameLen uint32, Pool byte, Name []String8) PrintGetOneAttributesCookie { cookie := c.NewCookie(false, true) c.NewRequest(printGetOneAttributesRequest(c, Context, NameLen, Pool, Name), cookie) return PrintGetOneAttributesCookie{cookie} } -// Request reply for PrintGetOneAttributes -// size: (32 + xgb.Pad((int(ValueLen) * 1))) +// PrintGetOneAttributesReply represents the data returned from a PrintGetOneAttributes request. type PrintGetOneAttributesReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes ValueLen uint32 // padding: 20 bytes Value []String8 // size: xgb.Pad((int(ValueLen) * 1)) } -// Waits and reads reply data from request PrintGetOneAttributes +// Reply blocks and returns the reply data for a PrintGetOneAttributes request. func (cook PrintGetOneAttributesCookie) Reply() (*PrintGetOneAttributesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1688,7 +1765,7 @@ func (cook PrintGetOneAttributesCookie) Reply() (*PrintGetOneAttributesReply, er return printGetOneAttributesReply(buf), nil } -// Read reply into structure from buffer for PrintGetOneAttributes +// printGetOneAttributesReply reads a byte slice into a PrintGetOneAttributesReply value. func printGetOneAttributesReply(buf []byte) *PrintGetOneAttributesReply { v := new(PrintGetOneAttributesReply) b := 1 // skip reply determinant @@ -1717,6 +1794,7 @@ func printGetOneAttributesReply(buf []byte) *PrintGetOneAttributesReply { } // Write request to wire for PrintGetOneAttributes +// printGetOneAttributesRequest writes a PrintGetOneAttributes request to a byte slice. func printGetOneAttributesRequest(c *xgb.Conn, Context Pcontext, NameLen uint32, Pool byte, Name []String8) []byte { size := xgb.Pad((16 + xgb.Pad((int(NameLen) * 1)))) b := 0 @@ -1751,30 +1829,35 @@ func printGetOneAttributesRequest(c *xgb.Conn, Context Pcontext, NameLen uint32, return buf } -// Request PrintSetAttributes -// size: xgb.Pad((16 + xgb.Pad((len(Attributes) * 1)))) +// PrintSetAttributesCookie is a cookie used only for PrintSetAttributes requests. type PrintSetAttributesCookie struct { *xgb.Cookie } -// Write request to wire for PrintSetAttributes +// PrintSetAttributes sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PrintSetAttributes(c *xgb.Conn, Context Pcontext, StringLen uint32, Pool byte, Rule byte, Attributes []String8) PrintSetAttributesCookie { cookie := c.NewCookie(false, false) c.NewRequest(printSetAttributesRequest(c, Context, StringLen, Pool, Rule, Attributes), cookie) return PrintSetAttributesCookie{cookie} } +// PrintSetAttributesChecked sends a checked request. +// If an error occurs, it can be retrieved using PrintSetAttributesCookie.Check() func PrintSetAttributesChecked(c *xgb.Conn, Context Pcontext, StringLen uint32, Pool byte, Rule byte, Attributes []String8) PrintSetAttributesCookie { cookie := c.NewCookie(true, false) c.NewRequest(printSetAttributesRequest(c, Context, StringLen, Pool, Rule, Attributes), cookie) return PrintSetAttributesCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook PrintSetAttributesCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for PrintSetAttributes +// printSetAttributesRequest writes a PrintSetAttributes request to a byte slice. func printSetAttributesRequest(c *xgb.Conn, Context Pcontext, StringLen uint32, Pool byte, Rule byte, Attributes []String8) []byte { size := xgb.Pad((16 + xgb.Pad((len(Attributes) * 1)))) b := 0 @@ -1812,29 +1895,31 @@ func printSetAttributesRequest(c *xgb.Conn, Context Pcontext, StringLen uint32, return buf } -// Request PrintGetPageDimensions -// size: 8 +// PrintGetPageDimensionsCookie is a cookie used only for PrintGetPageDimensions requests. type PrintGetPageDimensionsCookie struct { *xgb.Cookie } +// PrintGetPageDimensions sends a checked request. +// If an error occurs, it will be returned with the reply by calling PrintGetPageDimensionsCookie.Reply() func PrintGetPageDimensions(c *xgb.Conn, Context Pcontext) PrintGetPageDimensionsCookie { cookie := c.NewCookie(true, true) c.NewRequest(printGetPageDimensionsRequest(c, Context), cookie) return PrintGetPageDimensionsCookie{cookie} } +// PrintGetPageDimensionsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PrintGetPageDimensionsUnchecked(c *xgb.Conn, Context Pcontext) PrintGetPageDimensionsCookie { cookie := c.NewCookie(false, true) c.NewRequest(printGetPageDimensionsRequest(c, Context), cookie) return PrintGetPageDimensionsCookie{cookie} } -// Request reply for PrintGetPageDimensions -// size: 20 +// PrintGetPageDimensionsReply represents the data returned from a PrintGetPageDimensions request. type PrintGetPageDimensionsReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Width uint16 Height uint16 @@ -1844,7 +1929,7 @@ type PrintGetPageDimensionsReply struct { ReproducibleHeight uint16 } -// Waits and reads reply data from request PrintGetPageDimensions +// Reply blocks and returns the reply data for a PrintGetPageDimensions request. func (cook PrintGetPageDimensionsCookie) Reply() (*PrintGetPageDimensionsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1856,7 +1941,7 @@ func (cook PrintGetPageDimensionsCookie) Reply() (*PrintGetPageDimensionsReply, return printGetPageDimensionsReply(buf), nil } -// Read reply into structure from buffer for PrintGetPageDimensions +// printGetPageDimensionsReply reads a byte slice into a PrintGetPageDimensionsReply value. func printGetPageDimensionsReply(buf []byte) *PrintGetPageDimensionsReply { v := new(PrintGetPageDimensionsReply) b := 1 // skip reply determinant @@ -1891,6 +1976,7 @@ func printGetPageDimensionsReply(buf []byte) *PrintGetPageDimensionsReply { } // Write request to wire for PrintGetPageDimensions +// printGetPageDimensionsRequest writes a PrintGetPageDimensions request to a byte slice. func printGetPageDimensionsRequest(c *xgb.Conn, Context Pcontext) []byte { size := 8 b := 0 @@ -1911,36 +1997,38 @@ func printGetPageDimensionsRequest(c *xgb.Conn, Context Pcontext) []byte { return buf } -// Request PrintQueryScreens -// size: 4 +// PrintQueryScreensCookie is a cookie used only for PrintQueryScreens requests. type PrintQueryScreensCookie struct { *xgb.Cookie } +// PrintQueryScreens sends a checked request. +// If an error occurs, it will be returned with the reply by calling PrintQueryScreensCookie.Reply() func PrintQueryScreens(c *xgb.Conn) PrintQueryScreensCookie { cookie := c.NewCookie(true, true) c.NewRequest(printQueryScreensRequest(c), cookie) return PrintQueryScreensCookie{cookie} } +// PrintQueryScreensUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PrintQueryScreensUnchecked(c *xgb.Conn) PrintQueryScreensCookie { cookie := c.NewCookie(false, true) c.NewRequest(printQueryScreensRequest(c), cookie) return PrintQueryScreensCookie{cookie} } -// Request reply for PrintQueryScreens -// size: (32 + xgb.Pad((int(ListCount) * 4))) +// PrintQueryScreensReply represents the data returned from a PrintQueryScreens request. type PrintQueryScreensReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes ListCount uint32 // padding: 20 bytes Roots []xproto.Window // size: xgb.Pad((int(ListCount) * 4)) } -// Waits and reads reply data from request PrintQueryScreens +// Reply blocks and returns the reply data for a PrintQueryScreens request. func (cook PrintQueryScreensCookie) Reply() (*PrintQueryScreensReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1952,7 +2040,7 @@ func (cook PrintQueryScreensCookie) Reply() (*PrintQueryScreensReply, error) { return printQueryScreensReply(buf), nil } -// Read reply into structure from buffer for PrintQueryScreens +// printQueryScreensReply reads a byte slice into a PrintQueryScreensReply value. func printQueryScreensReply(buf []byte) *PrintQueryScreensReply { v := new(PrintQueryScreensReply) b := 1 // skip reply determinant @@ -1981,6 +2069,7 @@ func printQueryScreensReply(buf []byte) *PrintQueryScreensReply { } // Write request to wire for PrintQueryScreens +// printQueryScreensRequest writes a PrintQueryScreens request to a byte slice. func printQueryScreensRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -1998,34 +2087,36 @@ func printQueryScreensRequest(c *xgb.Conn) []byte { return buf } -// Request PrintSetImageResolution -// size: 12 +// PrintSetImageResolutionCookie is a cookie used only for PrintSetImageResolution requests. type PrintSetImageResolutionCookie struct { *xgb.Cookie } +// PrintSetImageResolution sends a checked request. +// If an error occurs, it will be returned with the reply by calling PrintSetImageResolutionCookie.Reply() func PrintSetImageResolution(c *xgb.Conn, Context Pcontext, ImageResolution uint16) PrintSetImageResolutionCookie { cookie := c.NewCookie(true, true) c.NewRequest(printSetImageResolutionRequest(c, Context, ImageResolution), cookie) return PrintSetImageResolutionCookie{cookie} } +// PrintSetImageResolutionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PrintSetImageResolutionUnchecked(c *xgb.Conn, Context Pcontext, ImageResolution uint16) PrintSetImageResolutionCookie { cookie := c.NewCookie(false, true) c.NewRequest(printSetImageResolutionRequest(c, Context, ImageResolution), cookie) return PrintSetImageResolutionCookie{cookie} } -// Request reply for PrintSetImageResolution -// size: 10 +// PrintSetImageResolutionReply represents the data returned from a PrintSetImageResolution request. type PrintSetImageResolutionReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply Status bool PreviousResolutions uint16 } -// Waits and reads reply data from request PrintSetImageResolution +// Reply blocks and returns the reply data for a PrintSetImageResolution request. func (cook PrintSetImageResolutionCookie) Reply() (*PrintSetImageResolutionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -2037,7 +2128,7 @@ func (cook PrintSetImageResolutionCookie) Reply() (*PrintSetImageResolutionReply return printSetImageResolutionReply(buf), nil } -// Read reply into structure from buffer for PrintSetImageResolution +// printSetImageResolutionReply reads a byte slice into a PrintSetImageResolutionReply value. func printSetImageResolutionReply(buf []byte) *PrintSetImageResolutionReply { v := new(PrintSetImageResolutionReply) b := 1 // skip reply determinant @@ -2062,6 +2153,7 @@ func printSetImageResolutionReply(buf []byte) *PrintSetImageResolutionReply { } // Write request to wire for PrintSetImageResolution +// printSetImageResolutionRequest writes a PrintSetImageResolution request to a byte slice. func printSetImageResolutionRequest(c *xgb.Conn, Context Pcontext, ImageResolution uint16) []byte { size := 12 b := 0 @@ -2085,34 +2177,36 @@ func printSetImageResolutionRequest(c *xgb.Conn, Context Pcontext, ImageResoluti return buf } -// Request PrintGetImageResolution -// size: 8 +// PrintGetImageResolutionCookie is a cookie used only for PrintGetImageResolution requests. type PrintGetImageResolutionCookie struct { *xgb.Cookie } +// PrintGetImageResolution sends a checked request. +// If an error occurs, it will be returned with the reply by calling PrintGetImageResolutionCookie.Reply() func PrintGetImageResolution(c *xgb.Conn, Context Pcontext) PrintGetImageResolutionCookie { cookie := c.NewCookie(true, true) c.NewRequest(printGetImageResolutionRequest(c, Context), cookie) return PrintGetImageResolutionCookie{cookie} } +// PrintGetImageResolutionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PrintGetImageResolutionUnchecked(c *xgb.Conn, Context Pcontext) PrintGetImageResolutionCookie { cookie := c.NewCookie(false, true) c.NewRequest(printGetImageResolutionRequest(c, Context), cookie) return PrintGetImageResolutionCookie{cookie} } -// Request reply for PrintGetImageResolution -// size: 10 +// PrintGetImageResolutionReply represents the data returned from a PrintGetImageResolution request. type PrintGetImageResolutionReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes ImageResolution uint16 } -// Waits and reads reply data from request PrintGetImageResolution +// Reply blocks and returns the reply data for a PrintGetImageResolution request. func (cook PrintGetImageResolutionCookie) Reply() (*PrintGetImageResolutionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -2124,7 +2218,7 @@ func (cook PrintGetImageResolutionCookie) Reply() (*PrintGetImageResolutionReply return printGetImageResolutionReply(buf), nil } -// Read reply into structure from buffer for PrintGetImageResolution +// printGetImageResolutionReply reads a byte slice into a PrintGetImageResolutionReply value. func printGetImageResolutionReply(buf []byte) *PrintGetImageResolutionReply { v := new(PrintGetImageResolutionReply) b := 1 // skip reply determinant @@ -2144,6 +2238,7 @@ func printGetImageResolutionReply(buf []byte) *PrintGetImageResolutionReply { } // Write request to wire for PrintGetImageResolution +// printGetImageResolutionRequest writes a PrintGetImageResolution request to a byte slice. func printGetImageResolutionRequest(c *xgb.Conn, Context Pcontext) []byte { size := 8 b := 0 diff --git a/nexgb/xproto/xproto.go b/nexgb/xproto/xproto.go index 39956f1..6b0fb6b 100644 --- a/nexgb/xproto/xproto.go +++ b/nexgb/xproto/xproto.go @@ -2,7 +2,7 @@ package xproto /* - This file was generated by xproto.xml on May 10 2012 8:04:32pm EDT. + This file was generated by xproto.xml on May 10 2012 11:56:19pm EDT. This file is automatically generated. Edit at your peril! */ @@ -23,16 +23,6 @@ func (s *SetupInfo) DefaultScreen(c *xgb.Conn) *ScreenInfo { return &s.Roots[c.DefaultScreen] } -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - -// Skipping definition for base type 'Float' - // Skipping definition for base type 'Card8' // Skipping definition for base type 'Int16' @@ -47,6 +37,16 @@ func (s *SetupInfo) DefaultScreen(c *xgb.Conn) *ScreenInfo { // Skipping definition for base type 'Card16' +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Bool' + +// Skipping definition for base type 'Float' + const ( VisualClassStaticGray = 0 VisualClassGrayScale = 1 @@ -733,14 +733,12 @@ type Keycode byte type Button byte -// 'Char2b' struct definition -// Size: 2 type Char2b struct { Byte1 byte Byte2 byte } -// Struct read Char2b +// Char2bRead reads a byte slice into a Char2b value. func Char2bRead(buf []byte, v *Char2b) int { b := 0 @@ -753,7 +751,7 @@ func Char2bRead(buf []byte, v *Char2b) int { return b } -// Struct list read Char2b +// Char2bReadList reads a byte slice into a list of Char2b values. func Char2bReadList(buf []byte, dest []Char2b) int { b := 0 for i := 0; i < len(dest); i++ { @@ -763,7 +761,7 @@ func Char2bReadList(buf []byte, dest []Char2b) int { return xgb.Pad(b) } -// Struct write Char2b +// Bytes writes a Char2b value to a byte slice. func (v Char2b) Bytes() []byte { buf := make([]byte, 2) b := 0 @@ -777,7 +775,7 @@ func (v Char2b) Bytes() []byte { return buf } -// Write struct list Char2b +// Char2bListBytes writes a list of %s(MISSING) values to a byte slice. func Char2bListBytes(buf []byte, list []Char2b) int { b := 0 var structBytes []byte @@ -789,14 +787,12 @@ func Char2bListBytes(buf []byte, list []Char2b) int { return b } -// 'Point' struct definition -// Size: 4 type Point struct { X int16 Y int16 } -// Struct read Point +// PointRead reads a byte slice into a Point value. func PointRead(buf []byte, v *Point) int { b := 0 @@ -809,7 +805,7 @@ func PointRead(buf []byte, v *Point) int { return b } -// Struct list read Point +// PointReadList reads a byte slice into a list of Point values. func PointReadList(buf []byte, dest []Point) int { b := 0 for i := 0; i < len(dest); i++ { @@ -819,7 +815,7 @@ func PointReadList(buf []byte, dest []Point) int { return xgb.Pad(b) } -// Struct write Point +// Bytes writes a Point value to a byte slice. func (v Point) Bytes() []byte { buf := make([]byte, 4) b := 0 @@ -833,7 +829,7 @@ func (v Point) Bytes() []byte { return buf } -// Write struct list Point +// PointListBytes writes a list of %s(MISSING) values to a byte slice. func PointListBytes(buf []byte, list []Point) int { b := 0 var structBytes []byte @@ -845,8 +841,6 @@ func PointListBytes(buf []byte, list []Point) int { return b } -// 'Rectangle' struct definition -// Size: 8 type Rectangle struct { X int16 Y int16 @@ -854,7 +848,7 @@ type Rectangle struct { Height uint16 } -// Struct read Rectangle +// RectangleRead reads a byte slice into a Rectangle value. func RectangleRead(buf []byte, v *Rectangle) int { b := 0 @@ -873,7 +867,7 @@ func RectangleRead(buf []byte, v *Rectangle) int { return b } -// Struct list read Rectangle +// RectangleReadList reads a byte slice into a list of Rectangle values. func RectangleReadList(buf []byte, dest []Rectangle) int { b := 0 for i := 0; i < len(dest); i++ { @@ -883,7 +877,7 @@ func RectangleReadList(buf []byte, dest []Rectangle) int { return xgb.Pad(b) } -// Struct write Rectangle +// Bytes writes a Rectangle value to a byte slice. func (v Rectangle) Bytes() []byte { buf := make([]byte, 8) b := 0 @@ -903,7 +897,7 @@ func (v Rectangle) Bytes() []byte { return buf } -// Write struct list Rectangle +// RectangleListBytes writes a list of %s(MISSING) values to a byte slice. func RectangleListBytes(buf []byte, list []Rectangle) int { b := 0 var structBytes []byte @@ -915,8 +909,6 @@ func RectangleListBytes(buf []byte, list []Rectangle) int { return b } -// 'Arc' struct definition -// Size: 12 type Arc struct { X int16 Y int16 @@ -926,7 +918,7 @@ type Arc struct { Angle2 int16 } -// Struct read Arc +// ArcRead reads a byte slice into a Arc value. func ArcRead(buf []byte, v *Arc) int { b := 0 @@ -951,7 +943,7 @@ func ArcRead(buf []byte, v *Arc) int { return b } -// Struct list read Arc +// ArcReadList reads a byte slice into a list of Arc values. func ArcReadList(buf []byte, dest []Arc) int { b := 0 for i := 0; i < len(dest); i++ { @@ -961,7 +953,7 @@ func ArcReadList(buf []byte, dest []Arc) int { return xgb.Pad(b) } -// Struct write Arc +// Bytes writes a Arc value to a byte slice. func (v Arc) Bytes() []byte { buf := make([]byte, 12) b := 0 @@ -987,7 +979,7 @@ func (v Arc) Bytes() []byte { return buf } -// Write struct list Arc +// ArcListBytes writes a list of %s(MISSING) values to a byte slice. func ArcListBytes(buf []byte, list []Arc) int { b := 0 var structBytes []byte @@ -999,8 +991,6 @@ func ArcListBytes(buf []byte, list []Arc) int { return b } -// 'Format' struct definition -// Size: 8 type Format struct { Depth byte BitsPerPixel byte @@ -1008,7 +998,7 @@ type Format struct { // padding: 5 bytes } -// Struct read Format +// FormatRead reads a byte slice into a Format value. func FormatRead(buf []byte, v *Format) int { b := 0 @@ -1026,7 +1016,7 @@ func FormatRead(buf []byte, v *Format) int { return b } -// Struct list read Format +// FormatReadList reads a byte slice into a list of Format values. func FormatReadList(buf []byte, dest []Format) int { b := 0 for i := 0; i < len(dest); i++ { @@ -1036,7 +1026,7 @@ func FormatReadList(buf []byte, dest []Format) int { return xgb.Pad(b) } -// Struct write Format +// Bytes writes a Format value to a byte slice. func (v Format) Bytes() []byte { buf := make([]byte, 8) b := 0 @@ -1055,7 +1045,7 @@ func (v Format) Bytes() []byte { return buf } -// Write struct list Format +// FormatListBytes writes a list of %s(MISSING) values to a byte slice. func FormatListBytes(buf []byte, list []Format) int { b := 0 var structBytes []byte @@ -1067,8 +1057,6 @@ func FormatListBytes(buf []byte, list []Format) int { return b } -// 'VisualInfo' struct definition -// Size: 24 type VisualInfo struct { VisualId Visualid Class byte @@ -1080,7 +1068,7 @@ type VisualInfo struct { // padding: 4 bytes } -// Struct read VisualInfo +// VisualInfoRead reads a byte slice into a VisualInfo value. func VisualInfoRead(buf []byte, v *VisualInfo) int { b := 0 @@ -1110,7 +1098,7 @@ func VisualInfoRead(buf []byte, v *VisualInfo) int { return b } -// Struct list read VisualInfo +// VisualInfoReadList reads a byte slice into a list of VisualInfo values. func VisualInfoReadList(buf []byte, dest []VisualInfo) int { b := 0 for i := 0; i < len(dest); i++ { @@ -1120,7 +1108,7 @@ func VisualInfoReadList(buf []byte, dest []VisualInfo) int { return xgb.Pad(b) } -// Struct write VisualInfo +// Bytes writes a VisualInfo value to a byte slice. func (v VisualInfo) Bytes() []byte { buf := make([]byte, 24) b := 0 @@ -1151,7 +1139,7 @@ func (v VisualInfo) Bytes() []byte { return buf } -// Write struct list VisualInfo +// VisualInfoListBytes writes a list of %s(MISSING) values to a byte slice. func VisualInfoListBytes(buf []byte, list []VisualInfo) int { b := 0 var structBytes []byte @@ -1163,8 +1151,6 @@ func VisualInfoListBytes(buf []byte, list []VisualInfo) int { return b } -// 'DepthInfo' struct definition -// Size: (8 + xgb.Pad((int(VisualsLen) * 24))) type DepthInfo struct { Depth byte // padding: 1 bytes @@ -1173,7 +1159,7 @@ type DepthInfo struct { Visuals []VisualInfo // size: xgb.Pad((int(VisualsLen) * 24)) } -// Struct read DepthInfo +// DepthInfoRead reads a byte slice into a DepthInfo value. func DepthInfoRead(buf []byte, v *DepthInfo) int { b := 0 @@ -1193,7 +1179,7 @@ func DepthInfoRead(buf []byte, v *DepthInfo) int { return b } -// Struct list read DepthInfo +// DepthInfoReadList reads a byte slice into a list of DepthInfo values. func DepthInfoReadList(buf []byte, dest []DepthInfo) int { b := 0 for i := 0; i < len(dest); i++ { @@ -1203,7 +1189,7 @@ func DepthInfoReadList(buf []byte, dest []DepthInfo) int { return xgb.Pad(b) } -// Struct write DepthInfo +// Bytes writes a DepthInfo value to a byte slice. func (v DepthInfo) Bytes() []byte { buf := make([]byte, (8 + xgb.Pad((int(v.VisualsLen) * 24)))) b := 0 @@ -1223,7 +1209,7 @@ func (v DepthInfo) Bytes() []byte { return buf } -// Write struct list DepthInfo +// DepthInfoListBytes writes a list of %s(MISSING) values to a byte slice. func DepthInfoListBytes(buf []byte, list []DepthInfo) int { b := 0 var structBytes []byte @@ -1235,7 +1221,7 @@ func DepthInfoListBytes(buf []byte, list []DepthInfo) int { return b } -// Struct list size DepthInfo +// DepthInfoListSize computes the size (bytes) of a list of DepthInfo values. func DepthInfoListSize(list []DepthInfo) int { size := 0 for _, item := range list { @@ -1244,8 +1230,6 @@ func DepthInfoListSize(list []DepthInfo) int { return size } -// 'ScreenInfo' struct definition -// Size: (40 + DepthInfoListSize(AllowedDepths)) type ScreenInfo struct { Root Window DefaultColormap Colormap @@ -1266,7 +1250,7 @@ type ScreenInfo struct { AllowedDepths []DepthInfo // size: DepthInfoListSize(AllowedDepths) } -// Struct read ScreenInfo +// ScreenInfoRead reads a byte slice into a ScreenInfo value. func ScreenInfoRead(buf []byte, v *ScreenInfo) int { b := 0 @@ -1328,7 +1312,7 @@ func ScreenInfoRead(buf []byte, v *ScreenInfo) int { return b } -// Struct list read ScreenInfo +// ScreenInfoReadList reads a byte slice into a list of ScreenInfo values. func ScreenInfoReadList(buf []byte, dest []ScreenInfo) int { b := 0 for i := 0; i < len(dest); i++ { @@ -1338,7 +1322,7 @@ func ScreenInfoReadList(buf []byte, dest []ScreenInfo) int { return xgb.Pad(b) } -// Struct write ScreenInfo +// Bytes writes a ScreenInfo value to a byte slice. func (v ScreenInfo) Bytes() []byte { buf := make([]byte, (40 + DepthInfoListSize(v.AllowedDepths))) b := 0 @@ -1400,7 +1384,7 @@ func (v ScreenInfo) Bytes() []byte { return buf } -// Write struct list ScreenInfo +// ScreenInfoListBytes writes a list of %s(MISSING) values to a byte slice. func ScreenInfoListBytes(buf []byte, list []ScreenInfo) int { b := 0 var structBytes []byte @@ -1412,7 +1396,7 @@ func ScreenInfoListBytes(buf []byte, list []ScreenInfo) int { return b } -// Struct list size ScreenInfo +// ScreenInfoListSize computes the size (bytes) of a list of ScreenInfo values. func ScreenInfoListSize(list []ScreenInfo) int { size := 0 for _, item := range list { @@ -1421,8 +1405,6 @@ func ScreenInfoListSize(list []ScreenInfo) int { return size } -// 'SetupRequest' struct definition -// Size: ((12 + xgb.Pad((int(AuthorizationProtocolNameLen) * 1))) + xgb.Pad((int(AuthorizationProtocolDataLen) * 1))) type SetupRequest struct { ByteOrder byte // padding: 1 bytes @@ -1435,7 +1417,7 @@ type SetupRequest struct { AuthorizationProtocolData string // size: xgb.Pad((int(AuthorizationProtocolDataLen) * 1)) } -// Struct read SetupRequest +// SetupRequestRead reads a byte slice into a SetupRequest value. func SetupRequestRead(buf []byte, v *SetupRequest) int { b := 0 @@ -1475,7 +1457,7 @@ func SetupRequestRead(buf []byte, v *SetupRequest) int { return b } -// Struct list read SetupRequest +// SetupRequestReadList reads a byte slice into a list of SetupRequest values. func SetupRequestReadList(buf []byte, dest []SetupRequest) int { b := 0 for i := 0; i < len(dest); i++ { @@ -1485,7 +1467,7 @@ func SetupRequestReadList(buf []byte, dest []SetupRequest) int { return xgb.Pad(b) } -// Struct write SetupRequest +// Bytes writes a SetupRequest value to a byte slice. func (v SetupRequest) Bytes() []byte { buf := make([]byte, ((12 + xgb.Pad((int(v.AuthorizationProtocolNameLen) * 1))) + xgb.Pad((int(v.AuthorizationProtocolDataLen) * 1)))) b := 0 @@ -1518,7 +1500,7 @@ func (v SetupRequest) Bytes() []byte { return buf } -// Write struct list SetupRequest +// SetupRequestListBytes writes a list of %s(MISSING) values to a byte slice. func SetupRequestListBytes(buf []byte, list []SetupRequest) int { b := 0 var structBytes []byte @@ -1530,7 +1512,7 @@ func SetupRequestListBytes(buf []byte, list []SetupRequest) int { return b } -// Struct list size SetupRequest +// SetupRequestListSize computes the size (bytes) of a list of SetupRequest values. func SetupRequestListSize(list []SetupRequest) int { size := 0 for _, item := range list { @@ -1539,8 +1521,6 @@ func SetupRequestListSize(list []SetupRequest) int { return size } -// 'SetupFailed' struct definition -// Size: (8 + xgb.Pad((int(ReasonLen) * 1))) type SetupFailed struct { Status byte ReasonLen byte @@ -1550,7 +1530,7 @@ type SetupFailed struct { Reason string // size: xgb.Pad((int(ReasonLen) * 1)) } -// Struct read SetupFailed +// SetupFailedRead reads a byte slice into a SetupFailed value. func SetupFailedRead(buf []byte, v *SetupFailed) int { b := 0 @@ -1579,7 +1559,7 @@ func SetupFailedRead(buf []byte, v *SetupFailed) int { return b } -// Struct list read SetupFailed +// SetupFailedReadList reads a byte slice into a list of SetupFailed values. func SetupFailedReadList(buf []byte, dest []SetupFailed) int { b := 0 for i := 0; i < len(dest); i++ { @@ -1589,7 +1569,7 @@ func SetupFailedReadList(buf []byte, dest []SetupFailed) int { return xgb.Pad(b) } -// Struct write SetupFailed +// Bytes writes a SetupFailed value to a byte slice. func (v SetupFailed) Bytes() []byte { buf := make([]byte, (8 + xgb.Pad((int(v.ReasonLen) * 1)))) b := 0 @@ -1615,7 +1595,7 @@ func (v SetupFailed) Bytes() []byte { return buf } -// Write struct list SetupFailed +// SetupFailedListBytes writes a list of %s(MISSING) values to a byte slice. func SetupFailedListBytes(buf []byte, list []SetupFailed) int { b := 0 var structBytes []byte @@ -1627,7 +1607,7 @@ func SetupFailedListBytes(buf []byte, list []SetupFailed) int { return b } -// Struct list size SetupFailed +// SetupFailedListSize computes the size (bytes) of a list of SetupFailed values. func SetupFailedListSize(list []SetupFailed) int { size := 0 for _, item := range list { @@ -1636,8 +1616,6 @@ func SetupFailedListSize(list []SetupFailed) int { return size } -// 'SetupAuthenticate' struct definition -// Size: (8 + xgb.Pad(((int(Length) * 4) * 1))) type SetupAuthenticate struct { Status byte // padding: 5 bytes @@ -1645,7 +1623,7 @@ type SetupAuthenticate struct { Reason string // size: xgb.Pad(((int(Length) * 4) * 1)) } -// Struct read SetupAuthenticate +// SetupAuthenticateRead reads a byte slice into a SetupAuthenticate value. func SetupAuthenticateRead(buf []byte, v *SetupAuthenticate) int { b := 0 @@ -1667,7 +1645,7 @@ func SetupAuthenticateRead(buf []byte, v *SetupAuthenticate) int { return b } -// Struct list read SetupAuthenticate +// SetupAuthenticateReadList reads a byte slice into a list of SetupAuthenticate values. func SetupAuthenticateReadList(buf []byte, dest []SetupAuthenticate) int { b := 0 for i := 0; i < len(dest); i++ { @@ -1677,7 +1655,7 @@ func SetupAuthenticateReadList(buf []byte, dest []SetupAuthenticate) int { return xgb.Pad(b) } -// Struct write SetupAuthenticate +// Bytes writes a SetupAuthenticate value to a byte slice. func (v SetupAuthenticate) Bytes() []byte { buf := make([]byte, (8 + xgb.Pad(((int(v.Length) * 4) * 1)))) b := 0 @@ -1696,7 +1674,7 @@ func (v SetupAuthenticate) Bytes() []byte { return buf } -// Write struct list SetupAuthenticate +// SetupAuthenticateListBytes writes a list of %s(MISSING) values to a byte slice. func SetupAuthenticateListBytes(buf []byte, list []SetupAuthenticate) int { b := 0 var structBytes []byte @@ -1708,7 +1686,7 @@ func SetupAuthenticateListBytes(buf []byte, list []SetupAuthenticate) int { return b } -// Struct list size SetupAuthenticate +// SetupAuthenticateListSize computes the size (bytes) of a list of SetupAuthenticate values. func SetupAuthenticateListSize(list []SetupAuthenticate) int { size := 0 for _, item := range list { @@ -1717,8 +1695,6 @@ func SetupAuthenticateListSize(list []SetupAuthenticate) int { return size } -// 'SetupInfo' struct definition -// Size: (((40 + xgb.Pad((int(VendorLen) * 1))) + xgb.Pad((int(PixmapFormatsLen) * 8))) + ScreenInfoListSize(Roots)) type SetupInfo struct { Status byte // padding: 1 bytes @@ -1745,7 +1721,7 @@ type SetupInfo struct { Roots []ScreenInfo // size: ScreenInfoListSize(Roots) } -// Struct read SetupInfo +// SetupInfoRead reads a byte slice into a SetupInfo value. func SetupInfoRead(buf []byte, v *SetupInfo) int { b := 0 @@ -1823,7 +1799,7 @@ func SetupInfoRead(buf []byte, v *SetupInfo) int { return b } -// Struct list read SetupInfo +// SetupInfoReadList reads a byte slice into a list of SetupInfo values. func SetupInfoReadList(buf []byte, dest []SetupInfo) int { b := 0 for i := 0; i < len(dest); i++ { @@ -1833,7 +1809,7 @@ func SetupInfoReadList(buf []byte, dest []SetupInfo) int { return xgb.Pad(b) } -// Struct write SetupInfo +// Bytes writes a SetupInfo value to a byte slice. func (v SetupInfo) Bytes() []byte { buf := make([]byte, (((40 + xgb.Pad((int(v.VendorLen) * 1))) + xgb.Pad((int(v.PixmapFormatsLen) * 8))) + ScreenInfoListSize(v.Roots))) b := 0 @@ -1906,7 +1882,7 @@ func (v SetupInfo) Bytes() []byte { return buf } -// Write struct list SetupInfo +// SetupInfoListBytes writes a list of %s(MISSING) values to a byte slice. func SetupInfoListBytes(buf []byte, list []SetupInfo) int { b := 0 var structBytes []byte @@ -1918,7 +1894,7 @@ func SetupInfoListBytes(buf []byte, list []SetupInfo) int { return b } -// Struct list size SetupInfo +// SetupInfoListSize computes the size (bytes) of a list of SetupInfo values. func SetupInfoListSize(list []SetupInfo) int { size := 0 for _, item := range list { @@ -1927,15 +1903,13 @@ func SetupInfoListSize(list []SetupInfo) int { return size } -// 'Timecoord' struct definition -// Size: 8 type Timecoord struct { Time Timestamp X int16 Y int16 } -// Struct read Timecoord +// TimecoordRead reads a byte slice into a Timecoord value. func TimecoordRead(buf []byte, v *Timecoord) int { b := 0 @@ -1951,7 +1925,7 @@ func TimecoordRead(buf []byte, v *Timecoord) int { return b } -// Struct list read Timecoord +// TimecoordReadList reads a byte slice into a list of Timecoord values. func TimecoordReadList(buf []byte, dest []Timecoord) int { b := 0 for i := 0; i < len(dest); i++ { @@ -1961,7 +1935,7 @@ func TimecoordReadList(buf []byte, dest []Timecoord) int { return xgb.Pad(b) } -// Struct write Timecoord +// Bytes writes a Timecoord value to a byte slice. func (v Timecoord) Bytes() []byte { buf := make([]byte, 8) b := 0 @@ -1978,7 +1952,7 @@ func (v Timecoord) Bytes() []byte { return buf } -// Write struct list Timecoord +// TimecoordListBytes writes a list of %s(MISSING) values to a byte slice. func TimecoordListBytes(buf []byte, list []Timecoord) int { b := 0 var structBytes []byte @@ -1990,14 +1964,12 @@ func TimecoordListBytes(buf []byte, list []Timecoord) int { return b } -// 'Fontprop' struct definition -// Size: 8 type Fontprop struct { Name Atom Value uint32 } -// Struct read Fontprop +// FontpropRead reads a byte slice into a Fontprop value. func FontpropRead(buf []byte, v *Fontprop) int { b := 0 @@ -2010,7 +1982,7 @@ func FontpropRead(buf []byte, v *Fontprop) int { return b } -// Struct list read Fontprop +// FontpropReadList reads a byte slice into a list of Fontprop values. func FontpropReadList(buf []byte, dest []Fontprop) int { b := 0 for i := 0; i < len(dest); i++ { @@ -2020,7 +1992,7 @@ func FontpropReadList(buf []byte, dest []Fontprop) int { return xgb.Pad(b) } -// Struct write Fontprop +// Bytes writes a Fontprop value to a byte slice. func (v Fontprop) Bytes() []byte { buf := make([]byte, 8) b := 0 @@ -2034,7 +2006,7 @@ func (v Fontprop) Bytes() []byte { return buf } -// Write struct list Fontprop +// FontpropListBytes writes a list of %s(MISSING) values to a byte slice. func FontpropListBytes(buf []byte, list []Fontprop) int { b := 0 var structBytes []byte @@ -2046,8 +2018,6 @@ func FontpropListBytes(buf []byte, list []Fontprop) int { return b } -// 'Charinfo' struct definition -// Size: 12 type Charinfo struct { LeftSideBearing int16 RightSideBearing int16 @@ -2057,7 +2027,7 @@ type Charinfo struct { Attributes uint16 } -// Struct read Charinfo +// CharinfoRead reads a byte slice into a Charinfo value. func CharinfoRead(buf []byte, v *Charinfo) int { b := 0 @@ -2082,7 +2052,7 @@ func CharinfoRead(buf []byte, v *Charinfo) int { return b } -// Struct list read Charinfo +// CharinfoReadList reads a byte slice into a list of Charinfo values. func CharinfoReadList(buf []byte, dest []Charinfo) int { b := 0 for i := 0; i < len(dest); i++ { @@ -2092,7 +2062,7 @@ func CharinfoReadList(buf []byte, dest []Charinfo) int { return xgb.Pad(b) } -// Struct write Charinfo +// Bytes writes a Charinfo value to a byte slice. func (v Charinfo) Bytes() []byte { buf := make([]byte, 12) b := 0 @@ -2118,7 +2088,7 @@ func (v Charinfo) Bytes() []byte { return buf } -// Write struct list Charinfo +// CharinfoListBytes writes a list of %s(MISSING) values to a byte slice. func CharinfoListBytes(buf []byte, list []Charinfo) int { b := 0 var structBytes []byte @@ -2130,14 +2100,12 @@ func CharinfoListBytes(buf []byte, list []Charinfo) int { return b } -// 'Str' struct definition -// Size: (1 + xgb.Pad((int(NameLen) * 1))) type Str struct { NameLen byte Name string // size: xgb.Pad((int(NameLen) * 1)) } -// Struct read Str +// StrRead reads a byte slice into a Str value. func StrRead(buf []byte, v *Str) int { b := 0 @@ -2154,7 +2122,7 @@ func StrRead(buf []byte, v *Str) int { return b } -// Struct list read Str +// StrReadList reads a byte slice into a list of Str values. func StrReadList(buf []byte, dest []Str) int { b := 0 for i := 0; i < len(dest); i++ { @@ -2164,7 +2132,7 @@ func StrReadList(buf []byte, dest []Str) int { return xgb.Pad(b) } -// Struct write Str +// Bytes writes a Str value to a byte slice. func (v Str) Bytes() []byte { buf := make([]byte, (1 + xgb.Pad((int(v.NameLen) * 1)))) b := 0 @@ -2178,7 +2146,7 @@ func (v Str) Bytes() []byte { return buf } -// Write struct list Str +// StrListBytes writes a list of %s(MISSING) values to a byte slice. func StrListBytes(buf []byte, list []Str) int { b := 0 var structBytes []byte @@ -2190,7 +2158,7 @@ func StrListBytes(buf []byte, list []Str) int { return b } -// Struct list size Str +// StrListSize computes the size (bytes) of a list of Str values. func StrListSize(list []Str) int { size := 0 for _, item := range list { @@ -2199,8 +2167,6 @@ func StrListSize(list []Str) int { return size } -// 'Segment' struct definition -// Size: 8 type Segment struct { X1 int16 Y1 int16 @@ -2208,7 +2174,7 @@ type Segment struct { Y2 int16 } -// Struct read Segment +// SegmentRead reads a byte slice into a Segment value. func SegmentRead(buf []byte, v *Segment) int { b := 0 @@ -2227,7 +2193,7 @@ func SegmentRead(buf []byte, v *Segment) int { return b } -// Struct list read Segment +// SegmentReadList reads a byte slice into a list of Segment values. func SegmentReadList(buf []byte, dest []Segment) int { b := 0 for i := 0; i < len(dest); i++ { @@ -2237,7 +2203,7 @@ func SegmentReadList(buf []byte, dest []Segment) int { return xgb.Pad(b) } -// Struct write Segment +// Bytes writes a Segment value to a byte slice. func (v Segment) Bytes() []byte { buf := make([]byte, 8) b := 0 @@ -2257,7 +2223,7 @@ func (v Segment) Bytes() []byte { return buf } -// Write struct list Segment +// SegmentListBytes writes a list of %s(MISSING) values to a byte slice. func SegmentListBytes(buf []byte, list []Segment) int { b := 0 var structBytes []byte @@ -2269,8 +2235,6 @@ func SegmentListBytes(buf []byte, list []Segment) int { return b } -// 'Coloritem' struct definition -// Size: 12 type Coloritem struct { Pixel uint32 Red uint16 @@ -2280,7 +2244,7 @@ type Coloritem struct { // padding: 1 bytes } -// Struct read Coloritem +// ColoritemRead reads a byte slice into a Coloritem value. func ColoritemRead(buf []byte, v *Coloritem) int { b := 0 @@ -2304,7 +2268,7 @@ func ColoritemRead(buf []byte, v *Coloritem) int { return b } -// Struct list read Coloritem +// ColoritemReadList reads a byte slice into a list of Coloritem values. func ColoritemReadList(buf []byte, dest []Coloritem) int { b := 0 for i := 0; i < len(dest); i++ { @@ -2314,7 +2278,7 @@ func ColoritemReadList(buf []byte, dest []Coloritem) int { return xgb.Pad(b) } -// Struct write Coloritem +// Bytes writes a Coloritem value to a byte slice. func (v Coloritem) Bytes() []byte { buf := make([]byte, 12) b := 0 @@ -2339,7 +2303,7 @@ func (v Coloritem) Bytes() []byte { return buf } -// Write struct list Coloritem +// ColoritemListBytes writes a list of %s(MISSING) values to a byte slice. func ColoritemListBytes(buf []byte, list []Coloritem) int { b := 0 var structBytes []byte @@ -2351,8 +2315,6 @@ func ColoritemListBytes(buf []byte, list []Coloritem) int { return b } -// 'Rgb' struct definition -// Size: 8 type Rgb struct { Red uint16 Green uint16 @@ -2360,7 +2322,7 @@ type Rgb struct { // padding: 2 bytes } -// Struct read Rgb +// RgbRead reads a byte slice into a Rgb value. func RgbRead(buf []byte, v *Rgb) int { b := 0 @@ -2378,7 +2340,7 @@ func RgbRead(buf []byte, v *Rgb) int { return b } -// Struct list read Rgb +// RgbReadList reads a byte slice into a list of Rgb values. func RgbReadList(buf []byte, dest []Rgb) int { b := 0 for i := 0; i < len(dest); i++ { @@ -2388,7 +2350,7 @@ func RgbReadList(buf []byte, dest []Rgb) int { return xgb.Pad(b) } -// Struct write Rgb +// Bytes writes a Rgb value to a byte slice. func (v Rgb) Bytes() []byte { buf := make([]byte, 8) b := 0 @@ -2407,7 +2369,7 @@ func (v Rgb) Bytes() []byte { return buf } -// Write struct list Rgb +// RgbListBytes writes a list of %s(MISSING) values to a byte slice. func RgbListBytes(buf []byte, list []Rgb) int { b := 0 var structBytes []byte @@ -2419,8 +2381,6 @@ func RgbListBytes(buf []byte, list []Rgb) int { return b } -// 'Host' struct definition -// Size: (4 + xgb.Pad((int(AddressLen) * 1))) type Host struct { Family byte // padding: 1 bytes @@ -2428,7 +2388,7 @@ type Host struct { Address []byte // size: xgb.Pad((int(AddressLen) * 1)) } -// Struct read Host +// HostRead reads a byte slice into a Host value. func HostRead(buf []byte, v *Host) int { b := 0 @@ -2447,7 +2407,7 @@ func HostRead(buf []byte, v *Host) int { return b } -// Struct list read Host +// HostReadList reads a byte slice into a list of Host values. func HostReadList(buf []byte, dest []Host) int { b := 0 for i := 0; i < len(dest); i++ { @@ -2457,7 +2417,7 @@ func HostReadList(buf []byte, dest []Host) int { return xgb.Pad(b) } -// Struct write Host +// Bytes writes a Host value to a byte slice. func (v Host) Bytes() []byte { buf := make([]byte, (4 + xgb.Pad((int(v.AddressLen) * 1)))) b := 0 @@ -2476,7 +2436,7 @@ func (v Host) Bytes() []byte { return buf } -// Write struct list Host +// HostListBytes writes a list of %s(MISSING) values to a byte slice. func HostListBytes(buf []byte, list []Host) int { b := 0 var structBytes []byte @@ -2488,7 +2448,7 @@ func HostListBytes(buf []byte, list []Host) int { return b } -// Struct list size Host +// HostListSize computes the size (bytes) of a list of Host values. func HostListSize(list []Host) int { size := 0 for _, item := range list { @@ -2497,7 +2457,7 @@ func HostListSize(list []Host) int { return size } -// Union definition ClientMessageDataUnion +// ClientMessageDataUnion is a represention of the ClientMessageDataUnion union type. // Note that to *create* a Union, you should *never* create // this struct directly (unless you know what you're doing). // Instead use one of the following constructors for 'ClientMessageDataUnion': @@ -2510,7 +2470,7 @@ type ClientMessageDataUnion struct { Data32 []uint32 // size: 20 } -// Union constructor for ClientMessageDataUnion for field Data8. +// ClientMessageDataUnionData8New constructs a new ClientMessageDataUnion union type with the Data8 field. func ClientMessageDataUnionData8New(Data8 []byte) ClientMessageDataUnion { var b int buf := make([]byte, 20) @@ -2547,7 +2507,7 @@ func ClientMessageDataUnionData8New(Data8 []byte) ClientMessageDataUnion { return v } -// Union constructor for ClientMessageDataUnion for field Data16. +// ClientMessageDataUnionData16New constructs a new ClientMessageDataUnion union type with the Data16 field. func ClientMessageDataUnionData16New(Data16 []uint16) ClientMessageDataUnion { var b int buf := make([]byte, 20) @@ -2587,7 +2547,7 @@ func ClientMessageDataUnionData16New(Data16 []uint16) ClientMessageDataUnion { return v } -// Union constructor for ClientMessageDataUnion for field Data32. +// ClientMessageDataUnionData32New constructs a new ClientMessageDataUnion union type with the Data32 field. func ClientMessageDataUnionData32New(Data32 []uint32) ClientMessageDataUnion { var b int buf := make([]byte, 20) @@ -2627,7 +2587,7 @@ func ClientMessageDataUnionData32New(Data32 []uint32) ClientMessageDataUnion { return v } -// Union read ClientMessageDataUnion +// ClientMessageDataUnionRead reads a byte slice into a ClientMessageDataUnion value. func ClientMessageDataUnionRead(buf []byte, v *ClientMessageDataUnion) int { var b int @@ -2655,7 +2615,7 @@ func ClientMessageDataUnionRead(buf []byte, v *ClientMessageDataUnion) int { return 20 } -// Union list read ClientMessageDataUnion +// ClientMessageDataUnionReadList reads a byte slice into a list of ClientMessageDataUnion values. func ClientMessageDataUnionReadList(buf []byte, dest []ClientMessageDataUnion) int { b := 0 for i := 0; i < len(dest); i++ { @@ -2665,7 +2625,7 @@ func ClientMessageDataUnionReadList(buf []byte, dest []ClientMessageDataUnion) i return xgb.Pad(b) } -// Union write ClientMessageDataUnion +// Bytes writes a ClientMessageDataUnion value to a byte slice. // Each field in a union must contain the same data. // So simply pick the first field and write that to the wire. func (v ClientMessageDataUnion) Bytes() []byte { @@ -2677,7 +2637,7 @@ func (v ClientMessageDataUnion) Bytes() []byte { return buf } -// Union list write ClientMessageDataUnion +// ClientMessageDataUnionListBytes writes a list of %s(MISSING) values to a byte slice. func ClientMessageDataUnionListBytes(buf []byte, list []ClientMessageDataUnion) int { b := 0 var unionBytes []byte @@ -2689,9 +2649,7 @@ func ClientMessageDataUnionListBytes(buf []byte, list []ClientMessageDataUnion) return b } -// Event definition KeyPress (2) -// Size: 32 - +// KeyPress is the event number for a KeyPressEvent. const KeyPress = 2 type KeyPressEvent struct { @@ -2710,7 +2668,7 @@ type KeyPressEvent struct { // padding: 1 bytes } -// Event read KeyPress +// KeyPressEventNew constructs a KeyPressEvent value that implements xgb.Event from a byte slice. func KeyPressEventNew(buf []byte) xgb.Event { v := KeyPressEvent{} b := 1 // don't read event number @@ -2760,7 +2718,7 @@ func KeyPressEventNew(buf []byte) xgb.Event { return v } -// Event write KeyPress +// Bytes writes a KeyPressEvent value to a byte slice. func (v KeyPressEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -2813,12 +2771,14 @@ func (v KeyPressEvent) Bytes() []byte { return buf } -func (v KeyPressEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the KeyPress event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v KeyPressEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of KeyPressEvent. func (v KeyPressEvent) String() string { fieldVals := make([]string, 0, 12) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -2840,9 +2800,7 @@ func init() { xgb.NewEventFuncs[2] = KeyPressEventNew } -// Event definition ButtonPress (4) -// Size: 32 - +// ButtonPress is the event number for a ButtonPressEvent. const ButtonPress = 4 type ButtonPressEvent struct { @@ -2861,7 +2819,7 @@ type ButtonPressEvent struct { // padding: 1 bytes } -// Event read ButtonPress +// ButtonPressEventNew constructs a ButtonPressEvent value that implements xgb.Event from a byte slice. func ButtonPressEventNew(buf []byte) xgb.Event { v := ButtonPressEvent{} b := 1 // don't read event number @@ -2911,7 +2869,7 @@ func ButtonPressEventNew(buf []byte) xgb.Event { return v } -// Event write ButtonPress +// Bytes writes a ButtonPressEvent value to a byte slice. func (v ButtonPressEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -2964,12 +2922,14 @@ func (v ButtonPressEvent) Bytes() []byte { return buf } -func (v ButtonPressEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the ButtonPress event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v ButtonPressEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of ButtonPressEvent. func (v ButtonPressEvent) String() string { fieldVals := make([]string, 0, 12) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -2991,9 +2951,7 @@ func init() { xgb.NewEventFuncs[4] = ButtonPressEventNew } -// Event definition MotionNotify (6) -// Size: 32 - +// MotionNotify is the event number for a MotionNotifyEvent. const MotionNotify = 6 type MotionNotifyEvent struct { @@ -3012,7 +2970,7 @@ type MotionNotifyEvent struct { // padding: 1 bytes } -// Event read MotionNotify +// MotionNotifyEventNew constructs a MotionNotifyEvent value that implements xgb.Event from a byte slice. func MotionNotifyEventNew(buf []byte) xgb.Event { v := MotionNotifyEvent{} b := 1 // don't read event number @@ -3062,7 +3020,7 @@ func MotionNotifyEventNew(buf []byte) xgb.Event { return v } -// Event write MotionNotify +// Bytes writes a MotionNotifyEvent value to a byte slice. func (v MotionNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -3115,12 +3073,14 @@ func (v MotionNotifyEvent) Bytes() []byte { return buf } -func (v MotionNotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the MotionNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v MotionNotifyEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of MotionNotifyEvent. func (v MotionNotifyEvent) String() string { fieldVals := make([]string, 0, 12) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -3142,9 +3102,7 @@ func init() { xgb.NewEventFuncs[6] = MotionNotifyEventNew } -// Event definition EnterNotify (7) -// Size: 32 - +// EnterNotify is the event number for a EnterNotifyEvent. const EnterNotify = 7 type EnterNotifyEvent struct { @@ -3163,7 +3121,7 @@ type EnterNotifyEvent struct { SameScreenFocus byte } -// Event read EnterNotify +// EnterNotifyEventNew constructs a EnterNotifyEvent value that implements xgb.Event from a byte slice. func EnterNotifyEventNew(buf []byte) xgb.Event { v := EnterNotifyEvent{} b := 1 // don't read event number @@ -3210,7 +3168,7 @@ func EnterNotifyEventNew(buf []byte) xgb.Event { return v } -// Event write EnterNotify +// Bytes writes a EnterNotifyEvent value to a byte slice. func (v EnterNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -3260,12 +3218,14 @@ func (v EnterNotifyEvent) Bytes() []byte { return buf } -func (v EnterNotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the EnterNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v EnterNotifyEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of EnterNotifyEvent. func (v EnterNotifyEvent) String() string { fieldVals := make([]string, 0, 12) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -3288,9 +3248,7 @@ func init() { xgb.NewEventFuncs[7] = EnterNotifyEventNew } -// Event definition FocusIn (9) -// Size: 32 - +// FocusIn is the event number for a FocusInEvent. const FocusIn = 9 type FocusInEvent struct { @@ -3301,7 +3259,7 @@ type FocusInEvent struct { // padding: 3 bytes } -// Event read FocusIn +// FocusInEventNew constructs a FocusInEvent value that implements xgb.Event from a byte slice. func FocusInEventNew(buf []byte) xgb.Event { v := FocusInEvent{} b := 1 // don't read event number @@ -3323,7 +3281,7 @@ func FocusInEventNew(buf []byte) xgb.Event { return v } -// Event write FocusIn +// Bytes writes a FocusInEvent value to a byte slice. func (v FocusInEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -3348,12 +3306,14 @@ func (v FocusInEvent) Bytes() []byte { return buf } -func (v FocusInEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the FocusIn event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v FocusInEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of FocusInEvent. func (v FocusInEvent) String() string { fieldVals := make([]string, 0, 4) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -3367,16 +3327,14 @@ func init() { xgb.NewEventFuncs[9] = FocusInEventNew } -// Event definition KeymapNotify (11) -// Size: 32 - +// KeymapNotify is the event number for a KeymapNotifyEvent. const KeymapNotify = 11 type KeymapNotifyEvent struct { Keys []byte // size: 32 } -// Event read KeymapNotify +// KeymapNotifyEventNew constructs a KeymapNotifyEvent value that implements xgb.Event from a byte slice. func KeymapNotifyEventNew(buf []byte) xgb.Event { v := KeymapNotifyEvent{} b := 1 // don't read event number @@ -3388,7 +3346,7 @@ func KeymapNotifyEventNew(buf []byte) xgb.Event { return v } -// Event write KeymapNotify +// Bytes writes a KeymapNotifyEvent value to a byte slice. func (v KeymapNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -3403,12 +3361,14 @@ func (v KeymapNotifyEvent) Bytes() []byte { return buf } -func (v KeymapNotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the KeymapNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v KeymapNotifyEvent) SequenceId() uint16 { return uint16(0) } +// String is a rudimentary string representation of KeymapNotifyEvent. func (v KeymapNotifyEvent) String() string { fieldVals := make([]string, 0, 1) return "KeymapNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" @@ -3418,9 +3378,7 @@ func init() { xgb.NewEventFuncs[11] = KeymapNotifyEventNew } -// Event definition Expose (12) -// Size: 32 - +// Expose is the event number for a ExposeEvent. const Expose = 12 type ExposeEvent struct { @@ -3435,7 +3393,7 @@ type ExposeEvent struct { // padding: 2 bytes } -// Event read Expose +// ExposeEventNew constructs a ExposeEvent value that implements xgb.Event from a byte slice. func ExposeEventNew(buf []byte) xgb.Event { v := ExposeEvent{} b := 1 // don't read event number @@ -3468,7 +3426,7 @@ func ExposeEventNew(buf []byte) xgb.Event { return v } -// Event write Expose +// Bytes writes a ExposeEvent value to a byte slice. func (v ExposeEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -3504,12 +3462,14 @@ func (v ExposeEvent) Bytes() []byte { return buf } -func (v ExposeEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the Expose event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v ExposeEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of ExposeEvent. func (v ExposeEvent) String() string { fieldVals := make([]string, 0, 8) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -3526,9 +3486,7 @@ func init() { xgb.NewEventFuncs[12] = ExposeEventNew } -// Event definition GraphicsExposure (13) -// Size: 32 - +// GraphicsExposure is the event number for a GraphicsExposureEvent. const GraphicsExposure = 13 type GraphicsExposureEvent struct { @@ -3545,7 +3503,7 @@ type GraphicsExposureEvent struct { // padding: 3 bytes } -// Event read GraphicsExposure +// GraphicsExposureEventNew constructs a GraphicsExposureEvent value that implements xgb.Event from a byte slice. func GraphicsExposureEventNew(buf []byte) xgb.Event { v := GraphicsExposureEvent{} b := 1 // don't read event number @@ -3584,7 +3542,7 @@ func GraphicsExposureEventNew(buf []byte) xgb.Event { return v } -// Event write GraphicsExposure +// Bytes writes a GraphicsExposureEvent value to a byte slice. func (v GraphicsExposureEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -3626,12 +3584,14 @@ func (v GraphicsExposureEvent) Bytes() []byte { return buf } -func (v GraphicsExposureEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the GraphicsExposure event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v GraphicsExposureEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of GraphicsExposureEvent. func (v GraphicsExposureEvent) String() string { fieldVals := make([]string, 0, 10) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -3650,9 +3610,7 @@ func init() { xgb.NewEventFuncs[13] = GraphicsExposureEventNew } -// Event definition NoExposure (14) -// Size: 32 - +// NoExposure is the event number for a NoExposureEvent. const NoExposure = 14 type NoExposureEvent struct { @@ -3664,7 +3622,7 @@ type NoExposureEvent struct { // padding: 1 bytes } -// Event read NoExposure +// NoExposureEventNew constructs a NoExposureEvent value that implements xgb.Event from a byte slice. func NoExposureEventNew(buf []byte) xgb.Event { v := NoExposureEvent{} b := 1 // don't read event number @@ -3688,7 +3646,7 @@ func NoExposureEventNew(buf []byte) xgb.Event { return v } -// Event write NoExposure +// Bytes writes a NoExposureEvent value to a byte slice. func (v NoExposureEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -3715,12 +3673,14 @@ func (v NoExposureEvent) Bytes() []byte { return buf } -func (v NoExposureEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the NoExposure event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v NoExposureEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of NoExposureEvent. func (v NoExposureEvent) String() string { fieldVals := make([]string, 0, 5) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -3734,9 +3694,7 @@ func init() { xgb.NewEventFuncs[14] = NoExposureEventNew } -// Event definition VisibilityNotify (15) -// Size: 32 - +// VisibilityNotify is the event number for a VisibilityNotifyEvent. const VisibilityNotify = 15 type VisibilityNotifyEvent struct { @@ -3747,7 +3705,7 @@ type VisibilityNotifyEvent struct { // padding: 3 bytes } -// Event read VisibilityNotify +// VisibilityNotifyEventNew constructs a VisibilityNotifyEvent value that implements xgb.Event from a byte slice. func VisibilityNotifyEventNew(buf []byte) xgb.Event { v := VisibilityNotifyEvent{} b := 1 // don't read event number @@ -3768,7 +3726,7 @@ func VisibilityNotifyEventNew(buf []byte) xgb.Event { return v } -// Event write VisibilityNotify +// Bytes writes a VisibilityNotifyEvent value to a byte slice. func (v VisibilityNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -3792,12 +3750,14 @@ func (v VisibilityNotifyEvent) Bytes() []byte { return buf } -func (v VisibilityNotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the VisibilityNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v VisibilityNotifyEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of VisibilityNotifyEvent. func (v VisibilityNotifyEvent) String() string { fieldVals := make([]string, 0, 4) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -3810,9 +3770,7 @@ func init() { xgb.NewEventFuncs[15] = VisibilityNotifyEventNew } -// Event definition CreateNotify (16) -// Size: 32 - +// CreateNotify is the event number for a CreateNotifyEvent. const CreateNotify = 16 type CreateNotifyEvent struct { @@ -3829,7 +3787,7 @@ type CreateNotifyEvent struct { // padding: 1 bytes } -// Event read CreateNotify +// CreateNotifyEventNew constructs a CreateNotifyEvent value that implements xgb.Event from a byte slice. func CreateNotifyEventNew(buf []byte) xgb.Event { v := CreateNotifyEvent{} b := 1 // don't read event number @@ -3872,7 +3830,7 @@ func CreateNotifyEventNew(buf []byte) xgb.Event { return v } -// Event write CreateNotify +// Bytes writes a CreateNotifyEvent value to a byte slice. func (v CreateNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -3918,12 +3876,14 @@ func (v CreateNotifyEvent) Bytes() []byte { return buf } -func (v CreateNotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the CreateNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v CreateNotifyEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of CreateNotifyEvent. func (v CreateNotifyEvent) String() string { fieldVals := make([]string, 0, 10) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -3942,9 +3902,7 @@ func init() { xgb.NewEventFuncs[16] = CreateNotifyEventNew } -// Event definition DestroyNotify (17) -// Size: 32 - +// DestroyNotify is the event number for a DestroyNotifyEvent. const DestroyNotify = 17 type DestroyNotifyEvent struct { @@ -3954,7 +3912,7 @@ type DestroyNotifyEvent struct { Window Window } -// Event read DestroyNotify +// DestroyNotifyEventNew constructs a DestroyNotifyEvent value that implements xgb.Event from a byte slice. func DestroyNotifyEventNew(buf []byte) xgb.Event { v := DestroyNotifyEvent{} b := 1 // don't read event number @@ -3973,7 +3931,7 @@ func DestroyNotifyEventNew(buf []byte) xgb.Event { return v } -// Event write DestroyNotify +// Bytes writes a DestroyNotifyEvent value to a byte slice. func (v DestroyNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -3995,12 +3953,14 @@ func (v DestroyNotifyEvent) Bytes() []byte { return buf } -func (v DestroyNotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the DestroyNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v DestroyNotifyEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of DestroyNotifyEvent. func (v DestroyNotifyEvent) String() string { fieldVals := make([]string, 0, 3) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -4013,9 +3973,7 @@ func init() { xgb.NewEventFuncs[17] = DestroyNotifyEventNew } -// Event definition UnmapNotify (18) -// Size: 32 - +// UnmapNotify is the event number for a UnmapNotifyEvent. const UnmapNotify = 18 type UnmapNotifyEvent struct { @@ -4027,7 +3985,7 @@ type UnmapNotifyEvent struct { // padding: 3 bytes } -// Event read UnmapNotify +// UnmapNotifyEventNew constructs a UnmapNotifyEvent value that implements xgb.Event from a byte slice. func UnmapNotifyEventNew(buf []byte) xgb.Event { v := UnmapNotifyEvent{} b := 1 // don't read event number @@ -4055,7 +4013,7 @@ func UnmapNotifyEventNew(buf []byte) xgb.Event { return v } -// Event write UnmapNotify +// Bytes writes a UnmapNotifyEvent value to a byte slice. func (v UnmapNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -4086,12 +4044,14 @@ func (v UnmapNotifyEvent) Bytes() []byte { return buf } -func (v UnmapNotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the UnmapNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v UnmapNotifyEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of UnmapNotifyEvent. func (v UnmapNotifyEvent) String() string { fieldVals := make([]string, 0, 5) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -4105,9 +4065,7 @@ func init() { xgb.NewEventFuncs[18] = UnmapNotifyEventNew } -// Event definition MapNotify (19) -// Size: 32 - +// MapNotify is the event number for a MapNotifyEvent. const MapNotify = 19 type MapNotifyEvent struct { @@ -4119,7 +4077,7 @@ type MapNotifyEvent struct { // padding: 3 bytes } -// Event read MapNotify +// MapNotifyEventNew constructs a MapNotifyEvent value that implements xgb.Event from a byte slice. func MapNotifyEventNew(buf []byte) xgb.Event { v := MapNotifyEvent{} b := 1 // don't read event number @@ -4147,7 +4105,7 @@ func MapNotifyEventNew(buf []byte) xgb.Event { return v } -// Event write MapNotify +// Bytes writes a MapNotifyEvent value to a byte slice. func (v MapNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -4178,12 +4136,14 @@ func (v MapNotifyEvent) Bytes() []byte { return buf } -func (v MapNotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the MapNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v MapNotifyEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of MapNotifyEvent. func (v MapNotifyEvent) String() string { fieldVals := make([]string, 0, 5) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -4197,9 +4157,7 @@ func init() { xgb.NewEventFuncs[19] = MapNotifyEventNew } -// Event definition MapRequest (20) -// Size: 32 - +// MapRequest is the event number for a MapRequestEvent. const MapRequest = 20 type MapRequestEvent struct { @@ -4209,7 +4167,7 @@ type MapRequestEvent struct { Window Window } -// Event read MapRequest +// MapRequestEventNew constructs a MapRequestEvent value that implements xgb.Event from a byte slice. func MapRequestEventNew(buf []byte) xgb.Event { v := MapRequestEvent{} b := 1 // don't read event number @@ -4228,7 +4186,7 @@ func MapRequestEventNew(buf []byte) xgb.Event { return v } -// Event write MapRequest +// Bytes writes a MapRequestEvent value to a byte slice. func (v MapRequestEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -4250,12 +4208,14 @@ func (v MapRequestEvent) Bytes() []byte { return buf } -func (v MapRequestEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the MapRequest event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v MapRequestEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of MapRequestEvent. func (v MapRequestEvent) String() string { fieldVals := make([]string, 0, 3) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -4268,9 +4228,7 @@ func init() { xgb.NewEventFuncs[20] = MapRequestEventNew } -// Event definition ReparentNotify (21) -// Size: 32 - +// ReparentNotify is the event number for a ReparentNotifyEvent. const ReparentNotify = 21 type ReparentNotifyEvent struct { @@ -4285,7 +4243,7 @@ type ReparentNotifyEvent struct { // padding: 3 bytes } -// Event read ReparentNotify +// ReparentNotifyEventNew constructs a ReparentNotifyEvent value that implements xgb.Event from a byte slice. func ReparentNotifyEventNew(buf []byte) xgb.Event { v := ReparentNotifyEvent{} b := 1 // don't read event number @@ -4322,7 +4280,7 @@ func ReparentNotifyEventNew(buf []byte) xgb.Event { return v } -// Event write ReparentNotify +// Bytes writes a ReparentNotifyEvent value to a byte slice. func (v ReparentNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -4362,12 +4320,14 @@ func (v ReparentNotifyEvent) Bytes() []byte { return buf } -func (v ReparentNotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the ReparentNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v ReparentNotifyEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of ReparentNotifyEvent. func (v ReparentNotifyEvent) String() string { fieldVals := make([]string, 0, 8) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -4384,9 +4344,7 @@ func init() { xgb.NewEventFuncs[21] = ReparentNotifyEventNew } -// Event definition ConfigureNotify (22) -// Size: 32 - +// ConfigureNotify is the event number for a ConfigureNotifyEvent. const ConfigureNotify = 22 type ConfigureNotifyEvent struct { @@ -4404,7 +4362,7 @@ type ConfigureNotifyEvent struct { // padding: 1 bytes } -// Event read ConfigureNotify +// ConfigureNotifyEventNew constructs a ConfigureNotifyEvent value that implements xgb.Event from a byte slice. func ConfigureNotifyEventNew(buf []byte) xgb.Event { v := ConfigureNotifyEvent{} b := 1 // don't read event number @@ -4450,7 +4408,7 @@ func ConfigureNotifyEventNew(buf []byte) xgb.Event { return v } -// Event write ConfigureNotify +// Bytes writes a ConfigureNotifyEvent value to a byte slice. func (v ConfigureNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -4499,12 +4457,14 @@ func (v ConfigureNotifyEvent) Bytes() []byte { return buf } -func (v ConfigureNotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the ConfigureNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v ConfigureNotifyEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of ConfigureNotifyEvent. func (v ConfigureNotifyEvent) String() string { fieldVals := make([]string, 0, 11) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -4524,9 +4484,7 @@ func init() { xgb.NewEventFuncs[22] = ConfigureNotifyEventNew } -// Event definition ConfigureRequest (23) -// Size: 32 - +// ConfigureRequest is the event number for a ConfigureRequestEvent. const ConfigureRequest = 23 type ConfigureRequestEvent struct { @@ -4543,7 +4501,7 @@ type ConfigureRequestEvent struct { ValueMask uint16 } -// Event read ConfigureRequest +// ConfigureRequestEventNew constructs a ConfigureRequestEvent value that implements xgb.Event from a byte slice. func ConfigureRequestEventNew(buf []byte) xgb.Event { v := ConfigureRequestEvent{} b := 1 // don't read event number @@ -4584,7 +4542,7 @@ func ConfigureRequestEventNew(buf []byte) xgb.Event { return v } -// Event write ConfigureRequest +// Bytes writes a ConfigureRequestEvent value to a byte slice. func (v ConfigureRequestEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -4628,12 +4586,14 @@ func (v ConfigureRequestEvent) Bytes() []byte { return buf } -func (v ConfigureRequestEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the ConfigureRequest event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v ConfigureRequestEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of ConfigureRequestEvent. func (v ConfigureRequestEvent) String() string { fieldVals := make([]string, 0, 10) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -4654,9 +4614,7 @@ func init() { xgb.NewEventFuncs[23] = ConfigureRequestEventNew } -// Event definition GravityNotify (24) -// Size: 32 - +// GravityNotify is the event number for a GravityNotifyEvent. const GravityNotify = 24 type GravityNotifyEvent struct { @@ -4668,7 +4626,7 @@ type GravityNotifyEvent struct { Y int16 } -// Event read GravityNotify +// GravityNotifyEventNew constructs a GravityNotifyEvent value that implements xgb.Event from a byte slice. func GravityNotifyEventNew(buf []byte) xgb.Event { v := GravityNotifyEvent{} b := 1 // don't read event number @@ -4693,7 +4651,7 @@ func GravityNotifyEventNew(buf []byte) xgb.Event { return v } -// Event write GravityNotify +// Bytes writes a GravityNotifyEvent value to a byte slice. func (v GravityNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -4721,12 +4679,14 @@ func (v GravityNotifyEvent) Bytes() []byte { return buf } -func (v GravityNotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the GravityNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v GravityNotifyEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of GravityNotifyEvent. func (v GravityNotifyEvent) String() string { fieldVals := make([]string, 0, 5) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -4741,9 +4701,7 @@ func init() { xgb.NewEventFuncs[24] = GravityNotifyEventNew } -// Event definition ResizeRequest (25) -// Size: 32 - +// ResizeRequest is the event number for a ResizeRequestEvent. const ResizeRequest = 25 type ResizeRequestEvent struct { @@ -4754,7 +4712,7 @@ type ResizeRequestEvent struct { Height uint16 } -// Event read ResizeRequest +// ResizeRequestEventNew constructs a ResizeRequestEvent value that implements xgb.Event from a byte slice. func ResizeRequestEventNew(buf []byte) xgb.Event { v := ResizeRequestEvent{} b := 1 // don't read event number @@ -4776,7 +4734,7 @@ func ResizeRequestEventNew(buf []byte) xgb.Event { return v } -// Event write ResizeRequest +// Bytes writes a ResizeRequestEvent value to a byte slice. func (v ResizeRequestEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -4801,12 +4759,14 @@ func (v ResizeRequestEvent) Bytes() []byte { return buf } -func (v ResizeRequestEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the ResizeRequest event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v ResizeRequestEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of ResizeRequestEvent. func (v ResizeRequestEvent) String() string { fieldVals := make([]string, 0, 4) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -4820,9 +4780,7 @@ func init() { xgb.NewEventFuncs[25] = ResizeRequestEventNew } -// Event definition CirculateNotify (26) -// Size: 32 - +// CirculateNotify is the event number for a CirculateNotifyEvent. const CirculateNotify = 26 type CirculateNotifyEvent struct { @@ -4835,7 +4793,7 @@ type CirculateNotifyEvent struct { // padding: 3 bytes } -// Event read CirculateNotify +// CirculateNotifyEventNew constructs a CirculateNotifyEvent value that implements xgb.Event from a byte slice. func CirculateNotifyEventNew(buf []byte) xgb.Event { v := CirculateNotifyEvent{} b := 1 // don't read event number @@ -4861,7 +4819,7 @@ func CirculateNotifyEventNew(buf []byte) xgb.Event { return v } -// Event write CirculateNotify +// Bytes writes a CirculateNotifyEvent value to a byte slice. func (v CirculateNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -4890,12 +4848,14 @@ func (v CirculateNotifyEvent) Bytes() []byte { return buf } -func (v CirculateNotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the CirculateNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v CirculateNotifyEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of CirculateNotifyEvent. func (v CirculateNotifyEvent) String() string { fieldVals := make([]string, 0, 6) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -4909,9 +4869,7 @@ func init() { xgb.NewEventFuncs[26] = CirculateNotifyEventNew } -// Event definition PropertyNotify (28) -// Size: 32 - +// PropertyNotify is the event number for a PropertyNotifyEvent. const PropertyNotify = 28 type PropertyNotifyEvent struct { @@ -4924,7 +4882,7 @@ type PropertyNotifyEvent struct { // padding: 3 bytes } -// Event read PropertyNotify +// PropertyNotifyEventNew constructs a PropertyNotifyEvent value that implements xgb.Event from a byte slice. func PropertyNotifyEventNew(buf []byte) xgb.Event { v := PropertyNotifyEvent{} b := 1 // don't read event number @@ -4951,7 +4909,7 @@ func PropertyNotifyEventNew(buf []byte) xgb.Event { return v } -// Event write PropertyNotify +// Bytes writes a PropertyNotifyEvent value to a byte slice. func (v PropertyNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -4981,12 +4939,14 @@ func (v PropertyNotifyEvent) Bytes() []byte { return buf } -func (v PropertyNotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the PropertyNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v PropertyNotifyEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of PropertyNotifyEvent. func (v PropertyNotifyEvent) String() string { fieldVals := make([]string, 0, 6) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -5001,9 +4961,7 @@ func init() { xgb.NewEventFuncs[28] = PropertyNotifyEventNew } -// Event definition SelectionClear (29) -// Size: 32 - +// SelectionClear is the event number for a SelectionClearEvent. const SelectionClear = 29 type SelectionClearEvent struct { @@ -5014,7 +4972,7 @@ type SelectionClearEvent struct { Selection Atom } -// Event read SelectionClear +// SelectionClearEventNew constructs a SelectionClearEvent value that implements xgb.Event from a byte slice. func SelectionClearEventNew(buf []byte) xgb.Event { v := SelectionClearEvent{} b := 1 // don't read event number @@ -5036,7 +4994,7 @@ func SelectionClearEventNew(buf []byte) xgb.Event { return v } -// Event write SelectionClear +// Bytes writes a SelectionClearEvent value to a byte slice. func (v SelectionClearEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -5061,12 +5019,14 @@ func (v SelectionClearEvent) Bytes() []byte { return buf } -func (v SelectionClearEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the SelectionClear event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v SelectionClearEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of SelectionClearEvent. func (v SelectionClearEvent) String() string { fieldVals := make([]string, 0, 4) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -5080,9 +5040,7 @@ func init() { xgb.NewEventFuncs[29] = SelectionClearEventNew } -// Event definition SelectionRequest (30) -// Size: 32 - +// SelectionRequest is the event number for a SelectionRequestEvent. const SelectionRequest = 30 type SelectionRequestEvent struct { @@ -5096,7 +5054,7 @@ type SelectionRequestEvent struct { Property Atom } -// Event read SelectionRequest +// SelectionRequestEventNew constructs a SelectionRequestEvent value that implements xgb.Event from a byte slice. func SelectionRequestEventNew(buf []byte) xgb.Event { v := SelectionRequestEvent{} b := 1 // don't read event number @@ -5127,7 +5085,7 @@ func SelectionRequestEventNew(buf []byte) xgb.Event { return v } -// Event write SelectionRequest +// Bytes writes a SelectionRequestEvent value to a byte slice. func (v SelectionRequestEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -5161,12 +5119,14 @@ func (v SelectionRequestEvent) Bytes() []byte { return buf } -func (v SelectionRequestEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the SelectionRequest event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v SelectionRequestEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of SelectionRequestEvent. func (v SelectionRequestEvent) String() string { fieldVals := make([]string, 0, 7) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -5183,9 +5143,7 @@ func init() { xgb.NewEventFuncs[30] = SelectionRequestEventNew } -// Event definition SelectionNotify (31) -// Size: 32 - +// SelectionNotify is the event number for a SelectionNotifyEvent. const SelectionNotify = 31 type SelectionNotifyEvent struct { @@ -5198,7 +5156,7 @@ type SelectionNotifyEvent struct { Property Atom } -// Event read SelectionNotify +// SelectionNotifyEventNew constructs a SelectionNotifyEvent value that implements xgb.Event from a byte slice. func SelectionNotifyEventNew(buf []byte) xgb.Event { v := SelectionNotifyEvent{} b := 1 // don't read event number @@ -5226,7 +5184,7 @@ func SelectionNotifyEventNew(buf []byte) xgb.Event { return v } -// Event write SelectionNotify +// Bytes writes a SelectionNotifyEvent value to a byte slice. func (v SelectionNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -5257,12 +5215,14 @@ func (v SelectionNotifyEvent) Bytes() []byte { return buf } -func (v SelectionNotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the SelectionNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v SelectionNotifyEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of SelectionNotifyEvent. func (v SelectionNotifyEvent) String() string { fieldVals := make([]string, 0, 6) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -5278,9 +5238,7 @@ func init() { xgb.NewEventFuncs[31] = SelectionNotifyEventNew } -// Event definition ColormapNotify (32) -// Size: 32 - +// ColormapNotify is the event number for a ColormapNotifyEvent. const ColormapNotify = 32 type ColormapNotifyEvent struct { @@ -5293,7 +5251,7 @@ type ColormapNotifyEvent struct { // padding: 2 bytes } -// Event read ColormapNotify +// ColormapNotifyEventNew constructs a ColormapNotifyEvent value that implements xgb.Event from a byte slice. func ColormapNotifyEventNew(buf []byte) xgb.Event { v := ColormapNotifyEvent{} b := 1 // don't read event number @@ -5324,7 +5282,7 @@ func ColormapNotifyEventNew(buf []byte) xgb.Event { return v } -// Event write ColormapNotify +// Bytes writes a ColormapNotifyEvent value to a byte slice. func (v ColormapNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -5358,12 +5316,14 @@ func (v ColormapNotifyEvent) Bytes() []byte { return buf } -func (v ColormapNotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the ColormapNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v ColormapNotifyEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of ColormapNotifyEvent. func (v ColormapNotifyEvent) String() string { fieldVals := make([]string, 0, 6) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -5378,9 +5338,7 @@ func init() { xgb.NewEventFuncs[32] = ColormapNotifyEventNew } -// Event definition ClientMessage (33) -// Size: 32 - +// ClientMessage is the event number for a ClientMessageEvent. const ClientMessage = 33 type ClientMessageEvent struct { @@ -5391,7 +5349,7 @@ type ClientMessageEvent struct { Data ClientMessageDataUnion } -// Event read ClientMessage +// ClientMessageEventNew constructs a ClientMessageEvent value that implements xgb.Event from a byte slice. func ClientMessageEventNew(buf []byte) xgb.Event { v := ClientMessageEvent{} b := 1 // don't read event number @@ -5414,7 +5372,7 @@ func ClientMessageEventNew(buf []byte) xgb.Event { return v } -// Event write ClientMessage +// Bytes writes a ClientMessageEvent value to a byte slice. func (v ClientMessageEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -5443,12 +5401,14 @@ func (v ClientMessageEvent) Bytes() []byte { return buf } -func (v ClientMessageEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the ClientMessage event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v ClientMessageEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of ClientMessageEvent. func (v ClientMessageEvent) String() string { fieldVals := make([]string, 0, 4) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -5462,9 +5422,7 @@ func init() { xgb.NewEventFuncs[33] = ClientMessageEventNew } -// Event definition MappingNotify (34) -// Size: 32 - +// MappingNotify is the event number for a MappingNotifyEvent. const MappingNotify = 34 type MappingNotifyEvent struct { @@ -5476,7 +5434,7 @@ type MappingNotifyEvent struct { // padding: 1 bytes } -// Event read MappingNotify +// MappingNotifyEventNew constructs a MappingNotifyEvent value that implements xgb.Event from a byte slice. func MappingNotifyEventNew(buf []byte) xgb.Event { v := MappingNotifyEvent{} b := 1 // don't read event number @@ -5500,7 +5458,7 @@ func MappingNotifyEventNew(buf []byte) xgb.Event { return v } -// Event write MappingNotify +// Bytes writes a MappingNotifyEvent value to a byte slice. func (v MappingNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -5527,12 +5485,14 @@ func (v MappingNotifyEvent) Bytes() []byte { return buf } -func (v MappingNotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the MappingNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v MappingNotifyEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of MappingNotifyEvent. func (v MappingNotifyEvent) String() string { fieldVals := make([]string, 0, 5) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -5546,22 +5506,24 @@ func init() { xgb.NewEventFuncs[34] = MappingNotifyEventNew } -// EventCopy definition KeyRelease (3) - +// KeyRelease is the event number for a KeyReleaseEvent. const KeyRelease = 3 type KeyReleaseEvent KeyPressEvent +// KeyReleaseEventNew constructs a KeyReleaseEvent value that implements xgb.Event from a byte slice. func KeyReleaseEventNew(buf []byte) xgb.Event { return KeyReleaseEvent(KeyPressEventNew(buf).(KeyPressEvent)) } +// Bytes writes a KeyReleaseEvent value to a byte slice. func (v KeyReleaseEvent) Bytes() []byte { return KeyPressEvent(v).Bytes() } -func (v KeyReleaseEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the KeyRelease event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v KeyReleaseEvent) SequenceId() uint16 { return v.Sequence } @@ -5587,22 +5549,24 @@ func init() { xgb.NewEventFuncs[3] = KeyReleaseEventNew } -// EventCopy definition ButtonRelease (5) - +// ButtonRelease is the event number for a ButtonReleaseEvent. const ButtonRelease = 5 type ButtonReleaseEvent ButtonPressEvent +// ButtonReleaseEventNew constructs a ButtonReleaseEvent value that implements xgb.Event from a byte slice. func ButtonReleaseEventNew(buf []byte) xgb.Event { return ButtonReleaseEvent(ButtonPressEventNew(buf).(ButtonPressEvent)) } +// Bytes writes a ButtonReleaseEvent value to a byte slice. func (v ButtonReleaseEvent) Bytes() []byte { return ButtonPressEvent(v).Bytes() } -func (v ButtonReleaseEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the ButtonRelease event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v ButtonReleaseEvent) SequenceId() uint16 { return v.Sequence } @@ -5628,22 +5592,24 @@ func init() { xgb.NewEventFuncs[5] = ButtonReleaseEventNew } -// EventCopy definition LeaveNotify (8) - +// LeaveNotify is the event number for a LeaveNotifyEvent. const LeaveNotify = 8 type LeaveNotifyEvent EnterNotifyEvent +// LeaveNotifyEventNew constructs a LeaveNotifyEvent value that implements xgb.Event from a byte slice. func LeaveNotifyEventNew(buf []byte) xgb.Event { return LeaveNotifyEvent(EnterNotifyEventNew(buf).(EnterNotifyEvent)) } +// Bytes writes a LeaveNotifyEvent value to a byte slice. func (v LeaveNotifyEvent) Bytes() []byte { return EnterNotifyEvent(v).Bytes() } -func (v LeaveNotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the LeaveNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v LeaveNotifyEvent) SequenceId() uint16 { return v.Sequence } @@ -5670,22 +5636,24 @@ func init() { xgb.NewEventFuncs[8] = LeaveNotifyEventNew } -// EventCopy definition FocusOut (10) - +// FocusOut is the event number for a FocusOutEvent. const FocusOut = 10 type FocusOutEvent FocusInEvent +// FocusOutEventNew constructs a FocusOutEvent value that implements xgb.Event from a byte slice. func FocusOutEventNew(buf []byte) xgb.Event { return FocusOutEvent(FocusInEventNew(buf).(FocusInEvent)) } +// Bytes writes a FocusOutEvent value to a byte slice. func (v FocusOutEvent) Bytes() []byte { return FocusInEvent(v).Bytes() } -func (v FocusOutEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the FocusOut event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v FocusOutEvent) SequenceId() uint16 { return v.Sequence } @@ -5703,22 +5671,24 @@ func init() { xgb.NewEventFuncs[10] = FocusOutEventNew } -// EventCopy definition CirculateRequest (27) - +// CirculateRequest is the event number for a CirculateRequestEvent. const CirculateRequest = 27 type CirculateRequestEvent CirculateNotifyEvent +// CirculateRequestEventNew constructs a CirculateRequestEvent value that implements xgb.Event from a byte slice. func CirculateRequestEventNew(buf []byte) xgb.Event { return CirculateRequestEvent(CirculateNotifyEventNew(buf).(CirculateNotifyEvent)) } +// Bytes writes a CirculateRequestEvent value to a byte slice. func (v CirculateRequestEvent) Bytes() []byte { return CirculateNotifyEvent(v).Bytes() } -func (v CirculateRequestEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the CirculateRequest event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v CirculateRequestEvent) SequenceId() uint16 { return v.Sequence } @@ -5736,9 +5706,7 @@ func init() { xgb.NewEventFuncs[27] = CirculateRequestEventNew } -// Error definition Request (1) -// Size: 32 - +// BadRequest is the error number for a BadRequest. const BadRequest = 1 type RequestError struct { @@ -5750,7 +5718,7 @@ type RequestError struct { // padding: 1 bytes } -// Error read Request +// RequestErrorNew constructs a RequestError value that implements xgb.Error from a byte slice. func RequestErrorNew(buf []byte) xgb.Error { v := RequestError{} v.NiceName = "Request" @@ -5775,8 +5743,8 @@ func RequestErrorNew(buf []byte) xgb.Error { return v } -func (err RequestError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadRequest error. +// This is mostly used internally. func (err RequestError) SequenceId() uint16 { return err.Sequence } @@ -5799,9 +5767,7 @@ func init() { xgb.NewErrorFuncs[1] = RequestErrorNew } -// Error definition Value (2) -// Size: 32 - +// BadValue is the error number for a BadValue. const BadValue = 2 type ValueError struct { @@ -5813,7 +5779,7 @@ type ValueError struct { // padding: 1 bytes } -// Error read Value +// ValueErrorNew constructs a ValueError value that implements xgb.Error from a byte slice. func ValueErrorNew(buf []byte) xgb.Error { v := ValueError{} v.NiceName = "Value" @@ -5838,8 +5804,8 @@ func ValueErrorNew(buf []byte) xgb.Error { return v } -func (err ValueError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadValue error. +// This is mostly used internally. func (err ValueError) SequenceId() uint16 { return err.Sequence } @@ -5862,20 +5828,20 @@ func init() { xgb.NewErrorFuncs[2] = ValueErrorNew } -// ErrorCopy definition Window (3) - +// BadWindow is the error number for a BadWindow. const BadWindow = 3 type WindowError ValueError +// WindowErrorNew constructs a WindowError value that implements xgb.Error from a byte slice. func WindowErrorNew(buf []byte) xgb.Error { v := WindowError(ValueErrorNew(buf).(ValueError)) v.NiceName = "Window" return v } -func (err WindowError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadWindow error. +// This is mostly used internally. func (err WindowError) SequenceId() uint16 { return err.Sequence } @@ -5898,20 +5864,20 @@ func init() { xgb.NewErrorFuncs[3] = WindowErrorNew } -// ErrorCopy definition Pixmap (4) - +// BadPixmap is the error number for a BadPixmap. const BadPixmap = 4 type PixmapError ValueError +// PixmapErrorNew constructs a PixmapError value that implements xgb.Error from a byte slice. func PixmapErrorNew(buf []byte) xgb.Error { v := PixmapError(ValueErrorNew(buf).(ValueError)) v.NiceName = "Pixmap" return v } -func (err PixmapError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadPixmap error. +// This is mostly used internally. func (err PixmapError) SequenceId() uint16 { return err.Sequence } @@ -5934,20 +5900,20 @@ func init() { xgb.NewErrorFuncs[4] = PixmapErrorNew } -// ErrorCopy definition Atom (5) - +// BadAtom is the error number for a BadAtom. const BadAtom = 5 type AtomError ValueError +// AtomErrorNew constructs a AtomError value that implements xgb.Error from a byte slice. func AtomErrorNew(buf []byte) xgb.Error { v := AtomError(ValueErrorNew(buf).(ValueError)) v.NiceName = "Atom" return v } -func (err AtomError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadAtom error. +// This is mostly used internally. func (err AtomError) SequenceId() uint16 { return err.Sequence } @@ -5970,20 +5936,20 @@ func init() { xgb.NewErrorFuncs[5] = AtomErrorNew } -// ErrorCopy definition Cursor (6) - +// BadCursor is the error number for a BadCursor. const BadCursor = 6 type CursorError ValueError +// CursorErrorNew constructs a CursorError value that implements xgb.Error from a byte slice. func CursorErrorNew(buf []byte) xgb.Error { v := CursorError(ValueErrorNew(buf).(ValueError)) v.NiceName = "Cursor" return v } -func (err CursorError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadCursor error. +// This is mostly used internally. func (err CursorError) SequenceId() uint16 { return err.Sequence } @@ -6006,20 +5972,20 @@ func init() { xgb.NewErrorFuncs[6] = CursorErrorNew } -// ErrorCopy definition Font (7) - +// BadFont is the error number for a BadFont. const BadFont = 7 type FontError ValueError +// FontErrorNew constructs a FontError value that implements xgb.Error from a byte slice. func FontErrorNew(buf []byte) xgb.Error { v := FontError(ValueErrorNew(buf).(ValueError)) v.NiceName = "Font" return v } -func (err FontError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadFont error. +// This is mostly used internally. func (err FontError) SequenceId() uint16 { return err.Sequence } @@ -6042,20 +6008,20 @@ func init() { xgb.NewErrorFuncs[7] = FontErrorNew } -// ErrorCopy definition Match (8) - +// BadMatch is the error number for a BadMatch. const BadMatch = 8 type MatchError RequestError +// MatchErrorNew constructs a MatchError value that implements xgb.Error from a byte slice. func MatchErrorNew(buf []byte) xgb.Error { v := MatchError(RequestErrorNew(buf).(RequestError)) v.NiceName = "Match" return v } -func (err MatchError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadMatch error. +// This is mostly used internally. func (err MatchError) SequenceId() uint16 { return err.Sequence } @@ -6078,20 +6044,20 @@ func init() { xgb.NewErrorFuncs[8] = MatchErrorNew } -// ErrorCopy definition Drawable (9) - +// BadDrawable is the error number for a BadDrawable. const BadDrawable = 9 type DrawableError ValueError +// DrawableErrorNew constructs a DrawableError value that implements xgb.Error from a byte slice. func DrawableErrorNew(buf []byte) xgb.Error { v := DrawableError(ValueErrorNew(buf).(ValueError)) v.NiceName = "Drawable" return v } -func (err DrawableError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadDrawable error. +// This is mostly used internally. func (err DrawableError) SequenceId() uint16 { return err.Sequence } @@ -6114,20 +6080,20 @@ func init() { xgb.NewErrorFuncs[9] = DrawableErrorNew } -// ErrorCopy definition Access (10) - +// BadAccess is the error number for a BadAccess. const BadAccess = 10 type AccessError RequestError +// AccessErrorNew constructs a AccessError value that implements xgb.Error from a byte slice. func AccessErrorNew(buf []byte) xgb.Error { v := AccessError(RequestErrorNew(buf).(RequestError)) v.NiceName = "Access" return v } -func (err AccessError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadAccess error. +// This is mostly used internally. func (err AccessError) SequenceId() uint16 { return err.Sequence } @@ -6150,20 +6116,20 @@ func init() { xgb.NewErrorFuncs[10] = AccessErrorNew } -// ErrorCopy definition Alloc (11) - +// BadAlloc is the error number for a BadAlloc. const BadAlloc = 11 type AllocError RequestError +// AllocErrorNew constructs a AllocError value that implements xgb.Error from a byte slice. func AllocErrorNew(buf []byte) xgb.Error { v := AllocError(RequestErrorNew(buf).(RequestError)) v.NiceName = "Alloc" return v } -func (err AllocError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadAlloc error. +// This is mostly used internally. func (err AllocError) SequenceId() uint16 { return err.Sequence } @@ -6186,20 +6152,20 @@ func init() { xgb.NewErrorFuncs[11] = AllocErrorNew } -// ErrorCopy definition Colormap (12) - +// BadColormap is the error number for a BadColormap. const BadColormap = 12 type ColormapError ValueError +// ColormapErrorNew constructs a ColormapError value that implements xgb.Error from a byte slice. func ColormapErrorNew(buf []byte) xgb.Error { v := ColormapError(ValueErrorNew(buf).(ValueError)) v.NiceName = "Colormap" return v } -func (err ColormapError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadColormap error. +// This is mostly used internally. func (err ColormapError) SequenceId() uint16 { return err.Sequence } @@ -6222,20 +6188,20 @@ func init() { xgb.NewErrorFuncs[12] = ColormapErrorNew } -// ErrorCopy definition GContext (13) - +// BadGContext is the error number for a BadGContext. const BadGContext = 13 type GContextError ValueError +// GContextErrorNew constructs a GContextError value that implements xgb.Error from a byte slice. func GContextErrorNew(buf []byte) xgb.Error { v := GContextError(ValueErrorNew(buf).(ValueError)) v.NiceName = "GContext" return v } -func (err GContextError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadGContext error. +// This is mostly used internally. func (err GContextError) SequenceId() uint16 { return err.Sequence } @@ -6258,20 +6224,20 @@ func init() { xgb.NewErrorFuncs[13] = GContextErrorNew } -// ErrorCopy definition IDChoice (14) - +// BadIDChoice is the error number for a BadIDChoice. const BadIDChoice = 14 type IDChoiceError ValueError +// IDChoiceErrorNew constructs a IDChoiceError value that implements xgb.Error from a byte slice. func IDChoiceErrorNew(buf []byte) xgb.Error { v := IDChoiceError(ValueErrorNew(buf).(ValueError)) v.NiceName = "IDChoice" return v } -func (err IDChoiceError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadIDChoice error. +// This is mostly used internally. func (err IDChoiceError) SequenceId() uint16 { return err.Sequence } @@ -6294,20 +6260,20 @@ func init() { xgb.NewErrorFuncs[14] = IDChoiceErrorNew } -// ErrorCopy definition Name (15) - +// BadName is the error number for a BadName. const BadName = 15 type NameError RequestError +// NameErrorNew constructs a NameError value that implements xgb.Error from a byte slice. func NameErrorNew(buf []byte) xgb.Error { v := NameError(RequestErrorNew(buf).(RequestError)) v.NiceName = "Name" return v } -func (err NameError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadName error. +// This is mostly used internally. func (err NameError) SequenceId() uint16 { return err.Sequence } @@ -6330,20 +6296,20 @@ func init() { xgb.NewErrorFuncs[15] = NameErrorNew } -// ErrorCopy definition Length (16) - +// BadLength is the error number for a BadLength. const BadLength = 16 type LengthError RequestError +// LengthErrorNew constructs a LengthError value that implements xgb.Error from a byte slice. func LengthErrorNew(buf []byte) xgb.Error { v := LengthError(RequestErrorNew(buf).(RequestError)) v.NiceName = "Length" return v } -func (err LengthError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadLength error. +// This is mostly used internally. func (err LengthError) SequenceId() uint16 { return err.Sequence } @@ -6366,20 +6332,20 @@ func init() { xgb.NewErrorFuncs[16] = LengthErrorNew } -// ErrorCopy definition Implementation (17) - +// BadImplementation is the error number for a BadImplementation. const BadImplementation = 17 type ImplementationError RequestError +// ImplementationErrorNew constructs a ImplementationError value that implements xgb.Error from a byte slice. func ImplementationErrorNew(buf []byte) xgb.Error { v := ImplementationError(RequestErrorNew(buf).(RequestError)) v.NiceName = "Implementation" return v } -func (err ImplementationError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadImplementation error. +// This is mostly used internally. func (err ImplementationError) SequenceId() uint16 { return err.Sequence } @@ -6402,30 +6368,35 @@ func init() { xgb.NewErrorFuncs[17] = ImplementationErrorNew } -// Request CreateWindow -// size: xgb.Pad((28 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +// CreateWindowCookie is a cookie used only for CreateWindow requests. type CreateWindowCookie struct { *xgb.Cookie } -// Write request to wire for CreateWindow +// CreateWindow sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreateWindow(c *xgb.Conn, Depth byte, Wid Window, Parent Window, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class uint16, Visual Visualid, ValueMask uint32, ValueList []uint32) CreateWindowCookie { cookie := c.NewCookie(false, false) c.NewRequest(createWindowRequest(c, Depth, Wid, Parent, X, Y, Width, Height, BorderWidth, Class, Visual, ValueMask, ValueList), cookie) return CreateWindowCookie{cookie} } +// CreateWindowChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateWindowCookie.Check() func CreateWindowChecked(c *xgb.Conn, Depth byte, Wid Window, Parent Window, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class uint16, Visual Visualid, ValueMask uint32, ValueList []uint32) CreateWindowCookie { cookie := c.NewCookie(true, false) c.NewRequest(createWindowRequest(c, Depth, Wid, Parent, X, Y, Width, Height, BorderWidth, Class, Visual, ValueMask, ValueList), cookie) return CreateWindowCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CreateWindowCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreateWindow +// createWindowRequest writes a CreateWindow request to a byte slice. func createWindowRequest(c *xgb.Conn, Depth byte, Wid Window, Parent Window, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class uint16, Visual Visualid, ValueMask uint32, ValueList []uint32) []byte { size := xgb.Pad((28 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) b := 0 @@ -6478,30 +6449,35 @@ func createWindowRequest(c *xgb.Conn, Depth byte, Wid Window, Parent Window, X i return buf } -// Request ChangeWindowAttributes -// size: xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +// ChangeWindowAttributesCookie is a cookie used only for ChangeWindowAttributes requests. type ChangeWindowAttributesCookie struct { *xgb.Cookie } -// Write request to wire for ChangeWindowAttributes +// ChangeWindowAttributes sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ChangeWindowAttributes(c *xgb.Conn, Window Window, ValueMask uint32, ValueList []uint32) ChangeWindowAttributesCookie { cookie := c.NewCookie(false, false) c.NewRequest(changeWindowAttributesRequest(c, Window, ValueMask, ValueList), cookie) return ChangeWindowAttributesCookie{cookie} } +// ChangeWindowAttributesChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeWindowAttributesCookie.Check() func ChangeWindowAttributesChecked(c *xgb.Conn, Window Window, ValueMask uint32, ValueList []uint32) ChangeWindowAttributesCookie { cookie := c.NewCookie(true, false) c.NewRequest(changeWindowAttributesRequest(c, Window, ValueMask, ValueList), cookie) return ChangeWindowAttributesCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook ChangeWindowAttributesCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ChangeWindowAttributes +// changeWindowAttributesRequest writes a ChangeWindowAttributes request to a byte slice. func changeWindowAttributesRequest(c *xgb.Conn, Window Window, ValueMask uint32, ValueList []uint32) []byte { size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) b := 0 @@ -6529,29 +6505,31 @@ func changeWindowAttributesRequest(c *xgb.Conn, Window Window, ValueMask uint32, return buf } -// Request GetWindowAttributes -// size: 8 +// GetWindowAttributesCookie is a cookie used only for GetWindowAttributes requests. type GetWindowAttributesCookie struct { *xgb.Cookie } +// GetWindowAttributes sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetWindowAttributesCookie.Reply() func GetWindowAttributes(c *xgb.Conn, Window Window) GetWindowAttributesCookie { cookie := c.NewCookie(true, true) c.NewRequest(getWindowAttributesRequest(c, Window), cookie) return GetWindowAttributesCookie{cookie} } +// GetWindowAttributesUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetWindowAttributesUnchecked(c *xgb.Conn, Window Window) GetWindowAttributesCookie { cookie := c.NewCookie(false, true) c.NewRequest(getWindowAttributesRequest(c, Window), cookie) return GetWindowAttributesCookie{cookie} } -// Request reply for GetWindowAttributes -// size: 44 +// GetWindowAttributesReply represents the data returned from a GetWindowAttributes request. type GetWindowAttributesReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply BackingStore byte Visual Visualid Class uint16 @@ -6570,7 +6548,7 @@ type GetWindowAttributesReply struct { // padding: 2 bytes } -// Waits and reads reply data from request GetWindowAttributes +// Reply blocks and returns the reply data for a GetWindowAttributes request. func (cook GetWindowAttributesCookie) Reply() (*GetWindowAttributesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -6582,7 +6560,7 @@ func (cook GetWindowAttributesCookie) Reply() (*GetWindowAttributesReply, error) return getWindowAttributesReply(buf), nil } -// Read reply into structure from buffer for GetWindowAttributes +// getWindowAttributesReply reads a byte slice into a GetWindowAttributesReply value. func getWindowAttributesReply(buf []byte) *GetWindowAttributesReply { v := new(GetWindowAttributesReply) b := 1 // skip reply determinant @@ -6656,6 +6634,7 @@ func getWindowAttributesReply(buf []byte) *GetWindowAttributesReply { } // Write request to wire for GetWindowAttributes +// getWindowAttributesRequest writes a GetWindowAttributes request to a byte slice. func getWindowAttributesRequest(c *xgb.Conn, Window Window) []byte { size := 8 b := 0 @@ -6675,30 +6654,35 @@ func getWindowAttributesRequest(c *xgb.Conn, Window Window) []byte { return buf } -// Request DestroyWindow -// size: 8 +// DestroyWindowCookie is a cookie used only for DestroyWindow requests. type DestroyWindowCookie struct { *xgb.Cookie } -// Write request to wire for DestroyWindow +// DestroyWindow sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func DestroyWindow(c *xgb.Conn, Window Window) DestroyWindowCookie { cookie := c.NewCookie(false, false) c.NewRequest(destroyWindowRequest(c, Window), cookie) return DestroyWindowCookie{cookie} } +// DestroyWindowChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroyWindowCookie.Check() func DestroyWindowChecked(c *xgb.Conn, Window Window) DestroyWindowCookie { cookie := c.NewCookie(true, false) c.NewRequest(destroyWindowRequest(c, Window), cookie) return DestroyWindowCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook DestroyWindowCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for DestroyWindow +// destroyWindowRequest writes a DestroyWindow request to a byte slice. func destroyWindowRequest(c *xgb.Conn, Window Window) []byte { size := 8 b := 0 @@ -6718,30 +6702,35 @@ func destroyWindowRequest(c *xgb.Conn, Window Window) []byte { return buf } -// Request DestroySubwindows -// size: 8 +// DestroySubwindowsCookie is a cookie used only for DestroySubwindows requests. type DestroySubwindowsCookie struct { *xgb.Cookie } -// Write request to wire for DestroySubwindows +// DestroySubwindows sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func DestroySubwindows(c *xgb.Conn, Window Window) DestroySubwindowsCookie { cookie := c.NewCookie(false, false) c.NewRequest(destroySubwindowsRequest(c, Window), cookie) return DestroySubwindowsCookie{cookie} } +// DestroySubwindowsChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroySubwindowsCookie.Check() func DestroySubwindowsChecked(c *xgb.Conn, Window Window) DestroySubwindowsCookie { cookie := c.NewCookie(true, false) c.NewRequest(destroySubwindowsRequest(c, Window), cookie) return DestroySubwindowsCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook DestroySubwindowsCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for DestroySubwindows +// destroySubwindowsRequest writes a DestroySubwindows request to a byte slice. func destroySubwindowsRequest(c *xgb.Conn, Window Window) []byte { size := 8 b := 0 @@ -6761,30 +6750,35 @@ func destroySubwindowsRequest(c *xgb.Conn, Window Window) []byte { return buf } -// Request ChangeSaveSet -// size: 8 +// ChangeSaveSetCookie is a cookie used only for ChangeSaveSet requests. type ChangeSaveSetCookie struct { *xgb.Cookie } -// Write request to wire for ChangeSaveSet +// ChangeSaveSet sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ChangeSaveSet(c *xgb.Conn, Mode byte, Window Window) ChangeSaveSetCookie { cookie := c.NewCookie(false, false) c.NewRequest(changeSaveSetRequest(c, Mode, Window), cookie) return ChangeSaveSetCookie{cookie} } +// ChangeSaveSetChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeSaveSetCookie.Check() func ChangeSaveSetChecked(c *xgb.Conn, Mode byte, Window Window) ChangeSaveSetCookie { cookie := c.NewCookie(true, false) c.NewRequest(changeSaveSetRequest(c, Mode, Window), cookie) return ChangeSaveSetCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook ChangeSaveSetCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ChangeSaveSet +// changeSaveSetRequest writes a ChangeSaveSet request to a byte slice. func changeSaveSetRequest(c *xgb.Conn, Mode byte, Window Window) []byte { size := 8 b := 0 @@ -6805,30 +6799,35 @@ func changeSaveSetRequest(c *xgb.Conn, Mode byte, Window Window) []byte { return buf } -// Request ReparentWindow -// size: 16 +// ReparentWindowCookie is a cookie used only for ReparentWindow requests. type ReparentWindowCookie struct { *xgb.Cookie } -// Write request to wire for ReparentWindow +// ReparentWindow sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ReparentWindow(c *xgb.Conn, Window Window, Parent Window, X int16, Y int16) ReparentWindowCookie { cookie := c.NewCookie(false, false) c.NewRequest(reparentWindowRequest(c, Window, Parent, X, Y), cookie) return ReparentWindowCookie{cookie} } +// ReparentWindowChecked sends a checked request. +// If an error occurs, it can be retrieved using ReparentWindowCookie.Check() func ReparentWindowChecked(c *xgb.Conn, Window Window, Parent Window, X int16, Y int16) ReparentWindowCookie { cookie := c.NewCookie(true, false) c.NewRequest(reparentWindowRequest(c, Window, Parent, X, Y), cookie) return ReparentWindowCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook ReparentWindowCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ReparentWindow +// reparentWindowRequest writes a ReparentWindow request to a byte slice. func reparentWindowRequest(c *xgb.Conn, Window Window, Parent Window, X int16, Y int16) []byte { size := 16 b := 0 @@ -6857,30 +6856,35 @@ func reparentWindowRequest(c *xgb.Conn, Window Window, Parent Window, X int16, Y return buf } -// Request MapWindow -// size: 8 +// MapWindowCookie is a cookie used only for MapWindow requests. type MapWindowCookie struct { *xgb.Cookie } -// Write request to wire for MapWindow +// MapWindow sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func MapWindow(c *xgb.Conn, Window Window) MapWindowCookie { cookie := c.NewCookie(false, false) c.NewRequest(mapWindowRequest(c, Window), cookie) return MapWindowCookie{cookie} } +// MapWindowChecked sends a checked request. +// If an error occurs, it can be retrieved using MapWindowCookie.Check() func MapWindowChecked(c *xgb.Conn, Window Window) MapWindowCookie { cookie := c.NewCookie(true, false) c.NewRequest(mapWindowRequest(c, Window), cookie) return MapWindowCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook MapWindowCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for MapWindow +// mapWindowRequest writes a MapWindow request to a byte slice. func mapWindowRequest(c *xgb.Conn, Window Window) []byte { size := 8 b := 0 @@ -6900,30 +6904,35 @@ func mapWindowRequest(c *xgb.Conn, Window Window) []byte { return buf } -// Request MapSubwindows -// size: 8 +// MapSubwindowsCookie is a cookie used only for MapSubwindows requests. type MapSubwindowsCookie struct { *xgb.Cookie } -// Write request to wire for MapSubwindows +// MapSubwindows sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func MapSubwindows(c *xgb.Conn, Window Window) MapSubwindowsCookie { cookie := c.NewCookie(false, false) c.NewRequest(mapSubwindowsRequest(c, Window), cookie) return MapSubwindowsCookie{cookie} } +// MapSubwindowsChecked sends a checked request. +// If an error occurs, it can be retrieved using MapSubwindowsCookie.Check() func MapSubwindowsChecked(c *xgb.Conn, Window Window) MapSubwindowsCookie { cookie := c.NewCookie(true, false) c.NewRequest(mapSubwindowsRequest(c, Window), cookie) return MapSubwindowsCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook MapSubwindowsCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for MapSubwindows +// mapSubwindowsRequest writes a MapSubwindows request to a byte slice. func mapSubwindowsRequest(c *xgb.Conn, Window Window) []byte { size := 8 b := 0 @@ -6943,30 +6952,35 @@ func mapSubwindowsRequest(c *xgb.Conn, Window Window) []byte { return buf } -// Request UnmapWindow -// size: 8 +// UnmapWindowCookie is a cookie used only for UnmapWindow requests. type UnmapWindowCookie struct { *xgb.Cookie } -// Write request to wire for UnmapWindow +// UnmapWindow sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func UnmapWindow(c *xgb.Conn, Window Window) UnmapWindowCookie { cookie := c.NewCookie(false, false) c.NewRequest(unmapWindowRequest(c, Window), cookie) return UnmapWindowCookie{cookie} } +// UnmapWindowChecked sends a checked request. +// If an error occurs, it can be retrieved using UnmapWindowCookie.Check() func UnmapWindowChecked(c *xgb.Conn, Window Window) UnmapWindowCookie { cookie := c.NewCookie(true, false) c.NewRequest(unmapWindowRequest(c, Window), cookie) return UnmapWindowCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook UnmapWindowCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for UnmapWindow +// unmapWindowRequest writes a UnmapWindow request to a byte slice. func unmapWindowRequest(c *xgb.Conn, Window Window) []byte { size := 8 b := 0 @@ -6986,30 +7000,35 @@ func unmapWindowRequest(c *xgb.Conn, Window Window) []byte { return buf } -// Request UnmapSubwindows -// size: 8 +// UnmapSubwindowsCookie is a cookie used only for UnmapSubwindows requests. type UnmapSubwindowsCookie struct { *xgb.Cookie } -// Write request to wire for UnmapSubwindows +// UnmapSubwindows sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func UnmapSubwindows(c *xgb.Conn, Window Window) UnmapSubwindowsCookie { cookie := c.NewCookie(false, false) c.NewRequest(unmapSubwindowsRequest(c, Window), cookie) return UnmapSubwindowsCookie{cookie} } +// UnmapSubwindowsChecked sends a checked request. +// If an error occurs, it can be retrieved using UnmapSubwindowsCookie.Check() func UnmapSubwindowsChecked(c *xgb.Conn, Window Window) UnmapSubwindowsCookie { cookie := c.NewCookie(true, false) c.NewRequest(unmapSubwindowsRequest(c, Window), cookie) return UnmapSubwindowsCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook UnmapSubwindowsCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for UnmapSubwindows +// unmapSubwindowsRequest writes a UnmapSubwindows request to a byte slice. func unmapSubwindowsRequest(c *xgb.Conn, Window Window) []byte { size := 8 b := 0 @@ -7029,30 +7048,35 @@ func unmapSubwindowsRequest(c *xgb.Conn, Window Window) []byte { return buf } -// Request ConfigureWindow -// size: xgb.Pad((10 + (2 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +// ConfigureWindowCookie is a cookie used only for ConfigureWindow requests. type ConfigureWindowCookie struct { *xgb.Cookie } -// Write request to wire for ConfigureWindow +// ConfigureWindow sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ConfigureWindow(c *xgb.Conn, Window Window, ValueMask uint16, ValueList []uint32) ConfigureWindowCookie { cookie := c.NewCookie(false, false) c.NewRequest(configureWindowRequest(c, Window, ValueMask, ValueList), cookie) return ConfigureWindowCookie{cookie} } +// ConfigureWindowChecked sends a checked request. +// If an error occurs, it can be retrieved using ConfigureWindowCookie.Check() func ConfigureWindowChecked(c *xgb.Conn, Window Window, ValueMask uint16, ValueList []uint32) ConfigureWindowCookie { cookie := c.NewCookie(true, false) c.NewRequest(configureWindowRequest(c, Window, ValueMask, ValueList), cookie) return ConfigureWindowCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook ConfigureWindowCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ConfigureWindow +// configureWindowRequest writes a ConfigureWindow request to a byte slice. func configureWindowRequest(c *xgb.Conn, Window Window, ValueMask uint16, ValueList []uint32) []byte { size := xgb.Pad((10 + (2 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) b := 0 @@ -7083,30 +7107,35 @@ func configureWindowRequest(c *xgb.Conn, Window Window, ValueMask uint16, ValueL return buf } -// Request CirculateWindow -// size: 8 +// CirculateWindowCookie is a cookie used only for CirculateWindow requests. type CirculateWindowCookie struct { *xgb.Cookie } -// Write request to wire for CirculateWindow +// CirculateWindow sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CirculateWindow(c *xgb.Conn, Direction byte, Window Window) CirculateWindowCookie { cookie := c.NewCookie(false, false) c.NewRequest(circulateWindowRequest(c, Direction, Window), cookie) return CirculateWindowCookie{cookie} } +// CirculateWindowChecked sends a checked request. +// If an error occurs, it can be retrieved using CirculateWindowCookie.Check() func CirculateWindowChecked(c *xgb.Conn, Direction byte, Window Window) CirculateWindowCookie { cookie := c.NewCookie(true, false) c.NewRequest(circulateWindowRequest(c, Direction, Window), cookie) return CirculateWindowCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CirculateWindowCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CirculateWindow +// circulateWindowRequest writes a CirculateWindow request to a byte slice. func circulateWindowRequest(c *xgb.Conn, Direction byte, Window Window) []byte { size := 8 b := 0 @@ -7127,29 +7156,31 @@ func circulateWindowRequest(c *xgb.Conn, Direction byte, Window Window) []byte { return buf } -// Request GetGeometry -// size: 8 +// GetGeometryCookie is a cookie used only for GetGeometry requests. type GetGeometryCookie struct { *xgb.Cookie } +// GetGeometry sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetGeometryCookie.Reply() func GetGeometry(c *xgb.Conn, Drawable Drawable) GetGeometryCookie { cookie := c.NewCookie(true, true) c.NewRequest(getGeometryRequest(c, Drawable), cookie) return GetGeometryCookie{cookie} } +// GetGeometryUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetGeometryUnchecked(c *xgb.Conn, Drawable Drawable) GetGeometryCookie { cookie := c.NewCookie(false, true) c.NewRequest(getGeometryRequest(c, Drawable), cookie) return GetGeometryCookie{cookie} } -// Request reply for GetGeometry -// size: 24 +// GetGeometryReply represents the data returned from a GetGeometry request. type GetGeometryReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply Depth byte Root Window X int16 @@ -7160,7 +7191,7 @@ type GetGeometryReply struct { // padding: 2 bytes } -// Waits and reads reply data from request GetGeometry +// Reply blocks and returns the reply data for a GetGeometry request. func (cook GetGeometryCookie) Reply() (*GetGeometryReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -7172,7 +7203,7 @@ func (cook GetGeometryCookie) Reply() (*GetGeometryReply, error) { return getGeometryReply(buf), nil } -// Read reply into structure from buffer for GetGeometry +// getGeometryReply reads a byte slice into a GetGeometryReply value. func getGeometryReply(buf []byte) *GetGeometryReply { v := new(GetGeometryReply) b := 1 // skip reply determinant @@ -7210,6 +7241,7 @@ func getGeometryReply(buf []byte) *GetGeometryReply { } // Write request to wire for GetGeometry +// getGeometryRequest writes a GetGeometry request to a byte slice. func getGeometryRequest(c *xgb.Conn, Drawable Drawable) []byte { size := 8 b := 0 @@ -7229,29 +7261,31 @@ func getGeometryRequest(c *xgb.Conn, Drawable Drawable) []byte { return buf } -// Request QueryTree -// size: 8 +// QueryTreeCookie is a cookie used only for QueryTree requests. type QueryTreeCookie struct { *xgb.Cookie } +// QueryTree sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryTreeCookie.Reply() func QueryTree(c *xgb.Conn, Window Window) QueryTreeCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryTreeRequest(c, Window), cookie) return QueryTreeCookie{cookie} } +// QueryTreeUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryTreeUnchecked(c *xgb.Conn, Window Window) QueryTreeCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryTreeRequest(c, Window), cookie) return QueryTreeCookie{cookie} } -// Request reply for QueryTree -// size: (32 + xgb.Pad((int(ChildrenLen) * 4))) +// QueryTreeReply represents the data returned from a QueryTree request. type QueryTreeReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Root Window Parent Window @@ -7260,7 +7294,7 @@ type QueryTreeReply struct { Children []Window // size: xgb.Pad((int(ChildrenLen) * 4)) } -// Waits and reads reply data from request QueryTree +// Reply blocks and returns the reply data for a QueryTree request. func (cook QueryTreeCookie) Reply() (*QueryTreeReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -7272,7 +7306,7 @@ func (cook QueryTreeCookie) Reply() (*QueryTreeReply, error) { return queryTreeReply(buf), nil } -// Read reply into structure from buffer for QueryTree +// queryTreeReply reads a byte slice into a QueryTreeReply value. func queryTreeReply(buf []byte) *QueryTreeReply { v := new(QueryTreeReply) b := 1 // skip reply determinant @@ -7307,6 +7341,7 @@ func queryTreeReply(buf []byte) *QueryTreeReply { } // Write request to wire for QueryTree +// queryTreeRequest writes a QueryTree request to a byte slice. func queryTreeRequest(c *xgb.Conn, Window Window) []byte { size := 8 b := 0 @@ -7326,34 +7361,36 @@ func queryTreeRequest(c *xgb.Conn, Window Window) []byte { return buf } -// Request InternAtom -// size: xgb.Pad((8 + xgb.Pad((int(NameLen) * 1)))) +// InternAtomCookie is a cookie used only for InternAtom requests. type InternAtomCookie struct { *xgb.Cookie } +// InternAtom sends a checked request. +// If an error occurs, it will be returned with the reply by calling InternAtomCookie.Reply() func InternAtom(c *xgb.Conn, OnlyIfExists bool, NameLen uint16, Name string) InternAtomCookie { cookie := c.NewCookie(true, true) c.NewRequest(internAtomRequest(c, OnlyIfExists, NameLen, Name), cookie) return InternAtomCookie{cookie} } +// InternAtomUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func InternAtomUnchecked(c *xgb.Conn, OnlyIfExists bool, NameLen uint16, Name string) InternAtomCookie { cookie := c.NewCookie(false, true) c.NewRequest(internAtomRequest(c, OnlyIfExists, NameLen, Name), cookie) return InternAtomCookie{cookie} } -// Request reply for InternAtom -// size: 12 +// InternAtomReply represents the data returned from a InternAtom request. type InternAtomReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Atom Atom } -// Waits and reads reply data from request InternAtom +// Reply blocks and returns the reply data for a InternAtom request. func (cook InternAtomCookie) Reply() (*InternAtomReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -7365,7 +7402,7 @@ func (cook InternAtomCookie) Reply() (*InternAtomReply, error) { return internAtomReply(buf), nil } -// Read reply into structure from buffer for InternAtom +// internAtomReply reads a byte slice into a InternAtomReply value. func internAtomReply(buf []byte) *InternAtomReply { v := new(InternAtomReply) b := 1 // skip reply determinant @@ -7385,6 +7422,7 @@ func internAtomReply(buf []byte) *InternAtomReply { } // Write request to wire for InternAtom +// internAtomRequest writes a InternAtom request to a byte slice. func internAtomRequest(c *xgb.Conn, OnlyIfExists bool, NameLen uint16, Name string) []byte { size := xgb.Pad((8 + xgb.Pad((int(NameLen) * 1)))) b := 0 @@ -7414,36 +7452,38 @@ func internAtomRequest(c *xgb.Conn, OnlyIfExists bool, NameLen uint16, Name stri return buf } -// Request GetAtomName -// size: 8 +// GetAtomNameCookie is a cookie used only for GetAtomName requests. type GetAtomNameCookie struct { *xgb.Cookie } +// GetAtomName sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetAtomNameCookie.Reply() func GetAtomName(c *xgb.Conn, Atom Atom) GetAtomNameCookie { cookie := c.NewCookie(true, true) c.NewRequest(getAtomNameRequest(c, Atom), cookie) return GetAtomNameCookie{cookie} } +// GetAtomNameUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetAtomNameUnchecked(c *xgb.Conn, Atom Atom) GetAtomNameCookie { cookie := c.NewCookie(false, true) c.NewRequest(getAtomNameRequest(c, Atom), cookie) return GetAtomNameCookie{cookie} } -// Request reply for GetAtomName -// size: (32 + xgb.Pad((int(NameLen) * 1))) +// GetAtomNameReply represents the data returned from a GetAtomName request. type GetAtomNameReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes NameLen uint16 // padding: 22 bytes Name string // size: xgb.Pad((int(NameLen) * 1)) } -// Waits and reads reply data from request GetAtomName +// Reply blocks and returns the reply data for a GetAtomName request. func (cook GetAtomNameCookie) Reply() (*GetAtomNameReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -7455,7 +7495,7 @@ func (cook GetAtomNameCookie) Reply() (*GetAtomNameReply, error) { return getAtomNameReply(buf), nil } -// Read reply into structure from buffer for GetAtomName +// getAtomNameReply reads a byte slice into a GetAtomNameReply value. func getAtomNameReply(buf []byte) *GetAtomNameReply { v := new(GetAtomNameReply) b := 1 // skip reply determinant @@ -7484,6 +7524,7 @@ func getAtomNameReply(buf []byte) *GetAtomNameReply { } // Write request to wire for GetAtomName +// getAtomNameRequest writes a GetAtomName request to a byte slice. func getAtomNameRequest(c *xgb.Conn, Atom Atom) []byte { size := 8 b := 0 @@ -7503,30 +7544,35 @@ func getAtomNameRequest(c *xgb.Conn, Atom Atom) []byte { return buf } -// Request ChangeProperty -// size: xgb.Pad((24 + xgb.Pad((((int(DataLen) * int(Format)) / 8) * 1)))) +// ChangePropertyCookie is a cookie used only for ChangeProperty requests. type ChangePropertyCookie struct { *xgb.Cookie } -// Write request to wire for ChangeProperty +// ChangeProperty sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ChangeProperty(c *xgb.Conn, Mode byte, Window Window, Property Atom, Type Atom, Format byte, DataLen uint32, Data []byte) ChangePropertyCookie { cookie := c.NewCookie(false, false) c.NewRequest(changePropertyRequest(c, Mode, Window, Property, Type, Format, DataLen, Data), cookie) return ChangePropertyCookie{cookie} } +// ChangePropertyChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangePropertyCookie.Check() func ChangePropertyChecked(c *xgb.Conn, Mode byte, Window Window, Property Atom, Type Atom, Format byte, DataLen uint32, Data []byte) ChangePropertyCookie { cookie := c.NewCookie(true, false) c.NewRequest(changePropertyRequest(c, Mode, Window, Property, Type, Format, DataLen, Data), cookie) return ChangePropertyCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook ChangePropertyCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ChangeProperty +// changePropertyRequest writes a ChangeProperty request to a byte slice. func changePropertyRequest(c *xgb.Conn, Mode byte, Window Window, Property Atom, Type Atom, Format byte, DataLen uint32, Data []byte) []byte { size := xgb.Pad((24 + xgb.Pad((((int(DataLen) * int(Format)) / 8) * 1)))) b := 0 @@ -7564,30 +7610,35 @@ func changePropertyRequest(c *xgb.Conn, Mode byte, Window Window, Property Atom, return buf } -// Request DeleteProperty -// size: 12 +// DeletePropertyCookie is a cookie used only for DeleteProperty requests. type DeletePropertyCookie struct { *xgb.Cookie } -// Write request to wire for DeleteProperty +// DeleteProperty sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func DeleteProperty(c *xgb.Conn, Window Window, Property Atom) DeletePropertyCookie { cookie := c.NewCookie(false, false) c.NewRequest(deletePropertyRequest(c, Window, Property), cookie) return DeletePropertyCookie{cookie} } +// DeletePropertyChecked sends a checked request. +// If an error occurs, it can be retrieved using DeletePropertyCookie.Check() func DeletePropertyChecked(c *xgb.Conn, Window Window, Property Atom) DeletePropertyCookie { cookie := c.NewCookie(true, false) c.NewRequest(deletePropertyRequest(c, Window, Property), cookie) return DeletePropertyCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook DeletePropertyCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for DeleteProperty +// deletePropertyRequest writes a DeleteProperty request to a byte slice. func deletePropertyRequest(c *xgb.Conn, Window Window, Property Atom) []byte { size := 12 b := 0 @@ -7610,29 +7661,31 @@ func deletePropertyRequest(c *xgb.Conn, Window Window, Property Atom) []byte { return buf } -// Request GetProperty -// size: 24 +// GetPropertyCookie is a cookie used only for GetProperty requests. type GetPropertyCookie struct { *xgb.Cookie } +// GetProperty sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPropertyCookie.Reply() func GetProperty(c *xgb.Conn, Delete bool, Window Window, Property Atom, Type Atom, LongOffset uint32, LongLength uint32) GetPropertyCookie { cookie := c.NewCookie(true, true) c.NewRequest(getPropertyRequest(c, Delete, Window, Property, Type, LongOffset, LongLength), cookie) return GetPropertyCookie{cookie} } +// GetPropertyUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetPropertyUnchecked(c *xgb.Conn, Delete bool, Window Window, Property Atom, Type Atom, LongOffset uint32, LongLength uint32) GetPropertyCookie { cookie := c.NewCookie(false, true) c.NewRequest(getPropertyRequest(c, Delete, Window, Property, Type, LongOffset, LongLength), cookie) return GetPropertyCookie{cookie} } -// Request reply for GetProperty -// size: (32 + xgb.Pad(((int(ValueLen) * (int(Format) / 8)) * 1))) +// GetPropertyReply represents the data returned from a GetProperty request. type GetPropertyReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply Format byte Type Atom BytesAfter uint32 @@ -7641,7 +7694,7 @@ type GetPropertyReply struct { Value []byte // size: xgb.Pad(((int(ValueLen) * (int(Format) / 8)) * 1)) } -// Waits and reads reply data from request GetProperty +// Reply blocks and returns the reply data for a GetProperty request. func (cook GetPropertyCookie) Reply() (*GetPropertyReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -7653,7 +7706,7 @@ func (cook GetPropertyCookie) Reply() (*GetPropertyReply, error) { return getPropertyReply(buf), nil } -// Read reply into structure from buffer for GetProperty +// getPropertyReply reads a byte slice into a GetPropertyReply value. func getPropertyReply(buf []byte) *GetPropertyReply { v := new(GetPropertyReply) b := 1 // skip reply determinant @@ -7686,6 +7739,7 @@ func getPropertyReply(buf []byte) *GetPropertyReply { } // Write request to wire for GetProperty +// getPropertyRequest writes a GetProperty request to a byte slice. func getPropertyRequest(c *xgb.Conn, Delete bool, Window Window, Property Atom, Type Atom, LongOffset uint32, LongLength uint32) []byte { size := 24 b := 0 @@ -7722,36 +7776,38 @@ func getPropertyRequest(c *xgb.Conn, Delete bool, Window Window, Property Atom, return buf } -// Request ListProperties -// size: 8 +// ListPropertiesCookie is a cookie used only for ListProperties requests. type ListPropertiesCookie struct { *xgb.Cookie } +// ListProperties sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListPropertiesCookie.Reply() func ListProperties(c *xgb.Conn, Window Window) ListPropertiesCookie { cookie := c.NewCookie(true, true) c.NewRequest(listPropertiesRequest(c, Window), cookie) return ListPropertiesCookie{cookie} } +// ListPropertiesUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ListPropertiesUnchecked(c *xgb.Conn, Window Window) ListPropertiesCookie { cookie := c.NewCookie(false, true) c.NewRequest(listPropertiesRequest(c, Window), cookie) return ListPropertiesCookie{cookie} } -// Request reply for ListProperties -// size: (32 + xgb.Pad((int(AtomsLen) * 4))) +// ListPropertiesReply represents the data returned from a ListProperties request. type ListPropertiesReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes AtomsLen uint16 // padding: 22 bytes Atoms []Atom // size: xgb.Pad((int(AtomsLen) * 4)) } -// Waits and reads reply data from request ListProperties +// Reply blocks and returns the reply data for a ListProperties request. func (cook ListPropertiesCookie) Reply() (*ListPropertiesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -7763,7 +7819,7 @@ func (cook ListPropertiesCookie) Reply() (*ListPropertiesReply, error) { return listPropertiesReply(buf), nil } -// Read reply into structure from buffer for ListProperties +// listPropertiesReply reads a byte slice into a ListPropertiesReply value. func listPropertiesReply(buf []byte) *ListPropertiesReply { v := new(ListPropertiesReply) b := 1 // skip reply determinant @@ -7792,6 +7848,7 @@ func listPropertiesReply(buf []byte) *ListPropertiesReply { } // Write request to wire for ListProperties +// listPropertiesRequest writes a ListProperties request to a byte slice. func listPropertiesRequest(c *xgb.Conn, Window Window) []byte { size := 8 b := 0 @@ -7811,30 +7868,35 @@ func listPropertiesRequest(c *xgb.Conn, Window Window) []byte { return buf } -// Request SetSelectionOwner -// size: 16 +// SetSelectionOwnerCookie is a cookie used only for SetSelectionOwner requests. type SetSelectionOwnerCookie struct { *xgb.Cookie } -// Write request to wire for SetSelectionOwner +// SetSelectionOwner sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetSelectionOwner(c *xgb.Conn, Owner Window, Selection Atom, Time Timestamp) SetSelectionOwnerCookie { cookie := c.NewCookie(false, false) c.NewRequest(setSelectionOwnerRequest(c, Owner, Selection, Time), cookie) return SetSelectionOwnerCookie{cookie} } +// SetSelectionOwnerChecked sends a checked request. +// If an error occurs, it can be retrieved using SetSelectionOwnerCookie.Check() func SetSelectionOwnerChecked(c *xgb.Conn, Owner Window, Selection Atom, Time Timestamp) SetSelectionOwnerCookie { cookie := c.NewCookie(true, false) c.NewRequest(setSelectionOwnerRequest(c, Owner, Selection, Time), cookie) return SetSelectionOwnerCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetSelectionOwnerCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetSelectionOwner +// setSelectionOwnerRequest writes a SetSelectionOwner request to a byte slice. func setSelectionOwnerRequest(c *xgb.Conn, Owner Window, Selection Atom, Time Timestamp) []byte { size := 16 b := 0 @@ -7860,34 +7922,36 @@ func setSelectionOwnerRequest(c *xgb.Conn, Owner Window, Selection Atom, Time Ti return buf } -// Request GetSelectionOwner -// size: 8 +// GetSelectionOwnerCookie is a cookie used only for GetSelectionOwner requests. type GetSelectionOwnerCookie struct { *xgb.Cookie } +// GetSelectionOwner sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetSelectionOwnerCookie.Reply() func GetSelectionOwner(c *xgb.Conn, Selection Atom) GetSelectionOwnerCookie { cookie := c.NewCookie(true, true) c.NewRequest(getSelectionOwnerRequest(c, Selection), cookie) return GetSelectionOwnerCookie{cookie} } +// GetSelectionOwnerUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetSelectionOwnerUnchecked(c *xgb.Conn, Selection Atom) GetSelectionOwnerCookie { cookie := c.NewCookie(false, true) c.NewRequest(getSelectionOwnerRequest(c, Selection), cookie) return GetSelectionOwnerCookie{cookie} } -// Request reply for GetSelectionOwner -// size: 12 +// GetSelectionOwnerReply represents the data returned from a GetSelectionOwner request. type GetSelectionOwnerReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Owner Window } -// Waits and reads reply data from request GetSelectionOwner +// Reply blocks and returns the reply data for a GetSelectionOwner request. func (cook GetSelectionOwnerCookie) Reply() (*GetSelectionOwnerReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -7899,7 +7963,7 @@ func (cook GetSelectionOwnerCookie) Reply() (*GetSelectionOwnerReply, error) { return getSelectionOwnerReply(buf), nil } -// Read reply into structure from buffer for GetSelectionOwner +// getSelectionOwnerReply reads a byte slice into a GetSelectionOwnerReply value. func getSelectionOwnerReply(buf []byte) *GetSelectionOwnerReply { v := new(GetSelectionOwnerReply) b := 1 // skip reply determinant @@ -7919,6 +7983,7 @@ func getSelectionOwnerReply(buf []byte) *GetSelectionOwnerReply { } // Write request to wire for GetSelectionOwner +// getSelectionOwnerRequest writes a GetSelectionOwner request to a byte slice. func getSelectionOwnerRequest(c *xgb.Conn, Selection Atom) []byte { size := 8 b := 0 @@ -7938,30 +8003,35 @@ func getSelectionOwnerRequest(c *xgb.Conn, Selection Atom) []byte { return buf } -// Request ConvertSelection -// size: 24 +// ConvertSelectionCookie is a cookie used only for ConvertSelection requests. type ConvertSelectionCookie struct { *xgb.Cookie } -// Write request to wire for ConvertSelection +// ConvertSelection sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ConvertSelection(c *xgb.Conn, Requestor Window, Selection Atom, Target Atom, Property Atom, Time Timestamp) ConvertSelectionCookie { cookie := c.NewCookie(false, false) c.NewRequest(convertSelectionRequest(c, Requestor, Selection, Target, Property, Time), cookie) return ConvertSelectionCookie{cookie} } +// ConvertSelectionChecked sends a checked request. +// If an error occurs, it can be retrieved using ConvertSelectionCookie.Check() func ConvertSelectionChecked(c *xgb.Conn, Requestor Window, Selection Atom, Target Atom, Property Atom, Time Timestamp) ConvertSelectionCookie { cookie := c.NewCookie(true, false) c.NewRequest(convertSelectionRequest(c, Requestor, Selection, Target, Property, Time), cookie) return ConvertSelectionCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook ConvertSelectionCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ConvertSelection +// convertSelectionRequest writes a ConvertSelection request to a byte slice. func convertSelectionRequest(c *xgb.Conn, Requestor Window, Selection Atom, Target Atom, Property Atom, Time Timestamp) []byte { size := 24 b := 0 @@ -7993,30 +8063,35 @@ func convertSelectionRequest(c *xgb.Conn, Requestor Window, Selection Atom, Targ return buf } -// Request SendEvent -// size: 44 +// SendEventCookie is a cookie used only for SendEvent requests. type SendEventCookie struct { *xgb.Cookie } -// Write request to wire for SendEvent +// SendEvent sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SendEvent(c *xgb.Conn, Propagate bool, Destination Window, EventMask uint32, Event string) SendEventCookie { cookie := c.NewCookie(false, false) c.NewRequest(sendEventRequest(c, Propagate, Destination, EventMask, Event), cookie) return SendEventCookie{cookie} } +// SendEventChecked sends a checked request. +// If an error occurs, it can be retrieved using SendEventCookie.Check() func SendEventChecked(c *xgb.Conn, Propagate bool, Destination Window, EventMask uint32, Event string) SendEventCookie { cookie := c.NewCookie(true, false) c.NewRequest(sendEventRequest(c, Propagate, Destination, EventMask, Event), cookie) return SendEventCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SendEventCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SendEvent +// sendEventRequest writes a SendEvent request to a byte slice. func sendEventRequest(c *xgb.Conn, Propagate bool, Destination Window, EventMask uint32, Event string) []byte { size := 44 b := 0 @@ -8047,33 +8122,35 @@ func sendEventRequest(c *xgb.Conn, Propagate bool, Destination Window, EventMask return buf } -// Request GrabPointer -// size: 24 +// GrabPointerCookie is a cookie used only for GrabPointer requests. type GrabPointerCookie struct { *xgb.Cookie } +// GrabPointer sends a checked request. +// If an error occurs, it will be returned with the reply by calling GrabPointerCookie.Reply() func GrabPointer(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Time Timestamp) GrabPointerCookie { cookie := c.NewCookie(true, true) c.NewRequest(grabPointerRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Time), cookie) return GrabPointerCookie{cookie} } +// GrabPointerUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GrabPointerUnchecked(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Time Timestamp) GrabPointerCookie { cookie := c.NewCookie(false, true) c.NewRequest(grabPointerRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Time), cookie) return GrabPointerCookie{cookie} } -// Request reply for GrabPointer -// size: 8 +// GrabPointerReply represents the data returned from a GrabPointer request. type GrabPointerReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply Status byte } -// Waits and reads reply data from request GrabPointer +// Reply blocks and returns the reply data for a GrabPointer request. func (cook GrabPointerCookie) Reply() (*GrabPointerReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -8085,7 +8162,7 @@ func (cook GrabPointerCookie) Reply() (*GrabPointerReply, error) { return grabPointerReply(buf), nil } -// Read reply into structure from buffer for GrabPointer +// grabPointerReply reads a byte slice into a GrabPointerReply value. func grabPointerReply(buf []byte) *GrabPointerReply { v := new(GrabPointerReply) b := 1 // skip reply determinant @@ -8103,6 +8180,7 @@ func grabPointerReply(buf []byte) *GrabPointerReply { } // Write request to wire for GrabPointer +// grabPointerRequest writes a GrabPointer request to a byte slice. func grabPointerRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Time Timestamp) []byte { size := 24 b := 0 @@ -8145,30 +8223,35 @@ func grabPointerRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventM return buf } -// Request UngrabPointer -// size: 8 +// UngrabPointerCookie is a cookie used only for UngrabPointer requests. type UngrabPointerCookie struct { *xgb.Cookie } -// Write request to wire for UngrabPointer +// UngrabPointer sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func UngrabPointer(c *xgb.Conn, Time Timestamp) UngrabPointerCookie { cookie := c.NewCookie(false, false) c.NewRequest(ungrabPointerRequest(c, Time), cookie) return UngrabPointerCookie{cookie} } +// UngrabPointerChecked sends a checked request. +// If an error occurs, it can be retrieved using UngrabPointerCookie.Check() func UngrabPointerChecked(c *xgb.Conn, Time Timestamp) UngrabPointerCookie { cookie := c.NewCookie(true, false) c.NewRequest(ungrabPointerRequest(c, Time), cookie) return UngrabPointerCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook UngrabPointerCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for UngrabPointer +// ungrabPointerRequest writes a UngrabPointer request to a byte slice. func ungrabPointerRequest(c *xgb.Conn, Time Timestamp) []byte { size := 8 b := 0 @@ -8188,30 +8271,35 @@ func ungrabPointerRequest(c *xgb.Conn, Time Timestamp) []byte { return buf } -// Request GrabButton -// size: 24 +// GrabButtonCookie is a cookie used only for GrabButton requests. type GrabButtonCookie struct { *xgb.Cookie } -// Write request to wire for GrabButton +// GrabButton sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GrabButton(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Button byte, Modifiers uint16) GrabButtonCookie { cookie := c.NewCookie(false, false) c.NewRequest(grabButtonRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Button, Modifiers), cookie) return GrabButtonCookie{cookie} } +// GrabButtonChecked sends a checked request. +// If an error occurs, it can be retrieved using GrabButtonCookie.Check() func GrabButtonChecked(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Button byte, Modifiers uint16) GrabButtonCookie { cookie := c.NewCookie(true, false) c.NewRequest(grabButtonRequest(c, OwnerEvents, GrabWindow, EventMask, PointerMode, KeyboardMode, ConfineTo, Cursor, Button, Modifiers), cookie) return GrabButtonCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook GrabButtonCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for GrabButton +// grabButtonRequest writes a GrabButton request to a byte slice. func grabButtonRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Window, Cursor Cursor, Button byte, Modifiers uint16) []byte { size := 24 b := 0 @@ -8259,30 +8347,35 @@ func grabButtonRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, EventMa return buf } -// Request UngrabButton -// size: 12 +// UngrabButtonCookie is a cookie used only for UngrabButton requests. type UngrabButtonCookie struct { *xgb.Cookie } -// Write request to wire for UngrabButton +// UngrabButton sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func UngrabButton(c *xgb.Conn, Button byte, GrabWindow Window, Modifiers uint16) UngrabButtonCookie { cookie := c.NewCookie(false, false) c.NewRequest(ungrabButtonRequest(c, Button, GrabWindow, Modifiers), cookie) return UngrabButtonCookie{cookie} } +// UngrabButtonChecked sends a checked request. +// If an error occurs, it can be retrieved using UngrabButtonCookie.Check() func UngrabButtonChecked(c *xgb.Conn, Button byte, GrabWindow Window, Modifiers uint16) UngrabButtonCookie { cookie := c.NewCookie(true, false) c.NewRequest(ungrabButtonRequest(c, Button, GrabWindow, Modifiers), cookie) return UngrabButtonCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook UngrabButtonCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for UngrabButton +// ungrabButtonRequest writes a UngrabButton request to a byte slice. func ungrabButtonRequest(c *xgb.Conn, Button byte, GrabWindow Window, Modifiers uint16) []byte { size := 12 b := 0 @@ -8308,30 +8401,35 @@ func ungrabButtonRequest(c *xgb.Conn, Button byte, GrabWindow Window, Modifiers return buf } -// Request ChangeActivePointerGrab -// size: 16 +// ChangeActivePointerGrabCookie is a cookie used only for ChangeActivePointerGrab requests. type ChangeActivePointerGrabCookie struct { *xgb.Cookie } -// Write request to wire for ChangeActivePointerGrab +// ChangeActivePointerGrab sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ChangeActivePointerGrab(c *xgb.Conn, Cursor Cursor, Time Timestamp, EventMask uint16) ChangeActivePointerGrabCookie { cookie := c.NewCookie(false, false) c.NewRequest(changeActivePointerGrabRequest(c, Cursor, Time, EventMask), cookie) return ChangeActivePointerGrabCookie{cookie} } +// ChangeActivePointerGrabChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeActivePointerGrabCookie.Check() func ChangeActivePointerGrabChecked(c *xgb.Conn, Cursor Cursor, Time Timestamp, EventMask uint16) ChangeActivePointerGrabCookie { cookie := c.NewCookie(true, false) c.NewRequest(changeActivePointerGrabRequest(c, Cursor, Time, EventMask), cookie) return ChangeActivePointerGrabCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook ChangeActivePointerGrabCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ChangeActivePointerGrab +// changeActivePointerGrabRequest writes a ChangeActivePointerGrab request to a byte slice. func changeActivePointerGrabRequest(c *xgb.Conn, Cursor Cursor, Time Timestamp, EventMask uint16) []byte { size := 16 b := 0 @@ -8359,33 +8457,35 @@ func changeActivePointerGrabRequest(c *xgb.Conn, Cursor Cursor, Time Timestamp, return buf } -// Request GrabKeyboard -// size: 16 +// GrabKeyboardCookie is a cookie used only for GrabKeyboard requests. type GrabKeyboardCookie struct { *xgb.Cookie } +// GrabKeyboard sends a checked request. +// If an error occurs, it will be returned with the reply by calling GrabKeyboardCookie.Reply() func GrabKeyboard(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Time Timestamp, PointerMode byte, KeyboardMode byte) GrabKeyboardCookie { cookie := c.NewCookie(true, true) c.NewRequest(grabKeyboardRequest(c, OwnerEvents, GrabWindow, Time, PointerMode, KeyboardMode), cookie) return GrabKeyboardCookie{cookie} } +// GrabKeyboardUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GrabKeyboardUnchecked(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Time Timestamp, PointerMode byte, KeyboardMode byte) GrabKeyboardCookie { cookie := c.NewCookie(false, true) c.NewRequest(grabKeyboardRequest(c, OwnerEvents, GrabWindow, Time, PointerMode, KeyboardMode), cookie) return GrabKeyboardCookie{cookie} } -// Request reply for GrabKeyboard -// size: 8 +// GrabKeyboardReply represents the data returned from a GrabKeyboard request. type GrabKeyboardReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply Status byte } -// Waits and reads reply data from request GrabKeyboard +// Reply blocks and returns the reply data for a GrabKeyboard request. func (cook GrabKeyboardCookie) Reply() (*GrabKeyboardReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -8397,7 +8497,7 @@ func (cook GrabKeyboardCookie) Reply() (*GrabKeyboardReply, error) { return grabKeyboardReply(buf), nil } -// Read reply into structure from buffer for GrabKeyboard +// grabKeyboardReply reads a byte slice into a GrabKeyboardReply value. func grabKeyboardReply(buf []byte) *GrabKeyboardReply { v := new(GrabKeyboardReply) b := 1 // skip reply determinant @@ -8415,6 +8515,7 @@ func grabKeyboardReply(buf []byte) *GrabKeyboardReply { } // Write request to wire for GrabKeyboard +// grabKeyboardRequest writes a GrabKeyboard request to a byte slice. func grabKeyboardRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Time Timestamp, PointerMode byte, KeyboardMode byte) []byte { size := 16 b := 0 @@ -8450,30 +8551,35 @@ func grabKeyboardRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Time return buf } -// Request UngrabKeyboard -// size: 8 +// UngrabKeyboardCookie is a cookie used only for UngrabKeyboard requests. type UngrabKeyboardCookie struct { *xgb.Cookie } -// Write request to wire for UngrabKeyboard +// UngrabKeyboard sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func UngrabKeyboard(c *xgb.Conn, Time Timestamp) UngrabKeyboardCookie { cookie := c.NewCookie(false, false) c.NewRequest(ungrabKeyboardRequest(c, Time), cookie) return UngrabKeyboardCookie{cookie} } +// UngrabKeyboardChecked sends a checked request. +// If an error occurs, it can be retrieved using UngrabKeyboardCookie.Check() func UngrabKeyboardChecked(c *xgb.Conn, Time Timestamp) UngrabKeyboardCookie { cookie := c.NewCookie(true, false) c.NewRequest(ungrabKeyboardRequest(c, Time), cookie) return UngrabKeyboardCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook UngrabKeyboardCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for UngrabKeyboard +// ungrabKeyboardRequest writes a UngrabKeyboard request to a byte slice. func ungrabKeyboardRequest(c *xgb.Conn, Time Timestamp) []byte { size := 8 b := 0 @@ -8493,30 +8599,35 @@ func ungrabKeyboardRequest(c *xgb.Conn, Time Timestamp) []byte { return buf } -// Request GrabKey -// size: 16 +// GrabKeyCookie is a cookie used only for GrabKey requests. type GrabKeyCookie struct { *xgb.Cookie } -// Write request to wire for GrabKey +// GrabKey sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GrabKey(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Modifiers uint16, Key Keycode, PointerMode byte, KeyboardMode byte) GrabKeyCookie { cookie := c.NewCookie(false, false) c.NewRequest(grabKeyRequest(c, OwnerEvents, GrabWindow, Modifiers, Key, PointerMode, KeyboardMode), cookie) return GrabKeyCookie{cookie} } +// GrabKeyChecked sends a checked request. +// If an error occurs, it can be retrieved using GrabKeyCookie.Check() func GrabKeyChecked(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Modifiers uint16, Key Keycode, PointerMode byte, KeyboardMode byte) GrabKeyCookie { cookie := c.NewCookie(true, false) c.NewRequest(grabKeyRequest(c, OwnerEvents, GrabWindow, Modifiers, Key, PointerMode, KeyboardMode), cookie) return GrabKeyCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook GrabKeyCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for GrabKey +// grabKeyRequest writes a GrabKey request to a byte slice. func grabKeyRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Modifiers uint16, Key Keycode, PointerMode byte, KeyboardMode byte) []byte { size := 16 b := 0 @@ -8555,30 +8666,35 @@ func grabKeyRequest(c *xgb.Conn, OwnerEvents bool, GrabWindow Window, Modifiers return buf } -// Request UngrabKey -// size: 12 +// UngrabKeyCookie is a cookie used only for UngrabKey requests. type UngrabKeyCookie struct { *xgb.Cookie } -// Write request to wire for UngrabKey +// UngrabKey sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func UngrabKey(c *xgb.Conn, Key Keycode, GrabWindow Window, Modifiers uint16) UngrabKeyCookie { cookie := c.NewCookie(false, false) c.NewRequest(ungrabKeyRequest(c, Key, GrabWindow, Modifiers), cookie) return UngrabKeyCookie{cookie} } +// UngrabKeyChecked sends a checked request. +// If an error occurs, it can be retrieved using UngrabKeyCookie.Check() func UngrabKeyChecked(c *xgb.Conn, Key Keycode, GrabWindow Window, Modifiers uint16) UngrabKeyCookie { cookie := c.NewCookie(true, false) c.NewRequest(ungrabKeyRequest(c, Key, GrabWindow, Modifiers), cookie) return UngrabKeyCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook UngrabKeyCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for UngrabKey +// ungrabKeyRequest writes a UngrabKey request to a byte slice. func ungrabKeyRequest(c *xgb.Conn, Key Keycode, GrabWindow Window, Modifiers uint16) []byte { size := 12 b := 0 @@ -8604,30 +8720,35 @@ func ungrabKeyRequest(c *xgb.Conn, Key Keycode, GrabWindow Window, Modifiers uin return buf } -// Request AllowEvents -// size: 8 +// AllowEventsCookie is a cookie used only for AllowEvents requests. type AllowEventsCookie struct { *xgb.Cookie } -// Write request to wire for AllowEvents +// AllowEvents sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func AllowEvents(c *xgb.Conn, Mode byte, Time Timestamp) AllowEventsCookie { cookie := c.NewCookie(false, false) c.NewRequest(allowEventsRequest(c, Mode, Time), cookie) return AllowEventsCookie{cookie} } +// AllowEventsChecked sends a checked request. +// If an error occurs, it can be retrieved using AllowEventsCookie.Check() func AllowEventsChecked(c *xgb.Conn, Mode byte, Time Timestamp) AllowEventsCookie { cookie := c.NewCookie(true, false) c.NewRequest(allowEventsRequest(c, Mode, Time), cookie) return AllowEventsCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook AllowEventsCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for AllowEvents +// allowEventsRequest writes a AllowEvents request to a byte slice. func allowEventsRequest(c *xgb.Conn, Mode byte, Time Timestamp) []byte { size := 8 b := 0 @@ -8648,30 +8769,35 @@ func allowEventsRequest(c *xgb.Conn, Mode byte, Time Timestamp) []byte { return buf } -// Request GrabServer -// size: 4 +// GrabServerCookie is a cookie used only for GrabServer requests. type GrabServerCookie struct { *xgb.Cookie } -// Write request to wire for GrabServer +// GrabServer sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GrabServer(c *xgb.Conn) GrabServerCookie { cookie := c.NewCookie(false, false) c.NewRequest(grabServerRequest(c), cookie) return GrabServerCookie{cookie} } +// GrabServerChecked sends a checked request. +// If an error occurs, it can be retrieved using GrabServerCookie.Check() func GrabServerChecked(c *xgb.Conn) GrabServerCookie { cookie := c.NewCookie(true, false) c.NewRequest(grabServerRequest(c), cookie) return GrabServerCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook GrabServerCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for GrabServer +// grabServerRequest writes a GrabServer request to a byte slice. func grabServerRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -8687,30 +8813,35 @@ func grabServerRequest(c *xgb.Conn) []byte { return buf } -// Request UngrabServer -// size: 4 +// UngrabServerCookie is a cookie used only for UngrabServer requests. type UngrabServerCookie struct { *xgb.Cookie } -// Write request to wire for UngrabServer +// UngrabServer sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func UngrabServer(c *xgb.Conn) UngrabServerCookie { cookie := c.NewCookie(false, false) c.NewRequest(ungrabServerRequest(c), cookie) return UngrabServerCookie{cookie} } +// UngrabServerChecked sends a checked request. +// If an error occurs, it can be retrieved using UngrabServerCookie.Check() func UngrabServerChecked(c *xgb.Conn) UngrabServerCookie { cookie := c.NewCookie(true, false) c.NewRequest(ungrabServerRequest(c), cookie) return UngrabServerCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook UngrabServerCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for UngrabServer +// ungrabServerRequest writes a UngrabServer request to a byte slice. func ungrabServerRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -8726,29 +8857,31 @@ func ungrabServerRequest(c *xgb.Conn) []byte { return buf } -// Request QueryPointer -// size: 8 +// QueryPointerCookie is a cookie used only for QueryPointer requests. type QueryPointerCookie struct { *xgb.Cookie } +// QueryPointer sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryPointerCookie.Reply() func QueryPointer(c *xgb.Conn, Window Window) QueryPointerCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryPointerRequest(c, Window), cookie) return QueryPointerCookie{cookie} } +// QueryPointerUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryPointerUnchecked(c *xgb.Conn, Window Window) QueryPointerCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryPointerRequest(c, Window), cookie) return QueryPointerCookie{cookie} } -// Request reply for QueryPointer -// size: 28 +// QueryPointerReply represents the data returned from a QueryPointer request. type QueryPointerReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply SameScreen bool Root Window Child Window @@ -8760,7 +8893,7 @@ type QueryPointerReply struct { // padding: 2 bytes } -// Waits and reads reply data from request QueryPointer +// Reply blocks and returns the reply data for a QueryPointer request. func (cook QueryPointerCookie) Reply() (*QueryPointerReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -8772,7 +8905,7 @@ func (cook QueryPointerCookie) Reply() (*QueryPointerReply, error) { return queryPointerReply(buf), nil } -// Read reply into structure from buffer for QueryPointer +// queryPointerReply reads a byte slice into a QueryPointerReply value. func queryPointerReply(buf []byte) *QueryPointerReply { v := new(QueryPointerReply) b := 1 // skip reply determinant @@ -8817,6 +8950,7 @@ func queryPointerReply(buf []byte) *QueryPointerReply { } // Write request to wire for QueryPointer +// queryPointerRequest writes a QueryPointer request to a byte slice. func queryPointerRequest(c *xgb.Conn, Window Window) []byte { size := 8 b := 0 @@ -8836,36 +8970,38 @@ func queryPointerRequest(c *xgb.Conn, Window Window) []byte { return buf } -// Request GetMotionEvents -// size: 16 +// GetMotionEventsCookie is a cookie used only for GetMotionEvents requests. type GetMotionEventsCookie struct { *xgb.Cookie } +// GetMotionEvents sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetMotionEventsCookie.Reply() func GetMotionEvents(c *xgb.Conn, Window Window, Start Timestamp, Stop Timestamp) GetMotionEventsCookie { cookie := c.NewCookie(true, true) c.NewRequest(getMotionEventsRequest(c, Window, Start, Stop), cookie) return GetMotionEventsCookie{cookie} } +// GetMotionEventsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetMotionEventsUnchecked(c *xgb.Conn, Window Window, Start Timestamp, Stop Timestamp) GetMotionEventsCookie { cookie := c.NewCookie(false, true) c.NewRequest(getMotionEventsRequest(c, Window, Start, Stop), cookie) return GetMotionEventsCookie{cookie} } -// Request reply for GetMotionEvents -// size: (32 + xgb.Pad((int(EventsLen) * 8))) +// GetMotionEventsReply represents the data returned from a GetMotionEvents request. type GetMotionEventsReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes EventsLen uint32 // padding: 20 bytes Events []Timecoord // size: xgb.Pad((int(EventsLen) * 8)) } -// Waits and reads reply data from request GetMotionEvents +// Reply blocks and returns the reply data for a GetMotionEvents request. func (cook GetMotionEventsCookie) Reply() (*GetMotionEventsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -8877,7 +9013,7 @@ func (cook GetMotionEventsCookie) Reply() (*GetMotionEventsReply, error) { return getMotionEventsReply(buf), nil } -// Read reply into structure from buffer for GetMotionEvents +// getMotionEventsReply reads a byte slice into a GetMotionEventsReply value. func getMotionEventsReply(buf []byte) *GetMotionEventsReply { v := new(GetMotionEventsReply) b := 1 // skip reply determinant @@ -8902,6 +9038,7 @@ func getMotionEventsReply(buf []byte) *GetMotionEventsReply { } // Write request to wire for GetMotionEvents +// getMotionEventsRequest writes a GetMotionEvents request to a byte slice. func getMotionEventsRequest(c *xgb.Conn, Window Window, Start Timestamp, Stop Timestamp) []byte { size := 16 b := 0 @@ -8927,36 +9064,38 @@ func getMotionEventsRequest(c *xgb.Conn, Window Window, Start Timestamp, Stop Ti return buf } -// Request TranslateCoordinates -// size: 16 +// TranslateCoordinatesCookie is a cookie used only for TranslateCoordinates requests. type TranslateCoordinatesCookie struct { *xgb.Cookie } +// TranslateCoordinates sends a checked request. +// If an error occurs, it will be returned with the reply by calling TranslateCoordinatesCookie.Reply() func TranslateCoordinates(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16) TranslateCoordinatesCookie { cookie := c.NewCookie(true, true) c.NewRequest(translateCoordinatesRequest(c, SrcWindow, DstWindow, SrcX, SrcY), cookie) return TranslateCoordinatesCookie{cookie} } +// TranslateCoordinatesUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func TranslateCoordinatesUnchecked(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16) TranslateCoordinatesCookie { cookie := c.NewCookie(false, true) c.NewRequest(translateCoordinatesRequest(c, SrcWindow, DstWindow, SrcX, SrcY), cookie) return TranslateCoordinatesCookie{cookie} } -// Request reply for TranslateCoordinates -// size: 16 +// TranslateCoordinatesReply represents the data returned from a TranslateCoordinates request. type TranslateCoordinatesReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply SameScreen bool Child Window DstX int16 DstY int16 } -// Waits and reads reply data from request TranslateCoordinates +// Reply blocks and returns the reply data for a TranslateCoordinates request. func (cook TranslateCoordinatesCookie) Reply() (*TranslateCoordinatesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -8968,7 +9107,7 @@ func (cook TranslateCoordinatesCookie) Reply() (*TranslateCoordinatesReply, erro return translateCoordinatesReply(buf), nil } -// Read reply into structure from buffer for TranslateCoordinates +// translateCoordinatesReply reads a byte slice into a TranslateCoordinatesReply value. func translateCoordinatesReply(buf []byte) *TranslateCoordinatesReply { v := new(TranslateCoordinatesReply) b := 1 // skip reply determinant @@ -8999,6 +9138,7 @@ func translateCoordinatesReply(buf []byte) *TranslateCoordinatesReply { } // Write request to wire for TranslateCoordinates +// translateCoordinatesRequest writes a TranslateCoordinates request to a byte slice. func translateCoordinatesRequest(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16) []byte { size := 16 b := 0 @@ -9027,30 +9167,35 @@ func translateCoordinatesRequest(c *xgb.Conn, SrcWindow Window, DstWindow Window return buf } -// Request WarpPointer -// size: 24 +// WarpPointerCookie is a cookie used only for WarpPointer requests. type WarpPointerCookie struct { *xgb.Cookie } -// Write request to wire for WarpPointer +// WarpPointer sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func WarpPointer(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16) WarpPointerCookie { cookie := c.NewCookie(false, false) c.NewRequest(warpPointerRequest(c, SrcWindow, DstWindow, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY), cookie) return WarpPointerCookie{cookie} } +// WarpPointerChecked sends a checked request. +// If an error occurs, it can be retrieved using WarpPointerCookie.Check() func WarpPointerChecked(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16) WarpPointerCookie { cookie := c.NewCookie(true, false) c.NewRequest(warpPointerRequest(c, SrcWindow, DstWindow, SrcX, SrcY, SrcWidth, SrcHeight, DstX, DstY), cookie) return WarpPointerCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook WarpPointerCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for WarpPointer +// warpPointerRequest writes a WarpPointer request to a byte slice. func warpPointerRequest(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX int16, SrcY int16, SrcWidth uint16, SrcHeight uint16, DstX int16, DstY int16) []byte { size := 24 b := 0 @@ -9091,30 +9236,35 @@ func warpPointerRequest(c *xgb.Conn, SrcWindow Window, DstWindow Window, SrcX in return buf } -// Request SetInputFocus -// size: 12 +// SetInputFocusCookie is a cookie used only for SetInputFocus requests. type SetInputFocusCookie struct { *xgb.Cookie } -// Write request to wire for SetInputFocus +// SetInputFocus sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetInputFocus(c *xgb.Conn, RevertTo byte, Focus Window, Time Timestamp) SetInputFocusCookie { cookie := c.NewCookie(false, false) c.NewRequest(setInputFocusRequest(c, RevertTo, Focus, Time), cookie) return SetInputFocusCookie{cookie} } +// SetInputFocusChecked sends a checked request. +// If an error occurs, it can be retrieved using SetInputFocusCookie.Check() func SetInputFocusChecked(c *xgb.Conn, RevertTo byte, Focus Window, Time Timestamp) SetInputFocusCookie { cookie := c.NewCookie(true, false) c.NewRequest(setInputFocusRequest(c, RevertTo, Focus, Time), cookie) return SetInputFocusCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetInputFocusCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetInputFocus +// setInputFocusRequest writes a SetInputFocus request to a byte slice. func setInputFocusRequest(c *xgb.Conn, RevertTo byte, Focus Window, Time Timestamp) []byte { size := 12 b := 0 @@ -9138,34 +9288,36 @@ func setInputFocusRequest(c *xgb.Conn, RevertTo byte, Focus Window, Time Timesta return buf } -// Request GetInputFocus -// size: 4 +// GetInputFocusCookie is a cookie used only for GetInputFocus requests. type GetInputFocusCookie struct { *xgb.Cookie } +// GetInputFocus sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetInputFocusCookie.Reply() func GetInputFocus(c *xgb.Conn) GetInputFocusCookie { cookie := c.NewCookie(true, true) c.NewRequest(getInputFocusRequest(c), cookie) return GetInputFocusCookie{cookie} } +// GetInputFocusUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetInputFocusUnchecked(c *xgb.Conn) GetInputFocusCookie { cookie := c.NewCookie(false, true) c.NewRequest(getInputFocusRequest(c), cookie) return GetInputFocusCookie{cookie} } -// Request reply for GetInputFocus -// size: 12 +// GetInputFocusReply represents the data returned from a GetInputFocus request. type GetInputFocusReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply RevertTo byte Focus Window } -// Waits and reads reply data from request GetInputFocus +// Reply blocks and returns the reply data for a GetInputFocus request. func (cook GetInputFocusCookie) Reply() (*GetInputFocusReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -9177,7 +9329,7 @@ func (cook GetInputFocusCookie) Reply() (*GetInputFocusReply, error) { return getInputFocusReply(buf), nil } -// Read reply into structure from buffer for GetInputFocus +// getInputFocusReply reads a byte slice into a GetInputFocusReply value. func getInputFocusReply(buf []byte) *GetInputFocusReply { v := new(GetInputFocusReply) b := 1 // skip reply determinant @@ -9198,6 +9350,7 @@ func getInputFocusReply(buf []byte) *GetInputFocusReply { } // Write request to wire for GetInputFocus +// getInputFocusRequest writes a GetInputFocus request to a byte slice. func getInputFocusRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -9213,34 +9366,36 @@ func getInputFocusRequest(c *xgb.Conn) []byte { return buf } -// Request QueryKeymap -// size: 4 +// QueryKeymapCookie is a cookie used only for QueryKeymap requests. type QueryKeymapCookie struct { *xgb.Cookie } +// QueryKeymap sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryKeymapCookie.Reply() func QueryKeymap(c *xgb.Conn) QueryKeymapCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryKeymapRequest(c), cookie) return QueryKeymapCookie{cookie} } +// QueryKeymapUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryKeymapUnchecked(c *xgb.Conn) QueryKeymapCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryKeymapRequest(c), cookie) return QueryKeymapCookie{cookie} } -// Request reply for QueryKeymap -// size: 40 +// QueryKeymapReply represents the data returned from a QueryKeymap request. type QueryKeymapReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Keys []byte // size: 32 } -// Waits and reads reply data from request QueryKeymap +// Reply blocks and returns the reply data for a QueryKeymap request. func (cook QueryKeymapCookie) Reply() (*QueryKeymapReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -9252,7 +9407,7 @@ func (cook QueryKeymapCookie) Reply() (*QueryKeymapReply, error) { return queryKeymapReply(buf), nil } -// Read reply into structure from buffer for QueryKeymap +// queryKeymapReply reads a byte slice into a QueryKeymapReply value. func queryKeymapReply(buf []byte) *QueryKeymapReply { v := new(QueryKeymapReply) b := 1 // skip reply determinant @@ -9273,6 +9428,7 @@ func queryKeymapReply(buf []byte) *QueryKeymapReply { } // Write request to wire for QueryKeymap +// queryKeymapRequest writes a QueryKeymap request to a byte slice. func queryKeymapRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -9288,30 +9444,35 @@ func queryKeymapRequest(c *xgb.Conn) []byte { return buf } -// Request OpenFont -// size: xgb.Pad((12 + xgb.Pad((int(NameLen) * 1)))) +// OpenFontCookie is a cookie used only for OpenFont requests. type OpenFontCookie struct { *xgb.Cookie } -// Write request to wire for OpenFont +// OpenFont sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func OpenFont(c *xgb.Conn, Fid Font, NameLen uint16, Name string) OpenFontCookie { cookie := c.NewCookie(false, false) c.NewRequest(openFontRequest(c, Fid, NameLen, Name), cookie) return OpenFontCookie{cookie} } +// OpenFontChecked sends a checked request. +// If an error occurs, it can be retrieved using OpenFontCookie.Check() func OpenFontChecked(c *xgb.Conn, Fid Font, NameLen uint16, Name string) OpenFontCookie { cookie := c.NewCookie(true, false) c.NewRequest(openFontRequest(c, Fid, NameLen, Name), cookie) return OpenFontCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook OpenFontCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for OpenFont +// openFontRequest writes a OpenFont request to a byte slice. func openFontRequest(c *xgb.Conn, Fid Font, NameLen uint16, Name string) []byte { size := xgb.Pad((12 + xgb.Pad((int(NameLen) * 1)))) b := 0 @@ -9339,30 +9500,35 @@ func openFontRequest(c *xgb.Conn, Fid Font, NameLen uint16, Name string) []byte return buf } -// Request CloseFont -// size: 8 +// CloseFontCookie is a cookie used only for CloseFont requests. type CloseFontCookie struct { *xgb.Cookie } -// Write request to wire for CloseFont +// CloseFont sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CloseFont(c *xgb.Conn, Font Font) CloseFontCookie { cookie := c.NewCookie(false, false) c.NewRequest(closeFontRequest(c, Font), cookie) return CloseFontCookie{cookie} } +// CloseFontChecked sends a checked request. +// If an error occurs, it can be retrieved using CloseFontCookie.Check() func CloseFontChecked(c *xgb.Conn, Font Font) CloseFontCookie { cookie := c.NewCookie(true, false) c.NewRequest(closeFontRequest(c, Font), cookie) return CloseFontCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CloseFontCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CloseFont +// closeFontRequest writes a CloseFont request to a byte slice. func closeFontRequest(c *xgb.Conn, Font Font) []byte { size := 8 b := 0 @@ -9382,29 +9548,31 @@ func closeFontRequest(c *xgb.Conn, Font Font) []byte { return buf } -// Request QueryFont -// size: 8 +// QueryFontCookie is a cookie used only for QueryFont requests. type QueryFontCookie struct { *xgb.Cookie } +// QueryFont sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryFontCookie.Reply() func QueryFont(c *xgb.Conn, Font Fontable) QueryFontCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryFontRequest(c, Font), cookie) return QueryFontCookie{cookie} } +// QueryFontUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryFontUnchecked(c *xgb.Conn, Font Fontable) QueryFontCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryFontRequest(c, Font), cookie) return QueryFontCookie{cookie} } -// Request reply for QueryFont -// size: ((60 + xgb.Pad((int(PropertiesLen) * 8))) + xgb.Pad((int(CharInfosLen) * 12))) +// QueryFontReply represents the data returned from a QueryFont request. type QueryFontReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes MinBounds Charinfo // padding: 4 bytes @@ -9425,7 +9593,7 @@ type QueryFontReply struct { CharInfos []Charinfo // size: xgb.Pad((int(CharInfosLen) * 12)) } -// Waits and reads reply data from request QueryFont +// Reply blocks and returns the reply data for a QueryFont request. func (cook QueryFontCookie) Reply() (*QueryFontReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -9437,7 +9605,7 @@ func (cook QueryFontCookie) Reply() (*QueryFontReply, error) { return queryFontReply(buf), nil } -// Read reply into structure from buffer for QueryFont +// queryFontReply reads a byte slice into a QueryFontReply value. func queryFontReply(buf []byte) *QueryFontReply { v := new(QueryFontReply) b := 1 // skip reply determinant @@ -9507,6 +9675,7 @@ func queryFontReply(buf []byte) *QueryFontReply { } // Write request to wire for QueryFont +// queryFontRequest writes a QueryFont request to a byte slice. func queryFontRequest(c *xgb.Conn, Font Fontable) []byte { size := 8 b := 0 @@ -9526,29 +9695,31 @@ func queryFontRequest(c *xgb.Conn, Font Fontable) []byte { return buf } -// Request QueryTextExtents -// size: xgb.Pad((8 + xgb.Pad((len(String) * 2)))) +// QueryTextExtentsCookie is a cookie used only for QueryTextExtents requests. type QueryTextExtentsCookie struct { *xgb.Cookie } +// QueryTextExtents sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryTextExtentsCookie.Reply() func QueryTextExtents(c *xgb.Conn, Font Fontable, String []Char2b, StringLen uint16) QueryTextExtentsCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryTextExtentsRequest(c, Font, String, StringLen), cookie) return QueryTextExtentsCookie{cookie} } +// QueryTextExtentsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryTextExtentsUnchecked(c *xgb.Conn, Font Fontable, String []Char2b, StringLen uint16) QueryTextExtentsCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryTextExtentsRequest(c, Font, String, StringLen), cookie) return QueryTextExtentsCookie{cookie} } -// Request reply for QueryTextExtents -// size: 28 +// QueryTextExtentsReply represents the data returned from a QueryTextExtents request. type QueryTextExtentsReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply DrawDirection byte FontAscent int16 FontDescent int16 @@ -9559,7 +9730,7 @@ type QueryTextExtentsReply struct { OverallRight int32 } -// Waits and reads reply data from request QueryTextExtents +// Reply blocks and returns the reply data for a QueryTextExtents request. func (cook QueryTextExtentsCookie) Reply() (*QueryTextExtentsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -9571,7 +9742,7 @@ func (cook QueryTextExtentsCookie) Reply() (*QueryTextExtentsReply, error) { return queryTextExtentsReply(buf), nil } -// Read reply into structure from buffer for QueryTextExtents +// queryTextExtentsReply reads a byte slice into a QueryTextExtentsReply value. func queryTextExtentsReply(buf []byte) *QueryTextExtentsReply { v := new(QueryTextExtentsReply) b := 1 // skip reply determinant @@ -9610,6 +9781,7 @@ func queryTextExtentsReply(buf []byte) *QueryTextExtentsReply { } // Write request to wire for QueryTextExtents +// queryTextExtentsRequest writes a QueryTextExtents request to a byte slice. func queryTextExtentsRequest(c *xgb.Conn, Font Fontable, String []Char2b, StringLen uint16) []byte { size := xgb.Pad((8 + xgb.Pad((len(String) * 2)))) b := 0 @@ -9634,36 +9806,38 @@ func queryTextExtentsRequest(c *xgb.Conn, Font Fontable, String []Char2b, String return buf } -// Request ListFonts -// size: xgb.Pad((8 + xgb.Pad((int(PatternLen) * 1)))) +// ListFontsCookie is a cookie used only for ListFonts requests. type ListFontsCookie struct { *xgb.Cookie } +// ListFonts sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListFontsCookie.Reply() func ListFonts(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) ListFontsCookie { cookie := c.NewCookie(true, true) c.NewRequest(listFontsRequest(c, MaxNames, PatternLen, Pattern), cookie) return ListFontsCookie{cookie} } +// ListFontsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ListFontsUnchecked(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) ListFontsCookie { cookie := c.NewCookie(false, true) c.NewRequest(listFontsRequest(c, MaxNames, PatternLen, Pattern), cookie) return ListFontsCookie{cookie} } -// Request reply for ListFonts -// size: (32 + StrListSize(Names)) +// ListFontsReply represents the data returned from a ListFonts request. type ListFontsReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes NamesLen uint16 // padding: 22 bytes Names []Str // size: StrListSize(Names) } -// Waits and reads reply data from request ListFonts +// Reply blocks and returns the reply data for a ListFonts request. func (cook ListFontsCookie) Reply() (*ListFontsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -9675,7 +9849,7 @@ func (cook ListFontsCookie) Reply() (*ListFontsReply, error) { return listFontsReply(buf), nil } -// Read reply into structure from buffer for ListFonts +// listFontsReply reads a byte slice into a ListFontsReply value. func listFontsReply(buf []byte) *ListFontsReply { v := new(ListFontsReply) b := 1 // skip reply determinant @@ -9700,6 +9874,7 @@ func listFontsReply(buf []byte) *ListFontsReply { } // Write request to wire for ListFonts +// listFontsRequest writes a ListFonts request to a byte slice. func listFontsRequest(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) []byte { size := xgb.Pad((8 + xgb.Pad((int(PatternLen) * 1)))) b := 0 @@ -9725,29 +9900,31 @@ func listFontsRequest(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern s return buf } -// Request ListFontsWithInfo -// size: xgb.Pad((8 + xgb.Pad((int(PatternLen) * 1)))) +// ListFontsWithInfoCookie is a cookie used only for ListFontsWithInfo requests. type ListFontsWithInfoCookie struct { *xgb.Cookie } +// ListFontsWithInfo sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListFontsWithInfoCookie.Reply() func ListFontsWithInfo(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) ListFontsWithInfoCookie { cookie := c.NewCookie(true, true) c.NewRequest(listFontsWithInfoRequest(c, MaxNames, PatternLen, Pattern), cookie) return ListFontsWithInfoCookie{cookie} } +// ListFontsWithInfoUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ListFontsWithInfoUnchecked(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) ListFontsWithInfoCookie { cookie := c.NewCookie(false, true) c.NewRequest(listFontsWithInfoRequest(c, MaxNames, PatternLen, Pattern), cookie) return ListFontsWithInfoCookie{cookie} } -// Request reply for ListFontsWithInfo -// size: ((60 + xgb.Pad((int(PropertiesLen) * 8))) + xgb.Pad((int(NameLen) * 1))) +// ListFontsWithInfoReply represents the data returned from a ListFontsWithInfo request. type ListFontsWithInfoReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply NameLen byte MinBounds Charinfo // padding: 4 bytes @@ -9768,7 +9945,7 @@ type ListFontsWithInfoReply struct { Name string // size: xgb.Pad((int(NameLen) * 1)) } -// Waits and reads reply data from request ListFontsWithInfo +// Reply blocks and returns the reply data for a ListFontsWithInfo request. func (cook ListFontsWithInfoCookie) Reply() (*ListFontsWithInfoReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -9780,7 +9957,7 @@ func (cook ListFontsWithInfoCookie) Reply() (*ListFontsWithInfoReply, error) { return listFontsWithInfoReply(buf), nil } -// Read reply into structure from buffer for ListFontsWithInfo +// listFontsWithInfoReply reads a byte slice into a ListFontsWithInfoReply value. func listFontsWithInfoReply(buf []byte) *ListFontsWithInfoReply { v := new(ListFontsWithInfoReply) b := 1 // skip reply determinant @@ -9855,6 +10032,7 @@ func listFontsWithInfoReply(buf []byte) *ListFontsWithInfoReply { } // Write request to wire for ListFontsWithInfo +// listFontsWithInfoRequest writes a ListFontsWithInfo request to a byte slice. func listFontsWithInfoRequest(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern string) []byte { size := xgb.Pad((8 + xgb.Pad((int(PatternLen) * 1)))) b := 0 @@ -9880,30 +10058,35 @@ func listFontsWithInfoRequest(c *xgb.Conn, MaxNames uint16, PatternLen uint16, P return buf } -// Request SetFontPath -// size: xgb.Pad((8 + StrListSize(Font))) +// SetFontPathCookie is a cookie used only for SetFontPath requests. type SetFontPathCookie struct { *xgb.Cookie } -// Write request to wire for SetFontPath +// SetFontPath sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetFontPath(c *xgb.Conn, FontQty uint16, Font []Str) SetFontPathCookie { cookie := c.NewCookie(false, false) c.NewRequest(setFontPathRequest(c, FontQty, Font), cookie) return SetFontPathCookie{cookie} } +// SetFontPathChecked sends a checked request. +// If an error occurs, it can be retrieved using SetFontPathCookie.Check() func SetFontPathChecked(c *xgb.Conn, FontQty uint16, Font []Str) SetFontPathCookie { cookie := c.NewCookie(true, false) c.NewRequest(setFontPathRequest(c, FontQty, Font), cookie) return SetFontPathCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetFontPathCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetFontPath +// setFontPathRequest writes a SetFontPath request to a byte slice. func setFontPathRequest(c *xgb.Conn, FontQty uint16, Font []Str) []byte { size := xgb.Pad((8 + StrListSize(Font))) b := 0 @@ -9927,36 +10110,38 @@ func setFontPathRequest(c *xgb.Conn, FontQty uint16, Font []Str) []byte { return buf } -// Request GetFontPath -// size: 4 +// GetFontPathCookie is a cookie used only for GetFontPath requests. type GetFontPathCookie struct { *xgb.Cookie } +// GetFontPath sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetFontPathCookie.Reply() func GetFontPath(c *xgb.Conn) GetFontPathCookie { cookie := c.NewCookie(true, true) c.NewRequest(getFontPathRequest(c), cookie) return GetFontPathCookie{cookie} } +// GetFontPathUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetFontPathUnchecked(c *xgb.Conn) GetFontPathCookie { cookie := c.NewCookie(false, true) c.NewRequest(getFontPathRequest(c), cookie) return GetFontPathCookie{cookie} } -// Request reply for GetFontPath -// size: (32 + StrListSize(Path)) +// GetFontPathReply represents the data returned from a GetFontPath request. type GetFontPathReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes PathLen uint16 // padding: 22 bytes Path []Str // size: StrListSize(Path) } -// Waits and reads reply data from request GetFontPath +// Reply blocks and returns the reply data for a GetFontPath request. func (cook GetFontPathCookie) Reply() (*GetFontPathReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -9968,7 +10153,7 @@ func (cook GetFontPathCookie) Reply() (*GetFontPathReply, error) { return getFontPathReply(buf), nil } -// Read reply into structure from buffer for GetFontPath +// getFontPathReply reads a byte slice into a GetFontPathReply value. func getFontPathReply(buf []byte) *GetFontPathReply { v := new(GetFontPathReply) b := 1 // skip reply determinant @@ -9993,6 +10178,7 @@ func getFontPathReply(buf []byte) *GetFontPathReply { } // Write request to wire for GetFontPath +// getFontPathRequest writes a GetFontPath request to a byte slice. func getFontPathRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -10008,30 +10194,35 @@ func getFontPathRequest(c *xgb.Conn) []byte { return buf } -// Request CreatePixmap -// size: 16 +// CreatePixmapCookie is a cookie used only for CreatePixmap requests. type CreatePixmapCookie struct { *xgb.Cookie } -// Write request to wire for CreatePixmap +// CreatePixmap sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreatePixmap(c *xgb.Conn, Depth byte, Pid Pixmap, Drawable Drawable, Width uint16, Height uint16) CreatePixmapCookie { cookie := c.NewCookie(false, false) c.NewRequest(createPixmapRequest(c, Depth, Pid, Drawable, Width, Height), cookie) return CreatePixmapCookie{cookie} } +// CreatePixmapChecked sends a checked request. +// If an error occurs, it can be retrieved using CreatePixmapCookie.Check() func CreatePixmapChecked(c *xgb.Conn, Depth byte, Pid Pixmap, Drawable Drawable, Width uint16, Height uint16) CreatePixmapCookie { cookie := c.NewCookie(true, false) c.NewRequest(createPixmapRequest(c, Depth, Pid, Drawable, Width, Height), cookie) return CreatePixmapCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CreatePixmapCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreatePixmap +// createPixmapRequest writes a CreatePixmap request to a byte slice. func createPixmapRequest(c *xgb.Conn, Depth byte, Pid Pixmap, Drawable Drawable, Width uint16, Height uint16) []byte { size := 16 b := 0 @@ -10061,30 +10252,35 @@ func createPixmapRequest(c *xgb.Conn, Depth byte, Pid Pixmap, Drawable Drawable, return buf } -// Request FreePixmap -// size: 8 +// FreePixmapCookie is a cookie used only for FreePixmap requests. type FreePixmapCookie struct { *xgb.Cookie } -// Write request to wire for FreePixmap +// FreePixmap sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func FreePixmap(c *xgb.Conn, Pixmap Pixmap) FreePixmapCookie { cookie := c.NewCookie(false, false) c.NewRequest(freePixmapRequest(c, Pixmap), cookie) return FreePixmapCookie{cookie} } +// FreePixmapChecked sends a checked request. +// If an error occurs, it can be retrieved using FreePixmapCookie.Check() func FreePixmapChecked(c *xgb.Conn, Pixmap Pixmap) FreePixmapCookie { cookie := c.NewCookie(true, false) c.NewRequest(freePixmapRequest(c, Pixmap), cookie) return FreePixmapCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook FreePixmapCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for FreePixmap +// freePixmapRequest writes a FreePixmap request to a byte slice. func freePixmapRequest(c *xgb.Conn, Pixmap Pixmap) []byte { size := 8 b := 0 @@ -10104,30 +10300,35 @@ func freePixmapRequest(c *xgb.Conn, Pixmap Pixmap) []byte { return buf } -// Request CreateGC -// size: xgb.Pad((12 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +// CreateGCCookie is a cookie used only for CreateGC requests. type CreateGCCookie struct { *xgb.Cookie } -// Write request to wire for CreateGC +// CreateGC sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreateGC(c *xgb.Conn, Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) CreateGCCookie { cookie := c.NewCookie(false, false) c.NewRequest(createGCRequest(c, Cid, Drawable, ValueMask, ValueList), cookie) return CreateGCCookie{cookie} } +// CreateGCChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateGCCookie.Check() func CreateGCChecked(c *xgb.Conn, Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) CreateGCCookie { cookie := c.NewCookie(true, false) c.NewRequest(createGCRequest(c, Cid, Drawable, ValueMask, ValueList), cookie) return CreateGCCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CreateGCCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreateGC +// createGCRequest writes a CreateGC request to a byte slice. func createGCRequest(c *xgb.Conn, Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) []byte { size := xgb.Pad((12 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) b := 0 @@ -10158,30 +10359,35 @@ func createGCRequest(c *xgb.Conn, Cid Gcontext, Drawable Drawable, ValueMask uin return buf } -// Request ChangeGC -// size: xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +// ChangeGCCookie is a cookie used only for ChangeGC requests. type ChangeGCCookie struct { *xgb.Cookie } -// Write request to wire for ChangeGC +// ChangeGC sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ChangeGC(c *xgb.Conn, Gc Gcontext, ValueMask uint32, ValueList []uint32) ChangeGCCookie { cookie := c.NewCookie(false, false) c.NewRequest(changeGCRequest(c, Gc, ValueMask, ValueList), cookie) return ChangeGCCookie{cookie} } +// ChangeGCChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeGCCookie.Check() func ChangeGCChecked(c *xgb.Conn, Gc Gcontext, ValueMask uint32, ValueList []uint32) ChangeGCCookie { cookie := c.NewCookie(true, false) c.NewRequest(changeGCRequest(c, Gc, ValueMask, ValueList), cookie) return ChangeGCCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook ChangeGCCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ChangeGC +// changeGCRequest writes a ChangeGC request to a byte slice. func changeGCRequest(c *xgb.Conn, Gc Gcontext, ValueMask uint32, ValueList []uint32) []byte { size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) b := 0 @@ -10209,30 +10415,35 @@ func changeGCRequest(c *xgb.Conn, Gc Gcontext, ValueMask uint32, ValueList []uin return buf } -// Request CopyGC -// size: 16 +// CopyGCCookie is a cookie used only for CopyGC requests. type CopyGCCookie struct { *xgb.Cookie } -// Write request to wire for CopyGC +// CopyGC sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CopyGC(c *xgb.Conn, SrcGc Gcontext, DstGc Gcontext, ValueMask uint32) CopyGCCookie { cookie := c.NewCookie(false, false) c.NewRequest(copyGCRequest(c, SrcGc, DstGc, ValueMask), cookie) return CopyGCCookie{cookie} } +// CopyGCChecked sends a checked request. +// If an error occurs, it can be retrieved using CopyGCCookie.Check() func CopyGCChecked(c *xgb.Conn, SrcGc Gcontext, DstGc Gcontext, ValueMask uint32) CopyGCCookie { cookie := c.NewCookie(true, false) c.NewRequest(copyGCRequest(c, SrcGc, DstGc, ValueMask), cookie) return CopyGCCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CopyGCCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CopyGC +// copyGCRequest writes a CopyGC request to a byte slice. func copyGCRequest(c *xgb.Conn, SrcGc Gcontext, DstGc Gcontext, ValueMask uint32) []byte { size := 16 b := 0 @@ -10258,30 +10469,35 @@ func copyGCRequest(c *xgb.Conn, SrcGc Gcontext, DstGc Gcontext, ValueMask uint32 return buf } -// Request SetDashes -// size: xgb.Pad((12 + xgb.Pad((int(DashesLen) * 1)))) +// SetDashesCookie is a cookie used only for SetDashes requests. type SetDashesCookie struct { *xgb.Cookie } -// Write request to wire for SetDashes +// SetDashes sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetDashes(c *xgb.Conn, Gc Gcontext, DashOffset uint16, DashesLen uint16, Dashes []byte) SetDashesCookie { cookie := c.NewCookie(false, false) c.NewRequest(setDashesRequest(c, Gc, DashOffset, DashesLen, Dashes), cookie) return SetDashesCookie{cookie} } +// SetDashesChecked sends a checked request. +// If an error occurs, it can be retrieved using SetDashesCookie.Check() func SetDashesChecked(c *xgb.Conn, Gc Gcontext, DashOffset uint16, DashesLen uint16, Dashes []byte) SetDashesCookie { cookie := c.NewCookie(true, false) c.NewRequest(setDashesRequest(c, Gc, DashOffset, DashesLen, Dashes), cookie) return SetDashesCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetDashesCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetDashes +// setDashesRequest writes a SetDashes request to a byte slice. func setDashesRequest(c *xgb.Conn, Gc Gcontext, DashOffset uint16, DashesLen uint16, Dashes []byte) []byte { size := xgb.Pad((12 + xgb.Pad((int(DashesLen) * 1)))) b := 0 @@ -10310,30 +10526,35 @@ func setDashesRequest(c *xgb.Conn, Gc Gcontext, DashOffset uint16, DashesLen uin return buf } -// Request SetClipRectangles -// size: xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) +// SetClipRectanglesCookie is a cookie used only for SetClipRectangles requests. type SetClipRectanglesCookie struct { *xgb.Cookie } -// Write request to wire for SetClipRectangles +// SetClipRectangles sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetClipRectangles(c *xgb.Conn, Ordering byte, Gc Gcontext, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) SetClipRectanglesCookie { cookie := c.NewCookie(false, false) c.NewRequest(setClipRectanglesRequest(c, Ordering, Gc, ClipXOrigin, ClipYOrigin, Rectangles), cookie) return SetClipRectanglesCookie{cookie} } +// SetClipRectanglesChecked sends a checked request. +// If an error occurs, it can be retrieved using SetClipRectanglesCookie.Check() func SetClipRectanglesChecked(c *xgb.Conn, Ordering byte, Gc Gcontext, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) SetClipRectanglesCookie { cookie := c.NewCookie(true, false) c.NewRequest(setClipRectanglesRequest(c, Ordering, Gc, ClipXOrigin, ClipYOrigin, Rectangles), cookie) return SetClipRectanglesCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetClipRectanglesCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetClipRectangles +// setClipRectanglesRequest writes a SetClipRectangles request to a byte slice. func setClipRectanglesRequest(c *xgb.Conn, Ordering byte, Gc Gcontext, ClipXOrigin int16, ClipYOrigin int16, Rectangles []Rectangle) []byte { size := xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) b := 0 @@ -10362,30 +10583,35 @@ func setClipRectanglesRequest(c *xgb.Conn, Ordering byte, Gc Gcontext, ClipXOrig return buf } -// Request FreeGC -// size: 8 +// FreeGCCookie is a cookie used only for FreeGC requests. type FreeGCCookie struct { *xgb.Cookie } -// Write request to wire for FreeGC +// FreeGC sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func FreeGC(c *xgb.Conn, Gc Gcontext) FreeGCCookie { cookie := c.NewCookie(false, false) c.NewRequest(freeGCRequest(c, Gc), cookie) return FreeGCCookie{cookie} } +// FreeGCChecked sends a checked request. +// If an error occurs, it can be retrieved using FreeGCCookie.Check() func FreeGCChecked(c *xgb.Conn, Gc Gcontext) FreeGCCookie { cookie := c.NewCookie(true, false) c.NewRequest(freeGCRequest(c, Gc), cookie) return FreeGCCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook FreeGCCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for FreeGC +// freeGCRequest writes a FreeGC request to a byte slice. func freeGCRequest(c *xgb.Conn, Gc Gcontext) []byte { size := 8 b := 0 @@ -10405,30 +10631,35 @@ func freeGCRequest(c *xgb.Conn, Gc Gcontext) []byte { return buf } -// Request ClearArea -// size: 16 +// ClearAreaCookie is a cookie used only for ClearArea requests. type ClearAreaCookie struct { *xgb.Cookie } -// Write request to wire for ClearArea +// ClearArea sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ClearArea(c *xgb.Conn, Exposures bool, Window Window, X int16, Y int16, Width uint16, Height uint16) ClearAreaCookie { cookie := c.NewCookie(false, false) c.NewRequest(clearAreaRequest(c, Exposures, Window, X, Y, Width, Height), cookie) return ClearAreaCookie{cookie} } +// ClearAreaChecked sends a checked request. +// If an error occurs, it can be retrieved using ClearAreaCookie.Check() func ClearAreaChecked(c *xgb.Conn, Exposures bool, Window Window, X int16, Y int16, Width uint16, Height uint16) ClearAreaCookie { cookie := c.NewCookie(true, false) c.NewRequest(clearAreaRequest(c, Exposures, Window, X, Y, Width, Height), cookie) return ClearAreaCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook ClearAreaCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ClearArea +// clearAreaRequest writes a ClearArea request to a byte slice. func clearAreaRequest(c *xgb.Conn, Exposures bool, Window Window, X int16, Y int16, Width uint16, Height uint16) []byte { size := 16 b := 0 @@ -10465,30 +10696,35 @@ func clearAreaRequest(c *xgb.Conn, Exposures bool, Window Window, X int16, Y int return buf } -// Request CopyArea -// size: 28 +// CopyAreaCookie is a cookie used only for CopyArea requests. type CopyAreaCookie struct { *xgb.Cookie } -// Write request to wire for CopyArea +// CopyArea sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CopyArea(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16) CopyAreaCookie { cookie := c.NewCookie(false, false) c.NewRequest(copyAreaRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height), cookie) return CopyAreaCookie{cookie} } +// CopyAreaChecked sends a checked request. +// If an error occurs, it can be retrieved using CopyAreaCookie.Check() func CopyAreaChecked(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16) CopyAreaCookie { cookie := c.NewCookie(true, false) c.NewRequest(copyAreaRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height), cookie) return CopyAreaCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CopyAreaCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CopyArea +// copyAreaRequest writes a CopyArea request to a byte slice. func copyAreaRequest(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16) []byte { size := 28 b := 0 @@ -10532,30 +10768,35 @@ func copyAreaRequest(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc return buf } -// Request CopyPlane -// size: 32 +// CopyPlaneCookie is a cookie used only for CopyPlane requests. type CopyPlaneCookie struct { *xgb.Cookie } -// Write request to wire for CopyPlane +// CopyPlane sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CopyPlane(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16, BitPlane uint32) CopyPlaneCookie { cookie := c.NewCookie(false, false) c.NewRequest(copyPlaneRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height, BitPlane), cookie) return CopyPlaneCookie{cookie} } +// CopyPlaneChecked sends a checked request. +// If an error occurs, it can be retrieved using CopyPlaneCookie.Check() func CopyPlaneChecked(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16, BitPlane uint32) CopyPlaneCookie { cookie := c.NewCookie(true, false) c.NewRequest(copyPlaneRequest(c, SrcDrawable, DstDrawable, Gc, SrcX, SrcY, DstX, DstY, Width, Height, BitPlane), cookie) return CopyPlaneCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CopyPlaneCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CopyPlane +// copyPlaneRequest writes a CopyPlane request to a byte slice. func copyPlaneRequest(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, Gc Gcontext, SrcX int16, SrcY int16, DstX int16, DstY int16, Width uint16, Height uint16, BitPlane uint32) []byte { size := 32 b := 0 @@ -10602,30 +10843,35 @@ func copyPlaneRequest(c *xgb.Conn, SrcDrawable Drawable, DstDrawable Drawable, G return buf } -// Request PolyPoint -// size: xgb.Pad((12 + xgb.Pad((len(Points) * 4)))) +// PolyPointCookie is a cookie used only for PolyPoint requests. type PolyPointCookie struct { *xgb.Cookie } -// Write request to wire for PolyPoint +// PolyPoint sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PolyPoint(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyPointCookie { cookie := c.NewCookie(false, false) c.NewRequest(polyPointRequest(c, CoordinateMode, Drawable, Gc, Points), cookie) return PolyPointCookie{cookie} } +// PolyPointChecked sends a checked request. +// If an error occurs, it can be retrieved using PolyPointCookie.Check() func PolyPointChecked(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyPointCookie { cookie := c.NewCookie(true, false) c.NewRequest(polyPointRequest(c, CoordinateMode, Drawable, Gc, Points), cookie) return PolyPointCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook PolyPointCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for PolyPoint +// polyPointRequest writes a PolyPoint request to a byte slice. func polyPointRequest(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) []byte { size := xgb.Pad((12 + xgb.Pad((len(Points) * 4)))) b := 0 @@ -10651,30 +10897,35 @@ func polyPointRequest(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gc return buf } -// Request PolyLine -// size: xgb.Pad((12 + xgb.Pad((len(Points) * 4)))) +// PolyLineCookie is a cookie used only for PolyLine requests. type PolyLineCookie struct { *xgb.Cookie } -// Write request to wire for PolyLine +// PolyLine sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PolyLine(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyLineCookie { cookie := c.NewCookie(false, false) c.NewRequest(polyLineRequest(c, CoordinateMode, Drawable, Gc, Points), cookie) return PolyLineCookie{cookie} } +// PolyLineChecked sends a checked request. +// If an error occurs, it can be retrieved using PolyLineCookie.Check() func PolyLineChecked(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) PolyLineCookie { cookie := c.NewCookie(true, false) c.NewRequest(polyLineRequest(c, CoordinateMode, Drawable, Gc, Points), cookie) return PolyLineCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook PolyLineCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for PolyLine +// polyLineRequest writes a PolyLine request to a byte slice. func polyLineRequest(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gcontext, Points []Point) []byte { size := xgb.Pad((12 + xgb.Pad((len(Points) * 4)))) b := 0 @@ -10700,30 +10951,35 @@ func polyLineRequest(c *xgb.Conn, CoordinateMode byte, Drawable Drawable, Gc Gco return buf } -// Request PolySegment -// size: xgb.Pad((12 + xgb.Pad((len(Segments) * 8)))) +// PolySegmentCookie is a cookie used only for PolySegment requests. type PolySegmentCookie struct { *xgb.Cookie } -// Write request to wire for PolySegment +// PolySegment sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PolySegment(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Segments []Segment) PolySegmentCookie { cookie := c.NewCookie(false, false) c.NewRequest(polySegmentRequest(c, Drawable, Gc, Segments), cookie) return PolySegmentCookie{cookie} } +// PolySegmentChecked sends a checked request. +// If an error occurs, it can be retrieved using PolySegmentCookie.Check() func PolySegmentChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Segments []Segment) PolySegmentCookie { cookie := c.NewCookie(true, false) c.NewRequest(polySegmentRequest(c, Drawable, Gc, Segments), cookie) return PolySegmentCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook PolySegmentCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for PolySegment +// polySegmentRequest writes a PolySegment request to a byte slice. func polySegmentRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Segments []Segment) []byte { size := xgb.Pad((12 + xgb.Pad((len(Segments) * 8)))) b := 0 @@ -10748,30 +11004,35 @@ func polySegmentRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Segments [] return buf } -// Request PolyRectangle -// size: xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) +// PolyRectangleCookie is a cookie used only for PolyRectangle requests. type PolyRectangleCookie struct { *xgb.Cookie } -// Write request to wire for PolyRectangle +// PolyRectangle sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PolyRectangle(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyRectangleCookie { cookie := c.NewCookie(false, false) c.NewRequest(polyRectangleRequest(c, Drawable, Gc, Rectangles), cookie) return PolyRectangleCookie{cookie} } +// PolyRectangleChecked sends a checked request. +// If an error occurs, it can be retrieved using PolyRectangleCookie.Check() func PolyRectangleChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyRectangleCookie { cookie := c.NewCookie(true, false) c.NewRequest(polyRectangleRequest(c, Drawable, Gc, Rectangles), cookie) return PolyRectangleCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook PolyRectangleCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for PolyRectangle +// polyRectangleRequest writes a PolyRectangle request to a byte slice. func polyRectangleRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) []byte { size := xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) b := 0 @@ -10796,30 +11057,35 @@ func polyRectangleRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangle return buf } -// Request PolyArc -// size: xgb.Pad((12 + xgb.Pad((len(Arcs) * 12)))) +// PolyArcCookie is a cookie used only for PolyArc requests. type PolyArcCookie struct { *xgb.Cookie } -// Write request to wire for PolyArc +// PolyArc sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PolyArc(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyArcCookie { cookie := c.NewCookie(false, false) c.NewRequest(polyArcRequest(c, Drawable, Gc, Arcs), cookie) return PolyArcCookie{cookie} } +// PolyArcChecked sends a checked request. +// If an error occurs, it can be retrieved using PolyArcCookie.Check() func PolyArcChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyArcCookie { cookie := c.NewCookie(true, false) c.NewRequest(polyArcRequest(c, Drawable, Gc, Arcs), cookie) return PolyArcCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook PolyArcCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for PolyArc +// polyArcRequest writes a PolyArc request to a byte slice. func polyArcRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) []byte { size := xgb.Pad((12 + xgb.Pad((len(Arcs) * 12)))) b := 0 @@ -10844,30 +11110,35 @@ func polyArcRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) []b return buf } -// Request FillPoly -// size: xgb.Pad((16 + xgb.Pad((len(Points) * 4)))) +// FillPolyCookie is a cookie used only for FillPoly requests. type FillPolyCookie struct { *xgb.Cookie } -// Write request to wire for FillPoly +// FillPoly sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func FillPoly(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Shape byte, CoordinateMode byte, Points []Point) FillPolyCookie { cookie := c.NewCookie(false, false) c.NewRequest(fillPolyRequest(c, Drawable, Gc, Shape, CoordinateMode, Points), cookie) return FillPolyCookie{cookie} } +// FillPolyChecked sends a checked request. +// If an error occurs, it can be retrieved using FillPolyCookie.Check() func FillPolyChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Shape byte, CoordinateMode byte, Points []Point) FillPolyCookie { cookie := c.NewCookie(true, false) c.NewRequest(fillPolyRequest(c, Drawable, Gc, Shape, CoordinateMode, Points), cookie) return FillPolyCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook FillPolyCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for FillPoly +// fillPolyRequest writes a FillPoly request to a byte slice. func fillPolyRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Shape byte, CoordinateMode byte, Points []Point) []byte { size := xgb.Pad((16 + xgb.Pad((len(Points) * 4)))) b := 0 @@ -10900,30 +11171,35 @@ func fillPolyRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Shape byte, Co return buf } -// Request PolyFillRectangle -// size: xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) +// PolyFillRectangleCookie is a cookie used only for PolyFillRectangle requests. type PolyFillRectangleCookie struct { *xgb.Cookie } -// Write request to wire for PolyFillRectangle +// PolyFillRectangle sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PolyFillRectangle(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyFillRectangleCookie { cookie := c.NewCookie(false, false) c.NewRequest(polyFillRectangleRequest(c, Drawable, Gc, Rectangles), cookie) return PolyFillRectangleCookie{cookie} } +// PolyFillRectangleChecked sends a checked request. +// If an error occurs, it can be retrieved using PolyFillRectangleCookie.Check() func PolyFillRectangleChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) PolyFillRectangleCookie { cookie := c.NewCookie(true, false) c.NewRequest(polyFillRectangleRequest(c, Drawable, Gc, Rectangles), cookie) return PolyFillRectangleCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook PolyFillRectangleCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for PolyFillRectangle +// polyFillRectangleRequest writes a PolyFillRectangle request to a byte slice. func polyFillRectangleRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Rectangles []Rectangle) []byte { size := xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8)))) b := 0 @@ -10948,30 +11224,35 @@ func polyFillRectangleRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Recta return buf } -// Request PolyFillArc -// size: xgb.Pad((12 + xgb.Pad((len(Arcs) * 12)))) +// PolyFillArcCookie is a cookie used only for PolyFillArc requests. type PolyFillArcCookie struct { *xgb.Cookie } -// Write request to wire for PolyFillArc +// PolyFillArc sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PolyFillArc(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyFillArcCookie { cookie := c.NewCookie(false, false) c.NewRequest(polyFillArcRequest(c, Drawable, Gc, Arcs), cookie) return PolyFillArcCookie{cookie} } +// PolyFillArcChecked sends a checked request. +// If an error occurs, it can be retrieved using PolyFillArcCookie.Check() func PolyFillArcChecked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) PolyFillArcCookie { cookie := c.NewCookie(true, false) c.NewRequest(polyFillArcRequest(c, Drawable, Gc, Arcs), cookie) return PolyFillArcCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook PolyFillArcCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for PolyFillArc +// polyFillArcRequest writes a PolyFillArc request to a byte slice. func polyFillArcRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) []byte { size := xgb.Pad((12 + xgb.Pad((len(Arcs) * 12)))) b := 0 @@ -10996,30 +11277,35 @@ func polyFillArcRequest(c *xgb.Conn, Drawable Drawable, Gc Gcontext, Arcs []Arc) return buf } -// Request PutImage -// size: xgb.Pad((24 + xgb.Pad((len(Data) * 1)))) +// PutImageCookie is a cookie used only for PutImage requests. type PutImageCookie struct { *xgb.Cookie } -// Write request to wire for PutImage +// PutImage sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PutImage(c *xgb.Conn, Format byte, Drawable Drawable, Gc Gcontext, Width uint16, Height uint16, DstX int16, DstY int16, LeftPad byte, Depth byte, Data []byte) PutImageCookie { cookie := c.NewCookie(false, false) c.NewRequest(putImageRequest(c, Format, Drawable, Gc, Width, Height, DstX, DstY, LeftPad, Depth, Data), cookie) return PutImageCookie{cookie} } +// PutImageChecked sends a checked request. +// If an error occurs, it can be retrieved using PutImageCookie.Check() func PutImageChecked(c *xgb.Conn, Format byte, Drawable Drawable, Gc Gcontext, Width uint16, Height uint16, DstX int16, DstY int16, LeftPad byte, Depth byte, Data []byte) PutImageCookie { cookie := c.NewCookie(true, false) c.NewRequest(putImageRequest(c, Format, Drawable, Gc, Width, Height, DstX, DstY, LeftPad, Depth, Data), cookie) return PutImageCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook PutImageCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for PutImage +// putImageRequest writes a PutImage request to a byte slice. func putImageRequest(c *xgb.Conn, Format byte, Drawable Drawable, Gc Gcontext, Width uint16, Height uint16, DstX int16, DstY int16, LeftPad byte, Depth byte, Data []byte) []byte { size := xgb.Pad((24 + xgb.Pad((len(Data) * 1)))) b := 0 @@ -11066,36 +11352,38 @@ func putImageRequest(c *xgb.Conn, Format byte, Drawable Drawable, Gc Gcontext, W return buf } -// Request GetImage -// size: 20 +// GetImageCookie is a cookie used only for GetImage requests. type GetImageCookie struct { *xgb.Cookie } +// GetImage sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetImageCookie.Reply() func GetImage(c *xgb.Conn, Format byte, Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32) GetImageCookie { cookie := c.NewCookie(true, true) c.NewRequest(getImageRequest(c, Format, Drawable, X, Y, Width, Height, PlaneMask), cookie) return GetImageCookie{cookie} } +// GetImageUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetImageUnchecked(c *xgb.Conn, Format byte, Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32) GetImageCookie { cookie := c.NewCookie(false, true) c.NewRequest(getImageRequest(c, Format, Drawable, X, Y, Width, Height, PlaneMask), cookie) return GetImageCookie{cookie} } -// Request reply for GetImage -// size: (32 + xgb.Pad(((int(Length) * 4) * 1))) +// GetImageReply represents the data returned from a GetImage request. type GetImageReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply Depth byte Visual Visualid // padding: 20 bytes Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) } -// Waits and reads reply data from request GetImage +// Reply blocks and returns the reply data for a GetImage request. func (cook GetImageCookie) Reply() (*GetImageReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -11107,7 +11395,7 @@ func (cook GetImageCookie) Reply() (*GetImageReply, error) { return getImageReply(buf), nil } -// Read reply into structure from buffer for GetImage +// getImageReply reads a byte slice into a GetImageReply value. func getImageReply(buf []byte) *GetImageReply { v := new(GetImageReply) b := 1 // skip reply determinant @@ -11134,6 +11422,7 @@ func getImageReply(buf []byte) *GetImageReply { } // Write request to wire for GetImage +// getImageRequest writes a GetImage request to a byte slice. func getImageRequest(c *xgb.Conn, Format byte, Drawable Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32) []byte { size := 20 b := 0 @@ -11169,30 +11458,35 @@ func getImageRequest(c *xgb.Conn, Format byte, Drawable Drawable, X int16, Y int return buf } -// Request PolyText8 -// size: xgb.Pad((16 + xgb.Pad((len(Items) * 1)))) +// PolyText8Cookie is a cookie used only for PolyText8 requests. type PolyText8Cookie struct { *xgb.Cookie } -// Write request to wire for PolyText8 +// PolyText8 sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PolyText8(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText8Cookie { cookie := c.NewCookie(false, false) c.NewRequest(polyText8Request(c, Drawable, Gc, X, Y, Items), cookie) return PolyText8Cookie{cookie} } +// PolyText8Checked sends a checked request. +// If an error occurs, it can be retrieved using PolyText8Cookie.Check() func PolyText8Checked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText8Cookie { cookie := c.NewCookie(true, false) c.NewRequest(polyText8Request(c, Drawable, Gc, X, Y, Items), cookie) return PolyText8Cookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook PolyText8Cookie) Check() error { return cook.Cookie.Check() } // Write request to wire for PolyText8 +// polyText8Request writes a PolyText8 request to a byte slice. func polyText8Request(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) []byte { size := xgb.Pad((16 + xgb.Pad((len(Items) * 1)))) b := 0 @@ -11224,30 +11518,35 @@ func polyText8Request(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y in return buf } -// Request PolyText16 -// size: xgb.Pad((16 + xgb.Pad((len(Items) * 1)))) +// PolyText16Cookie is a cookie used only for PolyText16 requests. type PolyText16Cookie struct { *xgb.Cookie } -// Write request to wire for PolyText16 +// PolyText16 sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PolyText16(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText16Cookie { cookie := c.NewCookie(false, false) c.NewRequest(polyText16Request(c, Drawable, Gc, X, Y, Items), cookie) return PolyText16Cookie{cookie} } +// PolyText16Checked sends a checked request. +// If an error occurs, it can be retrieved using PolyText16Cookie.Check() func PolyText16Checked(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) PolyText16Cookie { cookie := c.NewCookie(true, false) c.NewRequest(polyText16Request(c, Drawable, Gc, X, Y, Items), cookie) return PolyText16Cookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook PolyText16Cookie) Check() error { return cook.Cookie.Check() } // Write request to wire for PolyText16 +// polyText16Request writes a PolyText16 request to a byte slice. func polyText16Request(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y int16, Items []byte) []byte { size := xgb.Pad((16 + xgb.Pad((len(Items) * 1)))) b := 0 @@ -11279,30 +11578,35 @@ func polyText16Request(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y i return buf } -// Request ImageText8 -// size: xgb.Pad((16 + xgb.Pad((int(StringLen) * 1)))) +// ImageText8Cookie is a cookie used only for ImageText8 requests. type ImageText8Cookie struct { *xgb.Cookie } -// Write request to wire for ImageText8 +// ImageText8 sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ImageText8(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String string) ImageText8Cookie { cookie := c.NewCookie(false, false) c.NewRequest(imageText8Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) return ImageText8Cookie{cookie} } +// ImageText8Checked sends a checked request. +// If an error occurs, it can be retrieved using ImageText8Cookie.Check() func ImageText8Checked(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String string) ImageText8Cookie { cookie := c.NewCookie(true, false) c.NewRequest(imageText8Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) return ImageText8Cookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook ImageText8Cookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ImageText8 +// imageText8Request writes a ImageText8 request to a byte slice. func imageText8Request(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String string) []byte { size := xgb.Pad((16 + xgb.Pad((int(StringLen) * 1)))) b := 0 @@ -11335,30 +11639,35 @@ func imageText8Request(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gconte return buf } -// Request ImageText16 -// size: xgb.Pad((16 + xgb.Pad((int(StringLen) * 2)))) +// ImageText16Cookie is a cookie used only for ImageText16 requests. type ImageText16Cookie struct { *xgb.Cookie } -// Write request to wire for ImageText16 +// ImageText16 sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ImageText16(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String []Char2b) ImageText16Cookie { cookie := c.NewCookie(false, false) c.NewRequest(imageText16Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) return ImageText16Cookie{cookie} } +// ImageText16Checked sends a checked request. +// If an error occurs, it can be retrieved using ImageText16Cookie.Check() func ImageText16Checked(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String []Char2b) ImageText16Cookie { cookie := c.NewCookie(true, false) c.NewRequest(imageText16Request(c, StringLen, Drawable, Gc, X, Y, String), cookie) return ImageText16Cookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook ImageText16Cookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ImageText16 +// imageText16Request writes a ImageText16 request to a byte slice. func imageText16Request(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcontext, X int16, Y int16, String []Char2b) []byte { size := xgb.Pad((16 + xgb.Pad((int(StringLen) * 2)))) b := 0 @@ -11390,30 +11699,35 @@ func imageText16Request(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gcont return buf } -// Request CreateColormap -// size: 16 +// CreateColormapCookie is a cookie used only for CreateColormap requests. type CreateColormapCookie struct { *xgb.Cookie } -// Write request to wire for CreateColormap +// CreateColormap sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreateColormap(c *xgb.Conn, Alloc byte, Mid Colormap, Window Window, Visual Visualid) CreateColormapCookie { cookie := c.NewCookie(false, false) c.NewRequest(createColormapRequest(c, Alloc, Mid, Window, Visual), cookie) return CreateColormapCookie{cookie} } +// CreateColormapChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateColormapCookie.Check() func CreateColormapChecked(c *xgb.Conn, Alloc byte, Mid Colormap, Window Window, Visual Visualid) CreateColormapCookie { cookie := c.NewCookie(true, false) c.NewRequest(createColormapRequest(c, Alloc, Mid, Window, Visual), cookie) return CreateColormapCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CreateColormapCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreateColormap +// createColormapRequest writes a CreateColormap request to a byte slice. func createColormapRequest(c *xgb.Conn, Alloc byte, Mid Colormap, Window Window, Visual Visualid) []byte { size := 16 b := 0 @@ -11440,30 +11754,35 @@ func createColormapRequest(c *xgb.Conn, Alloc byte, Mid Colormap, Window Window, return buf } -// Request FreeColormap -// size: 8 +// FreeColormapCookie is a cookie used only for FreeColormap requests. type FreeColormapCookie struct { *xgb.Cookie } -// Write request to wire for FreeColormap +// FreeColormap sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func FreeColormap(c *xgb.Conn, Cmap Colormap) FreeColormapCookie { cookie := c.NewCookie(false, false) c.NewRequest(freeColormapRequest(c, Cmap), cookie) return FreeColormapCookie{cookie} } +// FreeColormapChecked sends a checked request. +// If an error occurs, it can be retrieved using FreeColormapCookie.Check() func FreeColormapChecked(c *xgb.Conn, Cmap Colormap) FreeColormapCookie { cookie := c.NewCookie(true, false) c.NewRequest(freeColormapRequest(c, Cmap), cookie) return FreeColormapCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook FreeColormapCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for FreeColormap +// freeColormapRequest writes a FreeColormap request to a byte slice. func freeColormapRequest(c *xgb.Conn, Cmap Colormap) []byte { size := 8 b := 0 @@ -11483,30 +11802,35 @@ func freeColormapRequest(c *xgb.Conn, Cmap Colormap) []byte { return buf } -// Request CopyColormapAndFree -// size: 12 +// CopyColormapAndFreeCookie is a cookie used only for CopyColormapAndFree requests. type CopyColormapAndFreeCookie struct { *xgb.Cookie } -// Write request to wire for CopyColormapAndFree +// CopyColormapAndFree sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CopyColormapAndFree(c *xgb.Conn, Mid Colormap, SrcCmap Colormap) CopyColormapAndFreeCookie { cookie := c.NewCookie(false, false) c.NewRequest(copyColormapAndFreeRequest(c, Mid, SrcCmap), cookie) return CopyColormapAndFreeCookie{cookie} } +// CopyColormapAndFreeChecked sends a checked request. +// If an error occurs, it can be retrieved using CopyColormapAndFreeCookie.Check() func CopyColormapAndFreeChecked(c *xgb.Conn, Mid Colormap, SrcCmap Colormap) CopyColormapAndFreeCookie { cookie := c.NewCookie(true, false) c.NewRequest(copyColormapAndFreeRequest(c, Mid, SrcCmap), cookie) return CopyColormapAndFreeCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CopyColormapAndFreeCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CopyColormapAndFree +// copyColormapAndFreeRequest writes a CopyColormapAndFree request to a byte slice. func copyColormapAndFreeRequest(c *xgb.Conn, Mid Colormap, SrcCmap Colormap) []byte { size := 12 b := 0 @@ -11529,30 +11853,35 @@ func copyColormapAndFreeRequest(c *xgb.Conn, Mid Colormap, SrcCmap Colormap) []b return buf } -// Request InstallColormap -// size: 8 +// InstallColormapCookie is a cookie used only for InstallColormap requests. type InstallColormapCookie struct { *xgb.Cookie } -// Write request to wire for InstallColormap +// InstallColormap sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func InstallColormap(c *xgb.Conn, Cmap Colormap) InstallColormapCookie { cookie := c.NewCookie(false, false) c.NewRequest(installColormapRequest(c, Cmap), cookie) return InstallColormapCookie{cookie} } +// InstallColormapChecked sends a checked request. +// If an error occurs, it can be retrieved using InstallColormapCookie.Check() func InstallColormapChecked(c *xgb.Conn, Cmap Colormap) InstallColormapCookie { cookie := c.NewCookie(true, false) c.NewRequest(installColormapRequest(c, Cmap), cookie) return InstallColormapCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook InstallColormapCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for InstallColormap +// installColormapRequest writes a InstallColormap request to a byte slice. func installColormapRequest(c *xgb.Conn, Cmap Colormap) []byte { size := 8 b := 0 @@ -11572,30 +11901,35 @@ func installColormapRequest(c *xgb.Conn, Cmap Colormap) []byte { return buf } -// Request UninstallColormap -// size: 8 +// UninstallColormapCookie is a cookie used only for UninstallColormap requests. type UninstallColormapCookie struct { *xgb.Cookie } -// Write request to wire for UninstallColormap +// UninstallColormap sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func UninstallColormap(c *xgb.Conn, Cmap Colormap) UninstallColormapCookie { cookie := c.NewCookie(false, false) c.NewRequest(uninstallColormapRequest(c, Cmap), cookie) return UninstallColormapCookie{cookie} } +// UninstallColormapChecked sends a checked request. +// If an error occurs, it can be retrieved using UninstallColormapCookie.Check() func UninstallColormapChecked(c *xgb.Conn, Cmap Colormap) UninstallColormapCookie { cookie := c.NewCookie(true, false) c.NewRequest(uninstallColormapRequest(c, Cmap), cookie) return UninstallColormapCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook UninstallColormapCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for UninstallColormap +// uninstallColormapRequest writes a UninstallColormap request to a byte slice. func uninstallColormapRequest(c *xgb.Conn, Cmap Colormap) []byte { size := 8 b := 0 @@ -11615,36 +11949,38 @@ func uninstallColormapRequest(c *xgb.Conn, Cmap Colormap) []byte { return buf } -// Request ListInstalledColormaps -// size: 8 +// ListInstalledColormapsCookie is a cookie used only for ListInstalledColormaps requests. type ListInstalledColormapsCookie struct { *xgb.Cookie } +// ListInstalledColormaps sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListInstalledColormapsCookie.Reply() func ListInstalledColormaps(c *xgb.Conn, Window Window) ListInstalledColormapsCookie { cookie := c.NewCookie(true, true) c.NewRequest(listInstalledColormapsRequest(c, Window), cookie) return ListInstalledColormapsCookie{cookie} } +// ListInstalledColormapsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ListInstalledColormapsUnchecked(c *xgb.Conn, Window Window) ListInstalledColormapsCookie { cookie := c.NewCookie(false, true) c.NewRequest(listInstalledColormapsRequest(c, Window), cookie) return ListInstalledColormapsCookie{cookie} } -// Request reply for ListInstalledColormaps -// size: (32 + xgb.Pad((int(CmapsLen) * 4))) +// ListInstalledColormapsReply represents the data returned from a ListInstalledColormaps request. type ListInstalledColormapsReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes CmapsLen uint16 // padding: 22 bytes Cmaps []Colormap // size: xgb.Pad((int(CmapsLen) * 4)) } -// Waits and reads reply data from request ListInstalledColormaps +// Reply blocks and returns the reply data for a ListInstalledColormaps request. func (cook ListInstalledColormapsCookie) Reply() (*ListInstalledColormapsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -11656,7 +11992,7 @@ func (cook ListInstalledColormapsCookie) Reply() (*ListInstalledColormapsReply, return listInstalledColormapsReply(buf), nil } -// Read reply into structure from buffer for ListInstalledColormaps +// listInstalledColormapsReply reads a byte slice into a ListInstalledColormapsReply value. func listInstalledColormapsReply(buf []byte) *ListInstalledColormapsReply { v := new(ListInstalledColormapsReply) b := 1 // skip reply determinant @@ -11685,6 +12021,7 @@ func listInstalledColormapsReply(buf []byte) *ListInstalledColormapsReply { } // Write request to wire for ListInstalledColormaps +// listInstalledColormapsRequest writes a ListInstalledColormaps request to a byte slice. func listInstalledColormapsRequest(c *xgb.Conn, Window Window) []byte { size := 8 b := 0 @@ -11704,29 +12041,31 @@ func listInstalledColormapsRequest(c *xgb.Conn, Window Window) []byte { return buf } -// Request AllocColor -// size: 16 +// AllocColorCookie is a cookie used only for AllocColor requests. type AllocColorCookie struct { *xgb.Cookie } +// AllocColor sends a checked request. +// If an error occurs, it will be returned with the reply by calling AllocColorCookie.Reply() func AllocColor(c *xgb.Conn, Cmap Colormap, Red uint16, Green uint16, Blue uint16) AllocColorCookie { cookie := c.NewCookie(true, true) c.NewRequest(allocColorRequest(c, Cmap, Red, Green, Blue), cookie) return AllocColorCookie{cookie} } +// AllocColorUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func AllocColorUnchecked(c *xgb.Conn, Cmap Colormap, Red uint16, Green uint16, Blue uint16) AllocColorCookie { cookie := c.NewCookie(false, true) c.NewRequest(allocColorRequest(c, Cmap, Red, Green, Blue), cookie) return AllocColorCookie{cookie} } -// Request reply for AllocColor -// size: 20 +// AllocColorReply represents the data returned from a AllocColor request. type AllocColorReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Red uint16 Green uint16 @@ -11735,7 +12074,7 @@ type AllocColorReply struct { Pixel uint32 } -// Waits and reads reply data from request AllocColor +// Reply blocks and returns the reply data for a AllocColor request. func (cook AllocColorCookie) Reply() (*AllocColorReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -11747,7 +12086,7 @@ func (cook AllocColorCookie) Reply() (*AllocColorReply, error) { return allocColorReply(buf), nil } -// Read reply into structure from buffer for AllocColor +// allocColorReply reads a byte slice into a AllocColorReply value. func allocColorReply(buf []byte) *AllocColorReply { v := new(AllocColorReply) b := 1 // skip reply determinant @@ -11778,6 +12117,7 @@ func allocColorReply(buf []byte) *AllocColorReply { } // Write request to wire for AllocColor +// allocColorRequest writes a AllocColor request to a byte slice. func allocColorRequest(c *xgb.Conn, Cmap Colormap, Red uint16, Green uint16, Blue uint16) []byte { size := 16 b := 0 @@ -11808,29 +12148,31 @@ func allocColorRequest(c *xgb.Conn, Cmap Colormap, Red uint16, Green uint16, Blu return buf } -// Request AllocNamedColor -// size: xgb.Pad((12 + xgb.Pad((int(NameLen) * 1)))) +// AllocNamedColorCookie is a cookie used only for AllocNamedColor requests. type AllocNamedColorCookie struct { *xgb.Cookie } +// AllocNamedColor sends a checked request. +// If an error occurs, it will be returned with the reply by calling AllocNamedColorCookie.Reply() func AllocNamedColor(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) AllocNamedColorCookie { cookie := c.NewCookie(true, true) c.NewRequest(allocNamedColorRequest(c, Cmap, NameLen, Name), cookie) return AllocNamedColorCookie{cookie} } +// AllocNamedColorUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func AllocNamedColorUnchecked(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) AllocNamedColorCookie { cookie := c.NewCookie(false, true) c.NewRequest(allocNamedColorRequest(c, Cmap, NameLen, Name), cookie) return AllocNamedColorCookie{cookie} } -// Request reply for AllocNamedColor -// size: 24 +// AllocNamedColorReply represents the data returned from a AllocNamedColor request. type AllocNamedColorReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Pixel uint32 ExactRed uint16 @@ -11841,7 +12183,7 @@ type AllocNamedColorReply struct { VisualBlue uint16 } -// Waits and reads reply data from request AllocNamedColor +// Reply blocks and returns the reply data for a AllocNamedColor request. func (cook AllocNamedColorCookie) Reply() (*AllocNamedColorReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -11853,7 +12195,7 @@ func (cook AllocNamedColorCookie) Reply() (*AllocNamedColorReply, error) { return allocNamedColorReply(buf), nil } -// Read reply into structure from buffer for AllocNamedColor +// allocNamedColorReply reads a byte slice into a AllocNamedColorReply value. func allocNamedColorReply(buf []byte) *AllocNamedColorReply { v := new(AllocNamedColorReply) b := 1 // skip reply determinant @@ -11891,6 +12233,7 @@ func allocNamedColorReply(buf []byte) *AllocNamedColorReply { } // Write request to wire for AllocNamedColor +// allocNamedColorRequest writes a AllocNamedColor request to a byte slice. func allocNamedColorRequest(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) []byte { size := xgb.Pad((12 + xgb.Pad((int(NameLen) * 1)))) b := 0 @@ -11918,29 +12261,31 @@ func allocNamedColorRequest(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name str return buf } -// Request AllocColorCells -// size: 12 +// AllocColorCellsCookie is a cookie used only for AllocColorCells requests. type AllocColorCellsCookie struct { *xgb.Cookie } +// AllocColorCells sends a checked request. +// If an error occurs, it will be returned with the reply by calling AllocColorCellsCookie.Reply() func AllocColorCells(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Planes uint16) AllocColorCellsCookie { cookie := c.NewCookie(true, true) c.NewRequest(allocColorCellsRequest(c, Contiguous, Cmap, Colors, Planes), cookie) return AllocColorCellsCookie{cookie} } +// AllocColorCellsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func AllocColorCellsUnchecked(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Planes uint16) AllocColorCellsCookie { cookie := c.NewCookie(false, true) c.NewRequest(allocColorCellsRequest(c, Contiguous, Cmap, Colors, Planes), cookie) return AllocColorCellsCookie{cookie} } -// Request reply for AllocColorCells -// size: ((32 + xgb.Pad((int(PixelsLen) * 4))) + xgb.Pad((int(MasksLen) * 4))) +// AllocColorCellsReply represents the data returned from a AllocColorCells request. type AllocColorCellsReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes PixelsLen uint16 MasksLen uint16 @@ -11949,7 +12294,7 @@ type AllocColorCellsReply struct { Masks []uint32 // size: xgb.Pad((int(MasksLen) * 4)) } -// Waits and reads reply data from request AllocColorCells +// Reply blocks and returns the reply data for a AllocColorCells request. func (cook AllocColorCellsCookie) Reply() (*AllocColorCellsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -11961,7 +12306,7 @@ func (cook AllocColorCellsCookie) Reply() (*AllocColorCellsReply, error) { return allocColorCellsReply(buf), nil } -// Read reply into structure from buffer for AllocColorCells +// allocColorCellsReply reads a byte slice into a AllocColorCellsReply value. func allocColorCellsReply(buf []byte) *AllocColorCellsReply { v := new(AllocColorCellsReply) b := 1 // skip reply determinant @@ -12000,6 +12345,7 @@ func allocColorCellsReply(buf []byte) *AllocColorCellsReply { } // Write request to wire for AllocColorCells +// allocColorCellsRequest writes a AllocColorCells request to a byte slice. func allocColorCellsRequest(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Planes uint16) []byte { size := 12 b := 0 @@ -12030,29 +12376,31 @@ func allocColorCellsRequest(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors return buf } -// Request AllocColorPlanes -// size: 16 +// AllocColorPlanesCookie is a cookie used only for AllocColorPlanes requests. type AllocColorPlanesCookie struct { *xgb.Cookie } +// AllocColorPlanes sends a checked request. +// If an error occurs, it will be returned with the reply by calling AllocColorPlanesCookie.Reply() func AllocColorPlanes(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Reds uint16, Greens uint16, Blues uint16) AllocColorPlanesCookie { cookie := c.NewCookie(true, true) c.NewRequest(allocColorPlanesRequest(c, Contiguous, Cmap, Colors, Reds, Greens, Blues), cookie) return AllocColorPlanesCookie{cookie} } +// AllocColorPlanesUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func AllocColorPlanesUnchecked(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Reds uint16, Greens uint16, Blues uint16) AllocColorPlanesCookie { cookie := c.NewCookie(false, true) c.NewRequest(allocColorPlanesRequest(c, Contiguous, Cmap, Colors, Reds, Greens, Blues), cookie) return AllocColorPlanesCookie{cookie} } -// Request reply for AllocColorPlanes -// size: (32 + xgb.Pad((int(PixelsLen) * 4))) +// AllocColorPlanesReply represents the data returned from a AllocColorPlanes request. type AllocColorPlanesReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes PixelsLen uint16 // padding: 2 bytes @@ -12063,7 +12411,7 @@ type AllocColorPlanesReply struct { Pixels []uint32 // size: xgb.Pad((int(PixelsLen) * 4)) } -// Waits and reads reply data from request AllocColorPlanes +// Reply blocks and returns the reply data for a AllocColorPlanes request. func (cook AllocColorPlanesCookie) Reply() (*AllocColorPlanesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -12075,7 +12423,7 @@ func (cook AllocColorPlanesCookie) Reply() (*AllocColorPlanesReply, error) { return allocColorPlanesReply(buf), nil } -// Read reply into structure from buffer for AllocColorPlanes +// allocColorPlanesReply reads a byte slice into a AllocColorPlanesReply value. func allocColorPlanesReply(buf []byte) *AllocColorPlanesReply { v := new(AllocColorPlanesReply) b := 1 // skip reply determinant @@ -12115,6 +12463,7 @@ func allocColorPlanesReply(buf []byte) *AllocColorPlanesReply { } // Write request to wire for AllocColorPlanes +// allocColorPlanesRequest writes a AllocColorPlanes request to a byte slice. func allocColorPlanesRequest(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors uint16, Reds uint16, Greens uint16, Blues uint16) []byte { size := 16 b := 0 @@ -12151,30 +12500,35 @@ func allocColorPlanesRequest(c *xgb.Conn, Contiguous bool, Cmap Colormap, Colors return buf } -// Request FreeColors -// size: xgb.Pad((12 + xgb.Pad((len(Pixels) * 4)))) +// FreeColorsCookie is a cookie used only for FreeColors requests. type FreeColorsCookie struct { *xgb.Cookie } -// Write request to wire for FreeColors +// FreeColors sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func FreeColors(c *xgb.Conn, Cmap Colormap, PlaneMask uint32, Pixels []uint32) FreeColorsCookie { cookie := c.NewCookie(false, false) c.NewRequest(freeColorsRequest(c, Cmap, PlaneMask, Pixels), cookie) return FreeColorsCookie{cookie} } +// FreeColorsChecked sends a checked request. +// If an error occurs, it can be retrieved using FreeColorsCookie.Check() func FreeColorsChecked(c *xgb.Conn, Cmap Colormap, PlaneMask uint32, Pixels []uint32) FreeColorsCookie { cookie := c.NewCookie(true, false) c.NewRequest(freeColorsRequest(c, Cmap, PlaneMask, Pixels), cookie) return FreeColorsCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook FreeColorsCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for FreeColors +// freeColorsRequest writes a FreeColors request to a byte slice. func freeColorsRequest(c *xgb.Conn, Cmap Colormap, PlaneMask uint32, Pixels []uint32) []byte { size := xgb.Pad((12 + xgb.Pad((len(Pixels) * 4)))) b := 0 @@ -12203,30 +12557,35 @@ func freeColorsRequest(c *xgb.Conn, Cmap Colormap, PlaneMask uint32, Pixels []ui return buf } -// Request StoreColors -// size: xgb.Pad((8 + xgb.Pad((len(Items) * 12)))) +// StoreColorsCookie is a cookie used only for StoreColors requests. type StoreColorsCookie struct { *xgb.Cookie } -// Write request to wire for StoreColors +// StoreColors sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func StoreColors(c *xgb.Conn, Cmap Colormap, Items []Coloritem) StoreColorsCookie { cookie := c.NewCookie(false, false) c.NewRequest(storeColorsRequest(c, Cmap, Items), cookie) return StoreColorsCookie{cookie} } +// StoreColorsChecked sends a checked request. +// If an error occurs, it can be retrieved using StoreColorsCookie.Check() func StoreColorsChecked(c *xgb.Conn, Cmap Colormap, Items []Coloritem) StoreColorsCookie { cookie := c.NewCookie(true, false) c.NewRequest(storeColorsRequest(c, Cmap, Items), cookie) return StoreColorsCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook StoreColorsCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for StoreColors +// storeColorsRequest writes a StoreColors request to a byte slice. func storeColorsRequest(c *xgb.Conn, Cmap Colormap, Items []Coloritem) []byte { size := xgb.Pad((8 + xgb.Pad((len(Items) * 12)))) b := 0 @@ -12248,30 +12607,35 @@ func storeColorsRequest(c *xgb.Conn, Cmap Colormap, Items []Coloritem) []byte { return buf } -// Request StoreNamedColor -// size: xgb.Pad((16 + xgb.Pad((int(NameLen) * 1)))) +// StoreNamedColorCookie is a cookie used only for StoreNamedColor requests. type StoreNamedColorCookie struct { *xgb.Cookie } -// Write request to wire for StoreNamedColor +// StoreNamedColor sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func StoreNamedColor(c *xgb.Conn, Flags byte, Cmap Colormap, Pixel uint32, NameLen uint16, Name string) StoreNamedColorCookie { cookie := c.NewCookie(false, false) c.NewRequest(storeNamedColorRequest(c, Flags, Cmap, Pixel, NameLen, Name), cookie) return StoreNamedColorCookie{cookie} } +// StoreNamedColorChecked sends a checked request. +// If an error occurs, it can be retrieved using StoreNamedColorCookie.Check() func StoreNamedColorChecked(c *xgb.Conn, Flags byte, Cmap Colormap, Pixel uint32, NameLen uint16, Name string) StoreNamedColorCookie { cookie := c.NewCookie(true, false) c.NewRequest(storeNamedColorRequest(c, Flags, Cmap, Pixel, NameLen, Name), cookie) return StoreNamedColorCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook StoreNamedColorCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for StoreNamedColor +// storeNamedColorRequest writes a StoreNamedColor request to a byte slice. func storeNamedColorRequest(c *xgb.Conn, Flags byte, Cmap Colormap, Pixel uint32, NameLen uint16, Name string) []byte { size := xgb.Pad((16 + xgb.Pad((int(NameLen) * 1)))) b := 0 @@ -12303,36 +12667,38 @@ func storeNamedColorRequest(c *xgb.Conn, Flags byte, Cmap Colormap, Pixel uint32 return buf } -// Request QueryColors -// size: xgb.Pad((8 + xgb.Pad((len(Pixels) * 4)))) +// QueryColorsCookie is a cookie used only for QueryColors requests. type QueryColorsCookie struct { *xgb.Cookie } +// QueryColors sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryColorsCookie.Reply() func QueryColors(c *xgb.Conn, Cmap Colormap, Pixels []uint32) QueryColorsCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryColorsRequest(c, Cmap, Pixels), cookie) return QueryColorsCookie{cookie} } +// QueryColorsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryColorsUnchecked(c *xgb.Conn, Cmap Colormap, Pixels []uint32) QueryColorsCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryColorsRequest(c, Cmap, Pixels), cookie) return QueryColorsCookie{cookie} } -// Request reply for QueryColors -// size: (32 + xgb.Pad((int(ColorsLen) * 8))) +// QueryColorsReply represents the data returned from a QueryColors request. type QueryColorsReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes ColorsLen uint16 // padding: 22 bytes Colors []Rgb // size: xgb.Pad((int(ColorsLen) * 8)) } -// Waits and reads reply data from request QueryColors +// Reply blocks and returns the reply data for a QueryColors request. func (cook QueryColorsCookie) Reply() (*QueryColorsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -12344,7 +12710,7 @@ func (cook QueryColorsCookie) Reply() (*QueryColorsReply, error) { return queryColorsReply(buf), nil } -// Read reply into structure from buffer for QueryColors +// queryColorsReply reads a byte slice into a QueryColorsReply value. func queryColorsReply(buf []byte) *QueryColorsReply { v := new(QueryColorsReply) b := 1 // skip reply determinant @@ -12369,6 +12735,7 @@ func queryColorsReply(buf []byte) *QueryColorsReply { } // Write request to wire for QueryColors +// queryColorsRequest writes a QueryColors request to a byte slice. func queryColorsRequest(c *xgb.Conn, Cmap Colormap, Pixels []uint32) []byte { size := xgb.Pad((8 + xgb.Pad((len(Pixels) * 4)))) b := 0 @@ -12394,29 +12761,31 @@ func queryColorsRequest(c *xgb.Conn, Cmap Colormap, Pixels []uint32) []byte { return buf } -// Request LookupColor -// size: xgb.Pad((12 + xgb.Pad((int(NameLen) * 1)))) +// LookupColorCookie is a cookie used only for LookupColor requests. type LookupColorCookie struct { *xgb.Cookie } +// LookupColor sends a checked request. +// If an error occurs, it will be returned with the reply by calling LookupColorCookie.Reply() func LookupColor(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) LookupColorCookie { cookie := c.NewCookie(true, true) c.NewRequest(lookupColorRequest(c, Cmap, NameLen, Name), cookie) return LookupColorCookie{cookie} } +// LookupColorUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func LookupColorUnchecked(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) LookupColorCookie { cookie := c.NewCookie(false, true) c.NewRequest(lookupColorRequest(c, Cmap, NameLen, Name), cookie) return LookupColorCookie{cookie} } -// Request reply for LookupColor -// size: 20 +// LookupColorReply represents the data returned from a LookupColor request. type LookupColorReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes ExactRed uint16 ExactGreen uint16 @@ -12426,7 +12795,7 @@ type LookupColorReply struct { VisualBlue uint16 } -// Waits and reads reply data from request LookupColor +// Reply blocks and returns the reply data for a LookupColor request. func (cook LookupColorCookie) Reply() (*LookupColorReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -12438,7 +12807,7 @@ func (cook LookupColorCookie) Reply() (*LookupColorReply, error) { return lookupColorReply(buf), nil } -// Read reply into structure from buffer for LookupColor +// lookupColorReply reads a byte slice into a LookupColorReply value. func lookupColorReply(buf []byte) *LookupColorReply { v := new(LookupColorReply) b := 1 // skip reply determinant @@ -12473,6 +12842,7 @@ func lookupColorReply(buf []byte) *LookupColorReply { } // Write request to wire for LookupColor +// lookupColorRequest writes a LookupColor request to a byte slice. func lookupColorRequest(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) []byte { size := xgb.Pad((12 + xgb.Pad((int(NameLen) * 1)))) b := 0 @@ -12500,30 +12870,35 @@ func lookupColorRequest(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) return buf } -// Request CreateCursor -// size: 32 +// CreateCursorCookie is a cookie used only for CreateCursor requests. type CreateCursorCookie struct { *xgb.Cookie } -// Write request to wire for CreateCursor +// CreateCursor sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreateCursor(c *xgb.Conn, Cid Cursor, Source Pixmap, Mask Pixmap, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16, X uint16, Y uint16) CreateCursorCookie { cookie := c.NewCookie(false, false) c.NewRequest(createCursorRequest(c, Cid, Source, Mask, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue, X, Y), cookie) return CreateCursorCookie{cookie} } +// CreateCursorChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateCursorCookie.Check() func CreateCursorChecked(c *xgb.Conn, Cid Cursor, Source Pixmap, Mask Pixmap, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16, X uint16, Y uint16) CreateCursorCookie { cookie := c.NewCookie(true, false) c.NewRequest(createCursorRequest(c, Cid, Source, Mask, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue, X, Y), cookie) return CreateCursorCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CreateCursorCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreateCursor +// createCursorRequest writes a CreateCursor request to a byte slice. func createCursorRequest(c *xgb.Conn, Cid Cursor, Source Pixmap, Mask Pixmap, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16, X uint16, Y uint16) []byte { size := 32 b := 0 @@ -12573,30 +12948,35 @@ func createCursorRequest(c *xgb.Conn, Cid Cursor, Source Pixmap, Mask Pixmap, Fo return buf } -// Request CreateGlyphCursor -// size: 32 +// CreateGlyphCursorCookie is a cookie used only for CreateGlyphCursor requests. type CreateGlyphCursorCookie struct { *xgb.Cookie } -// Write request to wire for CreateGlyphCursor +// CreateGlyphCursor sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreateGlyphCursor(c *xgb.Conn, Cid Cursor, SourceFont Font, MaskFont Font, SourceChar uint16, MaskChar uint16, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) CreateGlyphCursorCookie { cookie := c.NewCookie(false, false) c.NewRequest(createGlyphCursorRequest(c, Cid, SourceFont, MaskFont, SourceChar, MaskChar, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) return CreateGlyphCursorCookie{cookie} } +// CreateGlyphCursorChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateGlyphCursorCookie.Check() func CreateGlyphCursorChecked(c *xgb.Conn, Cid Cursor, SourceFont Font, MaskFont Font, SourceChar uint16, MaskChar uint16, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) CreateGlyphCursorCookie { cookie := c.NewCookie(true, false) c.NewRequest(createGlyphCursorRequest(c, Cid, SourceFont, MaskFont, SourceChar, MaskChar, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) return CreateGlyphCursorCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook CreateGlyphCursorCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreateGlyphCursor +// createGlyphCursorRequest writes a CreateGlyphCursor request to a byte slice. func createGlyphCursorRequest(c *xgb.Conn, Cid Cursor, SourceFont Font, MaskFont Font, SourceChar uint16, MaskChar uint16, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) []byte { size := 32 b := 0 @@ -12646,30 +13026,35 @@ func createGlyphCursorRequest(c *xgb.Conn, Cid Cursor, SourceFont Font, MaskFont return buf } -// Request FreeCursor -// size: 8 +// FreeCursorCookie is a cookie used only for FreeCursor requests. type FreeCursorCookie struct { *xgb.Cookie } -// Write request to wire for FreeCursor +// FreeCursor sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func FreeCursor(c *xgb.Conn, Cursor Cursor) FreeCursorCookie { cookie := c.NewCookie(false, false) c.NewRequest(freeCursorRequest(c, Cursor), cookie) return FreeCursorCookie{cookie} } +// FreeCursorChecked sends a checked request. +// If an error occurs, it can be retrieved using FreeCursorCookie.Check() func FreeCursorChecked(c *xgb.Conn, Cursor Cursor) FreeCursorCookie { cookie := c.NewCookie(true, false) c.NewRequest(freeCursorRequest(c, Cursor), cookie) return FreeCursorCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook FreeCursorCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for FreeCursor +// freeCursorRequest writes a FreeCursor request to a byte slice. func freeCursorRequest(c *xgb.Conn, Cursor Cursor) []byte { size := 8 b := 0 @@ -12689,30 +13074,35 @@ func freeCursorRequest(c *xgb.Conn, Cursor Cursor) []byte { return buf } -// Request RecolorCursor -// size: 20 +// RecolorCursorCookie is a cookie used only for RecolorCursor requests. type RecolorCursorCookie struct { *xgb.Cookie } -// Write request to wire for RecolorCursor +// RecolorCursor sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func RecolorCursor(c *xgb.Conn, Cursor Cursor, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) RecolorCursorCookie { cookie := c.NewCookie(false, false) c.NewRequest(recolorCursorRequest(c, Cursor, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) return RecolorCursorCookie{cookie} } +// RecolorCursorChecked sends a checked request. +// If an error occurs, it can be retrieved using RecolorCursorCookie.Check() func RecolorCursorChecked(c *xgb.Conn, Cursor Cursor, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) RecolorCursorCookie { cookie := c.NewCookie(true, false) c.NewRequest(recolorCursorRequest(c, Cursor, ForeRed, ForeGreen, ForeBlue, BackRed, BackGreen, BackBlue), cookie) return RecolorCursorCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook RecolorCursorCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for RecolorCursor +// recolorCursorRequest writes a RecolorCursor request to a byte slice. func recolorCursorRequest(c *xgb.Conn, Cursor Cursor, ForeRed uint16, ForeGreen uint16, ForeBlue uint16, BackRed uint16, BackGreen uint16, BackBlue uint16) []byte { size := 20 b := 0 @@ -12750,35 +13140,37 @@ func recolorCursorRequest(c *xgb.Conn, Cursor Cursor, ForeRed uint16, ForeGreen return buf } -// Request QueryBestSize -// size: 12 +// QueryBestSizeCookie is a cookie used only for QueryBestSize requests. type QueryBestSizeCookie struct { *xgb.Cookie } +// QueryBestSize sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryBestSizeCookie.Reply() func QueryBestSize(c *xgb.Conn, Class byte, Drawable Drawable, Width uint16, Height uint16) QueryBestSizeCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryBestSizeRequest(c, Class, Drawable, Width, Height), cookie) return QueryBestSizeCookie{cookie} } +// QueryBestSizeUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryBestSizeUnchecked(c *xgb.Conn, Class byte, Drawable Drawable, Width uint16, Height uint16) QueryBestSizeCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryBestSizeRequest(c, Class, Drawable, Width, Height), cookie) return QueryBestSizeCookie{cookie} } -// Request reply for QueryBestSize -// size: 12 +// QueryBestSizeReply represents the data returned from a QueryBestSize request. type QueryBestSizeReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Width uint16 Height uint16 } -// Waits and reads reply data from request QueryBestSize +// Reply blocks and returns the reply data for a QueryBestSize request. func (cook QueryBestSizeCookie) Reply() (*QueryBestSizeReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -12790,7 +13182,7 @@ func (cook QueryBestSizeCookie) Reply() (*QueryBestSizeReply, error) { return queryBestSizeReply(buf), nil } -// Read reply into structure from buffer for QueryBestSize +// queryBestSizeReply reads a byte slice into a QueryBestSizeReply value. func queryBestSizeReply(buf []byte) *QueryBestSizeReply { v := new(QueryBestSizeReply) b := 1 // skip reply determinant @@ -12813,6 +13205,7 @@ func queryBestSizeReply(buf []byte) *QueryBestSizeReply { } // Write request to wire for QueryBestSize +// queryBestSizeRequest writes a QueryBestSize request to a byte slice. func queryBestSizeRequest(c *xgb.Conn, Class byte, Drawable Drawable, Width uint16, Height uint16) []byte { size := 12 b := 0 @@ -12839,29 +13232,31 @@ func queryBestSizeRequest(c *xgb.Conn, Class byte, Drawable Drawable, Width uint return buf } -// Request QueryExtension -// size: xgb.Pad((8 + xgb.Pad((int(NameLen) * 1)))) +// QueryExtensionCookie is a cookie used only for QueryExtension requests. type QueryExtensionCookie struct { *xgb.Cookie } +// QueryExtension sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryExtensionCookie.Reply() func QueryExtension(c *xgb.Conn, NameLen uint16, Name string) QueryExtensionCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryExtensionRequest(c, NameLen, Name), cookie) return QueryExtensionCookie{cookie} } +// QueryExtensionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryExtensionUnchecked(c *xgb.Conn, NameLen uint16, Name string) QueryExtensionCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryExtensionRequest(c, NameLen, Name), cookie) return QueryExtensionCookie{cookie} } -// Request reply for QueryExtension -// size: 12 +// QueryExtensionReply represents the data returned from a QueryExtension request. type QueryExtensionReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Present bool MajorOpcode byte @@ -12869,7 +13264,7 @@ type QueryExtensionReply struct { FirstError byte } -// Waits and reads reply data from request QueryExtension +// Reply blocks and returns the reply data for a QueryExtension request. func (cook QueryExtensionCookie) Reply() (*QueryExtensionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -12881,7 +13276,7 @@ func (cook QueryExtensionCookie) Reply() (*QueryExtensionReply, error) { return queryExtensionReply(buf), nil } -// Read reply into structure from buffer for QueryExtension +// queryExtensionReply reads a byte slice into a QueryExtensionReply value. func queryExtensionReply(buf []byte) *QueryExtensionReply { v := new(QueryExtensionReply) b := 1 // skip reply determinant @@ -12914,6 +13309,7 @@ func queryExtensionReply(buf []byte) *QueryExtensionReply { } // Write request to wire for QueryExtension +// queryExtensionRequest writes a QueryExtension request to a byte slice. func queryExtensionRequest(c *xgb.Conn, NameLen uint16, Name string) []byte { size := xgb.Pad((8 + xgb.Pad((int(NameLen) * 1)))) b := 0 @@ -12938,35 +13334,37 @@ func queryExtensionRequest(c *xgb.Conn, NameLen uint16, Name string) []byte { return buf } -// Request ListExtensions -// size: 4 +// ListExtensionsCookie is a cookie used only for ListExtensions requests. type ListExtensionsCookie struct { *xgb.Cookie } +// ListExtensions sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListExtensionsCookie.Reply() func ListExtensions(c *xgb.Conn) ListExtensionsCookie { cookie := c.NewCookie(true, true) c.NewRequest(listExtensionsRequest(c), cookie) return ListExtensionsCookie{cookie} } +// ListExtensionsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ListExtensionsUnchecked(c *xgb.Conn) ListExtensionsCookie { cookie := c.NewCookie(false, true) c.NewRequest(listExtensionsRequest(c), cookie) return ListExtensionsCookie{cookie} } -// Request reply for ListExtensions -// size: (32 + StrListSize(Names)) +// ListExtensionsReply represents the data returned from a ListExtensions request. type ListExtensionsReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply NamesLen byte // padding: 24 bytes Names []Str // size: StrListSize(Names) } -// Waits and reads reply data from request ListExtensions +// Reply blocks and returns the reply data for a ListExtensions request. func (cook ListExtensionsCookie) Reply() (*ListExtensionsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -12978,7 +13376,7 @@ func (cook ListExtensionsCookie) Reply() (*ListExtensionsReply, error) { return listExtensionsReply(buf), nil } -// Read reply into structure from buffer for ListExtensions +// listExtensionsReply reads a byte slice into a ListExtensionsReply value. func listExtensionsReply(buf []byte) *ListExtensionsReply { v := new(ListExtensionsReply) b := 1 // skip reply determinant @@ -13001,6 +13399,7 @@ func listExtensionsReply(buf []byte) *ListExtensionsReply { } // Write request to wire for ListExtensions +// listExtensionsRequest writes a ListExtensions request to a byte slice. func listExtensionsRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -13016,30 +13415,35 @@ func listExtensionsRequest(c *xgb.Conn) []byte { return buf } -// Request ChangeKeyboardMapping -// size: xgb.Pad((8 + xgb.Pad(((int(KeycodeCount) * int(KeysymsPerKeycode)) * 4)))) +// ChangeKeyboardMappingCookie is a cookie used only for ChangeKeyboardMapping requests. type ChangeKeyboardMappingCookie struct { *xgb.Cookie } -// Write request to wire for ChangeKeyboardMapping +// ChangeKeyboardMapping sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ChangeKeyboardMapping(c *xgb.Conn, KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) ChangeKeyboardMappingCookie { cookie := c.NewCookie(false, false) c.NewRequest(changeKeyboardMappingRequest(c, KeycodeCount, FirstKeycode, KeysymsPerKeycode, Keysyms), cookie) return ChangeKeyboardMappingCookie{cookie} } +// ChangeKeyboardMappingChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeKeyboardMappingCookie.Check() func ChangeKeyboardMappingChecked(c *xgb.Conn, KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) ChangeKeyboardMappingCookie { cookie := c.NewCookie(true, false) c.NewRequest(changeKeyboardMappingRequest(c, KeycodeCount, FirstKeycode, KeysymsPerKeycode, Keysyms), cookie) return ChangeKeyboardMappingCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook ChangeKeyboardMappingCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ChangeKeyboardMapping +// changeKeyboardMappingRequest writes a ChangeKeyboardMapping request to a byte slice. func changeKeyboardMappingRequest(c *xgb.Conn, KeycodeCount byte, FirstKeycode Keycode, KeysymsPerKeycode byte, Keysyms []Keysym) []byte { size := xgb.Pad((8 + xgb.Pad(((int(KeycodeCount) * int(KeysymsPerKeycode)) * 4)))) b := 0 @@ -13071,35 +13475,37 @@ func changeKeyboardMappingRequest(c *xgb.Conn, KeycodeCount byte, FirstKeycode K return buf } -// Request GetKeyboardMapping -// size: 8 +// GetKeyboardMappingCookie is a cookie used only for GetKeyboardMapping requests. type GetKeyboardMappingCookie struct { *xgb.Cookie } +// GetKeyboardMapping sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetKeyboardMappingCookie.Reply() func GetKeyboardMapping(c *xgb.Conn, FirstKeycode Keycode, Count byte) GetKeyboardMappingCookie { cookie := c.NewCookie(true, true) c.NewRequest(getKeyboardMappingRequest(c, FirstKeycode, Count), cookie) return GetKeyboardMappingCookie{cookie} } +// GetKeyboardMappingUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetKeyboardMappingUnchecked(c *xgb.Conn, FirstKeycode Keycode, Count byte) GetKeyboardMappingCookie { cookie := c.NewCookie(false, true) c.NewRequest(getKeyboardMappingRequest(c, FirstKeycode, Count), cookie) return GetKeyboardMappingCookie{cookie} } -// Request reply for GetKeyboardMapping -// size: (32 + xgb.Pad((int(Length) * 4))) +// GetKeyboardMappingReply represents the data returned from a GetKeyboardMapping request. type GetKeyboardMappingReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply KeysymsPerKeycode byte // padding: 24 bytes Keysyms []Keysym // size: xgb.Pad((int(Length) * 4)) } -// Waits and reads reply data from request GetKeyboardMapping +// Reply blocks and returns the reply data for a GetKeyboardMapping request. func (cook GetKeyboardMappingCookie) Reply() (*GetKeyboardMappingReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -13111,7 +13517,7 @@ func (cook GetKeyboardMappingCookie) Reply() (*GetKeyboardMappingReply, error) { return getKeyboardMappingReply(buf), nil } -// Read reply into structure from buffer for GetKeyboardMapping +// getKeyboardMappingReply reads a byte slice into a GetKeyboardMappingReply value. func getKeyboardMappingReply(buf []byte) *GetKeyboardMappingReply { v := new(GetKeyboardMappingReply) b := 1 // skip reply determinant @@ -13138,6 +13544,7 @@ func getKeyboardMappingReply(buf []byte) *GetKeyboardMappingReply { } // Write request to wire for GetKeyboardMapping +// getKeyboardMappingRequest writes a GetKeyboardMapping request to a byte slice. func getKeyboardMappingRequest(c *xgb.Conn, FirstKeycode Keycode, Count byte) []byte { size := 8 b := 0 @@ -13160,30 +13567,35 @@ func getKeyboardMappingRequest(c *xgb.Conn, FirstKeycode Keycode, Count byte) [] return buf } -// Request ChangeKeyboardControl -// size: xgb.Pad((4 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +// ChangeKeyboardControlCookie is a cookie used only for ChangeKeyboardControl requests. type ChangeKeyboardControlCookie struct { *xgb.Cookie } -// Write request to wire for ChangeKeyboardControl +// ChangeKeyboardControl sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ChangeKeyboardControl(c *xgb.Conn, ValueMask uint32, ValueList []uint32) ChangeKeyboardControlCookie { cookie := c.NewCookie(false, false) c.NewRequest(changeKeyboardControlRequest(c, ValueMask, ValueList), cookie) return ChangeKeyboardControlCookie{cookie} } +// ChangeKeyboardControlChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeKeyboardControlCookie.Check() func ChangeKeyboardControlChecked(c *xgb.Conn, ValueMask uint32, ValueList []uint32) ChangeKeyboardControlCookie { cookie := c.NewCookie(true, false) c.NewRequest(changeKeyboardControlRequest(c, ValueMask, ValueList), cookie) return ChangeKeyboardControlCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook ChangeKeyboardControlCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ChangeKeyboardControl +// changeKeyboardControlRequest writes a ChangeKeyboardControl request to a byte slice. func changeKeyboardControlRequest(c *xgb.Conn, ValueMask uint32, ValueList []uint32) []byte { size := xgb.Pad((4 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) b := 0 @@ -13208,29 +13620,31 @@ func changeKeyboardControlRequest(c *xgb.Conn, ValueMask uint32, ValueList []uin return buf } -// Request GetKeyboardControl -// size: 4 +// GetKeyboardControlCookie is a cookie used only for GetKeyboardControl requests. type GetKeyboardControlCookie struct { *xgb.Cookie } +// GetKeyboardControl sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetKeyboardControlCookie.Reply() func GetKeyboardControl(c *xgb.Conn) GetKeyboardControlCookie { cookie := c.NewCookie(true, true) c.NewRequest(getKeyboardControlRequest(c), cookie) return GetKeyboardControlCookie{cookie} } +// GetKeyboardControlUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetKeyboardControlUnchecked(c *xgb.Conn) GetKeyboardControlCookie { cookie := c.NewCookie(false, true) c.NewRequest(getKeyboardControlRequest(c), cookie) return GetKeyboardControlCookie{cookie} } -// Request reply for GetKeyboardControl -// size: 52 +// GetKeyboardControlReply represents the data returned from a GetKeyboardControl request. type GetKeyboardControlReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply GlobalAutoRepeat byte LedMask uint32 KeyClickPercent byte @@ -13241,7 +13655,7 @@ type GetKeyboardControlReply struct { AutoRepeats []byte // size: 32 } -// Waits and reads reply data from request GetKeyboardControl +// Reply blocks and returns the reply data for a GetKeyboardControl request. func (cook GetKeyboardControlCookie) Reply() (*GetKeyboardControlReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -13253,7 +13667,7 @@ func (cook GetKeyboardControlCookie) Reply() (*GetKeyboardControlReply, error) { return getKeyboardControlReply(buf), nil } -// Read reply into structure from buffer for GetKeyboardControl +// getKeyboardControlReply reads a byte slice into a GetKeyboardControlReply value. func getKeyboardControlReply(buf []byte) *GetKeyboardControlReply { v := new(GetKeyboardControlReply) b := 1 // skip reply determinant @@ -13292,6 +13706,7 @@ func getKeyboardControlReply(buf []byte) *GetKeyboardControlReply { } // Write request to wire for GetKeyboardControl +// getKeyboardControlRequest writes a GetKeyboardControl request to a byte slice. func getKeyboardControlRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -13307,30 +13722,35 @@ func getKeyboardControlRequest(c *xgb.Conn) []byte { return buf } -// Request Bell -// size: 4 +// BellCookie is a cookie used only for Bell requests. type BellCookie struct { *xgb.Cookie } -// Write request to wire for Bell +// Bell sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func Bell(c *xgb.Conn, Percent int8) BellCookie { cookie := c.NewCookie(false, false) c.NewRequest(bellRequest(c, Percent), cookie) return BellCookie{cookie} } +// BellChecked sends a checked request. +// If an error occurs, it can be retrieved using BellCookie.Check() func BellChecked(c *xgb.Conn, Percent int8) BellCookie { cookie := c.NewCookie(true, false) c.NewRequest(bellRequest(c, Percent), cookie) return BellCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook BellCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for Bell +// bellRequest writes a Bell request to a byte slice. func bellRequest(c *xgb.Conn, Percent int8) []byte { size := 4 b := 0 @@ -13348,30 +13768,35 @@ func bellRequest(c *xgb.Conn, Percent int8) []byte { return buf } -// Request ChangePointerControl -// size: 12 +// ChangePointerControlCookie is a cookie used only for ChangePointerControl requests. type ChangePointerControlCookie struct { *xgb.Cookie } -// Write request to wire for ChangePointerControl +// ChangePointerControl sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ChangePointerControl(c *xgb.Conn, AccelerationNumerator int16, AccelerationDenominator int16, Threshold int16, DoAcceleration bool, DoThreshold bool) ChangePointerControlCookie { cookie := c.NewCookie(false, false) c.NewRequest(changePointerControlRequest(c, AccelerationNumerator, AccelerationDenominator, Threshold, DoAcceleration, DoThreshold), cookie) return ChangePointerControlCookie{cookie} } +// ChangePointerControlChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangePointerControlCookie.Check() func ChangePointerControlChecked(c *xgb.Conn, AccelerationNumerator int16, AccelerationDenominator int16, Threshold int16, DoAcceleration bool, DoThreshold bool) ChangePointerControlCookie { cookie := c.NewCookie(true, false) c.NewRequest(changePointerControlRequest(c, AccelerationNumerator, AccelerationDenominator, Threshold, DoAcceleration, DoThreshold), cookie) return ChangePointerControlCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook ChangePointerControlCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ChangePointerControl +// changePointerControlRequest writes a ChangePointerControl request to a byte slice. func changePointerControlRequest(c *xgb.Conn, AccelerationNumerator int16, AccelerationDenominator int16, Threshold int16, DoAcceleration bool, DoThreshold bool) []byte { size := 12 b := 0 @@ -13411,29 +13836,31 @@ func changePointerControlRequest(c *xgb.Conn, AccelerationNumerator int16, Accel return buf } -// Request GetPointerControl -// size: 4 +// GetPointerControlCookie is a cookie used only for GetPointerControl requests. type GetPointerControlCookie struct { *xgb.Cookie } +// GetPointerControl sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPointerControlCookie.Reply() func GetPointerControl(c *xgb.Conn) GetPointerControlCookie { cookie := c.NewCookie(true, true) c.NewRequest(getPointerControlRequest(c), cookie) return GetPointerControlCookie{cookie} } +// GetPointerControlUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetPointerControlUnchecked(c *xgb.Conn) GetPointerControlCookie { cookie := c.NewCookie(false, true) c.NewRequest(getPointerControlRequest(c), cookie) return GetPointerControlCookie{cookie} } -// Request reply for GetPointerControl -// size: 32 +// GetPointerControlReply represents the data returned from a GetPointerControl request. type GetPointerControlReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes AccelerationNumerator uint16 AccelerationDenominator uint16 @@ -13441,7 +13868,7 @@ type GetPointerControlReply struct { // padding: 18 bytes } -// Waits and reads reply data from request GetPointerControl +// Reply blocks and returns the reply data for a GetPointerControl request. func (cook GetPointerControlCookie) Reply() (*GetPointerControlReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -13453,7 +13880,7 @@ func (cook GetPointerControlCookie) Reply() (*GetPointerControlReply, error) { return getPointerControlReply(buf), nil } -// Read reply into structure from buffer for GetPointerControl +// getPointerControlReply reads a byte slice into a GetPointerControlReply value. func getPointerControlReply(buf []byte) *GetPointerControlReply { v := new(GetPointerControlReply) b := 1 // skip reply determinant @@ -13481,6 +13908,7 @@ func getPointerControlReply(buf []byte) *GetPointerControlReply { } // Write request to wire for GetPointerControl +// getPointerControlRequest writes a GetPointerControl request to a byte slice. func getPointerControlRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -13496,30 +13924,35 @@ func getPointerControlRequest(c *xgb.Conn) []byte { return buf } -// Request SetScreenSaver -// size: 12 +// SetScreenSaverCookie is a cookie used only for SetScreenSaver requests. type SetScreenSaverCookie struct { *xgb.Cookie } -// Write request to wire for SetScreenSaver +// SetScreenSaver sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetScreenSaver(c *xgb.Conn, Timeout int16, Interval int16, PreferBlanking byte, AllowExposures byte) SetScreenSaverCookie { cookie := c.NewCookie(false, false) c.NewRequest(setScreenSaverRequest(c, Timeout, Interval, PreferBlanking, AllowExposures), cookie) return SetScreenSaverCookie{cookie} } +// SetScreenSaverChecked sends a checked request. +// If an error occurs, it can be retrieved using SetScreenSaverCookie.Check() func SetScreenSaverChecked(c *xgb.Conn, Timeout int16, Interval int16, PreferBlanking byte, AllowExposures byte) SetScreenSaverCookie { cookie := c.NewCookie(true, false) c.NewRequest(setScreenSaverRequest(c, Timeout, Interval, PreferBlanking, AllowExposures), cookie) return SetScreenSaverCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetScreenSaverCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetScreenSaver +// setScreenSaverRequest writes a SetScreenSaver request to a byte slice. func setScreenSaverRequest(c *xgb.Conn, Timeout int16, Interval int16, PreferBlanking byte, AllowExposures byte) []byte { size := 12 b := 0 @@ -13548,29 +13981,31 @@ func setScreenSaverRequest(c *xgb.Conn, Timeout int16, Interval int16, PreferBla return buf } -// Request GetScreenSaver -// size: 4 +// GetScreenSaverCookie is a cookie used only for GetScreenSaver requests. type GetScreenSaverCookie struct { *xgb.Cookie } +// GetScreenSaver sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetScreenSaverCookie.Reply() func GetScreenSaver(c *xgb.Conn) GetScreenSaverCookie { cookie := c.NewCookie(true, true) c.NewRequest(getScreenSaverRequest(c), cookie) return GetScreenSaverCookie{cookie} } +// GetScreenSaverUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetScreenSaverUnchecked(c *xgb.Conn) GetScreenSaverCookie { cookie := c.NewCookie(false, true) c.NewRequest(getScreenSaverRequest(c), cookie) return GetScreenSaverCookie{cookie} } -// Request reply for GetScreenSaver -// size: 32 +// GetScreenSaverReply represents the data returned from a GetScreenSaver request. type GetScreenSaverReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Timeout uint16 Interval uint16 @@ -13579,7 +14014,7 @@ type GetScreenSaverReply struct { // padding: 18 bytes } -// Waits and reads reply data from request GetScreenSaver +// Reply blocks and returns the reply data for a GetScreenSaver request. func (cook GetScreenSaverCookie) Reply() (*GetScreenSaverReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -13591,7 +14026,7 @@ func (cook GetScreenSaverCookie) Reply() (*GetScreenSaverReply, error) { return getScreenSaverReply(buf), nil } -// Read reply into structure from buffer for GetScreenSaver +// getScreenSaverReply reads a byte slice into a GetScreenSaverReply value. func getScreenSaverReply(buf []byte) *GetScreenSaverReply { v := new(GetScreenSaverReply) b := 1 // skip reply determinant @@ -13622,6 +14057,7 @@ func getScreenSaverReply(buf []byte) *GetScreenSaverReply { } // Write request to wire for GetScreenSaver +// getScreenSaverRequest writes a GetScreenSaver request to a byte slice. func getScreenSaverRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -13637,30 +14073,35 @@ func getScreenSaverRequest(c *xgb.Conn) []byte { return buf } -// Request ChangeHosts -// size: xgb.Pad((8 + xgb.Pad((int(AddressLen) * 1)))) +// ChangeHostsCookie is a cookie used only for ChangeHosts requests. type ChangeHostsCookie struct { *xgb.Cookie } -// Write request to wire for ChangeHosts +// ChangeHosts sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ChangeHosts(c *xgb.Conn, Mode byte, Family byte, AddressLen uint16, Address []byte) ChangeHostsCookie { cookie := c.NewCookie(false, false) c.NewRequest(changeHostsRequest(c, Mode, Family, AddressLen, Address), cookie) return ChangeHostsCookie{cookie} } +// ChangeHostsChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeHostsCookie.Check() func ChangeHostsChecked(c *xgb.Conn, Mode byte, Family byte, AddressLen uint16, Address []byte) ChangeHostsCookie { cookie := c.NewCookie(true, false) c.NewRequest(changeHostsRequest(c, Mode, Family, AddressLen, Address), cookie) return ChangeHostsCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook ChangeHostsCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ChangeHosts +// changeHostsRequest writes a ChangeHosts request to a byte slice. func changeHostsRequest(c *xgb.Conn, Mode byte, Family byte, AddressLen uint16, Address []byte) []byte { size := xgb.Pad((8 + xgb.Pad((int(AddressLen) * 1)))) b := 0 @@ -13689,36 +14130,38 @@ func changeHostsRequest(c *xgb.Conn, Mode byte, Family byte, AddressLen uint16, return buf } -// Request ListHosts -// size: 4 +// ListHostsCookie is a cookie used only for ListHosts requests. type ListHostsCookie struct { *xgb.Cookie } +// ListHosts sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListHostsCookie.Reply() func ListHosts(c *xgb.Conn) ListHostsCookie { cookie := c.NewCookie(true, true) c.NewRequest(listHostsRequest(c), cookie) return ListHostsCookie{cookie} } +// ListHostsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ListHostsUnchecked(c *xgb.Conn) ListHostsCookie { cookie := c.NewCookie(false, true) c.NewRequest(listHostsRequest(c), cookie) return ListHostsCookie{cookie} } -// Request reply for ListHosts -// size: (32 + HostListSize(Hosts)) +// ListHostsReply represents the data returned from a ListHosts request. type ListHostsReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply Mode byte HostsLen uint16 // padding: 22 bytes Hosts []Host // size: HostListSize(Hosts) } -// Waits and reads reply data from request ListHosts +// Reply blocks and returns the reply data for a ListHosts request. func (cook ListHostsCookie) Reply() (*ListHostsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -13730,7 +14173,7 @@ func (cook ListHostsCookie) Reply() (*ListHostsReply, error) { return listHostsReply(buf), nil } -// Read reply into structure from buffer for ListHosts +// listHostsReply reads a byte slice into a ListHostsReply value. func listHostsReply(buf []byte) *ListHostsReply { v := new(ListHostsReply) b := 1 // skip reply determinant @@ -13756,6 +14199,7 @@ func listHostsReply(buf []byte) *ListHostsReply { } // Write request to wire for ListHosts +// listHostsRequest writes a ListHosts request to a byte slice. func listHostsRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -13771,30 +14215,35 @@ func listHostsRequest(c *xgb.Conn) []byte { return buf } -// Request SetAccessControl -// size: 4 +// SetAccessControlCookie is a cookie used only for SetAccessControl requests. type SetAccessControlCookie struct { *xgb.Cookie } -// Write request to wire for SetAccessControl +// SetAccessControl sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetAccessControl(c *xgb.Conn, Mode byte) SetAccessControlCookie { cookie := c.NewCookie(false, false) c.NewRequest(setAccessControlRequest(c, Mode), cookie) return SetAccessControlCookie{cookie} } +// SetAccessControlChecked sends a checked request. +// If an error occurs, it can be retrieved using SetAccessControlCookie.Check() func SetAccessControlChecked(c *xgb.Conn, Mode byte) SetAccessControlCookie { cookie := c.NewCookie(true, false) c.NewRequest(setAccessControlRequest(c, Mode), cookie) return SetAccessControlCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetAccessControlCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetAccessControl +// setAccessControlRequest writes a SetAccessControl request to a byte slice. func setAccessControlRequest(c *xgb.Conn, Mode byte) []byte { size := 4 b := 0 @@ -13812,30 +14261,35 @@ func setAccessControlRequest(c *xgb.Conn, Mode byte) []byte { return buf } -// Request SetCloseDownMode -// size: 4 +// SetCloseDownModeCookie is a cookie used only for SetCloseDownMode requests. type SetCloseDownModeCookie struct { *xgb.Cookie } -// Write request to wire for SetCloseDownMode +// SetCloseDownMode sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetCloseDownMode(c *xgb.Conn, Mode byte) SetCloseDownModeCookie { cookie := c.NewCookie(false, false) c.NewRequest(setCloseDownModeRequest(c, Mode), cookie) return SetCloseDownModeCookie{cookie} } +// SetCloseDownModeChecked sends a checked request. +// If an error occurs, it can be retrieved using SetCloseDownModeCookie.Check() func SetCloseDownModeChecked(c *xgb.Conn, Mode byte) SetCloseDownModeCookie { cookie := c.NewCookie(true, false) c.NewRequest(setCloseDownModeRequest(c, Mode), cookie) return SetCloseDownModeCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetCloseDownModeCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetCloseDownMode +// setCloseDownModeRequest writes a SetCloseDownMode request to a byte slice. func setCloseDownModeRequest(c *xgb.Conn, Mode byte) []byte { size := 4 b := 0 @@ -13853,30 +14307,35 @@ func setCloseDownModeRequest(c *xgb.Conn, Mode byte) []byte { return buf } -// Request KillClient -// size: 8 +// KillClientCookie is a cookie used only for KillClient requests. type KillClientCookie struct { *xgb.Cookie } -// Write request to wire for KillClient +// KillClient sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func KillClient(c *xgb.Conn, Resource uint32) KillClientCookie { cookie := c.NewCookie(false, false) c.NewRequest(killClientRequest(c, Resource), cookie) return KillClientCookie{cookie} } +// KillClientChecked sends a checked request. +// If an error occurs, it can be retrieved using KillClientCookie.Check() func KillClientChecked(c *xgb.Conn, Resource uint32) KillClientCookie { cookie := c.NewCookie(true, false) c.NewRequest(killClientRequest(c, Resource), cookie) return KillClientCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook KillClientCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for KillClient +// killClientRequest writes a KillClient request to a byte slice. func killClientRequest(c *xgb.Conn, Resource uint32) []byte { size := 8 b := 0 @@ -13896,30 +14355,35 @@ func killClientRequest(c *xgb.Conn, Resource uint32) []byte { return buf } -// Request RotateProperties -// size: xgb.Pad((12 + xgb.Pad((int(AtomsLen) * 4)))) +// RotatePropertiesCookie is a cookie used only for RotateProperties requests. type RotatePropertiesCookie struct { *xgb.Cookie } -// Write request to wire for RotateProperties +// RotateProperties sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func RotateProperties(c *xgb.Conn, Window Window, AtomsLen uint16, Delta int16, Atoms []Atom) RotatePropertiesCookie { cookie := c.NewCookie(false, false) c.NewRequest(rotatePropertiesRequest(c, Window, AtomsLen, Delta, Atoms), cookie) return RotatePropertiesCookie{cookie} } +// RotatePropertiesChecked sends a checked request. +// If an error occurs, it can be retrieved using RotatePropertiesCookie.Check() func RotatePropertiesChecked(c *xgb.Conn, Window Window, AtomsLen uint16, Delta int16, Atoms []Atom) RotatePropertiesCookie { cookie := c.NewCookie(true, false) c.NewRequest(rotatePropertiesRequest(c, Window, AtomsLen, Delta, Atoms), cookie) return RotatePropertiesCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook RotatePropertiesCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for RotateProperties +// rotatePropertiesRequest writes a RotateProperties request to a byte slice. func rotatePropertiesRequest(c *xgb.Conn, Window Window, AtomsLen uint16, Delta int16, Atoms []Atom) []byte { size := xgb.Pad((12 + xgb.Pad((int(AtomsLen) * 4)))) b := 0 @@ -13951,30 +14415,35 @@ func rotatePropertiesRequest(c *xgb.Conn, Window Window, AtomsLen uint16, Delta return buf } -// Request ForceScreenSaver -// size: 4 +// ForceScreenSaverCookie is a cookie used only for ForceScreenSaver requests. type ForceScreenSaverCookie struct { *xgb.Cookie } -// Write request to wire for ForceScreenSaver +// ForceScreenSaver sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ForceScreenSaver(c *xgb.Conn, Mode byte) ForceScreenSaverCookie { cookie := c.NewCookie(false, false) c.NewRequest(forceScreenSaverRequest(c, Mode), cookie) return ForceScreenSaverCookie{cookie} } +// ForceScreenSaverChecked sends a checked request. +// If an error occurs, it can be retrieved using ForceScreenSaverCookie.Check() func ForceScreenSaverChecked(c *xgb.Conn, Mode byte) ForceScreenSaverCookie { cookie := c.NewCookie(true, false) c.NewRequest(forceScreenSaverRequest(c, Mode), cookie) return ForceScreenSaverCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook ForceScreenSaverCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ForceScreenSaver +// forceScreenSaverRequest writes a ForceScreenSaver request to a byte slice. func forceScreenSaverRequest(c *xgb.Conn, Mode byte) []byte { size := 4 b := 0 @@ -13992,33 +14461,35 @@ func forceScreenSaverRequest(c *xgb.Conn, Mode byte) []byte { return buf } -// Request SetPointerMapping -// size: xgb.Pad((4 + xgb.Pad((int(MapLen) * 1)))) +// SetPointerMappingCookie is a cookie used only for SetPointerMapping requests. type SetPointerMappingCookie struct { *xgb.Cookie } +// SetPointerMapping sends a checked request. +// If an error occurs, it will be returned with the reply by calling SetPointerMappingCookie.Reply() func SetPointerMapping(c *xgb.Conn, MapLen byte, Map []byte) SetPointerMappingCookie { cookie := c.NewCookie(true, true) c.NewRequest(setPointerMappingRequest(c, MapLen, Map), cookie) return SetPointerMappingCookie{cookie} } +// SetPointerMappingUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetPointerMappingUnchecked(c *xgb.Conn, MapLen byte, Map []byte) SetPointerMappingCookie { cookie := c.NewCookie(false, true) c.NewRequest(setPointerMappingRequest(c, MapLen, Map), cookie) return SetPointerMappingCookie{cookie} } -// Request reply for SetPointerMapping -// size: 8 +// SetPointerMappingReply represents the data returned from a SetPointerMapping request. type SetPointerMappingReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply Status byte } -// Waits and reads reply data from request SetPointerMapping +// Reply blocks and returns the reply data for a SetPointerMapping request. func (cook SetPointerMappingCookie) Reply() (*SetPointerMappingReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -14030,7 +14501,7 @@ func (cook SetPointerMappingCookie) Reply() (*SetPointerMappingReply, error) { return setPointerMappingReply(buf), nil } -// Read reply into structure from buffer for SetPointerMapping +// setPointerMappingReply reads a byte slice into a SetPointerMappingReply value. func setPointerMappingReply(buf []byte) *SetPointerMappingReply { v := new(SetPointerMappingReply) b := 1 // skip reply determinant @@ -14048,6 +14519,7 @@ func setPointerMappingReply(buf []byte) *SetPointerMappingReply { } // Write request to wire for SetPointerMapping +// setPointerMappingRequest writes a SetPointerMapping request to a byte slice. func setPointerMappingRequest(c *xgb.Conn, MapLen byte, Map []byte) []byte { size := xgb.Pad((4 + xgb.Pad((int(MapLen) * 1)))) b := 0 @@ -14068,35 +14540,37 @@ func setPointerMappingRequest(c *xgb.Conn, MapLen byte, Map []byte) []byte { return buf } -// Request GetPointerMapping -// size: 4 +// GetPointerMappingCookie is a cookie used only for GetPointerMapping requests. type GetPointerMappingCookie struct { *xgb.Cookie } +// GetPointerMapping sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPointerMappingCookie.Reply() func GetPointerMapping(c *xgb.Conn) GetPointerMappingCookie { cookie := c.NewCookie(true, true) c.NewRequest(getPointerMappingRequest(c), cookie) return GetPointerMappingCookie{cookie} } +// GetPointerMappingUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetPointerMappingUnchecked(c *xgb.Conn) GetPointerMappingCookie { cookie := c.NewCookie(false, true) c.NewRequest(getPointerMappingRequest(c), cookie) return GetPointerMappingCookie{cookie} } -// Request reply for GetPointerMapping -// size: (32 + xgb.Pad((int(MapLen) * 1))) +// GetPointerMappingReply represents the data returned from a GetPointerMapping request. type GetPointerMappingReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply MapLen byte // padding: 24 bytes Map []byte // size: xgb.Pad((int(MapLen) * 1)) } -// Waits and reads reply data from request GetPointerMapping +// Reply blocks and returns the reply data for a GetPointerMapping request. func (cook GetPointerMappingCookie) Reply() (*GetPointerMappingReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -14108,7 +14582,7 @@ func (cook GetPointerMappingCookie) Reply() (*GetPointerMappingReply, error) { return getPointerMappingReply(buf), nil } -// Read reply into structure from buffer for GetPointerMapping +// getPointerMappingReply reads a byte slice into a GetPointerMappingReply value. func getPointerMappingReply(buf []byte) *GetPointerMappingReply { v := new(GetPointerMappingReply) b := 1 // skip reply determinant @@ -14132,6 +14606,7 @@ func getPointerMappingReply(buf []byte) *GetPointerMappingReply { } // Write request to wire for GetPointerMapping +// getPointerMappingRequest writes a GetPointerMapping request to a byte slice. func getPointerMappingRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -14147,33 +14622,35 @@ func getPointerMappingRequest(c *xgb.Conn) []byte { return buf } -// Request SetModifierMapping -// size: xgb.Pad((4 + xgb.Pad(((int(KeycodesPerModifier) * 8) * 1)))) +// SetModifierMappingCookie is a cookie used only for SetModifierMapping requests. type SetModifierMappingCookie struct { *xgb.Cookie } +// SetModifierMapping sends a checked request. +// If an error occurs, it will be returned with the reply by calling SetModifierMappingCookie.Reply() func SetModifierMapping(c *xgb.Conn, KeycodesPerModifier byte, Keycodes []Keycode) SetModifierMappingCookie { cookie := c.NewCookie(true, true) c.NewRequest(setModifierMappingRequest(c, KeycodesPerModifier, Keycodes), cookie) return SetModifierMappingCookie{cookie} } +// SetModifierMappingUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetModifierMappingUnchecked(c *xgb.Conn, KeycodesPerModifier byte, Keycodes []Keycode) SetModifierMappingCookie { cookie := c.NewCookie(false, true) c.NewRequest(setModifierMappingRequest(c, KeycodesPerModifier, Keycodes), cookie) return SetModifierMappingCookie{cookie} } -// Request reply for SetModifierMapping -// size: 8 +// SetModifierMappingReply represents the data returned from a SetModifierMapping request. type SetModifierMappingReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply Status byte } -// Waits and reads reply data from request SetModifierMapping +// Reply blocks and returns the reply data for a SetModifierMapping request. func (cook SetModifierMappingCookie) Reply() (*SetModifierMappingReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -14185,7 +14662,7 @@ func (cook SetModifierMappingCookie) Reply() (*SetModifierMappingReply, error) { return setModifierMappingReply(buf), nil } -// Read reply into structure from buffer for SetModifierMapping +// setModifierMappingReply reads a byte slice into a SetModifierMappingReply value. func setModifierMappingReply(buf []byte) *SetModifierMappingReply { v := new(SetModifierMappingReply) b := 1 // skip reply determinant @@ -14203,6 +14680,7 @@ func setModifierMappingReply(buf []byte) *SetModifierMappingReply { } // Write request to wire for SetModifierMapping +// setModifierMappingRequest writes a SetModifierMapping request to a byte slice. func setModifierMappingRequest(c *xgb.Conn, KeycodesPerModifier byte, Keycodes []Keycode) []byte { size := xgb.Pad((4 + xgb.Pad(((int(KeycodesPerModifier) * 8) * 1)))) b := 0 @@ -14226,35 +14704,37 @@ func setModifierMappingRequest(c *xgb.Conn, KeycodesPerModifier byte, Keycodes [ return buf } -// Request GetModifierMapping -// size: 4 +// GetModifierMappingCookie is a cookie used only for GetModifierMapping requests. type GetModifierMappingCookie struct { *xgb.Cookie } +// GetModifierMapping sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetModifierMappingCookie.Reply() func GetModifierMapping(c *xgb.Conn) GetModifierMappingCookie { cookie := c.NewCookie(true, true) c.NewRequest(getModifierMappingRequest(c), cookie) return GetModifierMappingCookie{cookie} } +// GetModifierMappingUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetModifierMappingUnchecked(c *xgb.Conn) GetModifierMappingCookie { cookie := c.NewCookie(false, true) c.NewRequest(getModifierMappingRequest(c), cookie) return GetModifierMappingCookie{cookie} } -// Request reply for GetModifierMapping -// size: (32 + xgb.Pad(((int(KeycodesPerModifier) * 8) * 1))) +// GetModifierMappingReply represents the data returned from a GetModifierMapping request. type GetModifierMappingReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply KeycodesPerModifier byte // padding: 24 bytes Keycodes []Keycode // size: xgb.Pad(((int(KeycodesPerModifier) * 8) * 1)) } -// Waits and reads reply data from request GetModifierMapping +// Reply blocks and returns the reply data for a GetModifierMapping request. func (cook GetModifierMappingCookie) Reply() (*GetModifierMappingReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -14266,7 +14746,7 @@ func (cook GetModifierMappingCookie) Reply() (*GetModifierMappingReply, error) { return getModifierMappingReply(buf), nil } -// Read reply into structure from buffer for GetModifierMapping +// getModifierMappingReply reads a byte slice into a GetModifierMappingReply value. func getModifierMappingReply(buf []byte) *GetModifierMappingReply { v := new(GetModifierMappingReply) b := 1 // skip reply determinant @@ -14293,6 +14773,7 @@ func getModifierMappingReply(buf []byte) *GetModifierMappingReply { } // Write request to wire for GetModifierMapping +// getModifierMappingRequest writes a GetModifierMapping request to a byte slice. func getModifierMappingRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -14308,30 +14789,35 @@ func getModifierMappingRequest(c *xgb.Conn) []byte { return buf } -// Request NoOperation -// size: 4 +// NoOperationCookie is a cookie used only for NoOperation requests. type NoOperationCookie struct { *xgb.Cookie } -// Write request to wire for NoOperation +// NoOperation sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func NoOperation(c *xgb.Conn) NoOperationCookie { cookie := c.NewCookie(false, false) c.NewRequest(noOperationRequest(c), cookie) return NoOperationCookie{cookie} } +// NoOperationChecked sends a checked request. +// If an error occurs, it can be retrieved using NoOperationCookie.Check() func NoOperationChecked(c *xgb.Conn) NoOperationCookie { cookie := c.NewCookie(true, false) c.NewRequest(noOperationRequest(c), cookie) return NoOperationCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook NoOperationCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for NoOperation +// noOperationRequest writes a NoOperation request to a byte slice. func noOperationRequest(c *xgb.Conn) []byte { size := 4 b := 0 diff --git a/nexgb/xselinux/xselinux.go b/nexgb/xselinux/xselinux.go index cb0532f..ac11a77 100644 --- a/nexgb/xselinux/xselinux.go +++ b/nexgb/xselinux/xselinux.go @@ -2,7 +2,7 @@ package xselinux /* - This file was generated by xselinux.xml on May 10 2012 8:04:33pm EDT. + This file was generated by xselinux.xml on May 10 2012 11:56:20pm EDT. This file is automatically generated. Edit at your peril! */ @@ -64,8 +64,6 @@ func init() { // Skipping definition for base type 'Byte' -// 'ListItem' struct definition -// Size: ((12 + xgb.Pad((int(ObjectContextLen) * 1))) + xgb.Pad((int(DataContextLen) * 1))) type ListItem struct { Name xproto.Atom ObjectContextLen uint32 @@ -74,7 +72,7 @@ type ListItem struct { DataContext string // size: xgb.Pad((int(DataContextLen) * 1)) } -// Struct read ListItem +// ListItemRead reads a byte slice into a ListItem value. func ListItemRead(buf []byte, v *ListItem) int { b := 0 @@ -104,7 +102,7 @@ func ListItemRead(buf []byte, v *ListItem) int { return b } -// Struct list read ListItem +// ListItemReadList reads a byte slice into a list of ListItem values. func ListItemReadList(buf []byte, dest []ListItem) int { b := 0 for i := 0; i < len(dest); i++ { @@ -114,7 +112,7 @@ func ListItemReadList(buf []byte, dest []ListItem) int { return xgb.Pad(b) } -// Struct write ListItem +// Bytes writes a ListItem value to a byte slice. func (v ListItem) Bytes() []byte { buf := make([]byte, ((12 + xgb.Pad((int(v.ObjectContextLen) * 1))) + xgb.Pad((int(v.DataContextLen) * 1)))) b := 0 @@ -137,7 +135,7 @@ func (v ListItem) Bytes() []byte { return buf } -// Write struct list ListItem +// ListItemListBytes writes a list of %s(MISSING) values to a byte slice. func ListItemListBytes(buf []byte, list []ListItem) int { b := 0 var structBytes []byte @@ -149,7 +147,7 @@ func ListItemListBytes(buf []byte, list []ListItem) int { return b } -// Struct list size ListItem +// ListItemListSize computes the size (bytes) of a list of ListItem values. func ListItemListSize(list []ListItem) int { size := 0 for _, item := range list { @@ -158,35 +156,37 @@ func ListItemListSize(list []ListItem) int { return size } -// Request QueryVersion -// size: 8 +// QueryVersionCookie is a cookie used only for QueryVersion requests. type QueryVersionCookie struct { *xgb.Cookie } +// QueryVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() func QueryVersion(c *xgb.Conn, ClientMajor byte, ClientMinor byte) QueryVersionCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryVersionRequest(c, ClientMajor, ClientMinor), cookie) return QueryVersionCookie{cookie} } +// QueryVersionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryVersionUnchecked(c *xgb.Conn, ClientMajor byte, ClientMinor byte) QueryVersionCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryVersionRequest(c, ClientMajor, ClientMinor), cookie) return QueryVersionCookie{cookie} } -// Request reply for QueryVersion -// size: 12 +// QueryVersionReply represents the data returned from a QueryVersion request. type QueryVersionReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes ServerMajor uint16 ServerMinor uint16 } -// Waits and reads reply data from request QueryVersion +// Reply blocks and returns the reply data for a QueryVersion request. func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -198,7 +198,7 @@ func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { return queryVersionReply(buf), nil } -// Read reply into structure from buffer for QueryVersion +// queryVersionReply reads a byte slice into a QueryVersionReply value. func queryVersionReply(buf []byte) *QueryVersionReply { v := new(QueryVersionReply) b := 1 // skip reply determinant @@ -221,6 +221,7 @@ func queryVersionReply(buf []byte) *QueryVersionReply { } // Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. func queryVersionRequest(c *xgb.Conn, ClientMajor byte, ClientMinor byte) []byte { size := 8 b := 0 @@ -244,30 +245,35 @@ func queryVersionRequest(c *xgb.Conn, ClientMajor byte, ClientMinor byte) []byte return buf } -// Request SetDeviceCreateContext -// size: xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) +// SetDeviceCreateContextCookie is a cookie used only for SetDeviceCreateContext requests. type SetDeviceCreateContextCookie struct { *xgb.Cookie } -// Write request to wire for SetDeviceCreateContext +// SetDeviceCreateContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetDeviceCreateContext(c *xgb.Conn, ContextLen uint32, Context string) SetDeviceCreateContextCookie { cookie := c.NewCookie(false, false) c.NewRequest(setDeviceCreateContextRequest(c, ContextLen, Context), cookie) return SetDeviceCreateContextCookie{cookie} } +// SetDeviceCreateContextChecked sends a checked request. +// If an error occurs, it can be retrieved using SetDeviceCreateContextCookie.Check() func SetDeviceCreateContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetDeviceCreateContextCookie { cookie := c.NewCookie(true, false) c.NewRequest(setDeviceCreateContextRequest(c, ContextLen, Context), cookie) return SetDeviceCreateContextCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetDeviceCreateContextCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetDeviceCreateContext +// setDeviceCreateContextRequest writes a SetDeviceCreateContext request to a byte slice. func setDeviceCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) b := 0 @@ -291,36 +297,38 @@ func setDeviceCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context strin return buf } -// Request GetDeviceCreateContext -// size: 4 +// GetDeviceCreateContextCookie is a cookie used only for GetDeviceCreateContext requests. type GetDeviceCreateContextCookie struct { *xgb.Cookie } +// GetDeviceCreateContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetDeviceCreateContextCookie.Reply() func GetDeviceCreateContext(c *xgb.Conn) GetDeviceCreateContextCookie { cookie := c.NewCookie(true, true) c.NewRequest(getDeviceCreateContextRequest(c), cookie) return GetDeviceCreateContextCookie{cookie} } +// GetDeviceCreateContextUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetDeviceCreateContextUnchecked(c *xgb.Conn) GetDeviceCreateContextCookie { cookie := c.NewCookie(false, true) c.NewRequest(getDeviceCreateContextRequest(c), cookie) return GetDeviceCreateContextCookie{cookie} } -// Request reply for GetDeviceCreateContext -// size: (32 + xgb.Pad((int(ContextLen) * 1))) +// GetDeviceCreateContextReply represents the data returned from a GetDeviceCreateContext request. type GetDeviceCreateContextReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes ContextLen uint32 // padding: 20 bytes Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Waits and reads reply data from request GetDeviceCreateContext +// Reply blocks and returns the reply data for a GetDeviceCreateContext request. func (cook GetDeviceCreateContextCookie) Reply() (*GetDeviceCreateContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -332,7 +340,7 @@ func (cook GetDeviceCreateContextCookie) Reply() (*GetDeviceCreateContextReply, return getDeviceCreateContextReply(buf), nil } -// Read reply into structure from buffer for GetDeviceCreateContext +// getDeviceCreateContextReply reads a byte slice into a GetDeviceCreateContextReply value. func getDeviceCreateContextReply(buf []byte) *GetDeviceCreateContextReply { v := new(GetDeviceCreateContextReply) b := 1 // skip reply determinant @@ -361,6 +369,7 @@ func getDeviceCreateContextReply(buf []byte) *GetDeviceCreateContextReply { } // Write request to wire for GetDeviceCreateContext +// getDeviceCreateContextRequest writes a GetDeviceCreateContext request to a byte slice. func getDeviceCreateContextRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -378,30 +387,35 @@ func getDeviceCreateContextRequest(c *xgb.Conn) []byte { return buf } -// Request SetDeviceContext -// size: xgb.Pad((12 + xgb.Pad((int(ContextLen) * 1)))) +// SetDeviceContextCookie is a cookie used only for SetDeviceContext requests. type SetDeviceContextCookie struct { *xgb.Cookie } -// Write request to wire for SetDeviceContext +// SetDeviceContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetDeviceContext(c *xgb.Conn, Device uint32, ContextLen uint32, Context string) SetDeviceContextCookie { cookie := c.NewCookie(false, false) c.NewRequest(setDeviceContextRequest(c, Device, ContextLen, Context), cookie) return SetDeviceContextCookie{cookie} } +// SetDeviceContextChecked sends a checked request. +// If an error occurs, it can be retrieved using SetDeviceContextCookie.Check() func SetDeviceContextChecked(c *xgb.Conn, Device uint32, ContextLen uint32, Context string) SetDeviceContextCookie { cookie := c.NewCookie(true, false) c.NewRequest(setDeviceContextRequest(c, Device, ContextLen, Context), cookie) return SetDeviceContextCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetDeviceContextCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetDeviceContext +// setDeviceContextRequest writes a SetDeviceContext request to a byte slice. func setDeviceContextRequest(c *xgb.Conn, Device uint32, ContextLen uint32, Context string) []byte { size := xgb.Pad((12 + xgb.Pad((int(ContextLen) * 1)))) b := 0 @@ -428,36 +442,38 @@ func setDeviceContextRequest(c *xgb.Conn, Device uint32, ContextLen uint32, Cont return buf } -// Request GetDeviceContext -// size: 8 +// GetDeviceContextCookie is a cookie used only for GetDeviceContext requests. type GetDeviceContextCookie struct { *xgb.Cookie } +// GetDeviceContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetDeviceContextCookie.Reply() func GetDeviceContext(c *xgb.Conn, Device uint32) GetDeviceContextCookie { cookie := c.NewCookie(true, true) c.NewRequest(getDeviceContextRequest(c, Device), cookie) return GetDeviceContextCookie{cookie} } +// GetDeviceContextUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetDeviceContextUnchecked(c *xgb.Conn, Device uint32) GetDeviceContextCookie { cookie := c.NewCookie(false, true) c.NewRequest(getDeviceContextRequest(c, Device), cookie) return GetDeviceContextCookie{cookie} } -// Request reply for GetDeviceContext -// size: (32 + xgb.Pad((int(ContextLen) * 1))) +// GetDeviceContextReply represents the data returned from a GetDeviceContext request. type GetDeviceContextReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes ContextLen uint32 // padding: 20 bytes Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Waits and reads reply data from request GetDeviceContext +// Reply blocks and returns the reply data for a GetDeviceContext request. func (cook GetDeviceContextCookie) Reply() (*GetDeviceContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -469,7 +485,7 @@ func (cook GetDeviceContextCookie) Reply() (*GetDeviceContextReply, error) { return getDeviceContextReply(buf), nil } -// Read reply into structure from buffer for GetDeviceContext +// getDeviceContextReply reads a byte slice into a GetDeviceContextReply value. func getDeviceContextReply(buf []byte) *GetDeviceContextReply { v := new(GetDeviceContextReply) b := 1 // skip reply determinant @@ -498,6 +514,7 @@ func getDeviceContextReply(buf []byte) *GetDeviceContextReply { } // Write request to wire for GetDeviceContext +// getDeviceContextRequest writes a GetDeviceContext request to a byte slice. func getDeviceContextRequest(c *xgb.Conn, Device uint32) []byte { size := 8 b := 0 @@ -518,30 +535,35 @@ func getDeviceContextRequest(c *xgb.Conn, Device uint32) []byte { return buf } -// Request SetWindowCreateContext -// size: xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) +// SetWindowCreateContextCookie is a cookie used only for SetWindowCreateContext requests. type SetWindowCreateContextCookie struct { *xgb.Cookie } -// Write request to wire for SetWindowCreateContext +// SetWindowCreateContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetWindowCreateContext(c *xgb.Conn, ContextLen uint32, Context string) SetWindowCreateContextCookie { cookie := c.NewCookie(false, false) c.NewRequest(setWindowCreateContextRequest(c, ContextLen, Context), cookie) return SetWindowCreateContextCookie{cookie} } +// SetWindowCreateContextChecked sends a checked request. +// If an error occurs, it can be retrieved using SetWindowCreateContextCookie.Check() func SetWindowCreateContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetWindowCreateContextCookie { cookie := c.NewCookie(true, false) c.NewRequest(setWindowCreateContextRequest(c, ContextLen, Context), cookie) return SetWindowCreateContextCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetWindowCreateContextCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetWindowCreateContext +// setWindowCreateContextRequest writes a SetWindowCreateContext request to a byte slice. func setWindowCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) b := 0 @@ -565,36 +587,38 @@ func setWindowCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context strin return buf } -// Request GetWindowCreateContext -// size: 4 +// GetWindowCreateContextCookie is a cookie used only for GetWindowCreateContext requests. type GetWindowCreateContextCookie struct { *xgb.Cookie } +// GetWindowCreateContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetWindowCreateContextCookie.Reply() func GetWindowCreateContext(c *xgb.Conn) GetWindowCreateContextCookie { cookie := c.NewCookie(true, true) c.NewRequest(getWindowCreateContextRequest(c), cookie) return GetWindowCreateContextCookie{cookie} } +// GetWindowCreateContextUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetWindowCreateContextUnchecked(c *xgb.Conn) GetWindowCreateContextCookie { cookie := c.NewCookie(false, true) c.NewRequest(getWindowCreateContextRequest(c), cookie) return GetWindowCreateContextCookie{cookie} } -// Request reply for GetWindowCreateContext -// size: (32 + xgb.Pad((int(ContextLen) * 1))) +// GetWindowCreateContextReply represents the data returned from a GetWindowCreateContext request. type GetWindowCreateContextReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes ContextLen uint32 // padding: 20 bytes Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Waits and reads reply data from request GetWindowCreateContext +// Reply blocks and returns the reply data for a GetWindowCreateContext request. func (cook GetWindowCreateContextCookie) Reply() (*GetWindowCreateContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -606,7 +630,7 @@ func (cook GetWindowCreateContextCookie) Reply() (*GetWindowCreateContextReply, return getWindowCreateContextReply(buf), nil } -// Read reply into structure from buffer for GetWindowCreateContext +// getWindowCreateContextReply reads a byte slice into a GetWindowCreateContextReply value. func getWindowCreateContextReply(buf []byte) *GetWindowCreateContextReply { v := new(GetWindowCreateContextReply) b := 1 // skip reply determinant @@ -635,6 +659,7 @@ func getWindowCreateContextReply(buf []byte) *GetWindowCreateContextReply { } // Write request to wire for GetWindowCreateContext +// getWindowCreateContextRequest writes a GetWindowCreateContext request to a byte slice. func getWindowCreateContextRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -652,36 +677,38 @@ func getWindowCreateContextRequest(c *xgb.Conn) []byte { return buf } -// Request GetWindowContext -// size: 8 +// GetWindowContextCookie is a cookie used only for GetWindowContext requests. type GetWindowContextCookie struct { *xgb.Cookie } +// GetWindowContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetWindowContextCookie.Reply() func GetWindowContext(c *xgb.Conn, Window xproto.Window) GetWindowContextCookie { cookie := c.NewCookie(true, true) c.NewRequest(getWindowContextRequest(c, Window), cookie) return GetWindowContextCookie{cookie} } +// GetWindowContextUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetWindowContextUnchecked(c *xgb.Conn, Window xproto.Window) GetWindowContextCookie { cookie := c.NewCookie(false, true) c.NewRequest(getWindowContextRequest(c, Window), cookie) return GetWindowContextCookie{cookie} } -// Request reply for GetWindowContext -// size: (32 + xgb.Pad((int(ContextLen) * 1))) +// GetWindowContextReply represents the data returned from a GetWindowContext request. type GetWindowContextReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes ContextLen uint32 // padding: 20 bytes Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Waits and reads reply data from request GetWindowContext +// Reply blocks and returns the reply data for a GetWindowContext request. func (cook GetWindowContextCookie) Reply() (*GetWindowContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -693,7 +720,7 @@ func (cook GetWindowContextCookie) Reply() (*GetWindowContextReply, error) { return getWindowContextReply(buf), nil } -// Read reply into structure from buffer for GetWindowContext +// getWindowContextReply reads a byte slice into a GetWindowContextReply value. func getWindowContextReply(buf []byte) *GetWindowContextReply { v := new(GetWindowContextReply) b := 1 // skip reply determinant @@ -722,6 +749,7 @@ func getWindowContextReply(buf []byte) *GetWindowContextReply { } // Write request to wire for GetWindowContext +// getWindowContextRequest writes a GetWindowContext request to a byte slice. func getWindowContextRequest(c *xgb.Conn, Window xproto.Window) []byte { size := 8 b := 0 @@ -742,30 +770,35 @@ func getWindowContextRequest(c *xgb.Conn, Window xproto.Window) []byte { return buf } -// Request SetPropertyCreateContext -// size: xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) +// SetPropertyCreateContextCookie is a cookie used only for SetPropertyCreateContext requests. type SetPropertyCreateContextCookie struct { *xgb.Cookie } -// Write request to wire for SetPropertyCreateContext +// SetPropertyCreateContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetPropertyCreateContext(c *xgb.Conn, ContextLen uint32, Context string) SetPropertyCreateContextCookie { cookie := c.NewCookie(false, false) c.NewRequest(setPropertyCreateContextRequest(c, ContextLen, Context), cookie) return SetPropertyCreateContextCookie{cookie} } +// SetPropertyCreateContextChecked sends a checked request. +// If an error occurs, it can be retrieved using SetPropertyCreateContextCookie.Check() func SetPropertyCreateContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetPropertyCreateContextCookie { cookie := c.NewCookie(true, false) c.NewRequest(setPropertyCreateContextRequest(c, ContextLen, Context), cookie) return SetPropertyCreateContextCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetPropertyCreateContextCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetPropertyCreateContext +// setPropertyCreateContextRequest writes a SetPropertyCreateContext request to a byte slice. func setPropertyCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) b := 0 @@ -789,36 +822,38 @@ func setPropertyCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context str return buf } -// Request GetPropertyCreateContext -// size: 4 +// GetPropertyCreateContextCookie is a cookie used only for GetPropertyCreateContext requests. type GetPropertyCreateContextCookie struct { *xgb.Cookie } +// GetPropertyCreateContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPropertyCreateContextCookie.Reply() func GetPropertyCreateContext(c *xgb.Conn) GetPropertyCreateContextCookie { cookie := c.NewCookie(true, true) c.NewRequest(getPropertyCreateContextRequest(c), cookie) return GetPropertyCreateContextCookie{cookie} } +// GetPropertyCreateContextUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetPropertyCreateContextUnchecked(c *xgb.Conn) GetPropertyCreateContextCookie { cookie := c.NewCookie(false, true) c.NewRequest(getPropertyCreateContextRequest(c), cookie) return GetPropertyCreateContextCookie{cookie} } -// Request reply for GetPropertyCreateContext -// size: (32 + xgb.Pad((int(ContextLen) * 1))) +// GetPropertyCreateContextReply represents the data returned from a GetPropertyCreateContext request. type GetPropertyCreateContextReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes ContextLen uint32 // padding: 20 bytes Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Waits and reads reply data from request GetPropertyCreateContext +// Reply blocks and returns the reply data for a GetPropertyCreateContext request. func (cook GetPropertyCreateContextCookie) Reply() (*GetPropertyCreateContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -830,7 +865,7 @@ func (cook GetPropertyCreateContextCookie) Reply() (*GetPropertyCreateContextRep return getPropertyCreateContextReply(buf), nil } -// Read reply into structure from buffer for GetPropertyCreateContext +// getPropertyCreateContextReply reads a byte slice into a GetPropertyCreateContextReply value. func getPropertyCreateContextReply(buf []byte) *GetPropertyCreateContextReply { v := new(GetPropertyCreateContextReply) b := 1 // skip reply determinant @@ -859,6 +894,7 @@ func getPropertyCreateContextReply(buf []byte) *GetPropertyCreateContextReply { } // Write request to wire for GetPropertyCreateContext +// getPropertyCreateContextRequest writes a GetPropertyCreateContext request to a byte slice. func getPropertyCreateContextRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -876,30 +912,35 @@ func getPropertyCreateContextRequest(c *xgb.Conn) []byte { return buf } -// Request SetPropertyUseContext -// size: xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) +// SetPropertyUseContextCookie is a cookie used only for SetPropertyUseContext requests. type SetPropertyUseContextCookie struct { *xgb.Cookie } -// Write request to wire for SetPropertyUseContext +// SetPropertyUseContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetPropertyUseContext(c *xgb.Conn, ContextLen uint32, Context string) SetPropertyUseContextCookie { cookie := c.NewCookie(false, false) c.NewRequest(setPropertyUseContextRequest(c, ContextLen, Context), cookie) return SetPropertyUseContextCookie{cookie} } +// SetPropertyUseContextChecked sends a checked request. +// If an error occurs, it can be retrieved using SetPropertyUseContextCookie.Check() func SetPropertyUseContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetPropertyUseContextCookie { cookie := c.NewCookie(true, false) c.NewRequest(setPropertyUseContextRequest(c, ContextLen, Context), cookie) return SetPropertyUseContextCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetPropertyUseContextCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetPropertyUseContext +// setPropertyUseContextRequest writes a SetPropertyUseContext request to a byte slice. func setPropertyUseContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) b := 0 @@ -923,36 +964,38 @@ func setPropertyUseContextRequest(c *xgb.Conn, ContextLen uint32, Context string return buf } -// Request GetPropertyUseContext -// size: 4 +// GetPropertyUseContextCookie is a cookie used only for GetPropertyUseContext requests. type GetPropertyUseContextCookie struct { *xgb.Cookie } +// GetPropertyUseContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPropertyUseContextCookie.Reply() func GetPropertyUseContext(c *xgb.Conn) GetPropertyUseContextCookie { cookie := c.NewCookie(true, true) c.NewRequest(getPropertyUseContextRequest(c), cookie) return GetPropertyUseContextCookie{cookie} } +// GetPropertyUseContextUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetPropertyUseContextUnchecked(c *xgb.Conn) GetPropertyUseContextCookie { cookie := c.NewCookie(false, true) c.NewRequest(getPropertyUseContextRequest(c), cookie) return GetPropertyUseContextCookie{cookie} } -// Request reply for GetPropertyUseContext -// size: (32 + xgb.Pad((int(ContextLen) * 1))) +// GetPropertyUseContextReply represents the data returned from a GetPropertyUseContext request. type GetPropertyUseContextReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes ContextLen uint32 // padding: 20 bytes Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Waits and reads reply data from request GetPropertyUseContext +// Reply blocks and returns the reply data for a GetPropertyUseContext request. func (cook GetPropertyUseContextCookie) Reply() (*GetPropertyUseContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -964,7 +1007,7 @@ func (cook GetPropertyUseContextCookie) Reply() (*GetPropertyUseContextReply, er return getPropertyUseContextReply(buf), nil } -// Read reply into structure from buffer for GetPropertyUseContext +// getPropertyUseContextReply reads a byte slice into a GetPropertyUseContextReply value. func getPropertyUseContextReply(buf []byte) *GetPropertyUseContextReply { v := new(GetPropertyUseContextReply) b := 1 // skip reply determinant @@ -993,6 +1036,7 @@ func getPropertyUseContextReply(buf []byte) *GetPropertyUseContextReply { } // Write request to wire for GetPropertyUseContext +// getPropertyUseContextRequest writes a GetPropertyUseContext request to a byte slice. func getPropertyUseContextRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -1010,36 +1054,38 @@ func getPropertyUseContextRequest(c *xgb.Conn) []byte { return buf } -// Request GetPropertyContext -// size: 12 +// GetPropertyContextCookie is a cookie used only for GetPropertyContext requests. type GetPropertyContextCookie struct { *xgb.Cookie } +// GetPropertyContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPropertyContextCookie.Reply() func GetPropertyContext(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) GetPropertyContextCookie { cookie := c.NewCookie(true, true) c.NewRequest(getPropertyContextRequest(c, Window, Property), cookie) return GetPropertyContextCookie{cookie} } +// GetPropertyContextUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetPropertyContextUnchecked(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) GetPropertyContextCookie { cookie := c.NewCookie(false, true) c.NewRequest(getPropertyContextRequest(c, Window, Property), cookie) return GetPropertyContextCookie{cookie} } -// Request reply for GetPropertyContext -// size: (32 + xgb.Pad((int(ContextLen) * 1))) +// GetPropertyContextReply represents the data returned from a GetPropertyContext request. type GetPropertyContextReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes ContextLen uint32 // padding: 20 bytes Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Waits and reads reply data from request GetPropertyContext +// Reply blocks and returns the reply data for a GetPropertyContext request. func (cook GetPropertyContextCookie) Reply() (*GetPropertyContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1051,7 +1097,7 @@ func (cook GetPropertyContextCookie) Reply() (*GetPropertyContextReply, error) { return getPropertyContextReply(buf), nil } -// Read reply into structure from buffer for GetPropertyContext +// getPropertyContextReply reads a byte slice into a GetPropertyContextReply value. func getPropertyContextReply(buf []byte) *GetPropertyContextReply { v := new(GetPropertyContextReply) b := 1 // skip reply determinant @@ -1080,6 +1126,7 @@ func getPropertyContextReply(buf []byte) *GetPropertyContextReply { } // Write request to wire for GetPropertyContext +// getPropertyContextRequest writes a GetPropertyContext request to a byte slice. func getPropertyContextRequest(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) []byte { size := 12 b := 0 @@ -1103,36 +1150,38 @@ func getPropertyContextRequest(c *xgb.Conn, Window xproto.Window, Property xprot return buf } -// Request GetPropertyDataContext -// size: 12 +// GetPropertyDataContextCookie is a cookie used only for GetPropertyDataContext requests. type GetPropertyDataContextCookie struct { *xgb.Cookie } +// GetPropertyDataContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPropertyDataContextCookie.Reply() func GetPropertyDataContext(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) GetPropertyDataContextCookie { cookie := c.NewCookie(true, true) c.NewRequest(getPropertyDataContextRequest(c, Window, Property), cookie) return GetPropertyDataContextCookie{cookie} } +// GetPropertyDataContextUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetPropertyDataContextUnchecked(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) GetPropertyDataContextCookie { cookie := c.NewCookie(false, true) c.NewRequest(getPropertyDataContextRequest(c, Window, Property), cookie) return GetPropertyDataContextCookie{cookie} } -// Request reply for GetPropertyDataContext -// size: (32 + xgb.Pad((int(ContextLen) * 1))) +// GetPropertyDataContextReply represents the data returned from a GetPropertyDataContext request. type GetPropertyDataContextReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes ContextLen uint32 // padding: 20 bytes Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Waits and reads reply data from request GetPropertyDataContext +// Reply blocks and returns the reply data for a GetPropertyDataContext request. func (cook GetPropertyDataContextCookie) Reply() (*GetPropertyDataContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1144,7 +1193,7 @@ func (cook GetPropertyDataContextCookie) Reply() (*GetPropertyDataContextReply, return getPropertyDataContextReply(buf), nil } -// Read reply into structure from buffer for GetPropertyDataContext +// getPropertyDataContextReply reads a byte slice into a GetPropertyDataContextReply value. func getPropertyDataContextReply(buf []byte) *GetPropertyDataContextReply { v := new(GetPropertyDataContextReply) b := 1 // skip reply determinant @@ -1173,6 +1222,7 @@ func getPropertyDataContextReply(buf []byte) *GetPropertyDataContextReply { } // Write request to wire for GetPropertyDataContext +// getPropertyDataContextRequest writes a GetPropertyDataContext request to a byte slice. func getPropertyDataContextRequest(c *xgb.Conn, Window xproto.Window, Property xproto.Atom) []byte { size := 12 b := 0 @@ -1196,36 +1246,38 @@ func getPropertyDataContextRequest(c *xgb.Conn, Window xproto.Window, Property x return buf } -// Request ListProperties -// size: 8 +// ListPropertiesCookie is a cookie used only for ListProperties requests. type ListPropertiesCookie struct { *xgb.Cookie } +// ListProperties sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListPropertiesCookie.Reply() func ListProperties(c *xgb.Conn, Window xproto.Window) ListPropertiesCookie { cookie := c.NewCookie(true, true) c.NewRequest(listPropertiesRequest(c, Window), cookie) return ListPropertiesCookie{cookie} } +// ListPropertiesUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ListPropertiesUnchecked(c *xgb.Conn, Window xproto.Window) ListPropertiesCookie { cookie := c.NewCookie(false, true) c.NewRequest(listPropertiesRequest(c, Window), cookie) return ListPropertiesCookie{cookie} } -// Request reply for ListProperties -// size: (32 + ListItemListSize(Properties)) +// ListPropertiesReply represents the data returned from a ListProperties request. type ListPropertiesReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes PropertiesLen uint32 // padding: 20 bytes Properties []ListItem // size: ListItemListSize(Properties) } -// Waits and reads reply data from request ListProperties +// Reply blocks and returns the reply data for a ListProperties request. func (cook ListPropertiesCookie) Reply() (*ListPropertiesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1237,7 +1289,7 @@ func (cook ListPropertiesCookie) Reply() (*ListPropertiesReply, error) { return listPropertiesReply(buf), nil } -// Read reply into structure from buffer for ListProperties +// listPropertiesReply reads a byte slice into a ListPropertiesReply value. func listPropertiesReply(buf []byte) *ListPropertiesReply { v := new(ListPropertiesReply) b := 1 // skip reply determinant @@ -1262,6 +1314,7 @@ func listPropertiesReply(buf []byte) *ListPropertiesReply { } // Write request to wire for ListProperties +// listPropertiesRequest writes a ListProperties request to a byte slice. func listPropertiesRequest(c *xgb.Conn, Window xproto.Window) []byte { size := 8 b := 0 @@ -1282,30 +1335,35 @@ func listPropertiesRequest(c *xgb.Conn, Window xproto.Window) []byte { return buf } -// Request SetSelectionCreateContext -// size: xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) +// SetSelectionCreateContextCookie is a cookie used only for SetSelectionCreateContext requests. type SetSelectionCreateContextCookie struct { *xgb.Cookie } -// Write request to wire for SetSelectionCreateContext +// SetSelectionCreateContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetSelectionCreateContext(c *xgb.Conn, ContextLen uint32, Context string) SetSelectionCreateContextCookie { cookie := c.NewCookie(false, false) c.NewRequest(setSelectionCreateContextRequest(c, ContextLen, Context), cookie) return SetSelectionCreateContextCookie{cookie} } +// SetSelectionCreateContextChecked sends a checked request. +// If an error occurs, it can be retrieved using SetSelectionCreateContextCookie.Check() func SetSelectionCreateContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetSelectionCreateContextCookie { cookie := c.NewCookie(true, false) c.NewRequest(setSelectionCreateContextRequest(c, ContextLen, Context), cookie) return SetSelectionCreateContextCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetSelectionCreateContextCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetSelectionCreateContext +// setSelectionCreateContextRequest writes a SetSelectionCreateContext request to a byte slice. func setSelectionCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) b := 0 @@ -1329,36 +1387,38 @@ func setSelectionCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context st return buf } -// Request GetSelectionCreateContext -// size: 4 +// GetSelectionCreateContextCookie is a cookie used only for GetSelectionCreateContext requests. type GetSelectionCreateContextCookie struct { *xgb.Cookie } +// GetSelectionCreateContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetSelectionCreateContextCookie.Reply() func GetSelectionCreateContext(c *xgb.Conn) GetSelectionCreateContextCookie { cookie := c.NewCookie(true, true) c.NewRequest(getSelectionCreateContextRequest(c), cookie) return GetSelectionCreateContextCookie{cookie} } +// GetSelectionCreateContextUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetSelectionCreateContextUnchecked(c *xgb.Conn) GetSelectionCreateContextCookie { cookie := c.NewCookie(false, true) c.NewRequest(getSelectionCreateContextRequest(c), cookie) return GetSelectionCreateContextCookie{cookie} } -// Request reply for GetSelectionCreateContext -// size: (32 + xgb.Pad((int(ContextLen) * 1))) +// GetSelectionCreateContextReply represents the data returned from a GetSelectionCreateContext request. type GetSelectionCreateContextReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes ContextLen uint32 // padding: 20 bytes Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Waits and reads reply data from request GetSelectionCreateContext +// Reply blocks and returns the reply data for a GetSelectionCreateContext request. func (cook GetSelectionCreateContextCookie) Reply() (*GetSelectionCreateContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1370,7 +1430,7 @@ func (cook GetSelectionCreateContextCookie) Reply() (*GetSelectionCreateContextR return getSelectionCreateContextReply(buf), nil } -// Read reply into structure from buffer for GetSelectionCreateContext +// getSelectionCreateContextReply reads a byte slice into a GetSelectionCreateContextReply value. func getSelectionCreateContextReply(buf []byte) *GetSelectionCreateContextReply { v := new(GetSelectionCreateContextReply) b := 1 // skip reply determinant @@ -1399,6 +1459,7 @@ func getSelectionCreateContextReply(buf []byte) *GetSelectionCreateContextReply } // Write request to wire for GetSelectionCreateContext +// getSelectionCreateContextRequest writes a GetSelectionCreateContext request to a byte slice. func getSelectionCreateContextRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -1416,30 +1477,35 @@ func getSelectionCreateContextRequest(c *xgb.Conn) []byte { return buf } -// Request SetSelectionUseContext -// size: xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) +// SetSelectionUseContextCookie is a cookie used only for SetSelectionUseContext requests. type SetSelectionUseContextCookie struct { *xgb.Cookie } -// Write request to wire for SetSelectionUseContext +// SetSelectionUseContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetSelectionUseContext(c *xgb.Conn, ContextLen uint32, Context string) SetSelectionUseContextCookie { cookie := c.NewCookie(false, false) c.NewRequest(setSelectionUseContextRequest(c, ContextLen, Context), cookie) return SetSelectionUseContextCookie{cookie} } +// SetSelectionUseContextChecked sends a checked request. +// If an error occurs, it can be retrieved using SetSelectionUseContextCookie.Check() func SetSelectionUseContextChecked(c *xgb.Conn, ContextLen uint32, Context string) SetSelectionUseContextCookie { cookie := c.NewCookie(true, false) c.NewRequest(setSelectionUseContextRequest(c, ContextLen, Context), cookie) return SetSelectionUseContextCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetSelectionUseContextCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetSelectionUseContext +// setSelectionUseContextRequest writes a SetSelectionUseContext request to a byte slice. func setSelectionUseContextRequest(c *xgb.Conn, ContextLen uint32, Context string) []byte { size := xgb.Pad((8 + xgb.Pad((int(ContextLen) * 1)))) b := 0 @@ -1463,36 +1529,38 @@ func setSelectionUseContextRequest(c *xgb.Conn, ContextLen uint32, Context strin return buf } -// Request GetSelectionUseContext -// size: 4 +// GetSelectionUseContextCookie is a cookie used only for GetSelectionUseContext requests. type GetSelectionUseContextCookie struct { *xgb.Cookie } +// GetSelectionUseContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetSelectionUseContextCookie.Reply() func GetSelectionUseContext(c *xgb.Conn) GetSelectionUseContextCookie { cookie := c.NewCookie(true, true) c.NewRequest(getSelectionUseContextRequest(c), cookie) return GetSelectionUseContextCookie{cookie} } +// GetSelectionUseContextUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetSelectionUseContextUnchecked(c *xgb.Conn) GetSelectionUseContextCookie { cookie := c.NewCookie(false, true) c.NewRequest(getSelectionUseContextRequest(c), cookie) return GetSelectionUseContextCookie{cookie} } -// Request reply for GetSelectionUseContext -// size: (32 + xgb.Pad((int(ContextLen) * 1))) +// GetSelectionUseContextReply represents the data returned from a GetSelectionUseContext request. type GetSelectionUseContextReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes ContextLen uint32 // padding: 20 bytes Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Waits and reads reply data from request GetSelectionUseContext +// Reply blocks and returns the reply data for a GetSelectionUseContext request. func (cook GetSelectionUseContextCookie) Reply() (*GetSelectionUseContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1504,7 +1572,7 @@ func (cook GetSelectionUseContextCookie) Reply() (*GetSelectionUseContextReply, return getSelectionUseContextReply(buf), nil } -// Read reply into structure from buffer for GetSelectionUseContext +// getSelectionUseContextReply reads a byte slice into a GetSelectionUseContextReply value. func getSelectionUseContextReply(buf []byte) *GetSelectionUseContextReply { v := new(GetSelectionUseContextReply) b := 1 // skip reply determinant @@ -1533,6 +1601,7 @@ func getSelectionUseContextReply(buf []byte) *GetSelectionUseContextReply { } // Write request to wire for GetSelectionUseContext +// getSelectionUseContextRequest writes a GetSelectionUseContext request to a byte slice. func getSelectionUseContextRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -1550,36 +1619,38 @@ func getSelectionUseContextRequest(c *xgb.Conn) []byte { return buf } -// Request GetSelectionContext -// size: 8 +// GetSelectionContextCookie is a cookie used only for GetSelectionContext requests. type GetSelectionContextCookie struct { *xgb.Cookie } +// GetSelectionContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetSelectionContextCookie.Reply() func GetSelectionContext(c *xgb.Conn, Selection xproto.Atom) GetSelectionContextCookie { cookie := c.NewCookie(true, true) c.NewRequest(getSelectionContextRequest(c, Selection), cookie) return GetSelectionContextCookie{cookie} } +// GetSelectionContextUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetSelectionContextUnchecked(c *xgb.Conn, Selection xproto.Atom) GetSelectionContextCookie { cookie := c.NewCookie(false, true) c.NewRequest(getSelectionContextRequest(c, Selection), cookie) return GetSelectionContextCookie{cookie} } -// Request reply for GetSelectionContext -// size: (32 + xgb.Pad((int(ContextLen) * 1))) +// GetSelectionContextReply represents the data returned from a GetSelectionContext request. type GetSelectionContextReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes ContextLen uint32 // padding: 20 bytes Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Waits and reads reply data from request GetSelectionContext +// Reply blocks and returns the reply data for a GetSelectionContext request. func (cook GetSelectionContextCookie) Reply() (*GetSelectionContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1591,7 +1662,7 @@ func (cook GetSelectionContextCookie) Reply() (*GetSelectionContextReply, error) return getSelectionContextReply(buf), nil } -// Read reply into structure from buffer for GetSelectionContext +// getSelectionContextReply reads a byte slice into a GetSelectionContextReply value. func getSelectionContextReply(buf []byte) *GetSelectionContextReply { v := new(GetSelectionContextReply) b := 1 // skip reply determinant @@ -1620,6 +1691,7 @@ func getSelectionContextReply(buf []byte) *GetSelectionContextReply { } // Write request to wire for GetSelectionContext +// getSelectionContextRequest writes a GetSelectionContext request to a byte slice. func getSelectionContextRequest(c *xgb.Conn, Selection xproto.Atom) []byte { size := 8 b := 0 @@ -1640,36 +1712,38 @@ func getSelectionContextRequest(c *xgb.Conn, Selection xproto.Atom) []byte { return buf } -// Request GetSelectionDataContext -// size: 8 +// GetSelectionDataContextCookie is a cookie used only for GetSelectionDataContext requests. type GetSelectionDataContextCookie struct { *xgb.Cookie } +// GetSelectionDataContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetSelectionDataContextCookie.Reply() func GetSelectionDataContext(c *xgb.Conn, Selection xproto.Atom) GetSelectionDataContextCookie { cookie := c.NewCookie(true, true) c.NewRequest(getSelectionDataContextRequest(c, Selection), cookie) return GetSelectionDataContextCookie{cookie} } +// GetSelectionDataContextUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetSelectionDataContextUnchecked(c *xgb.Conn, Selection xproto.Atom) GetSelectionDataContextCookie { cookie := c.NewCookie(false, true) c.NewRequest(getSelectionDataContextRequest(c, Selection), cookie) return GetSelectionDataContextCookie{cookie} } -// Request reply for GetSelectionDataContext -// size: (32 + xgb.Pad((int(ContextLen) * 1))) +// GetSelectionDataContextReply represents the data returned from a GetSelectionDataContext request. type GetSelectionDataContextReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes ContextLen uint32 // padding: 20 bytes Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Waits and reads reply data from request GetSelectionDataContext +// Reply blocks and returns the reply data for a GetSelectionDataContext request. func (cook GetSelectionDataContextCookie) Reply() (*GetSelectionDataContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1681,7 +1755,7 @@ func (cook GetSelectionDataContextCookie) Reply() (*GetSelectionDataContextReply return getSelectionDataContextReply(buf), nil } -// Read reply into structure from buffer for GetSelectionDataContext +// getSelectionDataContextReply reads a byte slice into a GetSelectionDataContextReply value. func getSelectionDataContextReply(buf []byte) *GetSelectionDataContextReply { v := new(GetSelectionDataContextReply) b := 1 // skip reply determinant @@ -1710,6 +1784,7 @@ func getSelectionDataContextReply(buf []byte) *GetSelectionDataContextReply { } // Write request to wire for GetSelectionDataContext +// getSelectionDataContextRequest writes a GetSelectionDataContext request to a byte slice. func getSelectionDataContextRequest(c *xgb.Conn, Selection xproto.Atom) []byte { size := 8 b := 0 @@ -1730,36 +1805,38 @@ func getSelectionDataContextRequest(c *xgb.Conn, Selection xproto.Atom) []byte { return buf } -// Request ListSelections -// size: 4 +// ListSelectionsCookie is a cookie used only for ListSelections requests. type ListSelectionsCookie struct { *xgb.Cookie } +// ListSelections sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListSelectionsCookie.Reply() func ListSelections(c *xgb.Conn) ListSelectionsCookie { cookie := c.NewCookie(true, true) c.NewRequest(listSelectionsRequest(c), cookie) return ListSelectionsCookie{cookie} } +// ListSelectionsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ListSelectionsUnchecked(c *xgb.Conn) ListSelectionsCookie { cookie := c.NewCookie(false, true) c.NewRequest(listSelectionsRequest(c), cookie) return ListSelectionsCookie{cookie} } -// Request reply for ListSelections -// size: (32 + ListItemListSize(Selections)) +// ListSelectionsReply represents the data returned from a ListSelections request. type ListSelectionsReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes SelectionsLen uint32 // padding: 20 bytes Selections []ListItem // size: ListItemListSize(Selections) } -// Waits and reads reply data from request ListSelections +// Reply blocks and returns the reply data for a ListSelections request. func (cook ListSelectionsCookie) Reply() (*ListSelectionsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1771,7 +1848,7 @@ func (cook ListSelectionsCookie) Reply() (*ListSelectionsReply, error) { return listSelectionsReply(buf), nil } -// Read reply into structure from buffer for ListSelections +// listSelectionsReply reads a byte slice into a ListSelectionsReply value. func listSelectionsReply(buf []byte) *ListSelectionsReply { v := new(ListSelectionsReply) b := 1 // skip reply determinant @@ -1796,6 +1873,7 @@ func listSelectionsReply(buf []byte) *ListSelectionsReply { } // Write request to wire for ListSelections +// listSelectionsRequest writes a ListSelections request to a byte slice. func listSelectionsRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -1813,36 +1891,38 @@ func listSelectionsRequest(c *xgb.Conn) []byte { return buf } -// Request GetClientContext -// size: 8 +// GetClientContextCookie is a cookie used only for GetClientContext requests. type GetClientContextCookie struct { *xgb.Cookie } +// GetClientContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetClientContextCookie.Reply() func GetClientContext(c *xgb.Conn, Resource uint32) GetClientContextCookie { cookie := c.NewCookie(true, true) c.NewRequest(getClientContextRequest(c, Resource), cookie) return GetClientContextCookie{cookie} } +// GetClientContextUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetClientContextUnchecked(c *xgb.Conn, Resource uint32) GetClientContextCookie { cookie := c.NewCookie(false, true) c.NewRequest(getClientContextRequest(c, Resource), cookie) return GetClientContextCookie{cookie} } -// Request reply for GetClientContext -// size: (32 + xgb.Pad((int(ContextLen) * 1))) +// GetClientContextReply represents the data returned from a GetClientContext request. type GetClientContextReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes ContextLen uint32 // padding: 20 bytes Context string // size: xgb.Pad((int(ContextLen) * 1)) } -// Waits and reads reply data from request GetClientContext +// Reply blocks and returns the reply data for a GetClientContext request. func (cook GetClientContextCookie) Reply() (*GetClientContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1854,7 +1934,7 @@ func (cook GetClientContextCookie) Reply() (*GetClientContextReply, error) { return getClientContextReply(buf), nil } -// Read reply into structure from buffer for GetClientContext +// getClientContextReply reads a byte slice into a GetClientContextReply value. func getClientContextReply(buf []byte) *GetClientContextReply { v := new(GetClientContextReply) b := 1 // skip reply determinant @@ -1883,6 +1963,7 @@ func getClientContextReply(buf []byte) *GetClientContextReply { } // Write request to wire for GetClientContext +// getClientContextRequest writes a GetClientContext request to a byte slice. func getClientContextRequest(c *xgb.Conn, Resource uint32) []byte { size := 8 b := 0 diff --git a/nexgb/xtest/xtest.go b/nexgb/xtest/xtest.go index 357b325..e2a2d80 100644 --- a/nexgb/xtest/xtest.go +++ b/nexgb/xtest/xtest.go @@ -2,7 +2,7 @@ package xtest /* - This file was generated by xtest.xml on May 10 2012 8:04:33pm EDT. + This file was generated by xtest.xml on May 10 2012 11:56:20pm EDT. This file is automatically generated. Edit at your peril! */ @@ -69,34 +69,36 @@ const ( CursorCurrent = 1 ) -// Request GetVersion -// size: 8 +// GetVersionCookie is a cookie used only for GetVersion requests. type GetVersionCookie struct { *xgb.Cookie } +// GetVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetVersionCookie.Reply() func GetVersion(c *xgb.Conn, MajorVersion byte, MinorVersion uint16) GetVersionCookie { cookie := c.NewCookie(true, true) c.NewRequest(getVersionRequest(c, MajorVersion, MinorVersion), cookie) return GetVersionCookie{cookie} } +// GetVersionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetVersionUnchecked(c *xgb.Conn, MajorVersion byte, MinorVersion uint16) GetVersionCookie { cookie := c.NewCookie(false, true) c.NewRequest(getVersionRequest(c, MajorVersion, MinorVersion), cookie) return GetVersionCookie{cookie} } -// Request reply for GetVersion -// size: 10 +// GetVersionReply represents the data returned from a GetVersion request. type GetVersionReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply MajorVersion byte MinorVersion uint16 } -// Waits and reads reply data from request GetVersion +// Reply blocks and returns the reply data for a GetVersion request. func (cook GetVersionCookie) Reply() (*GetVersionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -108,7 +110,7 @@ func (cook GetVersionCookie) Reply() (*GetVersionReply, error) { return getVersionReply(buf), nil } -// Read reply into structure from buffer for GetVersion +// getVersionReply reads a byte slice into a GetVersionReply value. func getVersionReply(buf []byte) *GetVersionReply { v := new(GetVersionReply) b := 1 // skip reply determinant @@ -129,6 +131,7 @@ func getVersionReply(buf []byte) *GetVersionReply { } // Write request to wire for GetVersion +// getVersionRequest writes a GetVersion request to a byte slice. func getVersionRequest(c *xgb.Conn, MajorVersion byte, MinorVersion uint16) []byte { size := 8 b := 0 @@ -154,33 +157,35 @@ func getVersionRequest(c *xgb.Conn, MajorVersion byte, MinorVersion uint16) []by return buf } -// Request CompareCursor -// size: 12 +// CompareCursorCookie is a cookie used only for CompareCursor requests. type CompareCursorCookie struct { *xgb.Cookie } +// CompareCursor sends a checked request. +// If an error occurs, it will be returned with the reply by calling CompareCursorCookie.Reply() func CompareCursor(c *xgb.Conn, Window xproto.Window, Cursor xproto.Cursor) CompareCursorCookie { cookie := c.NewCookie(true, true) c.NewRequest(compareCursorRequest(c, Window, Cursor), cookie) return CompareCursorCookie{cookie} } +// CompareCursorUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CompareCursorUnchecked(c *xgb.Conn, Window xproto.Window, Cursor xproto.Cursor) CompareCursorCookie { cookie := c.NewCookie(false, true) c.NewRequest(compareCursorRequest(c, Window, Cursor), cookie) return CompareCursorCookie{cookie} } -// Request reply for CompareCursor -// size: 8 +// CompareCursorReply represents the data returned from a CompareCursor request. type CompareCursorReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply Same bool } -// Waits and reads reply data from request CompareCursor +// Reply blocks and returns the reply data for a CompareCursor request. func (cook CompareCursorCookie) Reply() (*CompareCursorReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -192,7 +197,7 @@ func (cook CompareCursorCookie) Reply() (*CompareCursorReply, error) { return compareCursorReply(buf), nil } -// Read reply into structure from buffer for CompareCursor +// compareCursorReply reads a byte slice into a CompareCursorReply value. func compareCursorReply(buf []byte) *CompareCursorReply { v := new(CompareCursorReply) b := 1 // skip reply determinant @@ -214,6 +219,7 @@ func compareCursorReply(buf []byte) *CompareCursorReply { } // Write request to wire for CompareCursor +// compareCursorRequest writes a CompareCursor request to a byte slice. func compareCursorRequest(c *xgb.Conn, Window xproto.Window, Cursor xproto.Cursor) []byte { size := 12 b := 0 @@ -237,30 +243,35 @@ func compareCursorRequest(c *xgb.Conn, Window xproto.Window, Cursor xproto.Curso return buf } -// Request FakeInput -// size: 36 +// FakeInputCookie is a cookie used only for FakeInput requests. type FakeInputCookie struct { *xgb.Cookie } -// Write request to wire for FakeInput +// FakeInput sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func FakeInput(c *xgb.Conn, Type byte, Detail byte, Time uint32, Root xproto.Window, RootX int16, RootY int16, Deviceid byte) FakeInputCookie { cookie := c.NewCookie(false, false) c.NewRequest(fakeInputRequest(c, Type, Detail, Time, Root, RootX, RootY, Deviceid), cookie) return FakeInputCookie{cookie} } +// FakeInputChecked sends a checked request. +// If an error occurs, it can be retrieved using FakeInputCookie.Check() func FakeInputChecked(c *xgb.Conn, Type byte, Detail byte, Time uint32, Root xproto.Window, RootX int16, RootY int16, Deviceid byte) FakeInputCookie { cookie := c.NewCookie(true, false) c.NewRequest(fakeInputRequest(c, Type, Detail, Time, Root, RootX, RootY, Deviceid), cookie) return FakeInputCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook FakeInputCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for FakeInput +// fakeInputRequest writes a FakeInput request to a byte slice. func fakeInputRequest(c *xgb.Conn, Type byte, Detail byte, Time uint32, Root xproto.Window, RootX int16, RootY int16, Deviceid byte) []byte { size := 36 b := 0 @@ -305,30 +316,35 @@ func fakeInputRequest(c *xgb.Conn, Type byte, Detail byte, Time uint32, Root xpr return buf } -// Request GrabControl -// size: 8 +// GrabControlCookie is a cookie used only for GrabControl requests. type GrabControlCookie struct { *xgb.Cookie } -// Write request to wire for GrabControl +// GrabControl sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GrabControl(c *xgb.Conn, Impervious bool) GrabControlCookie { cookie := c.NewCookie(false, false) c.NewRequest(grabControlRequest(c, Impervious), cookie) return GrabControlCookie{cookie} } +// GrabControlChecked sends a checked request. +// If an error occurs, it can be retrieved using GrabControlCookie.Check() func GrabControlChecked(c *xgb.Conn, Impervious bool) GrabControlCookie { cookie := c.NewCookie(true, false) c.NewRequest(grabControlRequest(c, Impervious), cookie) return GrabControlCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook GrabControlCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for GrabControl +// grabControlRequest writes a GrabControl request to a byte slice. func grabControlRequest(c *xgb.Conn, Impervious bool) []byte { size := 8 b := 0 diff --git a/nexgb/xv/xv.go b/nexgb/xv/xv.go index 4e495cf..041b082 100644 --- a/nexgb/xv/xv.go +++ b/nexgb/xv/xv.go @@ -2,7 +2,7 @@ package xv /* - This file was generated by xv.xml on May 10 2012 8:04:33pm EDT. + This file was generated by xv.xml on May 10 2012 11:56:20pm EDT. This file is automatically generated. Edit at your peril! */ @@ -41,10 +41,6 @@ func init() { xgb.NewExtErrorFuncs["XVideo"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Int8' - -// Skipping definition for base type 'Card16' - // Skipping definition for base type 'Char' // Skipping definition for base type 'Card32' @@ -65,6 +61,10 @@ func init() { // Skipping definition for base type 'Byte' +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + const ( TypeInputMask = 1 TypeOutputMask = 2 @@ -130,14 +130,12 @@ func NewEncodingId(c *xgb.Conn) (Encoding, error) { return Encoding(id), nil } -// 'Rational' struct definition -// Size: 8 type Rational struct { Numerator int32 Denominator int32 } -// Struct read Rational +// RationalRead reads a byte slice into a Rational value. func RationalRead(buf []byte, v *Rational) int { b := 0 @@ -150,7 +148,7 @@ func RationalRead(buf []byte, v *Rational) int { return b } -// Struct list read Rational +// RationalReadList reads a byte slice into a list of Rational values. func RationalReadList(buf []byte, dest []Rational) int { b := 0 for i := 0; i < len(dest); i++ { @@ -160,7 +158,7 @@ func RationalReadList(buf []byte, dest []Rational) int { return xgb.Pad(b) } -// Struct write Rational +// Bytes writes a Rational value to a byte slice. func (v Rational) Bytes() []byte { buf := make([]byte, 8) b := 0 @@ -174,7 +172,7 @@ func (v Rational) Bytes() []byte { return buf } -// Write struct list Rational +// RationalListBytes writes a list of %s(MISSING) values to a byte slice. func RationalListBytes(buf []byte, list []Rational) int { b := 0 var structBytes []byte @@ -186,15 +184,13 @@ func RationalListBytes(buf []byte, list []Rational) int { return b } -// 'Format' struct definition -// Size: 8 type Format struct { Visual xproto.Visualid Depth byte // padding: 3 bytes } -// Struct read Format +// FormatRead reads a byte slice into a Format value. func FormatRead(buf []byte, v *Format) int { b := 0 @@ -209,7 +205,7 @@ func FormatRead(buf []byte, v *Format) int { return b } -// Struct list read Format +// FormatReadList reads a byte slice into a list of Format values. func FormatReadList(buf []byte, dest []Format) int { b := 0 for i := 0; i < len(dest); i++ { @@ -219,7 +215,7 @@ func FormatReadList(buf []byte, dest []Format) int { return xgb.Pad(b) } -// Struct write Format +// Bytes writes a Format value to a byte slice. func (v Format) Bytes() []byte { buf := make([]byte, 8) b := 0 @@ -235,7 +231,7 @@ func (v Format) Bytes() []byte { return buf } -// Write struct list Format +// FormatListBytes writes a list of %s(MISSING) values to a byte slice. func FormatListBytes(buf []byte, list []Format) int { b := 0 var structBytes []byte @@ -247,8 +243,6 @@ func FormatListBytes(buf []byte, list []Format) int { return b } -// 'AdaptorInfo' struct definition -// Size: ((12 + xgb.Pad((int(NameSize) * 1))) + xgb.Pad((int(NumFormats) * 8))) type AdaptorInfo struct { BaseId Port NameSize uint16 @@ -260,7 +254,7 @@ type AdaptorInfo struct { Formats []Format // size: xgb.Pad((int(NumFormats) * 8)) } -// Struct read AdaptorInfo +// AdaptorInfoRead reads a byte slice into a AdaptorInfo value. func AdaptorInfoRead(buf []byte, v *AdaptorInfo) int { b := 0 @@ -294,7 +288,7 @@ func AdaptorInfoRead(buf []byte, v *AdaptorInfo) int { return b } -// Struct list read AdaptorInfo +// AdaptorInfoReadList reads a byte slice into a list of AdaptorInfo values. func AdaptorInfoReadList(buf []byte, dest []AdaptorInfo) int { b := 0 for i := 0; i < len(dest); i++ { @@ -304,7 +298,7 @@ func AdaptorInfoReadList(buf []byte, dest []AdaptorInfo) int { return xgb.Pad(b) } -// Struct write AdaptorInfo +// Bytes writes a AdaptorInfo value to a byte slice. func (v AdaptorInfo) Bytes() []byte { buf := make([]byte, ((12 + xgb.Pad((int(v.NameSize) * 1))) + xgb.Pad((int(v.NumFormats) * 8)))) b := 0 @@ -334,7 +328,7 @@ func (v AdaptorInfo) Bytes() []byte { return buf } -// Write struct list AdaptorInfo +// AdaptorInfoListBytes writes a list of %s(MISSING) values to a byte slice. func AdaptorInfoListBytes(buf []byte, list []AdaptorInfo) int { b := 0 var structBytes []byte @@ -346,7 +340,7 @@ func AdaptorInfoListBytes(buf []byte, list []AdaptorInfo) int { return b } -// Struct list size AdaptorInfo +// AdaptorInfoListSize computes the size (bytes) of a list of AdaptorInfo values. func AdaptorInfoListSize(list []AdaptorInfo) int { size := 0 for _, item := range list { @@ -355,8 +349,6 @@ func AdaptorInfoListSize(list []AdaptorInfo) int { return size } -// 'EncodingInfo' struct definition -// Size: (20 + xgb.Pad((int(NameSize) * 1))) type EncodingInfo struct { Encoding Encoding NameSize uint16 @@ -367,7 +359,7 @@ type EncodingInfo struct { Name string // size: xgb.Pad((int(NameSize) * 1)) } -// Struct read EncodingInfo +// EncodingInfoRead reads a byte slice into a EncodingInfo value. func EncodingInfoRead(buf []byte, v *EncodingInfo) int { b := 0 @@ -398,7 +390,7 @@ func EncodingInfoRead(buf []byte, v *EncodingInfo) int { return b } -// Struct list read EncodingInfo +// EncodingInfoReadList reads a byte slice into a list of EncodingInfo values. func EncodingInfoReadList(buf []byte, dest []EncodingInfo) int { b := 0 for i := 0; i < len(dest); i++ { @@ -408,7 +400,7 @@ func EncodingInfoReadList(buf []byte, dest []EncodingInfo) int { return xgb.Pad(b) } -// Struct write EncodingInfo +// Bytes writes a EncodingInfo value to a byte slice. func (v EncodingInfo) Bytes() []byte { buf := make([]byte, (20 + xgb.Pad((int(v.NameSize) * 1)))) b := 0 @@ -439,7 +431,7 @@ func (v EncodingInfo) Bytes() []byte { return buf } -// Write struct list EncodingInfo +// EncodingInfoListBytes writes a list of %s(MISSING) values to a byte slice. func EncodingInfoListBytes(buf []byte, list []EncodingInfo) int { b := 0 var structBytes []byte @@ -451,7 +443,7 @@ func EncodingInfoListBytes(buf []byte, list []EncodingInfo) int { return b } -// Struct list size EncodingInfo +// EncodingInfoListSize computes the size (bytes) of a list of EncodingInfo values. func EncodingInfoListSize(list []EncodingInfo) int { size := 0 for _, item := range list { @@ -460,8 +452,6 @@ func EncodingInfoListSize(list []EncodingInfo) int { return size } -// 'Image' struct definition -// Size: (((16 + xgb.Pad((int(NumPlanes) * 4))) + xgb.Pad((int(NumPlanes) * 4))) + xgb.Pad((int(DataSize) * 1))) type Image struct { Id uint32 Width uint16 @@ -473,7 +463,7 @@ type Image struct { Data []byte // size: xgb.Pad((int(DataSize) * 1)) } -// Struct read Image +// ImageRead reads a byte slice into a Image value. func ImageRead(buf []byte, v *Image) int { b := 0 @@ -513,7 +503,7 @@ func ImageRead(buf []byte, v *Image) int { return b } -// Struct list read Image +// ImageReadList reads a byte slice into a list of Image values. func ImageReadList(buf []byte, dest []Image) int { b := 0 for i := 0; i < len(dest); i++ { @@ -523,7 +513,7 @@ func ImageReadList(buf []byte, dest []Image) int { return xgb.Pad(b) } -// Struct write Image +// Bytes writes a Image value to a byte slice. func (v Image) Bytes() []byte { buf := make([]byte, (((16 + xgb.Pad((int(v.NumPlanes) * 4))) + xgb.Pad((int(v.NumPlanes) * 4))) + xgb.Pad((int(v.DataSize) * 1)))) b := 0 @@ -561,7 +551,7 @@ func (v Image) Bytes() []byte { return buf } -// Write struct list Image +// ImageListBytes writes a list of %s(MISSING) values to a byte slice. func ImageListBytes(buf []byte, list []Image) int { b := 0 var structBytes []byte @@ -573,7 +563,7 @@ func ImageListBytes(buf []byte, list []Image) int { return b } -// Struct list size Image +// ImageListSize computes the size (bytes) of a list of Image values. func ImageListSize(list []Image) int { size := 0 for _, item := range list { @@ -582,8 +572,6 @@ func ImageListSize(list []Image) int { return size } -// 'AttributeInfo' struct definition -// Size: (16 + xgb.Pad((int(Size) * 1))) type AttributeInfo struct { Flags uint32 Min int32 @@ -592,7 +580,7 @@ type AttributeInfo struct { Name string // size: xgb.Pad((int(Size) * 1)) } -// Struct read AttributeInfo +// AttributeInfoRead reads a byte slice into a AttributeInfo value. func AttributeInfoRead(buf []byte, v *AttributeInfo) int { b := 0 @@ -618,7 +606,7 @@ func AttributeInfoRead(buf []byte, v *AttributeInfo) int { return b } -// Struct list read AttributeInfo +// AttributeInfoReadList reads a byte slice into a list of AttributeInfo values. func AttributeInfoReadList(buf []byte, dest []AttributeInfo) int { b := 0 for i := 0; i < len(dest); i++ { @@ -628,7 +616,7 @@ func AttributeInfoReadList(buf []byte, dest []AttributeInfo) int { return xgb.Pad(b) } -// Struct write AttributeInfo +// Bytes writes a AttributeInfo value to a byte slice. func (v AttributeInfo) Bytes() []byte { buf := make([]byte, (16 + xgb.Pad((int(v.Size) * 1)))) b := 0 @@ -651,7 +639,7 @@ func (v AttributeInfo) Bytes() []byte { return buf } -// Write struct list AttributeInfo +// AttributeInfoListBytes writes a list of %s(MISSING) values to a byte slice. func AttributeInfoListBytes(buf []byte, list []AttributeInfo) int { b := 0 var structBytes []byte @@ -663,7 +651,7 @@ func AttributeInfoListBytes(buf []byte, list []AttributeInfo) int { return b } -// Struct list size AttributeInfo +// AttributeInfoListSize computes the size (bytes) of a list of AttributeInfo values. func AttributeInfoListSize(list []AttributeInfo) int { size := 0 for _, item := range list { @@ -672,8 +660,6 @@ func AttributeInfoListSize(list []AttributeInfo) int { return size } -// 'ImageFormatInfo' struct definition -// Size: 128 type ImageFormatInfo struct { Id uint32 Type byte @@ -704,7 +690,7 @@ type ImageFormatInfo struct { // padding: 11 bytes } -// Struct read ImageFormatInfo +// ImageFormatInfoRead reads a byte slice into a ImageFormatInfo value. func ImageFormatInfoRead(buf []byte, v *ImageFormatInfo) int { b := 0 @@ -789,7 +775,7 @@ func ImageFormatInfoRead(buf []byte, v *ImageFormatInfo) int { return b } -// Struct list read ImageFormatInfo +// ImageFormatInfoReadList reads a byte slice into a list of ImageFormatInfo values. func ImageFormatInfoReadList(buf []byte, dest []ImageFormatInfo) int { b := 0 for i := 0; i < len(dest); i++ { @@ -799,7 +785,7 @@ func ImageFormatInfoReadList(buf []byte, dest []ImageFormatInfo) int { return xgb.Pad(b) } -// Struct write ImageFormatInfo +// Bytes writes a ImageFormatInfo value to a byte slice. func (v ImageFormatInfo) Bytes() []byte { buf := make([]byte, 128) b := 0 @@ -883,7 +869,7 @@ func (v ImageFormatInfo) Bytes() []byte { return buf } -// Write struct list ImageFormatInfo +// ImageFormatInfoListBytes writes a list of %s(MISSING) values to a byte slice. func ImageFormatInfoListBytes(buf []byte, list []ImageFormatInfo) int { b := 0 var structBytes []byte @@ -895,7 +881,7 @@ func ImageFormatInfoListBytes(buf []byte, list []ImageFormatInfo) int { return b } -// Struct list size ImageFormatInfo +// ImageFormatInfoListSize computes the size (bytes) of a list of ImageFormatInfo values. func ImageFormatInfoListSize(list []ImageFormatInfo) int { size := 0 for _ = range list { @@ -904,9 +890,7 @@ func ImageFormatInfoListSize(list []ImageFormatInfo) int { return size } -// Event definition VideoNotify (0) -// Size: 32 - +// VideoNotify is the event number for a VideoNotifyEvent. const VideoNotify = 0 type VideoNotifyEvent struct { @@ -917,7 +901,7 @@ type VideoNotifyEvent struct { Port Port } -// Event read VideoNotify +// VideoNotifyEventNew constructs a VideoNotifyEvent value that implements xgb.Event from a byte slice. func VideoNotifyEventNew(buf []byte) xgb.Event { v := VideoNotifyEvent{} b := 1 // don't read event number @@ -940,7 +924,7 @@ func VideoNotifyEventNew(buf []byte) xgb.Event { return v } -// Event write VideoNotify +// Bytes writes a VideoNotifyEvent value to a byte slice. func (v VideoNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -966,12 +950,14 @@ func (v VideoNotifyEvent) Bytes() []byte { return buf } -func (v VideoNotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the VideoNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v VideoNotifyEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of VideoNotifyEvent. func (v VideoNotifyEvent) String() string { fieldVals := make([]string, 0, 4) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -986,9 +972,7 @@ func init() { xgb.NewExtEventFuncs["XVideo"][0] = VideoNotifyEventNew } -// Event definition PortNotify (1) -// Size: 32 - +// PortNotify is the event number for a PortNotifyEvent. const PortNotify = 1 type PortNotifyEvent struct { @@ -1000,7 +984,7 @@ type PortNotifyEvent struct { Value int32 } -// Event read PortNotify +// PortNotifyEventNew constructs a PortNotifyEvent value that implements xgb.Event from a byte slice. func PortNotifyEventNew(buf []byte) xgb.Event { v := PortNotifyEvent{} b := 1 // don't read event number @@ -1025,7 +1009,7 @@ func PortNotifyEventNew(buf []byte) xgb.Event { return v } -// Event write PortNotify +// Bytes writes a PortNotifyEvent value to a byte slice. func (v PortNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -1053,12 +1037,14 @@ func (v PortNotifyEvent) Bytes() []byte { return buf } -func (v PortNotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the PortNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v PortNotifyEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of PortNotifyEvent. func (v PortNotifyEvent) String() string { fieldVals := make([]string, 0, 5) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -1073,9 +1059,7 @@ func init() { xgb.NewExtEventFuncs["XVideo"][1] = PortNotifyEventNew } -// Error definition BadPort (0) -// Size: 32 - +// BadBadPort is the error number for a BadBadPort. const BadBadPort = 0 type BadPortError struct { @@ -1083,7 +1067,7 @@ type BadPortError struct { NiceName string } -// Error read BadPort +// BadPortErrorNew constructs a BadPortError value that implements xgb.Error from a byte slice. func BadPortErrorNew(buf []byte) xgb.Error { v := BadPortError{} v.NiceName = "BadPort" @@ -1097,8 +1081,8 @@ func BadPortErrorNew(buf []byte) xgb.Error { return v } -func (err BadPortError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadBadPort error. +// This is mostly used internally. func (err BadPortError) SequenceId() uint16 { return err.Sequence } @@ -1118,9 +1102,7 @@ func init() { xgb.NewExtErrorFuncs["XVideo"][0] = BadPortErrorNew } -// Error definition BadEncoding (1) -// Size: 32 - +// BadBadEncoding is the error number for a BadBadEncoding. const BadBadEncoding = 1 type BadEncodingError struct { @@ -1128,7 +1110,7 @@ type BadEncodingError struct { NiceName string } -// Error read BadEncoding +// BadEncodingErrorNew constructs a BadEncodingError value that implements xgb.Error from a byte slice. func BadEncodingErrorNew(buf []byte) xgb.Error { v := BadEncodingError{} v.NiceName = "BadEncoding" @@ -1142,8 +1124,8 @@ func BadEncodingErrorNew(buf []byte) xgb.Error { return v } -func (err BadEncodingError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadBadEncoding error. +// This is mostly used internally. func (err BadEncodingError) SequenceId() uint16 { return err.Sequence } @@ -1163,9 +1145,7 @@ func init() { xgb.NewExtErrorFuncs["XVideo"][1] = BadEncodingErrorNew } -// Error definition BadControl (2) -// Size: 32 - +// BadBadControl is the error number for a BadBadControl. const BadBadControl = 2 type BadControlError struct { @@ -1173,7 +1153,7 @@ type BadControlError struct { NiceName string } -// Error read BadControl +// BadControlErrorNew constructs a BadControlError value that implements xgb.Error from a byte slice. func BadControlErrorNew(buf []byte) xgb.Error { v := BadControlError{} v.NiceName = "BadControl" @@ -1187,8 +1167,8 @@ func BadControlErrorNew(buf []byte) xgb.Error { return v } -func (err BadControlError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadBadControl error. +// This is mostly used internally. func (err BadControlError) SequenceId() uint16 { return err.Sequence } @@ -1208,35 +1188,37 @@ func init() { xgb.NewExtErrorFuncs["XVideo"][2] = BadControlErrorNew } -// Request QueryExtension -// size: 4 +// QueryExtensionCookie is a cookie used only for QueryExtension requests. type QueryExtensionCookie struct { *xgb.Cookie } +// QueryExtension sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryExtensionCookie.Reply() func QueryExtension(c *xgb.Conn) QueryExtensionCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryExtensionRequest(c), cookie) return QueryExtensionCookie{cookie} } +// QueryExtensionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryExtensionUnchecked(c *xgb.Conn) QueryExtensionCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryExtensionRequest(c), cookie) return QueryExtensionCookie{cookie} } -// Request reply for QueryExtension -// size: 12 +// QueryExtensionReply represents the data returned from a QueryExtension request. type QueryExtensionReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Major uint16 Minor uint16 } -// Waits and reads reply data from request QueryExtension +// Reply blocks and returns the reply data for a QueryExtension request. func (cook QueryExtensionCookie) Reply() (*QueryExtensionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1248,7 +1230,7 @@ func (cook QueryExtensionCookie) Reply() (*QueryExtensionReply, error) { return queryExtensionReply(buf), nil } -// Read reply into structure from buffer for QueryExtension +// queryExtensionReply reads a byte slice into a QueryExtensionReply value. func queryExtensionReply(buf []byte) *QueryExtensionReply { v := new(QueryExtensionReply) b := 1 // skip reply determinant @@ -1271,6 +1253,7 @@ func queryExtensionReply(buf []byte) *QueryExtensionReply { } // Write request to wire for QueryExtension +// queryExtensionRequest writes a QueryExtension request to a byte slice. func queryExtensionRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -1288,36 +1271,38 @@ func queryExtensionRequest(c *xgb.Conn) []byte { return buf } -// Request QueryAdaptors -// size: 8 +// QueryAdaptorsCookie is a cookie used only for QueryAdaptors requests. type QueryAdaptorsCookie struct { *xgb.Cookie } +// QueryAdaptors sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryAdaptorsCookie.Reply() func QueryAdaptors(c *xgb.Conn, Window xproto.Window) QueryAdaptorsCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryAdaptorsRequest(c, Window), cookie) return QueryAdaptorsCookie{cookie} } +// QueryAdaptorsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryAdaptorsUnchecked(c *xgb.Conn, Window xproto.Window) QueryAdaptorsCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryAdaptorsRequest(c, Window), cookie) return QueryAdaptorsCookie{cookie} } -// Request reply for QueryAdaptors -// size: (32 + AdaptorInfoListSize(Info)) +// QueryAdaptorsReply represents the data returned from a QueryAdaptors request. type QueryAdaptorsReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes NumAdaptors uint16 // padding: 22 bytes Info []AdaptorInfo // size: AdaptorInfoListSize(Info) } -// Waits and reads reply data from request QueryAdaptors +// Reply blocks and returns the reply data for a QueryAdaptors request. func (cook QueryAdaptorsCookie) Reply() (*QueryAdaptorsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1329,7 +1314,7 @@ func (cook QueryAdaptorsCookie) Reply() (*QueryAdaptorsReply, error) { return queryAdaptorsReply(buf), nil } -// Read reply into structure from buffer for QueryAdaptors +// queryAdaptorsReply reads a byte slice into a QueryAdaptorsReply value. func queryAdaptorsReply(buf []byte) *QueryAdaptorsReply { v := new(QueryAdaptorsReply) b := 1 // skip reply determinant @@ -1354,6 +1339,7 @@ func queryAdaptorsReply(buf []byte) *QueryAdaptorsReply { } // Write request to wire for QueryAdaptors +// queryAdaptorsRequest writes a QueryAdaptors request to a byte slice. func queryAdaptorsRequest(c *xgb.Conn, Window xproto.Window) []byte { size := 8 b := 0 @@ -1374,36 +1360,38 @@ func queryAdaptorsRequest(c *xgb.Conn, Window xproto.Window) []byte { return buf } -// Request QueryEncodings -// size: 8 +// QueryEncodingsCookie is a cookie used only for QueryEncodings requests. type QueryEncodingsCookie struct { *xgb.Cookie } +// QueryEncodings sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryEncodingsCookie.Reply() func QueryEncodings(c *xgb.Conn, Port Port) QueryEncodingsCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryEncodingsRequest(c, Port), cookie) return QueryEncodingsCookie{cookie} } +// QueryEncodingsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryEncodingsUnchecked(c *xgb.Conn, Port Port) QueryEncodingsCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryEncodingsRequest(c, Port), cookie) return QueryEncodingsCookie{cookie} } -// Request reply for QueryEncodings -// size: (32 + EncodingInfoListSize(Info)) +// QueryEncodingsReply represents the data returned from a QueryEncodings request. type QueryEncodingsReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes NumEncodings uint16 // padding: 22 bytes Info []EncodingInfo // size: EncodingInfoListSize(Info) } -// Waits and reads reply data from request QueryEncodings +// Reply blocks and returns the reply data for a QueryEncodings request. func (cook QueryEncodingsCookie) Reply() (*QueryEncodingsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1415,7 +1403,7 @@ func (cook QueryEncodingsCookie) Reply() (*QueryEncodingsReply, error) { return queryEncodingsReply(buf), nil } -// Read reply into structure from buffer for QueryEncodings +// queryEncodingsReply reads a byte slice into a QueryEncodingsReply value. func queryEncodingsReply(buf []byte) *QueryEncodingsReply { v := new(QueryEncodingsReply) b := 1 // skip reply determinant @@ -1440,6 +1428,7 @@ func queryEncodingsReply(buf []byte) *QueryEncodingsReply { } // Write request to wire for QueryEncodings +// queryEncodingsRequest writes a QueryEncodings request to a byte slice. func queryEncodingsRequest(c *xgb.Conn, Port Port) []byte { size := 8 b := 0 @@ -1460,33 +1449,35 @@ func queryEncodingsRequest(c *xgb.Conn, Port Port) []byte { return buf } -// Request GrabPort -// size: 12 +// GrabPortCookie is a cookie used only for GrabPort requests. type GrabPortCookie struct { *xgb.Cookie } +// GrabPort sends a checked request. +// If an error occurs, it will be returned with the reply by calling GrabPortCookie.Reply() func GrabPort(c *xgb.Conn, Port Port, Time xproto.Timestamp) GrabPortCookie { cookie := c.NewCookie(true, true) c.NewRequest(grabPortRequest(c, Port, Time), cookie) return GrabPortCookie{cookie} } +// GrabPortUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GrabPortUnchecked(c *xgb.Conn, Port Port, Time xproto.Timestamp) GrabPortCookie { cookie := c.NewCookie(false, true) c.NewRequest(grabPortRequest(c, Port, Time), cookie) return GrabPortCookie{cookie} } -// Request reply for GrabPort -// size: 8 +// GrabPortReply represents the data returned from a GrabPort request. type GrabPortReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply Result byte } -// Waits and reads reply data from request GrabPort +// Reply blocks and returns the reply data for a GrabPort request. func (cook GrabPortCookie) Reply() (*GrabPortReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1498,7 +1489,7 @@ func (cook GrabPortCookie) Reply() (*GrabPortReply, error) { return grabPortReply(buf), nil } -// Read reply into structure from buffer for GrabPort +// grabPortReply reads a byte slice into a GrabPortReply value. func grabPortReply(buf []byte) *GrabPortReply { v := new(GrabPortReply) b := 1 // skip reply determinant @@ -1516,6 +1507,7 @@ func grabPortReply(buf []byte) *GrabPortReply { } // Write request to wire for GrabPort +// grabPortRequest writes a GrabPort request to a byte slice. func grabPortRequest(c *xgb.Conn, Port Port, Time xproto.Timestamp) []byte { size := 12 b := 0 @@ -1539,30 +1531,35 @@ func grabPortRequest(c *xgb.Conn, Port Port, Time xproto.Timestamp) []byte { return buf } -// Request UngrabPort -// size: 12 +// UngrabPortCookie is a cookie used only for UngrabPort requests. type UngrabPortCookie struct { *xgb.Cookie } -// Write request to wire for UngrabPort +// UngrabPort sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func UngrabPort(c *xgb.Conn, Port Port, Time xproto.Timestamp) UngrabPortCookie { cookie := c.NewCookie(false, false) c.NewRequest(ungrabPortRequest(c, Port, Time), cookie) return UngrabPortCookie{cookie} } +// UngrabPortChecked sends a checked request. +// If an error occurs, it can be retrieved using UngrabPortCookie.Check() func UngrabPortChecked(c *xgb.Conn, Port Port, Time xproto.Timestamp) UngrabPortCookie { cookie := c.NewCookie(true, false) c.NewRequest(ungrabPortRequest(c, Port, Time), cookie) return UngrabPortCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook UngrabPortCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for UngrabPort +// ungrabPortRequest writes a UngrabPort request to a byte slice. func ungrabPortRequest(c *xgb.Conn, Port Port, Time xproto.Timestamp) []byte { size := 12 b := 0 @@ -1586,30 +1583,35 @@ func ungrabPortRequest(c *xgb.Conn, Port Port, Time xproto.Timestamp) []byte { return buf } -// Request PutVideo -// size: 32 +// PutVideoCookie is a cookie used only for PutVideo requests. type PutVideoCookie struct { *xgb.Cookie } -// Write request to wire for PutVideo +// PutVideo sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PutVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutVideoCookie { cookie := c.NewCookie(false, false) c.NewRequest(putVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) return PutVideoCookie{cookie} } +// PutVideoChecked sends a checked request. +// If an error occurs, it can be retrieved using PutVideoCookie.Check() func PutVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutVideoCookie { cookie := c.NewCookie(true, false) c.NewRequest(putVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) return PutVideoCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook PutVideoCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for PutVideo +// putVideoRequest writes a PutVideo request to a byte slice. func putVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { size := 32 b := 0 @@ -1660,30 +1662,35 @@ func putVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto return buf } -// Request PutStill -// size: 32 +// PutStillCookie is a cookie used only for PutStill requests. type PutStillCookie struct { *xgb.Cookie } -// Write request to wire for PutStill +// PutStill sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PutStill(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutStillCookie { cookie := c.NewCookie(false, false) c.NewRequest(putStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) return PutStillCookie{cookie} } +// PutStillChecked sends a checked request. +// If an error occurs, it can be retrieved using PutStillCookie.Check() func PutStillChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutStillCookie { cookie := c.NewCookie(true, false) c.NewRequest(putStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) return PutStillCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook PutStillCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for PutStill +// putStillRequest writes a PutStill request to a byte slice. func putStillRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { size := 32 b := 0 @@ -1734,30 +1741,35 @@ func putStillRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto return buf } -// Request GetVideo -// size: 32 +// GetVideoCookie is a cookie used only for GetVideo requests. type GetVideoCookie struct { *xgb.Cookie } -// Write request to wire for GetVideo +// GetVideo sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetVideoCookie { cookie := c.NewCookie(false, false) c.NewRequest(getVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) return GetVideoCookie{cookie} } +// GetVideoChecked sends a checked request. +// If an error occurs, it can be retrieved using GetVideoCookie.Check() func GetVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetVideoCookie { cookie := c.NewCookie(true, false) c.NewRequest(getVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) return GetVideoCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook GetVideoCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for GetVideo +// getVideoRequest writes a GetVideo request to a byte slice. func getVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { size := 32 b := 0 @@ -1808,30 +1820,35 @@ func getVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto return buf } -// Request GetStill -// size: 32 +// GetStillCookie is a cookie used only for GetStill requests. type GetStillCookie struct { *xgb.Cookie } -// Write request to wire for GetStill +// GetStill sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetStill(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetStillCookie { cookie := c.NewCookie(false, false) c.NewRequest(getStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) return GetStillCookie{cookie} } +// GetStillChecked sends a checked request. +// If an error occurs, it can be retrieved using GetStillCookie.Check() func GetStillChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetStillCookie { cookie := c.NewCookie(true, false) c.NewRequest(getStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) return GetStillCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook GetStillCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for GetStill +// getStillRequest writes a GetStill request to a byte slice. func getStillRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { size := 32 b := 0 @@ -1882,30 +1899,35 @@ func getStillRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto return buf } -// Request StopVideo -// size: 12 +// StopVideoCookie is a cookie used only for StopVideo requests. type StopVideoCookie struct { *xgb.Cookie } -// Write request to wire for StopVideo +// StopVideo sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func StopVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable) StopVideoCookie { cookie := c.NewCookie(false, false) c.NewRequest(stopVideoRequest(c, Port, Drawable), cookie) return StopVideoCookie{cookie} } +// StopVideoChecked sends a checked request. +// If an error occurs, it can be retrieved using StopVideoCookie.Check() func StopVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable) StopVideoCookie { cookie := c.NewCookie(true, false) c.NewRequest(stopVideoRequest(c, Port, Drawable), cookie) return StopVideoCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook StopVideoCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for StopVideo +// stopVideoRequest writes a StopVideo request to a byte slice. func stopVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable) []byte { size := 12 b := 0 @@ -1929,30 +1951,35 @@ func stopVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable) []byte { return buf } -// Request SelectVideoNotify -// size: 12 +// SelectVideoNotifyCookie is a cookie used only for SelectVideoNotify requests. type SelectVideoNotifyCookie struct { *xgb.Cookie } -// Write request to wire for SelectVideoNotify +// SelectVideoNotify sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SelectVideoNotify(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) SelectVideoNotifyCookie { cookie := c.NewCookie(false, false) c.NewRequest(selectVideoNotifyRequest(c, Drawable, Onoff), cookie) return SelectVideoNotifyCookie{cookie} } +// SelectVideoNotifyChecked sends a checked request. +// If an error occurs, it can be retrieved using SelectVideoNotifyCookie.Check() func SelectVideoNotifyChecked(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) SelectVideoNotifyCookie { cookie := c.NewCookie(true, false) c.NewRequest(selectVideoNotifyRequest(c, Drawable, Onoff), cookie) return SelectVideoNotifyCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SelectVideoNotifyCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SelectVideoNotify +// selectVideoNotifyRequest writes a SelectVideoNotify request to a byte slice. func selectVideoNotifyRequest(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) []byte { size := 12 b := 0 @@ -1982,30 +2009,35 @@ func selectVideoNotifyRequest(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) return buf } -// Request SelectPortNotify -// size: 12 +// SelectPortNotifyCookie is a cookie used only for SelectPortNotify requests. type SelectPortNotifyCookie struct { *xgb.Cookie } -// Write request to wire for SelectPortNotify +// SelectPortNotify sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SelectPortNotify(c *xgb.Conn, Port Port, Onoff bool) SelectPortNotifyCookie { cookie := c.NewCookie(false, false) c.NewRequest(selectPortNotifyRequest(c, Port, Onoff), cookie) return SelectPortNotifyCookie{cookie} } +// SelectPortNotifyChecked sends a checked request. +// If an error occurs, it can be retrieved using SelectPortNotifyCookie.Check() func SelectPortNotifyChecked(c *xgb.Conn, Port Port, Onoff bool) SelectPortNotifyCookie { cookie := c.NewCookie(true, false) c.NewRequest(selectPortNotifyRequest(c, Port, Onoff), cookie) return SelectPortNotifyCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SelectPortNotifyCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SelectPortNotify +// selectPortNotifyRequest writes a SelectPortNotify request to a byte slice. func selectPortNotifyRequest(c *xgb.Conn, Port Port, Onoff bool) []byte { size := 12 b := 0 @@ -2035,35 +2067,37 @@ func selectPortNotifyRequest(c *xgb.Conn, Port Port, Onoff bool) []byte { return buf } -// Request QueryBestSize -// size: 20 +// QueryBestSizeCookie is a cookie used only for QueryBestSize requests. type QueryBestSizeCookie struct { *xgb.Cookie } +// QueryBestSize sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryBestSizeCookie.Reply() func QueryBestSize(c *xgb.Conn, Port Port, VidW uint16, VidH uint16, DrwW uint16, DrwH uint16, Motion bool) QueryBestSizeCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryBestSizeRequest(c, Port, VidW, VidH, DrwW, DrwH, Motion), cookie) return QueryBestSizeCookie{cookie} } +// QueryBestSizeUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryBestSizeUnchecked(c *xgb.Conn, Port Port, VidW uint16, VidH uint16, DrwW uint16, DrwH uint16, Motion bool) QueryBestSizeCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryBestSizeRequest(c, Port, VidW, VidH, DrwW, DrwH, Motion), cookie) return QueryBestSizeCookie{cookie} } -// Request reply for QueryBestSize -// size: 12 +// QueryBestSizeReply represents the data returned from a QueryBestSize request. type QueryBestSizeReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes ActualWidth uint16 ActualHeight uint16 } -// Waits and reads reply data from request QueryBestSize +// Reply blocks and returns the reply data for a QueryBestSize request. func (cook QueryBestSizeCookie) Reply() (*QueryBestSizeReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -2075,7 +2109,7 @@ func (cook QueryBestSizeCookie) Reply() (*QueryBestSizeReply, error) { return queryBestSizeReply(buf), nil } -// Read reply into structure from buffer for QueryBestSize +// queryBestSizeReply reads a byte slice into a QueryBestSizeReply value. func queryBestSizeReply(buf []byte) *QueryBestSizeReply { v := new(QueryBestSizeReply) b := 1 // skip reply determinant @@ -2098,6 +2132,7 @@ func queryBestSizeReply(buf []byte) *QueryBestSizeReply { } // Write request to wire for QueryBestSize +// queryBestSizeRequest writes a QueryBestSize request to a byte slice. func queryBestSizeRequest(c *xgb.Conn, Port Port, VidW uint16, VidH uint16, DrwW uint16, DrwH uint16, Motion bool) []byte { size := 20 b := 0 @@ -2139,30 +2174,35 @@ func queryBestSizeRequest(c *xgb.Conn, Port Port, VidW uint16, VidH uint16, DrwW return buf } -// Request SetPortAttribute -// size: 16 +// SetPortAttributeCookie is a cookie used only for SetPortAttribute requests. type SetPortAttributeCookie struct { *xgb.Cookie } -// Write request to wire for SetPortAttribute +// SetPortAttribute sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetPortAttribute(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32) SetPortAttributeCookie { cookie := c.NewCookie(false, false) c.NewRequest(setPortAttributeRequest(c, Port, Attribute, Value), cookie) return SetPortAttributeCookie{cookie} } +// SetPortAttributeChecked sends a checked request. +// If an error occurs, it can be retrieved using SetPortAttributeCookie.Check() func SetPortAttributeChecked(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32) SetPortAttributeCookie { cookie := c.NewCookie(true, false) c.NewRequest(setPortAttributeRequest(c, Port, Attribute, Value), cookie) return SetPortAttributeCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetPortAttributeCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetPortAttribute +// setPortAttributeRequest writes a SetPortAttribute request to a byte slice. func setPortAttributeRequest(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32) []byte { size := 16 b := 0 @@ -2189,34 +2229,36 @@ func setPortAttributeRequest(c *xgb.Conn, Port Port, Attribute xproto.Atom, Valu return buf } -// Request GetPortAttribute -// size: 12 +// GetPortAttributeCookie is a cookie used only for GetPortAttribute requests. type GetPortAttributeCookie struct { *xgb.Cookie } +// GetPortAttribute sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPortAttributeCookie.Reply() func GetPortAttribute(c *xgb.Conn, Port Port, Attribute xproto.Atom) GetPortAttributeCookie { cookie := c.NewCookie(true, true) c.NewRequest(getPortAttributeRequest(c, Port, Attribute), cookie) return GetPortAttributeCookie{cookie} } +// GetPortAttributeUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetPortAttributeUnchecked(c *xgb.Conn, Port Port, Attribute xproto.Atom) GetPortAttributeCookie { cookie := c.NewCookie(false, true) c.NewRequest(getPortAttributeRequest(c, Port, Attribute), cookie) return GetPortAttributeCookie{cookie} } -// Request reply for GetPortAttribute -// size: 12 +// GetPortAttributeReply represents the data returned from a GetPortAttribute request. type GetPortAttributeReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Value int32 } -// Waits and reads reply data from request GetPortAttribute +// Reply blocks and returns the reply data for a GetPortAttribute request. func (cook GetPortAttributeCookie) Reply() (*GetPortAttributeReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -2228,7 +2270,7 @@ func (cook GetPortAttributeCookie) Reply() (*GetPortAttributeReply, error) { return getPortAttributeReply(buf), nil } -// Read reply into structure from buffer for GetPortAttribute +// getPortAttributeReply reads a byte slice into a GetPortAttributeReply value. func getPortAttributeReply(buf []byte) *GetPortAttributeReply { v := new(GetPortAttributeReply) b := 1 // skip reply determinant @@ -2248,6 +2290,7 @@ func getPortAttributeReply(buf []byte) *GetPortAttributeReply { } // Write request to wire for GetPortAttribute +// getPortAttributeRequest writes a GetPortAttribute request to a byte slice. func getPortAttributeRequest(c *xgb.Conn, Port Port, Attribute xproto.Atom) []byte { size := 12 b := 0 @@ -2271,29 +2314,31 @@ func getPortAttributeRequest(c *xgb.Conn, Port Port, Attribute xproto.Atom) []by return buf } -// Request QueryPortAttributes -// size: 8 +// QueryPortAttributesCookie is a cookie used only for QueryPortAttributes requests. type QueryPortAttributesCookie struct { *xgb.Cookie } +// QueryPortAttributes sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryPortAttributesCookie.Reply() func QueryPortAttributes(c *xgb.Conn, Port Port) QueryPortAttributesCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryPortAttributesRequest(c, Port), cookie) return QueryPortAttributesCookie{cookie} } +// QueryPortAttributesUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryPortAttributesUnchecked(c *xgb.Conn, Port Port) QueryPortAttributesCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryPortAttributesRequest(c, Port), cookie) return QueryPortAttributesCookie{cookie} } -// Request reply for QueryPortAttributes -// size: (32 + AttributeInfoListSize(Attributes)) +// QueryPortAttributesReply represents the data returned from a QueryPortAttributes request. type QueryPortAttributesReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes NumAttributes uint32 TextSize uint32 @@ -2301,7 +2346,7 @@ type QueryPortAttributesReply struct { Attributes []AttributeInfo // size: AttributeInfoListSize(Attributes) } -// Waits and reads reply data from request QueryPortAttributes +// Reply blocks and returns the reply data for a QueryPortAttributes request. func (cook QueryPortAttributesCookie) Reply() (*QueryPortAttributesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -2313,7 +2358,7 @@ func (cook QueryPortAttributesCookie) Reply() (*QueryPortAttributesReply, error) return queryPortAttributesReply(buf), nil } -// Read reply into structure from buffer for QueryPortAttributes +// queryPortAttributesReply reads a byte slice into a QueryPortAttributesReply value. func queryPortAttributesReply(buf []byte) *QueryPortAttributesReply { v := new(QueryPortAttributesReply) b := 1 // skip reply determinant @@ -2341,6 +2386,7 @@ func queryPortAttributesReply(buf []byte) *QueryPortAttributesReply { } // Write request to wire for QueryPortAttributes +// queryPortAttributesRequest writes a QueryPortAttributes request to a byte slice. func queryPortAttributesRequest(c *xgb.Conn, Port Port) []byte { size := 8 b := 0 @@ -2361,36 +2407,38 @@ func queryPortAttributesRequest(c *xgb.Conn, Port Port) []byte { return buf } -// Request ListImageFormats -// size: 8 +// ListImageFormatsCookie is a cookie used only for ListImageFormats requests. type ListImageFormatsCookie struct { *xgb.Cookie } +// ListImageFormats sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListImageFormatsCookie.Reply() func ListImageFormats(c *xgb.Conn, Port Port) ListImageFormatsCookie { cookie := c.NewCookie(true, true) c.NewRequest(listImageFormatsRequest(c, Port), cookie) return ListImageFormatsCookie{cookie} } +// ListImageFormatsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ListImageFormatsUnchecked(c *xgb.Conn, Port Port) ListImageFormatsCookie { cookie := c.NewCookie(false, true) c.NewRequest(listImageFormatsRequest(c, Port), cookie) return ListImageFormatsCookie{cookie} } -// Request reply for ListImageFormats -// size: (32 + ImageFormatInfoListSize(Format)) +// ListImageFormatsReply represents the data returned from a ListImageFormats request. type ListImageFormatsReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes NumFormats uint32 // padding: 20 bytes Format []ImageFormatInfo // size: ImageFormatInfoListSize(Format) } -// Waits and reads reply data from request ListImageFormats +// Reply blocks and returns the reply data for a ListImageFormats request. func (cook ListImageFormatsCookie) Reply() (*ListImageFormatsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -2402,7 +2450,7 @@ func (cook ListImageFormatsCookie) Reply() (*ListImageFormatsReply, error) { return listImageFormatsReply(buf), nil } -// Read reply into structure from buffer for ListImageFormats +// listImageFormatsReply reads a byte slice into a ListImageFormatsReply value. func listImageFormatsReply(buf []byte) *ListImageFormatsReply { v := new(ListImageFormatsReply) b := 1 // skip reply determinant @@ -2427,6 +2475,7 @@ func listImageFormatsReply(buf []byte) *ListImageFormatsReply { } // Write request to wire for ListImageFormats +// listImageFormatsRequest writes a ListImageFormats request to a byte slice. func listImageFormatsRequest(c *xgb.Conn, Port Port) []byte { size := 8 b := 0 @@ -2447,29 +2496,31 @@ func listImageFormatsRequest(c *xgb.Conn, Port Port) []byte { return buf } -// Request QueryImageAttributes -// size: 16 +// QueryImageAttributesCookie is a cookie used only for QueryImageAttributes requests. type QueryImageAttributesCookie struct { *xgb.Cookie } +// QueryImageAttributes sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryImageAttributesCookie.Reply() func QueryImageAttributes(c *xgb.Conn, Port Port, Id uint32, Width uint16, Height uint16) QueryImageAttributesCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryImageAttributesRequest(c, Port, Id, Width, Height), cookie) return QueryImageAttributesCookie{cookie} } +// QueryImageAttributesUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryImageAttributesUnchecked(c *xgb.Conn, Port Port, Id uint32, Width uint16, Height uint16) QueryImageAttributesCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryImageAttributesRequest(c, Port, Id, Width, Height), cookie) return QueryImageAttributesCookie{cookie} } -// Request reply for QueryImageAttributes -// size: ((32 + xgb.Pad((int(NumPlanes) * 4))) + xgb.Pad((int(NumPlanes) * 4))) +// QueryImageAttributesReply represents the data returned from a QueryImageAttributes request. type QueryImageAttributesReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes NumPlanes uint32 DataSize uint32 @@ -2480,7 +2531,7 @@ type QueryImageAttributesReply struct { Offsets []uint32 // size: xgb.Pad((int(NumPlanes) * 4)) } -// Waits and reads reply data from request QueryImageAttributes +// Reply blocks and returns the reply data for a QueryImageAttributes request. func (cook QueryImageAttributesCookie) Reply() (*QueryImageAttributesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -2492,7 +2543,7 @@ func (cook QueryImageAttributesCookie) Reply() (*QueryImageAttributesReply, erro return queryImageAttributesReply(buf), nil } -// Read reply into structure from buffer for QueryImageAttributes +// queryImageAttributesReply reads a byte slice into a QueryImageAttributesReply value. func queryImageAttributesReply(buf []byte) *QueryImageAttributesReply { v := new(QueryImageAttributesReply) b := 1 // skip reply determinant @@ -2537,6 +2588,7 @@ func queryImageAttributesReply(buf []byte) *QueryImageAttributesReply { } // Write request to wire for QueryImageAttributes +// queryImageAttributesRequest writes a QueryImageAttributes request to a byte slice. func queryImageAttributesRequest(c *xgb.Conn, Port Port, Id uint32, Width uint16, Height uint16) []byte { size := 16 b := 0 @@ -2566,30 +2618,35 @@ func queryImageAttributesRequest(c *xgb.Conn, Port Port, Id uint32, Width uint16 return buf } -// Request PutImage -// size: xgb.Pad((40 + xgb.Pad((len(Data) * 1)))) +// PutImageCookie is a cookie used only for PutImage requests. type PutImageCookie struct { *xgb.Cookie } -// Write request to wire for PutImage +// PutImage sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PutImage(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) PutImageCookie { cookie := c.NewCookie(false, false) c.NewRequest(putImageRequest(c, Port, Drawable, Gc, Id, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, Data), cookie) return PutImageCookie{cookie} } +// PutImageChecked sends a checked request. +// If an error occurs, it can be retrieved using PutImageCookie.Check() func PutImageChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) PutImageCookie { cookie := c.NewCookie(true, false) c.NewRequest(putImageRequest(c, Port, Drawable, Gc, Id, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, Data), cookie) return PutImageCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook PutImageCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for PutImage +// putImageRequest writes a PutImage request to a byte slice. func putImageRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) []byte { size := xgb.Pad((40 + xgb.Pad((len(Data) * 1)))) b := 0 @@ -2652,30 +2709,35 @@ func putImageRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto return buf } -// Request ShmPutImage -// size: 52 +// ShmPutImageCookie is a cookie used only for ShmPutImage requests. type ShmPutImageCookie struct { *xgb.Cookie } -// Write request to wire for ShmPutImage +// ShmPutImage sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ShmPutImage(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Shmseg shm.Seg, Id uint32, Offset uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, SendEvent byte) ShmPutImageCookie { cookie := c.NewCookie(false, false) c.NewRequest(shmPutImageRequest(c, Port, Drawable, Gc, Shmseg, Id, Offset, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, SendEvent), cookie) return ShmPutImageCookie{cookie} } +// ShmPutImageChecked sends a checked request. +// If an error occurs, it can be retrieved using ShmPutImageCookie.Check() func ShmPutImageChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Shmseg shm.Seg, Id uint32, Offset uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, SendEvent byte) ShmPutImageCookie { cookie := c.NewCookie(true, false) c.NewRequest(shmPutImageRequest(c, Port, Drawable, Gc, Shmseg, Id, Offset, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, SendEvent), cookie) return ShmPutImageCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook ShmPutImageCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ShmPutImage +// shmPutImageRequest writes a ShmPutImage request to a byte slice. func shmPutImageRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Shmseg shm.Seg, Id uint32, Offset uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, SendEvent byte) []byte { size := 52 b := 0 diff --git a/nexgb/xvmc/xvmc.go b/nexgb/xvmc/xvmc.go index 60fcb2e..dc9c220 100644 --- a/nexgb/xvmc/xvmc.go +++ b/nexgb/xvmc/xvmc.go @@ -2,7 +2,7 @@ package xvmc /* - This file was generated by xvmc.xml on May 10 2012 8:04:33pm EDT. + This file was generated by xvmc.xml on May 10 2012 11:56:20pm EDT. This file is automatically generated. Edit at your peril! */ @@ -41,6 +41,16 @@ func init() { xgb.NewExtErrorFuncs["XVideo-MotionCompensation"] = make(map[int]xgb.NewErrorFun) } +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Bool' + // Skipping definition for base type 'Float' // Skipping definition for base type 'Card8' @@ -55,16 +65,6 @@ func init() { // Skipping definition for base type 'Int8' -// Skipping definition for base type 'Card16' - -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - type Context uint32 func NewContextId(c *xgb.Conn) (Context, error) { @@ -95,8 +95,6 @@ func NewSubpictureId(c *xgb.Conn) (Subpicture, error) { return Subpicture(id), nil } -// 'SurfaceInfo' struct definition -// Size: 24 type SurfaceInfo struct { Id Surface ChromaFormat uint16 @@ -109,7 +107,7 @@ type SurfaceInfo struct { Flags uint32 } -// Struct read SurfaceInfo +// SurfaceInfoRead reads a byte slice into a SurfaceInfo value. func SurfaceInfoRead(buf []byte, v *SurfaceInfo) int { b := 0 @@ -143,7 +141,7 @@ func SurfaceInfoRead(buf []byte, v *SurfaceInfo) int { return b } -// Struct list read SurfaceInfo +// SurfaceInfoReadList reads a byte slice into a list of SurfaceInfo values. func SurfaceInfoReadList(buf []byte, dest []SurfaceInfo) int { b := 0 for i := 0; i < len(dest); i++ { @@ -153,7 +151,7 @@ func SurfaceInfoReadList(buf []byte, dest []SurfaceInfo) int { return xgb.Pad(b) } -// Struct write SurfaceInfo +// Bytes writes a SurfaceInfo value to a byte slice. func (v SurfaceInfo) Bytes() []byte { buf := make([]byte, 24) b := 0 @@ -188,7 +186,7 @@ func (v SurfaceInfo) Bytes() []byte { return buf } -// Write struct list SurfaceInfo +// SurfaceInfoListBytes writes a list of %s(MISSING) values to a byte slice. func SurfaceInfoListBytes(buf []byte, list []SurfaceInfo) int { b := 0 var structBytes []byte @@ -200,35 +198,37 @@ func SurfaceInfoListBytes(buf []byte, list []SurfaceInfo) int { return b } -// Request QueryVersion -// size: 4 +// QueryVersionCookie is a cookie used only for QueryVersion requests. type QueryVersionCookie struct { *xgb.Cookie } +// QueryVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() func QueryVersion(c *xgb.Conn) QueryVersionCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryVersionRequest(c), cookie) return QueryVersionCookie{cookie} } +// QueryVersionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryVersionUnchecked(c *xgb.Conn) QueryVersionCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryVersionRequest(c), cookie) return QueryVersionCookie{cookie} } -// Request reply for QueryVersion -// size: 16 +// QueryVersionReply represents the data returned from a QueryVersion request. type QueryVersionReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Major uint32 Minor uint32 } -// Waits and reads reply data from request QueryVersion +// Reply blocks and returns the reply data for a QueryVersion request. func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -240,7 +240,7 @@ func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { return queryVersionReply(buf), nil } -// Read reply into structure from buffer for QueryVersion +// queryVersionReply reads a byte slice into a QueryVersionReply value. func queryVersionReply(buf []byte) *QueryVersionReply { v := new(QueryVersionReply) b := 1 // skip reply determinant @@ -263,6 +263,7 @@ func queryVersionReply(buf []byte) *QueryVersionReply { } // Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. func queryVersionRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -280,36 +281,38 @@ func queryVersionRequest(c *xgb.Conn) []byte { return buf } -// Request ListSurfaceTypes -// size: 8 +// ListSurfaceTypesCookie is a cookie used only for ListSurfaceTypes requests. type ListSurfaceTypesCookie struct { *xgb.Cookie } +// ListSurfaceTypes sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListSurfaceTypesCookie.Reply() func ListSurfaceTypes(c *xgb.Conn, PortId xv.Port) ListSurfaceTypesCookie { cookie := c.NewCookie(true, true) c.NewRequest(listSurfaceTypesRequest(c, PortId), cookie) return ListSurfaceTypesCookie{cookie} } +// ListSurfaceTypesUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ListSurfaceTypesUnchecked(c *xgb.Conn, PortId xv.Port) ListSurfaceTypesCookie { cookie := c.NewCookie(false, true) c.NewRequest(listSurfaceTypesRequest(c, PortId), cookie) return ListSurfaceTypesCookie{cookie} } -// Request reply for ListSurfaceTypes -// size: (32 + xgb.Pad((int(Num) * 24))) +// ListSurfaceTypesReply represents the data returned from a ListSurfaceTypes request. type ListSurfaceTypesReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Num uint32 // padding: 20 bytes Surfaces []SurfaceInfo // size: xgb.Pad((int(Num) * 24)) } -// Waits and reads reply data from request ListSurfaceTypes +// Reply blocks and returns the reply data for a ListSurfaceTypes request. func (cook ListSurfaceTypesCookie) Reply() (*ListSurfaceTypesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -321,7 +324,7 @@ func (cook ListSurfaceTypesCookie) Reply() (*ListSurfaceTypesReply, error) { return listSurfaceTypesReply(buf), nil } -// Read reply into structure from buffer for ListSurfaceTypes +// listSurfaceTypesReply reads a byte slice into a ListSurfaceTypesReply value. func listSurfaceTypesReply(buf []byte) *ListSurfaceTypesReply { v := new(ListSurfaceTypesReply) b := 1 // skip reply determinant @@ -346,6 +349,7 @@ func listSurfaceTypesReply(buf []byte) *ListSurfaceTypesReply { } // Write request to wire for ListSurfaceTypes +// listSurfaceTypesRequest writes a ListSurfaceTypes request to a byte slice. func listSurfaceTypesRequest(c *xgb.Conn, PortId xv.Port) []byte { size := 8 b := 0 @@ -366,29 +370,31 @@ func listSurfaceTypesRequest(c *xgb.Conn, PortId xv.Port) []byte { return buf } -// Request CreateContext -// size: 24 +// CreateContextCookie is a cookie used only for CreateContext requests. type CreateContextCookie struct { *xgb.Cookie } +// CreateContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling CreateContextCookie.Reply() func CreateContext(c *xgb.Conn, ContextId Context, PortId xv.Port, SurfaceId Surface, Width uint16, Height uint16, Flags uint32) CreateContextCookie { cookie := c.NewCookie(true, true) c.NewRequest(createContextRequest(c, ContextId, PortId, SurfaceId, Width, Height, Flags), cookie) return CreateContextCookie{cookie} } +// CreateContextUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreateContextUnchecked(c *xgb.Conn, ContextId Context, PortId xv.Port, SurfaceId Surface, Width uint16, Height uint16, Flags uint32) CreateContextCookie { cookie := c.NewCookie(false, true) c.NewRequest(createContextRequest(c, ContextId, PortId, SurfaceId, Width, Height, Flags), cookie) return CreateContextCookie{cookie} } -// Request reply for CreateContext -// size: (36 + xgb.Pad((int(Length) * 4))) +// CreateContextReply represents the data returned from a CreateContext request. type CreateContextReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes WidthActual uint16 HeightActual uint16 @@ -397,7 +403,7 @@ type CreateContextReply struct { PrivData []uint32 // size: xgb.Pad((int(Length) * 4)) } -// Waits and reads reply data from request CreateContext +// Reply blocks and returns the reply data for a CreateContext request. func (cook CreateContextCookie) Reply() (*CreateContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -409,7 +415,7 @@ func (cook CreateContextCookie) Reply() (*CreateContextReply, error) { return createContextReply(buf), nil } -// Read reply into structure from buffer for CreateContext +// createContextReply reads a byte slice into a CreateContextReply value. func createContextReply(buf []byte) *CreateContextReply { v := new(CreateContextReply) b := 1 // skip reply determinant @@ -444,6 +450,7 @@ func createContextReply(buf []byte) *CreateContextReply { } // Write request to wire for CreateContext +// createContextRequest writes a CreateContext request to a byte slice. func createContextRequest(c *xgb.Conn, ContextId Context, PortId xv.Port, SurfaceId Surface, Width uint16, Height uint16, Flags uint32) []byte { size := 24 b := 0 @@ -479,30 +486,35 @@ func createContextRequest(c *xgb.Conn, ContextId Context, PortId xv.Port, Surfac return buf } -// Request DestroyContext -// size: 8 +// DestroyContextCookie is a cookie used only for DestroyContext requests. type DestroyContextCookie struct { *xgb.Cookie } -// Write request to wire for DestroyContext +// DestroyContext sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func DestroyContext(c *xgb.Conn, ContextId Context) DestroyContextCookie { cookie := c.NewCookie(false, false) c.NewRequest(destroyContextRequest(c, ContextId), cookie) return DestroyContextCookie{cookie} } +// DestroyContextChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroyContextCookie.Check() func DestroyContextChecked(c *xgb.Conn, ContextId Context) DestroyContextCookie { cookie := c.NewCookie(true, false) c.NewRequest(destroyContextRequest(c, ContextId), cookie) return DestroyContextCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook DestroyContextCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for DestroyContext +// destroyContextRequest writes a DestroyContext request to a byte slice. func destroyContextRequest(c *xgb.Conn, ContextId Context) []byte { size := 8 b := 0 @@ -523,35 +535,37 @@ func destroyContextRequest(c *xgb.Conn, ContextId Context) []byte { return buf } -// Request CreateSurface -// size: 12 +// CreateSurfaceCookie is a cookie used only for CreateSurface requests. type CreateSurfaceCookie struct { *xgb.Cookie } +// CreateSurface sends a checked request. +// If an error occurs, it will be returned with the reply by calling CreateSurfaceCookie.Reply() func CreateSurface(c *xgb.Conn, SurfaceId Surface, ContextId Context) CreateSurfaceCookie { cookie := c.NewCookie(true, true) c.NewRequest(createSurfaceRequest(c, SurfaceId, ContextId), cookie) return CreateSurfaceCookie{cookie} } +// CreateSurfaceUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreateSurfaceUnchecked(c *xgb.Conn, SurfaceId Surface, ContextId Context) CreateSurfaceCookie { cookie := c.NewCookie(false, true) c.NewRequest(createSurfaceRequest(c, SurfaceId, ContextId), cookie) return CreateSurfaceCookie{cookie} } -// Request reply for CreateSurface -// size: (32 + xgb.Pad((int(Length) * 4))) +// CreateSurfaceReply represents the data returned from a CreateSurface request. type CreateSurfaceReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes // padding: 24 bytes PrivData []uint32 // size: xgb.Pad((int(Length) * 4)) } -// Waits and reads reply data from request CreateSurface +// Reply blocks and returns the reply data for a CreateSurface request. func (cook CreateSurfaceCookie) Reply() (*CreateSurfaceReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -563,7 +577,7 @@ func (cook CreateSurfaceCookie) Reply() (*CreateSurfaceReply, error) { return createSurfaceReply(buf), nil } -// Read reply into structure from buffer for CreateSurface +// createSurfaceReply reads a byte slice into a CreateSurfaceReply value. func createSurfaceReply(buf []byte) *CreateSurfaceReply { v := new(CreateSurfaceReply) b := 1 // skip reply determinant @@ -589,6 +603,7 @@ func createSurfaceReply(buf []byte) *CreateSurfaceReply { } // Write request to wire for CreateSurface +// createSurfaceRequest writes a CreateSurface request to a byte slice. func createSurfaceRequest(c *xgb.Conn, SurfaceId Surface, ContextId Context) []byte { size := 12 b := 0 @@ -612,30 +627,35 @@ func createSurfaceRequest(c *xgb.Conn, SurfaceId Surface, ContextId Context) []b return buf } -// Request DestroySurface -// size: 8 +// DestroySurfaceCookie is a cookie used only for DestroySurface requests. type DestroySurfaceCookie struct { *xgb.Cookie } -// Write request to wire for DestroySurface +// DestroySurface sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func DestroySurface(c *xgb.Conn, SurfaceId Surface) DestroySurfaceCookie { cookie := c.NewCookie(false, false) c.NewRequest(destroySurfaceRequest(c, SurfaceId), cookie) return DestroySurfaceCookie{cookie} } +// DestroySurfaceChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroySurfaceCookie.Check() func DestroySurfaceChecked(c *xgb.Conn, SurfaceId Surface) DestroySurfaceCookie { cookie := c.NewCookie(true, false) c.NewRequest(destroySurfaceRequest(c, SurfaceId), cookie) return DestroySurfaceCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook DestroySurfaceCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for DestroySurface +// destroySurfaceRequest writes a DestroySurface request to a byte slice. func destroySurfaceRequest(c *xgb.Conn, SurfaceId Surface) []byte { size := 8 b := 0 @@ -656,29 +676,31 @@ func destroySurfaceRequest(c *xgb.Conn, SurfaceId Surface) []byte { return buf } -// Request CreateSubpicture -// size: 20 +// CreateSubpictureCookie is a cookie used only for CreateSubpicture requests. type CreateSubpictureCookie struct { *xgb.Cookie } +// CreateSubpicture sends a checked request. +// If an error occurs, it will be returned with the reply by calling CreateSubpictureCookie.Reply() func CreateSubpicture(c *xgb.Conn, SubpictureId Subpicture, Context Context, XvimageId uint32, Width uint16, Height uint16) CreateSubpictureCookie { cookie := c.NewCookie(true, true) c.NewRequest(createSubpictureRequest(c, SubpictureId, Context, XvimageId, Width, Height), cookie) return CreateSubpictureCookie{cookie} } +// CreateSubpictureUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreateSubpictureUnchecked(c *xgb.Conn, SubpictureId Subpicture, Context Context, XvimageId uint32, Width uint16, Height uint16) CreateSubpictureCookie { cookie := c.NewCookie(false, true) c.NewRequest(createSubpictureRequest(c, SubpictureId, Context, XvimageId, Width, Height), cookie) return CreateSubpictureCookie{cookie} } -// Request reply for CreateSubpicture -// size: (32 + xgb.Pad((int(Length) * 4))) +// CreateSubpictureReply represents the data returned from a CreateSubpicture request. type CreateSubpictureReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes WidthActual uint16 HeightActual uint16 @@ -689,7 +711,7 @@ type CreateSubpictureReply struct { PrivData []uint32 // size: xgb.Pad((int(Length) * 4)) } -// Waits and reads reply data from request CreateSubpicture +// Reply blocks and returns the reply data for a CreateSubpicture request. func (cook CreateSubpictureCookie) Reply() (*CreateSubpictureReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -701,7 +723,7 @@ func (cook CreateSubpictureCookie) Reply() (*CreateSubpictureReply, error) { return createSubpictureReply(buf), nil } -// Read reply into structure from buffer for CreateSubpicture +// createSubpictureReply reads a byte slice into a CreateSubpictureReply value. func createSubpictureReply(buf []byte) *CreateSubpictureReply { v := new(CreateSubpictureReply) b := 1 // skip reply determinant @@ -743,6 +765,7 @@ func createSubpictureReply(buf []byte) *CreateSubpictureReply { } // Write request to wire for CreateSubpicture +// createSubpictureRequest writes a CreateSubpicture request to a byte slice. func createSubpictureRequest(c *xgb.Conn, SubpictureId Subpicture, Context Context, XvimageId uint32, Width uint16, Height uint16) []byte { size := 20 b := 0 @@ -775,30 +798,35 @@ func createSubpictureRequest(c *xgb.Conn, SubpictureId Subpicture, Context Conte return buf } -// Request DestroySubpicture -// size: 8 +// DestroySubpictureCookie is a cookie used only for DestroySubpicture requests. type DestroySubpictureCookie struct { *xgb.Cookie } -// Write request to wire for DestroySubpicture +// DestroySubpicture sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func DestroySubpicture(c *xgb.Conn, SubpictureId Subpicture) DestroySubpictureCookie { cookie := c.NewCookie(false, false) c.NewRequest(destroySubpictureRequest(c, SubpictureId), cookie) return DestroySubpictureCookie{cookie} } +// DestroySubpictureChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroySubpictureCookie.Check() func DestroySubpictureChecked(c *xgb.Conn, SubpictureId Subpicture) DestroySubpictureCookie { cookie := c.NewCookie(true, false) c.NewRequest(destroySubpictureRequest(c, SubpictureId), cookie) return DestroySubpictureCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook DestroySubpictureCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for DestroySubpicture +// destroySubpictureRequest writes a DestroySubpicture request to a byte slice. func destroySubpictureRequest(c *xgb.Conn, SubpictureId Subpicture) []byte { size := 8 b := 0 @@ -819,36 +847,38 @@ func destroySubpictureRequest(c *xgb.Conn, SubpictureId Subpicture) []byte { return buf } -// Request ListSubpictureTypes -// size: 12 +// ListSubpictureTypesCookie is a cookie used only for ListSubpictureTypes requests. type ListSubpictureTypesCookie struct { *xgb.Cookie } +// ListSubpictureTypes sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListSubpictureTypesCookie.Reply() func ListSubpictureTypes(c *xgb.Conn, PortId xv.Port, SurfaceId Surface) ListSubpictureTypesCookie { cookie := c.NewCookie(true, true) c.NewRequest(listSubpictureTypesRequest(c, PortId, SurfaceId), cookie) return ListSubpictureTypesCookie{cookie} } +// ListSubpictureTypesUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ListSubpictureTypesUnchecked(c *xgb.Conn, PortId xv.Port, SurfaceId Surface) ListSubpictureTypesCookie { cookie := c.NewCookie(false, true) c.NewRequest(listSubpictureTypesRequest(c, PortId, SurfaceId), cookie) return ListSubpictureTypesCookie{cookie} } -// Request reply for ListSubpictureTypes -// size: (32 + xv.ImageFormatInfoListSize(Types)) +// ListSubpictureTypesReply represents the data returned from a ListSubpictureTypes request. type ListSubpictureTypesReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Num uint32 // padding: 20 bytes Types []xv.ImageFormatInfo // size: xv.ImageFormatInfoListSize(Types) } -// Waits and reads reply data from request ListSubpictureTypes +// Reply blocks and returns the reply data for a ListSubpictureTypes request. func (cook ListSubpictureTypesCookie) Reply() (*ListSubpictureTypesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -860,7 +890,7 @@ func (cook ListSubpictureTypesCookie) Reply() (*ListSubpictureTypesReply, error) return listSubpictureTypesReply(buf), nil } -// Read reply into structure from buffer for ListSubpictureTypes +// listSubpictureTypesReply reads a byte slice into a ListSubpictureTypesReply value. func listSubpictureTypesReply(buf []byte) *ListSubpictureTypesReply { v := new(ListSubpictureTypesReply) b := 1 // skip reply determinant @@ -885,6 +915,7 @@ func listSubpictureTypesReply(buf []byte) *ListSubpictureTypesReply { } // Write request to wire for ListSubpictureTypes +// listSubpictureTypesRequest writes a ListSubpictureTypes request to a byte slice. func listSubpictureTypesRequest(c *xgb.Conn, PortId xv.Port, SurfaceId Surface) []byte { size := 12 b := 0 -- cgit v1.2.3-70-g09d2