From 05d8ec6a16acf88c5ae7521d86131f5ea7f9b4e4 Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Mon, 30 Apr 2012 02:40:55 -0400 Subject: complete and total overhaul like i promised. things are much easier to reason about. still not working yet though. --- nexgb/xgbgen/size.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 nexgb/xgbgen/size.go (limited to 'nexgb/xgbgen/size.go') diff --git a/nexgb/xgbgen/size.go b/nexgb/xgbgen/size.go new file mode 100644 index 0000000..d00e297 --- /dev/null +++ b/nexgb/xgbgen/size.go @@ -0,0 +1,22 @@ +package main + +type Size struct { + Expression +} + +func newFixedSize(fixed uint) Size { + return Size{&Value{v: fixed}} +} + +func newExpressionSize(variable Expression) Size { + return Size{variable} +} + +func (s1 Size) Add(s2 Size) Size { + return Size{newBinaryOp("+", s1, s2)} +} + +func (s1 Size) Multiply(s2 Size) Size { + return Size{newBinaryOp("*", s1, s2)} +} + -- cgit v1.2.3-70-g09d2 From 2a2d8653b3a7918dfb00dcca8937b0e878279c70 Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Mon, 30 Apr 2012 02:44:31 -0400 Subject: gofmt --- nexgb/xgbgen/bufcount.go | 15 -------- nexgb/xgbgen/context.go | 4 +-- nexgb/xgbgen/expression.go | 11 +++--- nexgb/xgbgen/field.go | 19 +++++----- nexgb/xgbgen/go.go | 57 +++++++++++++++-------------- nexgb/xgbgen/main.go | 1 - nexgb/xgbgen/morph.go | 50 -------------------------- nexgb/xgbgen/representation.go | 17 +++++---- nexgb/xgbgen/size.go | 1 - nexgb/xgbgen/translation.go | 75 +++++++++++++++++++------------------- nexgb/xgbgen/type.go | 32 ++++++++--------- nexgb/xgbgen/xml.go | 81 +++++++++++++++++++++--------------------- nexgb/xgbgen/xml_expression.go | 16 ++++----- nexgb/xgbgen/xml_fields.go | 17 ++++----- 14 files changed, 163 insertions(+), 233 deletions(-) delete mode 100644 nexgb/xgbgen/bufcount.go delete mode 100644 nexgb/xgbgen/morph.go (limited to 'nexgb/xgbgen/size.go') diff --git a/nexgb/xgbgen/bufcount.go b/nexgb/xgbgen/bufcount.go deleted file mode 100644 index c3a5645..0000000 --- a/nexgb/xgbgen/bufcount.go +++ /dev/null @@ -1,15 +0,0 @@ -package main - -/* - A buffer count is a mechanism by which to keep track of which byte one - is reading or writing to/from the wire. - - It's an abstraction over the fact that while such a counter is usually - fixed, it can be made variable based on values at run-time. -*/ - -type BufCount struct { - Fixed int - Exprs []*Expression -} - diff --git a/nexgb/xgbgen/context.go b/nexgb/xgbgen/context.go index d3cbb81..67801c7 100644 --- a/nexgb/xgbgen/context.go +++ b/nexgb/xgbgen/context.go @@ -9,7 +9,7 @@ import ( type Context struct { protocol *Protocol - out *bytes.Buffer + out *bytes.Buffer } func newContext() *Context { @@ -20,7 +20,7 @@ func newContext() *Context { // Putln calls put and adds a new line to the end of 'format'. func (c *Context) Putln(format string, v ...interface{}) { - c.Put(format + "\n", v...) + c.Put(format+"\n", v...) } // Put is a short alias to write to 'out'. diff --git a/nexgb/xgbgen/expression.go b/nexgb/xgbgen/expression.go index a163692..7099c25 100644 --- a/nexgb/xgbgen/expression.go +++ b/nexgb/xgbgen/expression.go @@ -14,7 +14,7 @@ type Expression interface { } type BinaryOp struct { - Op string + Op string Expr1 Expression Expr2 Expression } @@ -23,7 +23,7 @@ func newBinaryOp(op string, expr1, expr2 Expression) Expression { switch { case expr1 != nil && expr2 != nil: return &BinaryOp{ - Op: op, + Op: op, Expr1: expr1, Expr2: expr2, } @@ -79,7 +79,7 @@ func (e *BinaryOp) Initialize(p *Protocol) { } type UnaryOp struct { - Op string + Op string Expr Expression } @@ -159,7 +159,7 @@ func (e *Value) String() string { return e.Reduce("", "") } -func (e *Value) Initialize(p *Protocol) { } +func (e *Value) Initialize(p *Protocol) {} type Bit struct { b uint @@ -181,7 +181,7 @@ func (e *Bit) String() string { return e.Reduce("", "") } -func (e *Bit) Initialize(p *Protocol) { } +func (e *Bit) Initialize(p *Protocol) {} type FieldRef struct { Name string @@ -273,4 +273,3 @@ func (e *SumOf) String() string { func (e *SumOf) Initialize(p *Protocol) { e.Name = SrcName(e.Name) } - diff --git a/nexgb/xgbgen/field.go b/nexgb/xgbgen/field.go index a659e6e..ed113e0 100644 --- a/nexgb/xgbgen/field.go +++ b/nexgb/xgbgen/field.go @@ -31,7 +31,7 @@ func (p *PadField) Size() Size { type SingleField struct { srcName string xmlName string - Type Type + Type Type } func (f *SingleField) Initialize(p *Protocol) { @@ -52,9 +52,9 @@ func (f *SingleField) Size() Size { } type ListField struct { - srcName string - xmlName string - Type Type + srcName string + xmlName string + Type Type LengthExpr Expression } @@ -85,8 +85,8 @@ type LocalField struct { type ExprField struct { srcName string xmlName string - Type Type - Expr Expression + Type Type + Expr Expression } func (f *ExprField) SrcName() string { @@ -132,8 +132,8 @@ func (f *ValueField) Initialize(p *Protocol) { } type SwitchField struct { - Name string - Expr Expression + Name string + Expr Expression Bitcases []*Bitcase } @@ -165,6 +165,5 @@ func (f *SwitchField) Initialize(p *Protocol) { type Bitcase struct { Fields []Field - Expr Expression + Expr Expression } - diff --git a/nexgb/xgbgen/go.go b/nexgb/xgbgen/go.go index ac3ed2c..014b76b 100644 --- a/nexgb/xgbgen/go.go +++ b/nexgb/xgbgen/go.go @@ -16,37 +16,37 @@ var xgbGenResourceIdName = "Id" // XML protocol description will produce an invalid Go program. // The types on the left *never* show themselves in the source. var BaseTypeMap = map[string]string{ - "CARD8": "byte", + "CARD8": "byte", "CARD16": "uint16", "CARD32": "uint32", - "INT8": "int8", - "INT16": "int16", - "INT32": "int32", - "BYTE": "byte", - "BOOL": "bool", - "float": "float64", + "INT8": "int8", + "INT16": "int16", + "INT32": "int32", + "BYTE": "byte", + "BOOL": "bool", + "float": "float64", "double": "float64", - "char": "byte", - "void": "byte", - "Id": "Id", + "char": "byte", + "void": "byte", + "Id": "Id", } // BaseTypeSizes should have precisely the same keys as in BaseTypeMap, // and the values should correspond to the size of the type in bytes. var BaseTypeSizes = map[string]uint{ - "CARD8": 1, + "CARD8": 1, "CARD16": 2, "CARD32": 4, - "INT8": 1, - "INT16": 2, - "INT32": 4, - "BYTE": 1, - "BOOL": 1, - "float": 4, + "INT8": 1, + "INT16": 2, + "INT32": 4, + "BYTE": 1, + "BOOL": 1, + "float": 4, "double": 8, - "char": 1, - "void": 1, - "Id": 4, + "char": 1, + "void": 1, + "Id": 4, } // TypeMap is a map from types in the XML to type names that is used @@ -54,13 +54,13 @@ var BaseTypeSizes = map[string]uint{ // type is replaced with the value type. var TypeMap = map[string]string{ "VISUALTYPE": "VisualInfo", - "DEPTH": "DepthInfo", - "SCREEN": "ScreenInfo", - "Setup": "SetupInfo", + "DEPTH": "DepthInfo", + "SCREEN": "ScreenInfo", + "Setup": "SetupInfo", } // NameMap is the same as TypeMap, but for names. -var NameMap = map[string]string{ } +var NameMap = map[string]string{} // Reading, writing and defining... @@ -151,8 +151,8 @@ func (s *Struct) ReadList(c *Context) { c.Putln("consumed := 0") c.Putln("consumed = 0 + consumed // no-op") // dirty hack for a no-op c.Putln("for i := 0; i < length; i++ {") - c.Putln("v[i], consumed = New%s(buf[b:])", s.SrcName()) - c.Putln("b += consumed") + c.Putln("v[i], consumed = New%s(buf[b:])", s.SrcName()) + c.Putln("b += consumed") c.Putln("}") c.Putln("return v, pad(b)") @@ -347,14 +347,14 @@ func (f *ListField) Read(c *Context) { 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) + ReadSimpleSingleField(c, fmt.Sprintf("v.%s[i]", f.SrcName()), t) c.Putln("}") c.Putln("") case *Base: length := f.LengthExpr.Reduce("v.", "") c.Putln("v.%s = make([]%s, %s)", f.SrcName(), t.SrcName(), length) c.Putln("for i := 0; i < %s; i++ {", length) - ReadSimpleSingleField(c, fmt.Sprintf("v.%s[i]", f.SrcName()), t) + ReadSimpleSingleField(c, fmt.Sprintf("v.%s[i]", f.SrcName()), t) c.Putln("}") c.Putln("") case *Struct: @@ -408,4 +408,3 @@ func (f *SwitchField) Define(c *Context) { func (f *SwitchField) Read(c *Context) { c.Putln("// reading switch field: %s (%s)", f.Name, f.Expr) } - diff --git a/nexgb/xgbgen/main.go b/nexgb/xgbgen/main.go index 33f7971..fd5eac7 100644 --- a/nexgb/xgbgen/main.go +++ b/nexgb/xgbgen/main.go @@ -62,4 +62,3 @@ func main() { } } } - diff --git a/nexgb/xgbgen/morph.go b/nexgb/xgbgen/morph.go deleted file mode 100644 index c39b333..0000000 --- a/nexgb/xgbgen/morph.go +++ /dev/null @@ -1,50 +0,0 @@ - -// Morph cascades down all of the XML and calls each type's corresponding -// Morph function with itself as an argument (the context). -func (x *XML) Morph(c *Context) { - // Start the header... - c.Putln("package xgb") - c.Putln("/*") - c.Putln("\tX protocol API for '%s.xml'.", c.xml.Header) - c.Putln("\tThis file is automatically generated. Edit at your own peril!") - c.Putln("\tGenerated on %s", - time.Now().Format("Jan 2, 2006 at 3:04:05pm MST")) - c.Putln("*/") - c.Putln("") - - x.Imports.Morph(c) - c.Putln("") - - x.Enums.Morph(c) - c.Putln("") - - x.Xids.Morph(c) - c.Putln("") - - x.XidUnions.Morph(c) - c.Putln("") - - x.TypeDefs.Morph(c) - c.Putln("") - - x.Structs.Morph(c) - c.Putln("") - - x.Unions.Morph(c) - c.Putln("") - - x.Requests.Morph(c) - c.Putln("") - - x.Errors.Morph(c) - c.Putln("") - - x.ErrorCopies.Morph(c) - c.Putln("") - - x.Events.Morph(c) - c.Putln("") - - x.EventCopies.Morph(c) - c.Putln("") -} diff --git a/nexgb/xgbgen/representation.go b/nexgb/xgbgen/representation.go index 928e219..2d33a45 100644 --- a/nexgb/xgbgen/representation.go +++ b/nexgb/xgbgen/representation.go @@ -1,14 +1,14 @@ package main type Protocol struct { - Name string - ExtXName string - ExtName string + Name string + ExtXName string + ExtName string MajorVersion string MinorVersion string - Imports []*Protocol - Types []Type + Imports []*Protocol + Types []Type Requests []*Request } @@ -28,10 +28,10 @@ func (p *Protocol) Initialize() { type Request struct { srcName string xmlName string - Opcode int + Opcode int Combine bool - Fields []Field - Reply *Reply + Fields []Field + Reply *Reply } func (r *Request) Initialize(p *Protocol) { @@ -53,4 +53,3 @@ func (r *Reply) Initialize(p *Protocol) { field.Initialize(p) } } - diff --git a/nexgb/xgbgen/size.go b/nexgb/xgbgen/size.go index d00e297..70edb8f 100644 --- a/nexgb/xgbgen/size.go +++ b/nexgb/xgbgen/size.go @@ -19,4 +19,3 @@ func (s1 Size) Add(s2 Size) Size { func (s1 Size) Multiply(s2 Size) Size { return Size{newBinaryOp("*", s1, s2)} } - diff --git a/nexgb/xgbgen/translation.go b/nexgb/xgbgen/translation.go index 85e756d..36daa8b 100644 --- a/nexgb/xgbgen/translation.go +++ b/nexgb/xgbgen/translation.go @@ -1,4 +1,5 @@ package main + /* translation.go provides a 'Translate' method on every XML type that converts the XML type into our "better" representation. @@ -19,14 +20,14 @@ import ( func (xml *XML) Translate() *Protocol { protocol := &Protocol{ - Name: xml.Header, - ExtXName: xml.ExtensionXName, - ExtName: xml.ExtensionName, + Name: xml.Header, + ExtXName: xml.ExtensionXName, + ExtName: xml.ExtensionName, MajorVersion: xml.MajorVersion, MinorVersion: xml.MinorVersion, - Imports: make([]*Protocol, 0), - Types: make([]Type, 0), + Imports: make([]*Protocol, 0), + Types: make([]Type, 0), Requests: make([]*Request, len(xml.Requests)), } @@ -40,7 +41,7 @@ func (xml *XML) Translate() *Protocol { newBaseType := &Base{ srcName: srcName, xmlName: xmlName, - size: newFixedSize(BaseTypeSizes[xmlName]), + size: newFixedSize(BaseTypeSizes[xmlName]), } protocol.Types = append(protocol.Types, newBaseType) } @@ -105,12 +106,12 @@ func (xml *XML) Translate() *Protocol { func (x *XMLEnum) Translate() *Enum { enum := &Enum{ xmlName: x.Name, - Items: make([]*EnumItem, len(x.Items)), + Items: make([]*EnumItem, len(x.Items)), } for i, item := range x.Items { enum.Items[i] = &EnumItem{ xmlName: item.Name, - Expr: item.Expr.Translate(), + Expr: item.Expr.Translate(), } } return enum @@ -125,16 +126,16 @@ func (x *XMLXid) Translate() *Resource { func (x *XMLTypeDef) Translate() *TypeDef { return &TypeDef{ xmlName: x.New, - Old: newTranslation(x.Old), + Old: newTranslation(x.Old), } } func (x *XMLEvent) Translate() *Event { ev := &Event{ - xmlName: x.Name, - Number: x.Number, + xmlName: x.Name, + Number: x.Number, NoSequence: x.NoSequence, - Fields: make([]Field, len(x.Fields)), + Fields: make([]Field, len(x.Fields)), } for i, field := range x.Fields { ev.Fields[i] = field.Translate() @@ -145,16 +146,16 @@ func (x *XMLEvent) Translate() *Event { func (x *XMLEventCopy) Translate() *EventCopy { return &EventCopy{ xmlName: x.Name, - Number: x.Number, - Old: newTranslation(x.Ref), + Number: x.Number, + Old: newTranslation(x.Ref), } } func (x *XMLError) Translate() *Error { err := &Error{ xmlName: x.Name, - Number: x.Number, - Fields: make([]Field, len(x.Fields)), + Number: x.Number, + Fields: make([]Field, len(x.Fields)), } for i, field := range x.Fields { err.Fields[i] = field.Translate() @@ -165,15 +166,15 @@ func (x *XMLError) Translate() *Error { func (x *XMLErrorCopy) Translate() *ErrorCopy { return &ErrorCopy{ xmlName: x.Name, - Number: x.Number, - Old: newTranslation(x.Ref), + Number: x.Number, + Old: newTranslation(x.Ref), } } func (x *XMLStruct) Translate() *Struct { s := &Struct{ xmlName: x.Name, - Fields: make([]Field, len(x.Fields)), + Fields: make([]Field, len(x.Fields)), } for i, field := range x.Fields { s.Fields[i] = field.Translate() @@ -184,7 +185,7 @@ func (x *XMLStruct) Translate() *Struct { func (x *XMLUnion) Translate() *Union { u := &Union{ xmlName: x.Name, - Fields: make([]Field, len(x.Fields)), + Fields: make([]Field, len(x.Fields)), } for i, field := range x.Fields { u.Fields[i] = field.Translate() @@ -195,10 +196,10 @@ func (x *XMLUnion) Translate() *Union { func (x *XMLRequest) Translate() *Request { r := &Request{ xmlName: x.Name, - Opcode: x.Opcode, + Opcode: x.Opcode, Combine: x.Combine, - Fields: make([]Field, len(x.Fields)), - Reply: x.Reply.Translate(), + Fields: make([]Field, len(x.Fields)), + Reply: x.Reply.Translate(), } for i, field := range x.Fields { r.Fields[i] = field.Translate() @@ -211,7 +212,7 @@ func (x *XMLRequest) Translate() *Request { // (i.e., a parameter in the caller but does not get send over the wire.) stringLenLocal := &LocalField{&SingleField{ xmlName: "string_len", - Type: newTranslation("CARD16"), + Type: newTranslation("CARD16"), }} r.Fields = append(r.Fields, stringLenLocal) @@ -243,7 +244,7 @@ func (x *XMLExpression) Translate() Expression { log.Panicf("'op' found %d expressions; expected 2.", len(x.Exprs)) } return &BinaryOp{ - Op: x.Op, + Op: x.Op, Expr1: x.Exprs[0].Translate(), Expr2: x.Exprs[1].Translate(), } @@ -252,7 +253,7 @@ func (x *XMLExpression) Translate() Expression { log.Panicf("'unop' found %d expressions; expected 1.", len(x.Exprs)) } return &UnaryOp{ - Op: x.Op, + Op: x.Op, Expr: x.Exprs[0].Translate(), } case "popcount": @@ -279,7 +280,7 @@ func (x *XMLExpression) Translate() Expression { x.Data) } if bit < 0 || bit > 31 { - log.Panicf("A 'bit' literal must be in the range [0, 31], but " + + log.Panicf("A 'bit' literal must be in the range [0, 31], but "+ " is %d", bit) } return &Bit{ @@ -300,7 +301,7 @@ func (x *XMLExpression) Translate() Expression { } } - log.Panicf("Unrecognized tag '%s' in expression context. Expected one of " + + log.Panicf("Unrecognized tag '%s' in expression context. Expected one of "+ "op, fieldref, value, bit, enumref, unop, sumof or popcount.", x.XMLName.Local) panic("unreachable") @@ -315,24 +316,24 @@ func (x *XMLField) Translate() Field { case "field": return &SingleField{ xmlName: x.Name, - Type: newTranslation(x.Type), + Type: newTranslation(x.Type), } case "list": return &ListField{ - xmlName: x.Name, - Type: newTranslation(x.Type), + xmlName: x.Name, + Type: newTranslation(x.Type), LengthExpr: x.Expr.Translate(), } case "localfield": return &LocalField{&SingleField{ xmlName: x.Name, - Type: newTranslation(x.Type), + Type: newTranslation(x.Type), }} case "exprfield": return &ExprField{ xmlName: x.Name, - Type: newTranslation(x.Type), - Expr: x.Expr.Translate(), + Type: newTranslation(x.Type), + Expr: x.Expr.Translate(), } case "valueparam": return &ValueField{ @@ -342,8 +343,8 @@ func (x *XMLField) Translate() Field { } case "switch": swtch := &SwitchField{ - Name: x.Name, - Expr: x.Expr.Translate(), + Name: x.Name, + Expr: x.Expr.Translate(), Bitcases: make([]*Bitcase, len(x.Bitcases)), } for i, bitcase := range x.Bitcases { @@ -358,7 +359,7 @@ func (x *XMLField) Translate() Field { func (x *XMLBitcase) Translate() *Bitcase { b := &Bitcase{ - Expr: x.Expr().Translate(), + Expr: x.Expr().Translate(), Fields: make([]Field, len(x.Fields)), } for i, field := range x.Fields { diff --git a/nexgb/xgbgen/type.go b/nexgb/xgbgen/type.go index 1574922..9fbef65 100644 --- a/nexgb/xgbgen/type.go +++ b/nexgb/xgbgen/type.go @@ -77,7 +77,7 @@ func (t *Translation) Initialize(p *Protocol) { type Base struct { srcName string xmlName string - size Size + size Size } func (b *Base) SrcName() string { @@ -99,13 +99,13 @@ func (b *Base) Initialize(p *Protocol) { type Enum struct { srcName string xmlName string - Items []*EnumItem + Items []*EnumItem } type EnumItem struct { srcName string xmlName string - Expr Expression + Expr Expression } func (enum *Enum) SrcName() string { @@ -154,7 +154,7 @@ func (r *Resource) Initialize(p *Protocol) { type TypeDef struct { srcName string xmlName string - Old Type + Old Type } func (t *TypeDef) SrcName() string { @@ -175,11 +175,11 @@ func (t *TypeDef) Initialize(p *Protocol) { } type Event struct { - srcName string - xmlName string - Number int + srcName string + xmlName string + Number int NoSequence bool - Fields []Field + Fields []Field } func (e *Event) SrcName() string { @@ -208,8 +208,8 @@ func (e *Event) EvType() string { type EventCopy struct { srcName string xmlName string - Old Type - Number int + Old Type + Number int } func (e *EventCopy) SrcName() string { @@ -239,8 +239,8 @@ func (e *EventCopy) EvType() string { type Error struct { srcName string xmlName string - Number int - Fields []Field + Number int + Fields []Field } func (e *Error) SrcName() string { @@ -270,8 +270,8 @@ func (e *Error) ErrType() string { type ErrorCopy struct { srcName string xmlName string - Old Type - Number int + Old Type + Number int } func (e *ErrorCopy) SrcName() string { @@ -305,7 +305,7 @@ func (e *ErrorCopy) ErrType() string { type Struct struct { srcName string xmlName string - Fields []Field + Fields []Field } func (s *Struct) SrcName() string { @@ -334,7 +334,7 @@ func (s *Struct) Initialize(p *Protocol) { type Union struct { srcName string xmlName string - Fields []Field + Fields []Field } func (u *Union) SrcName() string { diff --git a/nexgb/xgbgen/xml.go b/nexgb/xgbgen/xml.go index 7e50831..f219c2d 100644 --- a/nexgb/xgbgen/xml.go +++ b/nexgb/xgbgen/xml.go @@ -8,29 +8,29 @@ import ( type XML struct { // Root 'xcb' element properties. - XMLName xml.Name `xml:"xcb"` - Header string `xml:"header,attr"` - ExtensionXName string `xml:"extension-xname,attr"` - ExtensionName string `xml:"extension-name,attr"` - MajorVersion string `xml:"major-version,attr"` - MinorVersion string `xml:"minor-version,attr"` + XMLName xml.Name `xml:"xcb"` + Header string `xml:"header,attr"` + ExtensionXName string `xml:"extension-xname,attr"` + ExtensionName string `xml:"extension-name,attr"` + MajorVersion string `xml:"major-version,attr"` + MinorVersion string `xml:"minor-version,attr"` // Types for all top-level elements. // First are the simple ones. - Imports XMLImports `xml:"import"` - Enums XMLEnums `xml:"enum"` - Xids XMLXids `xml:"xidtype"` - XidUnions XMLXids `xml:"xidunion"` - TypeDefs XMLTypeDefs `xml:"typedef"` + Imports XMLImports `xml:"import"` + Enums XMLEnums `xml:"enum"` + Xids XMLXids `xml:"xidtype"` + XidUnions XMLXids `xml:"xidunion"` + TypeDefs XMLTypeDefs `xml:"typedef"` EventCopies XMLEventCopies `xml:"eventcopy"` ErrorCopies XMLErrorCopies `xml:"errorcopy"` // Here are the complex ones, i.e., anything with "structure contents" - Structs XMLStructs `xml:"struct"` - Unions XMLUnions `xml:"union"` + Structs XMLStructs `xml:"struct"` + Unions XMLUnions `xml:"union"` Requests XMLRequests `xml:"request"` - Events XMLEvents `xml:"event"` - Errors XMLErrors `xml:"error"` + Events XMLEvents `xml:"event"` + Errors XMLErrors `xml:"error"` } type XMLImports []*XMLImport @@ -39,14 +39,14 @@ func (imports XMLImports) Eval() { for _, imp := range imports { xmlBytes, err := ioutil.ReadFile(*protoPath + "/" + imp.Name + ".xml") if err != nil { - log.Fatalf("Could not read X protocol description for import " + + log.Fatalf("Could not read X protocol description for import "+ "'%s' because: %s", imp.Name, err) } imp.xml = &XML{} err = xml.Unmarshal(xmlBytes, imp.xml) if err != nil { - log.Fatal("Could not parse X protocol description for import " + + log.Fatal("Could not parse X protocol description for import "+ "'%s' because: %s", imp.Name, err) } @@ -57,18 +57,18 @@ func (imports XMLImports) Eval() { type XMLImport struct { Name string `xml:",chardata"` - xml *XML `xml:"-"` + xml *XML `xml:"-"` } type XMLEnums []XMLEnum type XMLEnum struct { - Name string `xml:"name,attr"` + Name string `xml:"name,attr"` Items []*XMLEnumItem `xml:"item"` } type XMLEnumItem struct { - Name string `xml:"name,attr"` + Name string `xml:"name,attr"` Expr *XMLExpression `xml:",any"` } @@ -76,7 +76,7 @@ type XMLXids []*XMLXid type XMLXid struct { XMLName xml.Name - Name string `xml:"name,attr"` + Name string `xml:"name,attr"` } type XMLTypeDefs []*XMLTypeDef @@ -89,41 +89,41 @@ type XMLTypeDef struct { type XMLEventCopies []*XMLEventCopy type XMLEventCopy struct { - Name string `xml:"name,attr"` - Number int `xml:"number,attr"` - Ref string `xml:"ref,attr"` + Name string `xml:"name,attr"` + Number int `xml:"number,attr"` + Ref string `xml:"ref,attr"` } type XMLErrorCopies []*XMLErrorCopy type XMLErrorCopy struct { - Name string `xml:"name,attr"` - Number int `xml:"number,attr"` - Ref string `xml:"ref,attr"` + Name string `xml:"name,attr"` + Number int `xml:"number,attr"` + Ref string `xml:"ref,attr"` } type XMLStructs []*XMLStruct type XMLStruct struct { - Name string `xml:"name,attr"` + Name string `xml:"name,attr"` Fields XMLFields `xml:",any"` } type XMLUnions []*XMLUnion type XMLUnion struct { - Name string `xml:"name,attr"` + Name string `xml:"name,attr"` Fields XMLFields `xml:",any"` } type XMLRequests []*XMLRequest type XMLRequest struct { - Name string `xml:"name,attr"` - Opcode int `xml:"opcode,attr"` - Combine bool `xml:"combine-adjacent,attr"` - Fields XMLFields `xml:",any"` - Reply *XMLReply `xml:"reply"` + Name string `xml:"name,attr"` + Opcode int `xml:"opcode,attr"` + Combine bool `xml:"combine-adjacent,attr"` + Fields XMLFields `xml:",any"` + Reply *XMLReply `xml:"reply"` } type XMLReply struct { @@ -133,17 +133,16 @@ type XMLReply struct { type XMLEvents []*XMLEvent type XMLEvent struct { - Name string `xml:"name,attr"` - Number int `xml:"number,attr"` - NoSequence bool `xml:"no-sequence-number,true"` - Fields XMLFields `xml:",any"` + Name string `xml:"name,attr"` + Number int `xml:"number,attr"` + NoSequence bool `xml:"no-sequence-number,true"` + Fields XMLFields `xml:",any"` } type XMLErrors []*XMLError type XMLError struct { - Name string `xml:"name,attr"` - Number int `xml:"number,attr"` + Name string `xml:"name,attr"` + Number int `xml:"number,attr"` Fields XMLFields `xml:",any"` } - diff --git a/nexgb/xgbgen/xml_expression.go b/nexgb/xgbgen/xml_expression.go index 57ff62e..2989668 100644 --- a/nexgb/xgbgen/xml_expression.go +++ b/nexgb/xgbgen/xml_expression.go @@ -13,14 +13,14 @@ type XMLExpression struct { Exprs []*XMLExpression `xml:",any"` Data string `xml:",chardata"` - Op string `xml:"op,attr"` - Ref string `xml:"ref,attr"` + Op string `xml:"op,attr"` + Ref string `xml:"ref,attr"` } func newValueExpression(v uint) *XMLExpression { return &XMLExpression{ XMLName: xml.Name{Local: "value"}, - Data: fmt.Sprintf("%d", v), + Data: fmt.Sprintf("%d", v), } } @@ -87,22 +87,22 @@ func (e *XMLExpression) Eval() uint { e.Data) } if bit < 0 || bit > 31 { - log.Panicf("A 'bit' literal must be in the range [0, 31], but " + + log.Panicf("A 'bit' literal must be in the range [0, 31], but "+ " is %d", bit) } return 1 << uint(bit) case "fieldref": - log.Panicf("Cannot compute concrete value of 'fieldref' in " + + log.Panicf("Cannot compute concrete value of 'fieldref' in "+ "expression '%s'.", e) case "enumref": - log.Panicf("Cannot compute concrete value of 'enumref' in " + + log.Panicf("Cannot compute concrete value of 'enumref' in "+ "expression '%s'.", e) case "sumof": - log.Panicf("Cannot compute concrete value of 'sumof' in " + + log.Panicf("Cannot compute concrete value of 'sumof' in "+ "expression '%s'.", e) } - log.Panicf("Unrecognized tag '%s' in expression context. Expected one of " + + log.Panicf("Unrecognized tag '%s' in expression context. Expected one of "+ "op, fieldref, value, bit, enumref, unop, sumof or popcount.", e.XMLName.Local) panic("unreachable") diff --git a/nexgb/xgbgen/xml_fields.go b/nexgb/xgbgen/xml_fields.go index d6d99c5..991141b 100644 --- a/nexgb/xgbgen/xml_fields.go +++ b/nexgb/xgbgen/xml_fields.go @@ -1,4 +1,5 @@ package main + /* A series of fields should be taken as "structure contents", and *not* just the single 'field' elements. Namely, 'fields' subsumes 'field' @@ -50,8 +51,8 @@ type XMLField struct { // I don't know which elements these are for. The documentation is vague. // They also seem to be completely optional. - OptEnum string `xml:"enum,attr"` - OptMask string `xml:"mask,attr"` + OptEnum string `xml:"enum,attr"` + OptMask string `xml:"mask,attr"` OptAltEnum string `xml:"altenum,attr"` } @@ -103,14 +104,14 @@ type XMLBitcase struct { // All the different expressions. // When it comes time to choose one, use the 'Expr' method. - ExprOp *XMLExpression `xml:"op"` - ExprUnOp *XMLExpression `xml:"unop"` + ExprOp *XMLExpression `xml:"op"` + ExprUnOp *XMLExpression `xml:"unop"` ExprField *XMLExpression `xml:"fieldref"` ExprValue *XMLExpression `xml:"value"` - ExprBit *XMLExpression `xml:"bit"` - ExprEnum *XMLExpression `xml:"enumref"` - ExprSum *XMLExpression `xml:"sumof"` - ExprPop *XMLExpression `xml:"popcount"` + ExprBit *XMLExpression `xml:"bit"` + ExprEnum *XMLExpression `xml:"enumref"` + ExprSum *XMLExpression `xml:"sumof"` + ExprPop *XMLExpression `xml:"popcount"` } // StringPrefix is for debugging purposes only. -- cgit v1.2.3-70-g09d2 From 18b2d420b092d71313f0c05210c3038ff32483e7 Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Sun, 6 May 2012 02:21:31 -0400 Subject: added documentation and did some slight restructuring. it's party time. --- nexgb/xgbgen/context.go | 2 + nexgb/xgbgen/doc.go | 74 +++++++++++++++++++ nexgb/xgbgen/expression.go | 41 +++++++++++ nexgb/xgbgen/field.go | 60 ++++++++++++++-- nexgb/xgbgen/misc.go | 4 +- nexgb/xgbgen/protocol.go | 41 +++++++++++ nexgb/xgbgen/representation.go | 149 -------------------------------------- nexgb/xgbgen/request_reply.go | 149 ++++++++++++++++++++++++++++++++++++++ nexgb/xgbgen/size.go | 9 +++ nexgb/xgbgen/xml.go | 64 +++++++---------- nexgb/xgbgen/xml_expression.go | 160 ----------------------------------------- nexgb/xgbgen/xml_fields.go | 71 +----------------- 12 files changed, 402 insertions(+), 422 deletions(-) create mode 100644 nexgb/xgbgen/doc.go create mode 100644 nexgb/xgbgen/protocol.go delete mode 100644 nexgb/xgbgen/representation.go create mode 100644 nexgb/xgbgen/request_reply.go delete mode 100644 nexgb/xgbgen/xml_expression.go (limited to 'nexgb/xgbgen/size.go') diff --git a/nexgb/xgbgen/context.go b/nexgb/xgbgen/context.go index 3e484f3..d433531 100644 --- a/nexgb/xgbgen/context.go +++ b/nexgb/xgbgen/context.go @@ -8,6 +8,8 @@ import ( "time" ) +// Context represents the protocol we're converting to Go, and a writer +// buffer to write the Go source to. type Context struct { protocol *Protocol out *bytes.Buffer diff --git a/nexgb/xgbgen/doc.go b/nexgb/xgbgen/doc.go new file mode 100644 index 0000000..4ba6145 --- /dev/null +++ b/nexgb/xgbgen/doc.go @@ -0,0 +1,74 @@ +/* +xgbgen constructs Go source files from xproto XML description files. xgbgen +accomplishes the same task as the Python code generator for XCB and xpyb. + +Usage: + xgbgen [flags] some-protocol.xml + +The flags are: + --proto-path path + The path to a directory containing xproto XML description files. + This is only necessary when 'some-protocol.xml' imports other + protocol files. + --gofmt=true + When false, the outputted Go code will not be gofmt'd. And it won't + be very pretty at all. This is typically useful if there are syntax + errors that need to be debugged in code generation. gofmt will hiccup; + this will allow you to see the raw code. + +How it works + +xgbgen works by parsing the input XML file using Go's encoding/xml package. +The majority of this work is done in xml.go and xml_fields.go, where the +appropriate types are declared. + +Due to the nature of the XML in the protocol description files, the types +required to parse the XML are not well suited to reasoning about code +generation. Because of this, all data parsed in the XML types is translated +into more reasonable types. This translation is done in translation.go, +and is mainly grunt work. (The only interesting tidbits are the translation +of XML names to Go source names, and connecting fields with their +appropriate types.) + +The organization of these types is greatly +inspired by the description of the XML found here: +http://cgit.freedesktop.org/xcb/proto/tree/doc/xml-xcb.txt + +These types come with a lot of supporting methods to make their use in +code generation easier. They can be found in expression.go, field.go, +protocol.go, request_reply.go and type.go. Of particular interest are +expression evaluation and size calculation (in bytes). + +These types also come with supporting methods that convert their +representation into Go source code. I've quartered such methods in +go.go, go_error.go, go_event.go, go_list.go, go_request_reply.go, +go_single_field.go, go_struct.go and go_union.go. The idea is to keep +as much of the Go specific code generation in one area as possible. Namely, +while not *all* Go related code is found in the 'go*.go' files, *most* +of it is. (If there's any interest in using xgbgen for other languages, +I'd be happy to try and make xgbgen a little more friendly in this regard. +I did, however, design xgbgen with this in mind, so it shouldn't involve +anything as serious as a re-design.) + +Why + +I wrote xgbgen because I found the existing code generator that was written in +Python to be unwieldy. In particular, static and strong typing greatly helped +me reason better about the code generation task. + +What does not work + +The core X protocol should be completely working. As far as I know, most +extensions should work too, although I've only tested (and not much) the +Xinerama and RandR extensions. + +XKB does not work. I don't have any real plans of working on this unless there +is demand and I have some test cases to work with. (i.e., even if I could get +something generated for XKB, I don't have the inclination to understand it +enough to verify that it works.) XKB poses several extremely difficult +problems that XCB also has trouble with. More info on that can be found at +http://cgit.freedesktop.org/xcb/libxcb/tree/doc/xkb_issues and +http://cgit.freedesktop.org/xcb/libxcb/tree/doc/xkb_internals. + +*/ +package main diff --git a/nexgb/xgbgen/expression.go b/nexgb/xgbgen/expression.go index 2350979..721ebfd 100644 --- a/nexgb/xgbgen/expression.go +++ b/nexgb/xgbgen/expression.go @@ -5,11 +5,32 @@ import ( "log" ) +// Expression represents all the different forms of expressions possible in +// side an XML protocol description file. It's also received a few custom +// addendums to make applying special functions (like padding) easier. type Expression interface { + // Concrete determines whether this particular expression can be computed + // to some constant value inside xgbgen. (The alternative is that the + // expression can only be computed with values at run time of the + // generated code.) Concrete() bool + + // Eval evaluates a concrete expression. It is an error to call Eval + // on any expression that is not concrete (or contains any sub-expression + // that is not concrete). Eval() uint + + // Reduce attempts to evaluate any concrete sub-expressions. + // i.e., (1 + 2 * (5 + 1 + someSizeOfStruct) reduces to + // (3 * (6 + someSizeOfStruct)). + // 'prefix' is used preprended to any field reference name. Reduce(prefix string) string + + // String is an alias for Reduce("") String() string + + // Initialize makes sure all names in this expression and any subexpressions + // have been translated to Go source names. Initialize(p *Protocol) } @@ -41,12 +62,17 @@ func (e *Function) Initialize(p *Protocol) { e.Expr.Initialize(p) } +// BinaryOp is an expression that performs some operation (defined in the XML +// file) with Expr1 and Expr2 as operands. type BinaryOp struct { Op string Expr1 Expression Expr2 Expression } +// newBinaryOp constructs a new binary expression when both expr1 and expr2 +// are not nil. If one or both are nil, then the non-nil expression is +// returned unchanged or nil is returned. func newBinaryOp(op string, expr1, expr2 Expression) Expression { switch { case expr1 != nil && expr2 != nil: @@ -124,6 +150,8 @@ func (e *BinaryOp) Initialize(p *Protocol) { e.Expr2.Initialize(p) } +// UnaryOp is the same as BinaryOp, except it's a unary operator with only +// one sub-expression. type UnaryOp struct { Op string Expr Expression @@ -158,6 +186,8 @@ func (e *UnaryOp) Initialize(p *Protocol) { e.Expr.Initialize(p) } +// Padding represents the application of the 'pad' function to some +// sub-expression. type Padding struct { Expr Expression } @@ -185,6 +215,8 @@ func (e *Padding) Initialize(p *Protocol) { e.Expr.Initialize(p) } +// PopCount represents the application of the 'PopCount' function to +// some sub-expression. type PopCount struct { Expr Expression } @@ -212,6 +244,7 @@ func (e *PopCount) Initialize(p *Protocol) { e.Expr.Initialize(p) } +// Value represents some constant integer. type Value struct { v uint } @@ -234,6 +267,7 @@ func (e *Value) String() string { func (e *Value) Initialize(p *Protocol) {} +// Bit represents some bit whose value is computed by '1 << bit'. type Bit struct { b uint } @@ -256,6 +290,8 @@ func (e *Bit) String() string { func (e *Bit) Initialize(p *Protocol) {} +// FieldRef represents a reference to some variable in the generated code +// with name Name. type FieldRef struct { Name string } @@ -285,6 +321,9 @@ func (e *FieldRef) Initialize(p *Protocol) { e.Name = SrcName(p, e.Name) } +// EnumRef represents a reference to some enumeration field. +// EnumKind is the "group" an EnumItem is the name of the specific enumeration +// value inside that group. type EnumRef struct { EnumKind Type EnumItem string @@ -312,6 +351,8 @@ func (e *EnumRef) Initialize(p *Protocol) { e.EnumItem = SrcName(p, e.EnumItem) } +// SumOf represents a summation of the variable in the generated code named by +// Name. It is not currently used. (It's XKB voodoo.) type SumOf struct { Name string } diff --git a/nexgb/xgbgen/field.go b/nexgb/xgbgen/field.go index 5041f77..725f3de 100644 --- a/nexgb/xgbgen/field.go +++ b/nexgb/xgbgen/field.go @@ -6,20 +6,48 @@ import ( "strings" ) +// Field corresponds to any field described in an XML protocol description +// file. This includes struct fields, union fields, request fields, +// reply fields and so on. +// To make code generation easier, fields that have types are also stored. +// Note that not all fields support all methods defined in this interface. +// For instance, a padding field does not have a source name. type Field interface { + // Initialize sets up the source name of this field. Initialize(p *Protocol) + + // SrcName is the Go source name of this field. SrcName() string + + // XmlName is the name of this field from the XML file. XmlName() string + + // SrcType is the Go source type name of this field. SrcType() string + + // Size returns an expression that computes the size (in bytes) + // of this field. Size() Size + // Define writes the Go code to declare this field (in a struct definition). Define(c *Context) + + // Read writes the Go code to convert a byte slice to a Go value + // of this field. + // 'prefix' is the prefix of the name of the Go value. Read(c *Context, prefix string) + + // Write writes the Go code to convert a Go value to a byte slice of + // this field. + // 'prefix' is the prefix of the name of the Go value. Write(c *Context, prefix string) } func (pad *PadField) Initialize(p *Protocol) {} +// PadField represents any type of padding. It is omitted from +// definitions, but is used in Read/Write to increment the buffer index. +// It is also used in size calculation. type PadField struct { Bytes uint } @@ -40,6 +68,8 @@ func (p *PadField) Size() Size { return newFixedSize(p.Bytes) } +// SingleField represents most of the fields in an XML protocol description. +// It corresponds to any single value. type SingleField struct { srcName string xmlName string @@ -67,6 +97,7 @@ func (f *SingleField) Size() Size { return f.Type.Size() } +// ListField represents a list of values. type ListField struct { srcName string xmlName string @@ -89,6 +120,9 @@ func (f *ListField) SrcType() string { return fmt.Sprintf("[]%s", f.Type.SrcName()) } +// Length computes the *number* of values in a list. +// If this ListField does not have any length expression, we throw our hands +// up and simply compute the 'len' of the field name of this list. func (f *ListField) Length() Size { if f.LengthExpr == nil { return newExpressionSize(&Function{ @@ -101,6 +135,12 @@ func (f *ListField) Length() Size { return newExpressionSize(f.LengthExpr) } +// Size computes the *size* of a list (in bytes). +// It it typically a simple matter of multiplying the length of the list by +// the size of the type of the list. +// But if it's a list of struct where the struct has a list field, we use a +// special function written in go_struct.go to compute the size (since the +// size in this case can only be computed recursively). func (f *ListField) Size() Size { simpleLen := &Function{ Name: "pad", @@ -120,11 +160,6 @@ func (f *ListField) Size() Size { } 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: @@ -145,10 +180,14 @@ func (f *ListField) Initialize(p *Protocol) { } } +// LocalField is exactly the same as a regular SingleField, except it isn't +// sent over the wire. (i.e., it's probably used to compute an ExprField). type LocalField struct { *SingleField } +// ExprField is a field that is not parameterized, but is computed from values +// of other fields. type ExprField struct { srcName string xmlName string @@ -178,6 +217,9 @@ func (f *ExprField) Initialize(p *Protocol) { f.Expr.Initialize(p) } +// ValueField represents two fields in one: a mask and a list of 4-byte +// integers. The mask specifies which kinds of values are in the list. +// (i.e., See ConfigureWindow, CreateWindow, ChangeWindowAttributes, etc.) type ValueField struct { Parent interface{} MaskType Type @@ -197,6 +239,10 @@ func (f *ValueField) SrcType() string { return f.MaskType.SrcName() } +// Size computes the size in bytes of the combination of the mask and list +// in this value field. +// The expression to compute this looks complicated, but it's really just +// the number of bits set in the mask multiplied 4 (and padded of course). func (f *ValueField) Size() Size { maskSize := f.MaskType.Size() listSize := newExpressionSize(&Function{ @@ -234,6 +280,8 @@ func (f *ValueField) Initialize(p *Protocol) { f.ListName = SrcName(p, f.ListName) } +// SwitchField represents a 'switch' element in the XML protocol description +// file. It is not currently used. (i.e., it is XKB voodoo.) type SwitchField struct { Name string Expr Expression @@ -270,6 +318,8 @@ func (f *SwitchField) Initialize(p *Protocol) { } } +// Bitcase represents a single bitcase inside a switch expression. +// It is not currently used. (i.e., it's XKB voodoo.) type Bitcase struct { Fields []Field Expr Expression diff --git a/nexgb/xgbgen/misc.go b/nexgb/xgbgen/misc.go index 13c4cc2..85d788f 100644 --- a/nexgb/xgbgen/misc.go +++ b/nexgb/xgbgen/misc.go @@ -7,7 +7,7 @@ import ( // AllCaps is a regex to test if a string identifier is made of // all upper case letters. -var AllCaps = regexp.MustCompile("^[A-Z0-9]+$") +var allCaps = regexp.MustCompile("^[A-Z0-9]+$") // popCount counts number of bits 'set' in mask. func popCount(mask uint) uint { @@ -30,7 +30,7 @@ func pad(n int) int { // first letter of each chunk, and smushes'em back together. func splitAndTitle(s string) string { // If the string is all caps, lower it and capitalize first letter. - if AllCaps.MatchString(s) { + if allCaps.MatchString(s) { return strings.Title(strings.ToLower(s)) } diff --git a/nexgb/xgbgen/protocol.go b/nexgb/xgbgen/protocol.go new file mode 100644 index 0000000..505b400 --- /dev/null +++ b/nexgb/xgbgen/protocol.go @@ -0,0 +1,41 @@ +package main + +import ( + "strings" +) + +// Protocol is a type that encapsulates all information about one +// particular XML file. It also contains links to other protocol types +// if this protocol imports other other extensions. The import relationship +// is recursive. +type Protocol struct { + Name string + ExtXName string + ExtName string + MajorVersion string + MinorVersion string + + Imports []*Protocol + Types []Type + Requests []*Request +} + +// Initialize traverses all structures, looks for 'Translation' type, +// and looks up the real type in the namespace. It also sets the source +// name for all relevant fields/structures. +// This is necessary because we don't traverse the XML in order initially. +func (p *Protocol) Initialize() { + for _, typ := range p.Types { + typ.Initialize(p) + } + for _, req := range p.Requests { + req.Initialize(p) + } +} + +// 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" +} + diff --git a/nexgb/xgbgen/representation.go b/nexgb/xgbgen/representation.go deleted file mode 100644 index 62a3eb2..0000000 --- a/nexgb/xgbgen/representation.go +++ /dev/null @@ -1,149 +0,0 @@ -package main - -import ( - "fmt" - "log" - "strings" - "unicode" -) - -type Protocol struct { - Name string - ExtXName string - ExtName string - MajorVersion string - MinorVersion string - - Imports []*Protocol - Types []Type - Requests []*Request -} - -// Initialize traverses all structures, looks for 'Translation' type, -// and looks up the real type in the namespace. It also sets the source -// name for all relevant fields/structures. -// This is necessary because we don't traverse the XML in order initially. -func (p *Protocol) Initialize() { - for _, typ := range p.Types { - typ.Initialize(p) - } - for _, req := range p.Requests { - req.Initialize(p) - } -} - -type Request struct { - srcName string - xmlName string - Opcode int - Combine bool - Fields []Field - Reply *Reply -} - -func (r *Request) Initialize(p *Protocol) { - 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) - } - for _, field := range r.Fields { - field.Initialize(p) - } -} - -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()) - } - 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()) - } - return fmt.Sprintf("%sReply", r.SrcName()) -} - -func (r *Request) ReqName() string { - 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. -// 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 { - 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 newExpressionSize(&Padding{ - Expr: size.Expression, - }) -} - -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/request_reply.go b/nexgb/xgbgen/request_reply.go new file mode 100644 index 0000000..7cd2859 --- /dev/null +++ b/nexgb/xgbgen/request_reply.go @@ -0,0 +1,149 @@ +package main + +import ( + "fmt" + "log" + "strings" + "unicode" +) + +// Request represents all XML 'request' nodes. +// If the request doesn't have a reply, Reply is nil. +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. + Fields []Field // All fields in the request. + Reply *Reply // A reply, if one exists for this request. +} + +// Initialize creates the proper Go source name for this request. +// 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" { + r.srcName = strings.Title(strings.ToLower(p.Name)) + r.srcName + } + + if r.Reply != nil { + r.Reply.Initialize(p) + } + for _, field := range r.Fields { + field.Initialize(p) + } +} + +func (r *Request) SrcName() string { + return r.srcName +} + +func (r *Request) XmlName() string { + return r.xmlName +} + +// ReplyName gets the Go source name of the function that generates a +// reply type from a slice of bytes. +// The generated function is not currently exported. +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) +} + +// ReplyTypeName gets the Go source name of the type holding all reply data +// for this request. +func (r *Request) ReplyTypeName() 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()) +} + +// ReqName gets the Go source name of the function that generates a byte +// slice from a list of parameters. +// The generated function is not currently exported. +func (r *Request) ReqName() string { + name := r.SrcName() + lower := string(unicode.ToLower(rune(name[0]))) + name[1:] + return fmt.Sprintf("%sRequest", lower) +} + +// CookieName gets the Go source name of the type that holds cookies for +// this request. +func (r *Request) CookieName() string { + return fmt.Sprintf("%sCookie", 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 this is a core protocol request, we squeeze in an extra byte of + // data (from the fields below) between the opcode and the size of the + // 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" { + size = size.Add(newFixedSize(3)) + } else { + size = size.Add(newFixedSize(4)) + } + + for _, field := range r.Fields { + switch field.(type) { + case *LocalField: // local fields don't go over the wire + continue + case *SingleField: + // mofos!!! + if r.SrcName() == "ConfigureWindow" && + field.SrcName() == "ValueMask" { + + continue + } + size = size.Add(field.Size()) + default: + size = size.Add(field.Size()) + } + } + return newExpressionSize(&Padding{ + Expr: size.Expression, + }) +} + +// Reply encapsulates the fields associated with a 'reply' element. +type Reply struct { + Fields []Field +} + +// Size gets the number of bytes in this request's reply. +// A reply always has at least 7 bytes: +// 1 byte: A reply discriminant (first byte set to 1) +// 2 bytes: A sequence number +// 4 bytes: Number of additional bytes in 4-byte units past initial 32 bytes. +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/size.go b/nexgb/xgbgen/size.go index 70edb8f..d8d3ac3 100644 --- a/nexgb/xgbgen/size.go +++ b/nexgb/xgbgen/size.go @@ -1,21 +1,30 @@ package main +// Size corresponds to an expression that represents the number of bytes +// in some *thing*. Generally, sizes are used to allocate buffers and to +// inform X how big requests are. +// Size is basically a thin layer over an Expression that yields easy methods +// for adding and multiplying sizes. type Size struct { Expression } +// newFixedSize creates a new Size with some fixed and known value. func newFixedSize(fixed uint) Size { return Size{&Value{v: fixed}} } +// newExpressionSize creates a new Size with some expression. func newExpressionSize(variable Expression) Size { return Size{variable} } +// Add adds s1 and s2 and returns a new Size. func (s1 Size) Add(s2 Size) Size { return Size{newBinaryOp("+", s1, s2)} } +// Multiply mupltiplies s1 and s2 and returns a new Size. func (s1 Size) Multiply(s2 Size) Size { return Size{newBinaryOp("*", s1, s2)} } diff --git a/nexgb/xgbgen/xml.go b/nexgb/xgbgen/xml.go index 1b2f89a..df21433 100644 --- a/nexgb/xgbgen/xml.go +++ b/nexgb/xgbgen/xml.go @@ -18,19 +18,19 @@ type XML struct { // Types for all top-level elements. // First are the simple ones. Imports XMLImports `xml:"import"` - Enums XMLEnums `xml:"enum"` - Xids XMLXids `xml:"xidtype"` - XidUnions XMLXids `xml:"xidunion"` - TypeDefs XMLTypeDefs `xml:"typedef"` - EventCopies XMLEventCopies `xml:"eventcopy"` - ErrorCopies XMLErrorCopies `xml:"errorcopy"` + Enums []*XMLEnum `xml:"enum"` + Xids []*XMLXid `xml:"xidtype"` + XidUnions []*XMLXid `xml:"xidunion"` + TypeDefs []*XMLTypeDef `xml:"typedef"` + EventCopies []*XMLEventCopy `xml:"eventcopy"` + ErrorCopies []*XMLErrorCopy `xml:"errorcopy"` // Here are the complex ones, i.e., anything with "structure contents" - Structs XMLStructs `xml:"struct"` - Unions XMLUnions `xml:"union"` - Requests XMLRequests `xml:"request"` - Events XMLEvents `xml:"event"` - Errors XMLErrors `xml:"error"` + Structs []*XMLStruct `xml:"struct"` + Unions []*XMLUnion `xml:"union"` + Requests []*XMLRequest `xml:"request"` + Events []*XMLEvent `xml:"event"` + Errors []*XMLError `xml:"error"` } type XMLImports []*XMLImport @@ -60,8 +60,6 @@ type XMLImport struct { xml *XML `xml:"-"` } -type XMLEnums []XMLEnum - type XMLEnum struct { Name string `xml:"name,attr"` Items []*XMLEnumItem `xml:"item"` @@ -72,77 +70,69 @@ type XMLEnumItem struct { Expr *XMLExpression `xml:",any"` } -type XMLXids []*XMLXid - type XMLXid struct { XMLName xml.Name Name string `xml:"name,attr"` } -type XMLTypeDefs []*XMLTypeDef - type XMLTypeDef struct { Old string `xml:"oldname,attr"` New string `xml:"newname,attr"` } -type XMLEventCopies []*XMLEventCopy - type XMLEventCopy struct { Name string `xml:"name,attr"` Number int `xml:"number,attr"` Ref string `xml:"ref,attr"` } -type XMLErrorCopies []*XMLErrorCopy - type XMLErrorCopy struct { Name string `xml:"name,attr"` Number int `xml:"number,attr"` Ref string `xml:"ref,attr"` } -type XMLStructs []*XMLStruct - type XMLStruct struct { Name string `xml:"name,attr"` - Fields XMLFields `xml:",any"` + Fields []*XMLField `xml:",any"` } -type XMLUnions []*XMLUnion - type XMLUnion struct { Name string `xml:"name,attr"` - Fields XMLFields `xml:",any"` + Fields []*XMLField `xml:",any"` } -type XMLRequests []*XMLRequest - type XMLRequest struct { Name string `xml:"name,attr"` Opcode int `xml:"opcode,attr"` Combine bool `xml:"combine-adjacent,attr"` - Fields XMLFields `xml:",any"` + Fields []*XMLField `xml:",any"` Reply *XMLReply `xml:"reply"` } type XMLReply struct { - Fields XMLFields `xml:",any"` + Fields []*XMLField `xml:",any"` } -type XMLEvents []*XMLEvent - type XMLEvent struct { Name string `xml:"name,attr"` Number int `xml:"number,attr"` NoSequence bool `xml:"no-sequence-number,attr"` - Fields XMLFields `xml:",any"` + Fields []*XMLField `xml:",any"` } -type XMLErrors []*XMLError - type XMLError struct { Name string `xml:"name,attr"` Number int `xml:"number,attr"` - Fields XMLFields `xml:",any"` + Fields []*XMLField `xml:",any"` +} + +type XMLExpression struct { + XMLName xml.Name + + Exprs []*XMLExpression `xml:",any"` + + Data string `xml:",chardata"` + Op string `xml:"op,attr"` + Ref string `xml:"ref,attr"` } diff --git a/nexgb/xgbgen/xml_expression.go b/nexgb/xgbgen/xml_expression.go deleted file mode 100644 index 2989668..0000000 --- a/nexgb/xgbgen/xml_expression.go +++ /dev/null @@ -1,160 +0,0 @@ -package main - -import ( - "encoding/xml" - "fmt" - "log" - "strconv" -) - -type XMLExpression struct { - XMLName xml.Name - - Exprs []*XMLExpression `xml:",any"` - - Data string `xml:",chardata"` - Op string `xml:"op,attr"` - Ref string `xml:"ref,attr"` -} - -func newValueExpression(v uint) *XMLExpression { - return &XMLExpression{ - XMLName: xml.Name{Local: "value"}, - Data: fmt.Sprintf("%d", v), - } -} - -// String is for debugging. For actual use, please use 'Morph'. -func (e *XMLExpression) String() string { - switch e.XMLName.Local { - case "op": - return fmt.Sprintf("(%s %s %s)", e.Exprs[0], e.Op, e.Exprs[1]) - case "unop": - return fmt.Sprintf("(%s (%s))", e.Op, e.Exprs[0]) - case "popcount": - return fmt.Sprintf("popcount(%s)", e.Exprs[0]) - case "fieldref": - fallthrough - case "value": - return fmt.Sprintf("%s", e.Data) - case "bit": - return fmt.Sprintf("(1 << %s)", e.Data) - case "enumref": - return fmt.Sprintf("%s%s", e.Ref, e.Data) - case "sumof": - return fmt.Sprintf("sum(%s)", e.Ref) - default: - log.Panicf("Unrecognized expression element: %s", e.XMLName.Local) - } - - panic("unreachable") -} - -// Eval is used to *attempt* to compute a concrete value for a particular -// expression. This is used in the initial setup to instantiate values for -// empty items in enums. -// We can't compute a concrete value for expressions that rely on a context, -// i.e., some field value. -func (e *XMLExpression) Eval() uint { - switch e.XMLName.Local { - case "op": - if len(e.Exprs) != 2 { - log.Panicf("'op' found %d expressions; expected 2.", len(e.Exprs)) - } - return e.BinaryOp(e.Exprs[0], e.Exprs[1]).Eval() - case "unop": - if len(e.Exprs) != 1 { - log.Panicf("'unop' found %d expressions; expected 1.", len(e.Exprs)) - } - return e.UnaryOp(e.Exprs[0]).Eval() - case "popcount": - if len(e.Exprs) != 1 { - log.Panicf("'popcount' found %d expressions; expected 1.", - len(e.Exprs)) - } - return popCount(e.Exprs[0].Eval()) - case "value": - val, err := strconv.Atoi(e.Data) - if err != nil { - log.Panicf("Could not convert '%s' in 'value' expression to int.", - e.Data) - } - return uint(val) - case "bit": - bit, err := strconv.Atoi(e.Data) - if err != nil { - log.Panicf("Could not convert '%s' in 'bit' expression to int.", - e.Data) - } - if bit < 0 || bit > 31 { - log.Panicf("A 'bit' literal must be in the range [0, 31], but "+ - " is %d", bit) - } - return 1 << uint(bit) - case "fieldref": - log.Panicf("Cannot compute concrete value of 'fieldref' in "+ - "expression '%s'.", e) - case "enumref": - log.Panicf("Cannot compute concrete value of 'enumref' in "+ - "expression '%s'.", e) - case "sumof": - log.Panicf("Cannot compute concrete value of 'sumof' in "+ - "expression '%s'.", e) - } - - log.Panicf("Unrecognized tag '%s' in expression context. Expected one of "+ - "op, fieldref, value, bit, enumref, unop, sumof or popcount.", - e.XMLName.Local) - panic("unreachable") -} - -func (e *XMLExpression) BinaryOp(oprnd1, oprnd2 *XMLExpression) *XMLExpression { - if e.XMLName.Local != "op" { - log.Panicf("Cannot perform binary operation on non-op expression: %s", - e.XMLName.Local) - } - if len(e.Op) == 0 { - log.Panicf("Cannot perform binary operation without operator for: %s", - e.XMLName.Local) - } - - wrap := newValueExpression - switch e.Op { - case "+": - return wrap(oprnd1.Eval() + oprnd2.Eval()) - case "-": - return wrap(oprnd1.Eval() + oprnd2.Eval()) - case "*": - return wrap(oprnd1.Eval() * oprnd2.Eval()) - case "/": - return wrap(oprnd1.Eval() / oprnd2.Eval()) - case "&": - return wrap(oprnd1.Eval() & oprnd2.Eval()) - case "<<": - return wrap(oprnd1.Eval() << oprnd2.Eval()) - } - - log.Panicf("Invalid binary operator '%s' for '%s' expression.", - e.Op, e.XMLName.Local) - panic("unreachable") -} - -func (e *XMLExpression) UnaryOp(oprnd *XMLExpression) *XMLExpression { - if e.XMLName.Local != "unop" { - log.Panicf("Cannot perform unary operation on non-unop expression: %s", - e.XMLName.Local) - } - if len(e.Op) == 0 { - log.Panicf("Cannot perform unary operation without operator for: %s", - e.XMLName.Local) - } - - switch e.Op { - case "~": - return newValueExpression(^oprnd.Eval()) - } - - log.Panicf("Invalid unary operator '%s' for '%s' expression.", - e.Op, e.XMLName.Local) - panic("unreachable") -} diff --git a/nexgb/xgbgen/xml_fields.go b/nexgb/xgbgen/xml_fields.go index 991141b..fe6c5d5 100644 --- a/nexgb/xgbgen/xml_fields.go +++ b/nexgb/xgbgen/xml_fields.go @@ -1,31 +1,10 @@ package main -/* - A series of fields should be taken as "structure contents", and *not* - just the single 'field' elements. Namely, 'fields' subsumes 'field' - elements. - - More particularly, 'fields' corresponds to list, in order, of any of the - follow elements: pad, field, list, localfield, exprfield, valueparm - and switch. - - Thus, the 'Field' type must contain the union of information corresponding - to all aforementioned fields. - - This would ideally be a better job for interfaces, but I could not figure - out how to make them jive with Go's XML package. (And I don't really feel - up to type translation.) -*/ - import ( "encoding/xml" - "fmt" "log" - "strings" ) -type XMLFields []*XMLField - type XMLField struct { XMLName xml.Name @@ -47,7 +26,7 @@ type XMLField struct { ValueListName string `xml:"value-list-name,attr"` // For 'switch' element. - Bitcases XMLBitcases `xml:"bitcase"` + Bitcases []*XMLBitcase `xml:"bitcase"` // I don't know which elements these are for. The documentation is vague. // They also seem to be completely optional. @@ -56,41 +35,6 @@ type XMLField struct { OptAltEnum string `xml:"altenum,attr"` } -// String is for debugging purposes. -func (f *XMLField) String() string { - switch f.XMLName.Local { - case "pad": - return fmt.Sprintf("pad (%d bytes)", f.Bytes) - case "field": - return fmt.Sprintf("field (type = '%s', name = '%s')", f.Type, f.Name) - case "list": - return fmt.Sprintf("list (type = '%s', name = '%s', length = '%s')", - f.Type, f.Name, f.Expr) - case "localfield": - return fmt.Sprintf("localfield (type = '%s', name = '%s')", - f.Type, f.Name) - case "exprfield": - return fmt.Sprintf("exprfield (type = '%s', name = '%s', expr = '%s')", - f.Type, f.Name, f.Expr) - case "valueparam": - return fmt.Sprintf("valueparam (type = '%s', name = '%s', list = '%s')", - f.ValueMaskType, f.ValueMaskName, f.ValueListName) - case "switch": - bitcases := make([]string, len(f.Bitcases)) - for i, bitcase := range f.Bitcases { - bitcases[i] = bitcase.StringPrefix("\t") - } - return fmt.Sprintf("switch (name = '%s', expr = '%s')\n\t%s", - f.Name, f.Expr, strings.Join(bitcases, "\n\t")) - default: - log.Panicf("Unrecognized field element: %s", f.XMLName.Local) - } - - panic("unreachable") -} - -type XMLBitcases []*XMLBitcase - // Bitcase represents a single expression followed by any number of fields. // Namely, if the switch's expression (all bitcases are inside a switch), // and'd with the bitcase's expression is equal to the bitcase expression, @@ -100,7 +44,7 @@ type XMLBitcases []*XMLBitcase // it's the closest thing to a Union I can get to in Go without interfaces. // Would an '' tag have been too much to ask? :-( type XMLBitcase struct { - Fields XMLFields `xml:",any"` + Fields []*XMLField `xml:",any"` // All the different expressions. // When it comes time to choose one, use the 'Expr' method. @@ -114,17 +58,6 @@ type XMLBitcase struct { ExprPop *XMLExpression `xml:"popcount"` } -// StringPrefix is for debugging purposes only. -// StringPrefix takes a string to prefix to every extra line for formatting. -func (b *XMLBitcase) StringPrefix(prefix string) string { - fields := make([]string, len(b.Fields)) - for i, field := range b.Fields { - fields[i] = fmt.Sprintf("%s%s", prefix, field) - } - return fmt.Sprintf("%s\n\t%s%s", b.Expr(), prefix, - strings.Join(fields, "\n\t")) -} - // Expr chooses the only non-nil Expr* field from Bitcase. // Panic if there is more than one non-nil expression. func (b *XMLBitcase) Expr() *XMLExpression { -- cgit v1.2.3-70-g09d2 From ea30f1a0a718e5e86343cceac12104baab1bedca Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Sun, 6 May 2012 03:06:02 -0400 Subject: more bug fixes for the rest of the extensions --- nexgb/auto_randr.go | 3988 ++++++++++++ nexgb/auto_render.go | 3506 ++++++++++ nexgb/auto_xinerama.go | 629 ++ nexgb/auto_xproto.go | 14420 ++++++++++++++++++++++++++++++++++++++++++ nexgb/randr.go | 3988 ------------ nexgb/render.go | 3506 ---------- nexgb/xgbgen/expression.go | 34 +- nexgb/xgbgen/field.go | 3 +- nexgb/xgbgen/go.go | 18 +- nexgb/xgbgen/go_struct.go | 6 +- nexgb/xgbgen/size.go | 2 +- nexgb/xgbgen/translation.go | 10 +- nexgb/xinerama.go | 629 -- nexgb/xproto.go | 14420 ------------------------------------------ 14 files changed, 22584 insertions(+), 22575 deletions(-) create mode 100644 nexgb/auto_randr.go create mode 100644 nexgb/auto_render.go create mode 100644 nexgb/auto_xinerama.go create mode 100644 nexgb/auto_xproto.go delete mode 100644 nexgb/randr.go delete mode 100644 nexgb/render.go delete mode 100644 nexgb/xinerama.go delete mode 100644 nexgb/xproto.go (limited to 'nexgb/xgbgen/size.go') diff --git a/nexgb/auto_randr.go b/nexgb/auto_randr.go new file mode 100644 index 0000000..fdb10ca --- /dev/null +++ b/nexgb/auto_randr.go @@ -0,0 +1,3988 @@ +package xgb + +/* + This file was generated by randr.xml on May 5 2012 6:06:50pm 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" + +// 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' + +// 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 +) + +// Skipping resource definition of 'Mode' + +// Skipping resource definition of 'Crtc' + +// Skipping resource definition of 'Output' + +// '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 Id + Crtc Id + Mode Id + 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 = Id(Get32(buf[b:])) + b += 4 + + v.Crtc = Id(Get32(buf[b:])) + b += 4 + + v.Mode = Id(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 Id + Output Id + Crtc Id + Mode Id + 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 = Id(Get32(buf[b:])) + b += 4 + + v.Output = Id(Get32(buf[b:])) + b += 4 + + v.Crtc = Id(Get32(buf[b:])) + b += 4 + + v.Mode = Id(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 Id + Output Id + Atom Id + Timestamp Timestamp + Status byte + // padding: 11 bytes +} + +// Struct read RandrOutputProperty +func ReadRandrOutputProperty(buf []byte, v *RandrOutputProperty) int { + b := 0 + + v.Window = Id(Get32(buf[b:])) + b += 4 + + v.Output = Id(Get32(buf[b:])) + b += 4 + + v.Atom = Id(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 Id + RequestWindow Id + 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 = Id(Get32(buf[b:])) + b += 4 + + v.RequestWindow = Id(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() { + newEventFuncs[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() { + newEventFuncs[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() Id { + 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() { + newErrorFuncs[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() Id { + 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() { + newErrorFuncs[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() Id { + 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() { + newErrorFuncs[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 Id, 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 Id, 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 Id + 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 = Id(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 Id, 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 Id, Enable uint16) RandrSelectInputCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.randrSelectInputRequest(Window, Enable), cookie) + return RandrSelectInputCookie{cookie} +} + +func (c *Conn) RandrSelectInputChecked(Window Id, 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 Id, 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 Id) RandrGetScreenInfoCookie { + cookie := c.newCookie(true, true) + c.newRequest(c.randrGetScreenInfoRequest(Window), cookie) + return RandrGetScreenInfoCookie{cookie} +} + +func (c *Conn) RandrGetScreenInfoUnchecked(Window Id) 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 Id + 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 = Id(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 Id) []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 Id) RandrGetScreenSizeRangeCookie { + cookie := c.newCookie(true, true) + c.newRequest(c.randrGetScreenSizeRangeRequest(Window), cookie) + return RandrGetScreenSizeRangeCookie{cookie} +} + +func (c *Conn) RandrGetScreenSizeRangeUnchecked(Window Id) 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 Id) []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 Id, 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 Id, 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 Id, 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 Id) RandrGetScreenResourcesCookie { + cookie := c.newCookie(true, true) + c.newRequest(c.randrGetScreenResourcesRequest(Window), cookie) + return RandrGetScreenResourcesCookie{cookie} +} + +func (c *Conn) RandrGetScreenResourcesUnchecked(Window Id) 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 []Id // size: pad((int(NumCrtcs) * 4)) + Outputs []Id // 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([]Id, v.NumCrtcs) + for i := 0; i < int(v.NumCrtcs); i++ { + v.Crtcs[i] = Id(Get32(buf[b:])) + b += 4 + } + b = pad(b) + + v.Outputs = make([]Id, v.NumOutputs) + for i := 0; i < int(v.NumOutputs); i++ { + v.Outputs[i] = Id(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 Id) []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 Id, ConfigTimestamp Timestamp) RandrGetOutputInfoCookie { + cookie := c.newCookie(true, true) + c.newRequest(c.randrGetOutputInfoRequest(Output, ConfigTimestamp), cookie) + return RandrGetOutputInfoCookie{cookie} +} + +func (c *Conn) RandrGetOutputInfoUnchecked(Output Id, 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 Id + MmWidth uint32 + MmHeight uint32 + Connection byte + SubpixelOrder byte + NumCrtcs uint16 + NumModes uint16 + NumPreferred uint16 + NumClones uint16 + NameLen uint16 + Crtcs []Id // size: pad((int(NumCrtcs) * 4)) + Modes []Id // size: pad((int(NumModes) * 4)) + Clones []Id // 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 = Id(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([]Id, v.NumCrtcs) + for i := 0; i < int(v.NumCrtcs); i++ { + v.Crtcs[i] = Id(Get32(buf[b:])) + b += 4 + } + b = pad(b) + + v.Modes = make([]Id, v.NumModes) + for i := 0; i < int(v.NumModes); i++ { + v.Modes[i] = Id(Get32(buf[b:])) + b += 4 + } + b = pad(b) + + v.Clones = make([]Id, v.NumClones) + for i := 0; i < int(v.NumClones); i++ { + v.Clones[i] = Id(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 Id, 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 Id) RandrListOutputPropertiesCookie { + cookie := c.newCookie(true, true) + c.newRequest(c.randrListOutputPropertiesRequest(Output), cookie) + return RandrListOutputPropertiesCookie{cookie} +} + +func (c *Conn) RandrListOutputPropertiesUnchecked(Output Id) 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 []Id // 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([]Id, v.NumAtoms) + for i := 0; i < int(v.NumAtoms); i++ { + v.Atoms[i] = Id(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 Id) []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 Id, Property Id) RandrQueryOutputPropertyCookie { + cookie := c.newCookie(true, true) + c.newRequest(c.randrQueryOutputPropertyRequest(Output, Property), cookie) + return RandrQueryOutputPropertyCookie{cookie} +} + +func (c *Conn) RandrQueryOutputPropertyUnchecked(Output Id, Property Id) 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 Id, Property Id) []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 Id, Property Id, 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 Id, Property Id, 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 Id, Property Id, 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 Id, Property Id, Type Id, 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 Id, Property Id, Type Id, 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 Id, Property Id, Type Id, 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 Id, Property Id) RandrDeleteOutputPropertyCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.randrDeleteOutputPropertyRequest(Output, Property), cookie) + return RandrDeleteOutputPropertyCookie{cookie} +} + +func (c *Conn) RandrDeleteOutputPropertyChecked(Output Id, Property Id) 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 Id, Property Id) []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 Id, Property Id, Type Id, 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 Id, Property Id, Type Id, 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 Id + 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 = Id(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 Id, Property Id, Type Id, 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 Id, 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 Id, 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 Id + // 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 = Id(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 Id, 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 Id) RandrDestroyModeCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.randrDestroyModeRequest(Mode), cookie) + return RandrDestroyModeCookie{cookie} +} + +func (c *Conn) RandrDestroyModeChecked(Mode Id) 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 Id) []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 Id, Mode Id) RandrAddOutputModeCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.randrAddOutputModeRequest(Output, Mode), cookie) + return RandrAddOutputModeCookie{cookie} +} + +func (c *Conn) RandrAddOutputModeChecked(Output Id, Mode Id) 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 Id, Mode Id) []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 Id, Mode Id) RandrDeleteOutputModeCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.randrDeleteOutputModeRequest(Output, Mode), cookie) + return RandrDeleteOutputModeCookie{cookie} +} + +func (c *Conn) RandrDeleteOutputModeChecked(Output Id, Mode Id) 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 Id, Mode Id) []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 Id, ConfigTimestamp Timestamp) RandrGetCrtcInfoCookie { + cookie := c.newCookie(true, true) + c.newRequest(c.randrGetCrtcInfoRequest(Crtc, ConfigTimestamp), cookie) + return RandrGetCrtcInfoCookie{cookie} +} + +func (c *Conn) RandrGetCrtcInfoUnchecked(Crtc Id, 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 Id + Rotation uint16 + Rotations uint16 + NumOutputs uint16 + NumPossibleOutputs uint16 + Outputs []Id // size: pad((int(NumOutputs) * 4)) + Possible []Id // 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 = Id(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([]Id, v.NumOutputs) + for i := 0; i < int(v.NumOutputs); i++ { + v.Outputs[i] = Id(Get32(buf[b:])) + b += 4 + } + b = pad(b) + + v.Possible = make([]Id, v.NumPossibleOutputs) + for i := 0; i < int(v.NumPossibleOutputs); i++ { + v.Possible[i] = Id(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 Id, 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 Id, Timestamp Timestamp, ConfigTimestamp Timestamp, X int16, Y int16, Mode Id, Rotation uint16, Outputs []Id) 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 Id, Timestamp Timestamp, ConfigTimestamp Timestamp, X int16, Y int16, Mode Id, Rotation uint16, Outputs []Id) 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 Id, Timestamp Timestamp, ConfigTimestamp Timestamp, X int16, Y int16, Mode Id, Rotation uint16, Outputs []Id) []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 Id) RandrGetCrtcGammaSizeCookie { + cookie := c.newCookie(true, true) + c.newRequest(c.randrGetCrtcGammaSizeRequest(Crtc), cookie) + return RandrGetCrtcGammaSizeCookie{cookie} +} + +func (c *Conn) RandrGetCrtcGammaSizeUnchecked(Crtc Id) 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 Id) []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 Id) RandrGetCrtcGammaCookie { + cookie := c.newCookie(true, true) + c.newRequest(c.randrGetCrtcGammaRequest(Crtc), cookie) + return RandrGetCrtcGammaCookie{cookie} +} + +func (c *Conn) RandrGetCrtcGammaUnchecked(Crtc Id) 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 Id) []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 Id, 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 Id, 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 Id, 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 Id) RandrGetScreenResourcesCurrentCookie { + cookie := c.newCookie(true, true) + c.newRequest(c.randrGetScreenResourcesCurrentRequest(Window), cookie) + return RandrGetScreenResourcesCurrentCookie{cookie} +} + +func (c *Conn) RandrGetScreenResourcesCurrentUnchecked(Window Id) 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 []Id // size: pad((int(NumCrtcs) * 4)) + Outputs []Id // 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([]Id, v.NumCrtcs) + for i := 0; i < int(v.NumCrtcs); i++ { + v.Crtcs[i] = Id(Get32(buf[b:])) + b += 4 + } + b = pad(b) + + v.Outputs = make([]Id, v.NumOutputs) + for i := 0; i < int(v.NumOutputs); i++ { + v.Outputs[i] = Id(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 Id) []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 Id, 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 Id, 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 Id, 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 Id) RandrGetCrtcTransformCookie { + cookie := c.newCookie(true, true) + c.newRequest(c.randrGetCrtcTransformRequest(Crtc), cookie) + return RandrGetCrtcTransformCookie{cookie} +} + +func (c *Conn) RandrGetCrtcTransformUnchecked(Crtc Id) 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 Id) []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 Id) RandrGetPanningCookie { + cookie := c.newCookie(true, true) + c.newRequest(c.randrGetPanningRequest(Crtc), cookie) + return RandrGetPanningCookie{cookie} +} + +func (c *Conn) RandrGetPanningUnchecked(Crtc Id) 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 Id) []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 Id, 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 Id, 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 Id, 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 Id, Output Id) RandrSetOutputPrimaryCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.randrSetOutputPrimaryRequest(Window, Output), cookie) + return RandrSetOutputPrimaryCookie{cookie} +} + +func (c *Conn) RandrSetOutputPrimaryChecked(Window Id, Output Id) 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 Id, Output Id) []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 Id) RandrGetOutputPrimaryCookie { + cookie := c.newCookie(true, true) + c.newRequest(c.randrGetOutputPrimaryRequest(Window), cookie) + return RandrGetOutputPrimaryCookie{cookie} +} + +func (c *Conn) RandrGetOutputPrimaryUnchecked(Window Id) 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 Id +} + +// 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 = Id(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 Id) []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_render.go b/nexgb/auto_render.go new file mode 100644 index 0000000..069ce76 --- /dev/null +++ b/nexgb/auto_render.go @@ -0,0 +1,3506 @@ +package xgb + +/* + This file was generated by render.xml on May 5 2012 6:07:02pm 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" + +// 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' + +// Skipping definition for base type 'Float' + +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 +) + +// Skipping resource definition of 'Glyphset' + +// Skipping resource definition of 'Picture' + +// Skipping resource definition of 'Pictformat' + +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 Id + Type byte + Depth byte + // padding: 2 bytes + Direct RenderDirectformat + Colormap Id +} + +// Struct read RenderPictforminfo +func ReadRenderPictforminfo(buf []byte, v *RenderPictforminfo) int { + b := 0 + + v.Id = Id(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 = Id(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 Id +} + +// Struct read RenderPictvisual +func ReadRenderPictvisual(buf []byte, v *RenderPictvisual) int { + b := 0 + + v.Visual = Visualid(Get32(buf[b:])) + b += 4 + + v.Format = Id(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 Id + 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 = Id(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 Id + Delay uint32 +} + +// Struct read RenderAnimcursorelt +func ReadRenderAnimcursorelt(buf []byte, v *RenderAnimcursorelt) int { + b := 0 + + v.Cursor = Id(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() Id { + 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() { + newErrorFuncs[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() Id { + 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() { + newErrorFuncs[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() Id { + 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() { + newErrorFuncs[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() Id { + 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() { + newErrorFuncs[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() Id { + 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() { + newErrorFuncs[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 Id) RenderQueryPictIndexValuesCookie { + cookie := c.newCookie(true, true) + c.newRequest(c.renderQueryPictIndexValuesRequest(Format), cookie) + return RenderQueryPictIndexValuesCookie{cookie} +} + +func (c *Conn) RenderQueryPictIndexValuesUnchecked(Format Id) 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 Id) []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 Id, Drawable Id, Format Id, 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 Id, Drawable Id, Format Id, 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 Id, Drawable Id, Format Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id) RenderFreePictureCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.renderFreePictureRequest(Picture), cookie) + return RenderFreePictureCookie{cookie} +} + +func (c *Conn) RenderFreePictureChecked(Picture Id) 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 Id) []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 Id, Mask Id, Dst Id, 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 Id, Mask Id, Dst Id, 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 Id, Mask Id, Dst Id, 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 Id, Dst Id, MaskFormat Id, 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 Id, Dst Id, MaskFormat Id, 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 Id, Dst Id, MaskFormat Id, 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 Id, Dst Id, MaskFormat Id, 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 Id, Dst Id, MaskFormat Id, 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 Id, Dst Id, MaskFormat Id, 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 Id, Dst Id, MaskFormat Id, 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 Id, Dst Id, MaskFormat Id, 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 Id, Dst Id, MaskFormat Id, 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 Id, Dst Id, MaskFormat Id, 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 Id, Dst Id, MaskFormat Id, 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 Id, Dst Id, MaskFormat Id, 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 Id, Format Id) RenderCreateGlyphSetCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.renderCreateGlyphSetRequest(Gsid, Format), cookie) + return RenderCreateGlyphSetCookie{cookie} +} + +func (c *Conn) RenderCreateGlyphSetChecked(Gsid Id, Format Id) 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 Id, Format Id) []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 Id, Existing Id) RenderReferenceGlyphSetCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.renderReferenceGlyphSetRequest(Gsid, Existing), cookie) + return RenderReferenceGlyphSetCookie{cookie} +} + +func (c *Conn) RenderReferenceGlyphSetChecked(Gsid Id, Existing Id) 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 Id, Existing Id) []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 Id) RenderFreeGlyphSetCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.renderFreeGlyphSetRequest(Glyphset), cookie) + return RenderFreeGlyphSetCookie{cookie} +} + +func (c *Conn) RenderFreeGlyphSetChecked(Glyphset Id) 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 Id) []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 Id, 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 Id, 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 Id, 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 Id, Glyphs []RenderGlyph) RenderFreeGlyphsCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.renderFreeGlyphsRequest(Glyphset, Glyphs), cookie) + return RenderFreeGlyphsCookie{cookie} +} + +func (c *Conn) RenderFreeGlyphsChecked(Glyphset Id, 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 Id, 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 Id, Dst Id, MaskFormat Id, Glyphset Id, 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 Id, Dst Id, MaskFormat Id, Glyphset Id, 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 Id, Dst Id, MaskFormat Id, Glyphset Id, 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 Id, Dst Id, MaskFormat Id, Glyphset Id, 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 Id, Dst Id, MaskFormat Id, Glyphset Id, 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 Id, Dst Id, MaskFormat Id, Glyphset Id, 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 Id, Dst Id, MaskFormat Id, Glyphset Id, 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 Id, Dst Id, MaskFormat Id, Glyphset Id, 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 Id, Dst Id, MaskFormat Id, Glyphset Id, 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 Id, 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 Id, 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 Id, 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 Id, Source Id, 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 Id, Source Id, 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 Id, Source Id, 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 Id, Transform RenderTransform) RenderSetPictureTransformCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.renderSetPictureTransformRequest(Picture, Transform), cookie) + return RenderSetPictureTransformCookie{cookie} +} + +func (c *Conn) RenderSetPictureTransformChecked(Picture Id, 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 Id, 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 Id) RenderQueryFiltersCookie { + cookie := c.newCookie(true, true) + c.newRequest(c.renderQueryFiltersRequest(Drawable), cookie) + return RenderQueryFiltersCookie{cookie} +} + +func (c *Conn) RenderQueryFiltersUnchecked(Drawable Id) 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 Id) []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 Id, 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 Id, 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 Id, 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 Id, Cursors []RenderAnimcursorelt) RenderCreateAnimCursorCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.renderCreateAnimCursorRequest(Cid, Cursors), cookie) + return RenderCreateAnimCursorCookie{cookie} +} + +func (c *Conn) RenderCreateAnimCursorChecked(Cid Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, Color RenderColor) RenderCreateSolidFillCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.renderCreateSolidFillRequest(Picture, Color), cookie) + return RenderCreateSolidFillCookie{cookie} +} + +func (c *Conn) RenderCreateSolidFillChecked(Picture Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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_xinerama.go b/nexgb/auto_xinerama.go new file mode 100644 index 0000000..c2e031c --- /dev/null +++ b/nexgb/auto_xinerama.go @@ -0,0 +1,629 @@ +package xgb + +/* + This file was generated by xinerama.xml on May 5 2012 5:56:52pm 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" + +// 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 'Id' + +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +// '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 + + buf[b] = Major + b += 1 + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + buf[b] = Minor + b += 1 + + return buf +} + +// Request XineramaGetState +// size: 8 +type XineramaGetStateCookie struct { + *cookie +} + +func (c *Conn) XineramaGetState(Window Id) XineramaGetStateCookie { + cookie := c.newCookie(true, true) + c.newRequest(c.xineramaGetStateRequest(Window), cookie) + return XineramaGetStateCookie{cookie} +} + +func (c *Conn) XineramaGetStateUnchecked(Window Id) 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 Id +} + +// 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 = Id(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 Id) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.extensions["XINERAMA"] + b += 1 + + buf[b] = 1 // request opcode + b += 1 + + Put32(buf[b:], uint32(Window)) + b += 4 + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request XineramaGetScreenCount +// size: 8 +type XineramaGetScreenCountCookie struct { + *cookie +} + +func (c *Conn) XineramaGetScreenCount(Window Id) XineramaGetScreenCountCookie { + cookie := c.newCookie(true, true) + c.newRequest(c.xineramaGetScreenCountRequest(Window), cookie) + return XineramaGetScreenCountCookie{cookie} +} + +func (c *Conn) XineramaGetScreenCountUnchecked(Window Id) 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 Id +} + +// 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 = Id(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 Id) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.extensions["XINERAMA"] + b += 1 + + buf[b] = 2 // request opcode + b += 1 + + Put32(buf[b:], uint32(Window)) + b += 4 + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request XineramaGetScreenSize +// size: 12 +type XineramaGetScreenSizeCookie struct { + *cookie +} + +func (c *Conn) XineramaGetScreenSize(Window Id, Screen uint32) XineramaGetScreenSizeCookie { + cookie := c.newCookie(true, true) + c.newRequest(c.xineramaGetScreenSizeRequest(Window, Screen), cookie) + return XineramaGetScreenSizeCookie{cookie} +} + +func (c *Conn) XineramaGetScreenSizeUnchecked(Window Id, 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 Id + 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 = Id(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 Id, 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 + + Put32(buf[b:], uint32(Window)) + b += 4 + + Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + 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_xproto.go b/nexgb/auto_xproto.go new file mode 100644 index 0000000..32fa6dd --- /dev/null +++ b/nexgb/auto_xproto.go @@ -0,0 +1,14420 @@ +package xgb + +/* + This file was generated by xproto.xml on May 5 2012 5:43:45pm EDT. + This file is automatically generated. Edit at your peril! +*/ + +// 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 'Id' + +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +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 (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 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 (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 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 (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 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 (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 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 (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: 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 (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 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 (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 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 (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 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 (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 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 (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 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 (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 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 (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 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 (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 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 (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 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 (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 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 (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 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 (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 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 (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 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 (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 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 (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 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 (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 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 (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 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 (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 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 (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 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 (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 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 (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 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 (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() 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: 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 Id, Parent Id, 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 Id, Parent Id, 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 Id, Parent Id, 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 Id, 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 Id, 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 Id, 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 Id) GetWindowAttributesCookie { + cookie := c.newCookie(true, true) + c.newRequest(c.getWindowAttributesRequest(Window), cookie) + return GetWindowAttributesCookie{cookie} +} + +func (c *Conn) GetWindowAttributesUnchecked(Window Id) 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 Id + 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 = 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 +} + +func (cook GetWindowAttributesCookie) Check() error { + return cook.check() +} + +// Write request to wire for GetWindowAttributes +func (c *Conn) getWindowAttributesRequest(Window Id) []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 Id) DestroyWindowCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.destroyWindowRequest(Window), cookie) + return DestroyWindowCookie{cookie} +} + +func (c *Conn) DestroyWindowChecked(Window Id) 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 Id) []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 Id) DestroySubwindowsCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.destroySubwindowsRequest(Window), cookie) + return DestroySubwindowsCookie{cookie} +} + +func (c *Conn) DestroySubwindowsChecked(Window Id) 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 Id) []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 Id) ChangeSaveSetCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.changeSaveSetRequest(Mode, Window), cookie) + return ChangeSaveSetCookie{cookie} +} + +func (c *Conn) ChangeSaveSetChecked(Mode byte, Window Id) 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 Id) []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 Id, Parent Id, 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 Id, Parent Id, 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 Id, Parent Id, 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 Id) MapWindowCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.mapWindowRequest(Window), cookie) + return MapWindowCookie{cookie} +} + +func (c *Conn) MapWindowChecked(Window Id) 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 Id) []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 Id) MapSubwindowsCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.mapSubwindowsRequest(Window), cookie) + return MapSubwindowsCookie{cookie} +} + +func (c *Conn) MapSubwindowsChecked(Window Id) 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 Id) []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 Id) UnmapWindowCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.unmapWindowRequest(Window), cookie) + return UnmapWindowCookie{cookie} +} + +func (c *Conn) UnmapWindowChecked(Window Id) 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 Id) []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 Id) UnmapSubwindowsCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.unmapSubwindowsRequest(Window), cookie) + return UnmapSubwindowsCookie{cookie} +} + +func (c *Conn) UnmapSubwindowsChecked(Window Id) 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 Id) []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 Id, 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 Id, 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 Id, 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 Id) CirculateWindowCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.circulateWindowRequest(Direction, Window), cookie) + return CirculateWindowCookie{cookie} +} + +func (c *Conn) CirculateWindowChecked(Direction byte, Window Id) 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 Id) []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 Id) GetGeometryCookie { + cookie := c.newCookie(true, true) + c.newRequest(c.getGeometryRequest(Drawable), cookie) + return GetGeometryCookie{cookie} +} + +func (c *Conn) GetGeometryUnchecked(Drawable Id) 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 Id + 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 = 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 +} + +func (cook GetGeometryCookie) Check() error { + return cook.check() +} + +// Write request to wire for GetGeometry +func (c *Conn) getGeometryRequest(Drawable Id) []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 Id) QueryTreeCookie { + cookie := c.newCookie(true, true) + c.newRequest(c.queryTreeRequest(Window), cookie) + return QueryTreeCookie{cookie} +} + +func (c *Conn) QueryTreeUnchecked(Window Id) 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 Id + Parent Id + ChildrenLen uint16 + // padding: 14 bytes + Children []Id // 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 = 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 +} + +func (cook QueryTreeCookie) Check() error { + return cook.check() +} + +// Write request to wire for QueryTree +func (c *Conn) queryTreeRequest(Window Id) []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 Id +} + +// 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 = Id(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 Id) GetAtomNameCookie { + cookie := c.newCookie(true, true) + c.newRequest(c.getAtomNameRequest(Atom), cookie) + return GetAtomNameCookie{cookie} +} + +func (c *Conn) GetAtomNameUnchecked(Atom Id) 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 Id) []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 Id, Property Id, Type Id, 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 Id, Property Id, Type Id, 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 Id, Property Id, Type Id, 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 Id, Property Id) DeletePropertyCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.deletePropertyRequest(Window, Property), cookie) + return DeletePropertyCookie{cookie} +} + +func (c *Conn) DeletePropertyChecked(Window Id, Property Id) 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 Id, Property Id) []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 Id, Property Id, Type Id, 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 Id, Property Id, Type Id, 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 Id + 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 = 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 +} + +func (cook GetPropertyCookie) Check() error { + return cook.check() +} + +// Write request to wire for GetProperty +func (c *Conn) getPropertyRequest(Delete bool, Window Id, Property Id, Type Id, 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 Id) ListPropertiesCookie { + cookie := c.newCookie(true, true) + c.newRequest(c.listPropertiesRequest(Window), cookie) + return ListPropertiesCookie{cookie} +} + +func (c *Conn) ListPropertiesUnchecked(Window Id) 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 []Id // 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([]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 +} + +func (cook ListPropertiesCookie) Check() error { + return cook.check() +} + +// Write request to wire for ListProperties +func (c *Conn) listPropertiesRequest(Window Id) []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 Id, Selection Id, Time Timestamp) SetSelectionOwnerCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.setSelectionOwnerRequest(Owner, Selection, Time), cookie) + return SetSelectionOwnerCookie{cookie} +} + +func (c *Conn) SetSelectionOwnerChecked(Owner Id, Selection Id, 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 Id, Selection Id, 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 Id) GetSelectionOwnerCookie { + cookie := c.newCookie(true, true) + c.newRequest(c.getSelectionOwnerRequest(Selection), cookie) + return GetSelectionOwnerCookie{cookie} +} + +func (c *Conn) GetSelectionOwnerUnchecked(Selection Id) 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 Id +} + +// 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 = Id(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 Id) []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 Id, Selection Id, Target Id, Property Id, 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 Id, Selection Id, Target Id, Property Id, 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 Id, Selection Id, Target Id, Property Id, 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: pad((12 + pad(32))) +type SendEventCookie struct { + *cookie +} + +// Write request to wire for SendEvent +func (c *Conn) SendEvent(Propagate bool, Destination Id, 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 Id, 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 Id, EventMask uint32, Event string) []byte { + size := pad((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)) + + return buf +} + +// Request GrabPointer +// size: 24 +type GrabPointerCookie struct { + *cookie +} + +func (c *Conn) GrabPointer(OwnerEvents bool, GrabWindow Id, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Id, Cursor Id, 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 Id, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Id, Cursor Id, 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 Id, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Id, Cursor Id, 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 Id, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Id, Cursor Id, 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 Id, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Id, Cursor Id, 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 Id, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Id, Cursor Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id) QueryPointerCookie { + cookie := c.newCookie(true, true) + c.newRequest(c.queryPointerRequest(Window), cookie) + return QueryPointerCookie{cookie} +} + +func (c *Conn) QueryPointerUnchecked(Window Id) 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 Id + Child Id + 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 = 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 +} + +func (cook QueryPointerCookie) Check() error { + return cook.check() +} + +// Write request to wire for QueryPointer +func (c *Conn) queryPointerRequest(Window Id) []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 Id, 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 Id, 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 Id, 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 Id, DstWindow Id, 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 Id, DstWindow Id, 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 Id + 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 = Id(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 Id, DstWindow Id, 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 Id, DstWindow Id, 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 Id, DstWindow Id, 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 Id, DstWindow Id, 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 Id, 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 Id, 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 Id, 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 Id +} + +// 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 = Id(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: (8 + pad(32)) +type QueryKeymapReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Keys []byte // size: pad(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 Id, 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 Id, 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 Id, 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 Id) CloseFontCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.closeFontRequest(Font), cookie) + return CloseFontCookie{cookie} +} + +func (c *Conn) CloseFontChecked(Font Id) 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 Id) []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 Id) QueryFontCookie { + cookie := c.newCookie(true, true) + c.newRequest(c.queryFontRequest(Font), cookie) + return QueryFontCookie{cookie} +} + +func (c *Conn) QueryFontUnchecked(Font Id) 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 Id) []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 Id, 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 Id, 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 Id, 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 Id, Drawable Id, 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 Id, Drawable Id, 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 Id, Drawable Id, 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 Id) FreePixmapCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.freePixmapRequest(Pixmap), cookie) + return FreePixmapCookie{cookie} +} + +func (c *Conn) FreePixmapChecked(Pixmap Id) 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 Id) []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 Id, Drawable Id, 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 Id, Drawable Id, 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 Id, Drawable Id, 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 Id, 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 Id, 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 Id, 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 Id, DstGc Id, ValueMask uint32) CopyGCCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.copyGCRequest(SrcGc, DstGc, ValueMask), cookie) + return CopyGCCookie{cookie} +} + +func (c *Conn) CopyGCChecked(SrcGc Id, DstGc Id, 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 Id, DstGc Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id) FreeGCCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.freeGCRequest(Gc), cookie) + return FreeGCCookie{cookie} +} + +func (c *Conn) FreeGCChecked(Gc Id) 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 Id) []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 Id, 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 Id, 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 Id, 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 Id, DstDrawable Id, Gc Id, 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 Id, DstDrawable Id, Gc Id, 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 Id, DstDrawable Id, Gc Id, 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 Id, DstDrawable Id, Gc Id, 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 Id, DstDrawable Id, Gc Id, 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 Id, DstDrawable Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, Segments []Segment) PolySegmentCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.polySegmentRequest(Drawable, Gc, Segments), cookie) + return PolySegmentCookie{cookie} +} + +func (c *Conn) PolySegmentChecked(Drawable Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, Rectangles []Rectangle) PolyRectangleCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.polyRectangleRequest(Drawable, Gc, Rectangles), cookie) + return PolyRectangleCookie{cookie} +} + +func (c *Conn) PolyRectangleChecked(Drawable Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, Arcs []Arc) PolyArcCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.polyArcRequest(Drawable, Gc, Arcs), cookie) + return PolyArcCookie{cookie} +} + +func (c *Conn) PolyArcChecked(Drawable Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, Rectangles []Rectangle) PolyFillRectangleCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.polyFillRectangleRequest(Drawable, Gc, Rectangles), cookie) + return PolyFillRectangleCookie{cookie} +} + +func (c *Conn) PolyFillRectangleChecked(Drawable Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, Arcs []Arc) PolyFillArcCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.polyFillArcRequest(Drawable, Gc, Arcs), cookie) + return PolyFillArcCookie{cookie} +} + +func (c *Conn) PolyFillArcChecked(Drawable Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, 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 Id, 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 Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Window Id, 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 Id, Window Id, 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 Id, Window Id, 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 Id) FreeColormapCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.freeColormapRequest(Cmap), cookie) + return FreeColormapCookie{cookie} +} + +func (c *Conn) FreeColormapChecked(Cmap Id) 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 Id) []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 Id, SrcCmap Id) CopyColormapAndFreeCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.copyColormapAndFreeRequest(Mid, SrcCmap), cookie) + return CopyColormapAndFreeCookie{cookie} +} + +func (c *Conn) CopyColormapAndFreeChecked(Mid Id, SrcCmap Id) 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 Id, SrcCmap Id) []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 Id) InstallColormapCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.installColormapRequest(Cmap), cookie) + return InstallColormapCookie{cookie} +} + +func (c *Conn) InstallColormapChecked(Cmap Id) 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 Id) []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 Id) UninstallColormapCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.uninstallColormapRequest(Cmap), cookie) + return UninstallColormapCookie{cookie} +} + +func (c *Conn) UninstallColormapChecked(Cmap Id) 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 Id) []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 Id) ListInstalledColormapsCookie { + cookie := c.newCookie(true, true) + c.newRequest(c.listInstalledColormapsRequest(Window), cookie) + return ListInstalledColormapsCookie{cookie} +} + +func (c *Conn) ListInstalledColormapsUnchecked(Window Id) 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 []Id // 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([]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 +} + +func (cook ListInstalledColormapsCookie) Check() error { + return cook.check() +} + +// Write request to wire for ListInstalledColormaps +func (c *Conn) listInstalledColormapsRequest(Window Id) []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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, Items []Coloritem) StoreColorsCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.storeColorsRequest(Cmap, Items), cookie) + return StoreColorsCookie{cookie} +} + +func (c *Conn) StoreColorsChecked(Cmap Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, Pixels []uint32) QueryColorsCookie { + cookie := c.newCookie(true, true) + c.newRequest(c.queryColorsRequest(Cmap, Pixels), cookie) + return QueryColorsCookie{cookie} +} + +func (c *Conn) QueryColorsUnchecked(Cmap Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, Source Id, Mask Id, 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 Id, Source Id, Mask Id, 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 Id, Source Id, Mask Id, 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 Id, SourceFont Id, MaskFont Id, 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 Id, SourceFont Id, MaskFont Id, 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 Id, SourceFont Id, MaskFont Id, 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 Id) FreeCursorCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.freeCursorRequest(Cursor), cookie) + return FreeCursorCookie{cookie} +} + +func (c *Conn) FreeCursorChecked(Cursor Id) 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 Id) []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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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: (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) +} + +// 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 Id, AtomsLen uint16, Delta int16, Atoms []Id) RotatePropertiesCookie { + cookie := c.newCookie(false, false) + c.newRequest(c.rotatePropertiesRequest(Window, AtomsLen, Delta, Atoms), cookie) + return RotatePropertiesCookie{cookie} +} + +func (c *Conn) RotatePropertiesChecked(Window Id, AtomsLen uint16, Delta int16, Atoms []Id) 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 Id, AtomsLen uint16, Delta int16, Atoms []Id) []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/randr.go b/nexgb/randr.go deleted file mode 100644 index fdb10ca..0000000 --- a/nexgb/randr.go +++ /dev/null @@ -1,3988 +0,0 @@ -package xgb - -/* - This file was generated by randr.xml on May 5 2012 6:06:50pm 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" - -// 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' - -// 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 -) - -// Skipping resource definition of 'Mode' - -// Skipping resource definition of 'Crtc' - -// Skipping resource definition of 'Output' - -// '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 Id - Crtc Id - Mode Id - 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 = Id(Get32(buf[b:])) - b += 4 - - v.Crtc = Id(Get32(buf[b:])) - b += 4 - - v.Mode = Id(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 Id - Output Id - Crtc Id - Mode Id - 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 = Id(Get32(buf[b:])) - b += 4 - - v.Output = Id(Get32(buf[b:])) - b += 4 - - v.Crtc = Id(Get32(buf[b:])) - b += 4 - - v.Mode = Id(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 Id - Output Id - Atom Id - Timestamp Timestamp - Status byte - // padding: 11 bytes -} - -// Struct read RandrOutputProperty -func ReadRandrOutputProperty(buf []byte, v *RandrOutputProperty) int { - b := 0 - - v.Window = Id(Get32(buf[b:])) - b += 4 - - v.Output = Id(Get32(buf[b:])) - b += 4 - - v.Atom = Id(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 Id - RequestWindow Id - 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 = Id(Get32(buf[b:])) - b += 4 - - v.RequestWindow = Id(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() { - newEventFuncs[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() { - newEventFuncs[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() Id { - 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() { - newErrorFuncs[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() Id { - 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() { - newErrorFuncs[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() Id { - 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() { - newErrorFuncs[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 Id, 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 Id, 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 Id - 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 = Id(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 Id, 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 Id, Enable uint16) RandrSelectInputCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.randrSelectInputRequest(Window, Enable), cookie) - return RandrSelectInputCookie{cookie} -} - -func (c *Conn) RandrSelectInputChecked(Window Id, 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 Id, 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 Id) RandrGetScreenInfoCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrGetScreenInfoRequest(Window), cookie) - return RandrGetScreenInfoCookie{cookie} -} - -func (c *Conn) RandrGetScreenInfoUnchecked(Window Id) 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 Id - 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 = Id(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 Id) []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 Id) RandrGetScreenSizeRangeCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrGetScreenSizeRangeRequest(Window), cookie) - return RandrGetScreenSizeRangeCookie{cookie} -} - -func (c *Conn) RandrGetScreenSizeRangeUnchecked(Window Id) 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 Id) []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 Id, 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 Id, 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 Id, 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 Id) RandrGetScreenResourcesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrGetScreenResourcesRequest(Window), cookie) - return RandrGetScreenResourcesCookie{cookie} -} - -func (c *Conn) RandrGetScreenResourcesUnchecked(Window Id) 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 []Id // size: pad((int(NumCrtcs) * 4)) - Outputs []Id // 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([]Id, v.NumCrtcs) - for i := 0; i < int(v.NumCrtcs); i++ { - v.Crtcs[i] = Id(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - v.Outputs = make([]Id, v.NumOutputs) - for i := 0; i < int(v.NumOutputs); i++ { - v.Outputs[i] = Id(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 Id) []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 Id, ConfigTimestamp Timestamp) RandrGetOutputInfoCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrGetOutputInfoRequest(Output, ConfigTimestamp), cookie) - return RandrGetOutputInfoCookie{cookie} -} - -func (c *Conn) RandrGetOutputInfoUnchecked(Output Id, 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 Id - MmWidth uint32 - MmHeight uint32 - Connection byte - SubpixelOrder byte - NumCrtcs uint16 - NumModes uint16 - NumPreferred uint16 - NumClones uint16 - NameLen uint16 - Crtcs []Id // size: pad((int(NumCrtcs) * 4)) - Modes []Id // size: pad((int(NumModes) * 4)) - Clones []Id // 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 = Id(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([]Id, v.NumCrtcs) - for i := 0; i < int(v.NumCrtcs); i++ { - v.Crtcs[i] = Id(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - v.Modes = make([]Id, v.NumModes) - for i := 0; i < int(v.NumModes); i++ { - v.Modes[i] = Id(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - v.Clones = make([]Id, v.NumClones) - for i := 0; i < int(v.NumClones); i++ { - v.Clones[i] = Id(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 Id, 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 Id) RandrListOutputPropertiesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrListOutputPropertiesRequest(Output), cookie) - return RandrListOutputPropertiesCookie{cookie} -} - -func (c *Conn) RandrListOutputPropertiesUnchecked(Output Id) 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 []Id // 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([]Id, v.NumAtoms) - for i := 0; i < int(v.NumAtoms); i++ { - v.Atoms[i] = Id(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 Id) []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 Id, Property Id) RandrQueryOutputPropertyCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrQueryOutputPropertyRequest(Output, Property), cookie) - return RandrQueryOutputPropertyCookie{cookie} -} - -func (c *Conn) RandrQueryOutputPropertyUnchecked(Output Id, Property Id) 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 Id, Property Id) []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 Id, Property Id, 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 Id, Property Id, 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 Id, Property Id, 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 Id, Property Id, Type Id, 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 Id, Property Id, Type Id, 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 Id, Property Id, Type Id, 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 Id, Property Id) RandrDeleteOutputPropertyCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.randrDeleteOutputPropertyRequest(Output, Property), cookie) - return RandrDeleteOutputPropertyCookie{cookie} -} - -func (c *Conn) RandrDeleteOutputPropertyChecked(Output Id, Property Id) 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 Id, Property Id) []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 Id, Property Id, Type Id, 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 Id, Property Id, Type Id, 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 Id - 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 = Id(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 Id, Property Id, Type Id, 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 Id, 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 Id, 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 Id - // 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 = Id(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 Id, 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 Id) RandrDestroyModeCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.randrDestroyModeRequest(Mode), cookie) - return RandrDestroyModeCookie{cookie} -} - -func (c *Conn) RandrDestroyModeChecked(Mode Id) 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 Id) []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 Id, Mode Id) RandrAddOutputModeCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.randrAddOutputModeRequest(Output, Mode), cookie) - return RandrAddOutputModeCookie{cookie} -} - -func (c *Conn) RandrAddOutputModeChecked(Output Id, Mode Id) 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 Id, Mode Id) []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 Id, Mode Id) RandrDeleteOutputModeCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.randrDeleteOutputModeRequest(Output, Mode), cookie) - return RandrDeleteOutputModeCookie{cookie} -} - -func (c *Conn) RandrDeleteOutputModeChecked(Output Id, Mode Id) 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 Id, Mode Id) []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 Id, ConfigTimestamp Timestamp) RandrGetCrtcInfoCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrGetCrtcInfoRequest(Crtc, ConfigTimestamp), cookie) - return RandrGetCrtcInfoCookie{cookie} -} - -func (c *Conn) RandrGetCrtcInfoUnchecked(Crtc Id, 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 Id - Rotation uint16 - Rotations uint16 - NumOutputs uint16 - NumPossibleOutputs uint16 - Outputs []Id // size: pad((int(NumOutputs) * 4)) - Possible []Id // 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 = Id(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([]Id, v.NumOutputs) - for i := 0; i < int(v.NumOutputs); i++ { - v.Outputs[i] = Id(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - v.Possible = make([]Id, v.NumPossibleOutputs) - for i := 0; i < int(v.NumPossibleOutputs); i++ { - v.Possible[i] = Id(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 Id, 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 Id, Timestamp Timestamp, ConfigTimestamp Timestamp, X int16, Y int16, Mode Id, Rotation uint16, Outputs []Id) 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 Id, Timestamp Timestamp, ConfigTimestamp Timestamp, X int16, Y int16, Mode Id, Rotation uint16, Outputs []Id) 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 Id, Timestamp Timestamp, ConfigTimestamp Timestamp, X int16, Y int16, Mode Id, Rotation uint16, Outputs []Id) []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 Id) RandrGetCrtcGammaSizeCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrGetCrtcGammaSizeRequest(Crtc), cookie) - return RandrGetCrtcGammaSizeCookie{cookie} -} - -func (c *Conn) RandrGetCrtcGammaSizeUnchecked(Crtc Id) 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 Id) []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 Id) RandrGetCrtcGammaCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrGetCrtcGammaRequest(Crtc), cookie) - return RandrGetCrtcGammaCookie{cookie} -} - -func (c *Conn) RandrGetCrtcGammaUnchecked(Crtc Id) 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 Id) []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 Id, 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 Id, 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 Id, 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 Id) RandrGetScreenResourcesCurrentCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrGetScreenResourcesCurrentRequest(Window), cookie) - return RandrGetScreenResourcesCurrentCookie{cookie} -} - -func (c *Conn) RandrGetScreenResourcesCurrentUnchecked(Window Id) 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 []Id // size: pad((int(NumCrtcs) * 4)) - Outputs []Id // 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([]Id, v.NumCrtcs) - for i := 0; i < int(v.NumCrtcs); i++ { - v.Crtcs[i] = Id(Get32(buf[b:])) - b += 4 - } - b = pad(b) - - v.Outputs = make([]Id, v.NumOutputs) - for i := 0; i < int(v.NumOutputs); i++ { - v.Outputs[i] = Id(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 Id) []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 Id, 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 Id, 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 Id, 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 Id) RandrGetCrtcTransformCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrGetCrtcTransformRequest(Crtc), cookie) - return RandrGetCrtcTransformCookie{cookie} -} - -func (c *Conn) RandrGetCrtcTransformUnchecked(Crtc Id) 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 Id) []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 Id) RandrGetPanningCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrGetPanningRequest(Crtc), cookie) - return RandrGetPanningCookie{cookie} -} - -func (c *Conn) RandrGetPanningUnchecked(Crtc Id) 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 Id) []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 Id, 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 Id, 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 Id, 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 Id, Output Id) RandrSetOutputPrimaryCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.randrSetOutputPrimaryRequest(Window, Output), cookie) - return RandrSetOutputPrimaryCookie{cookie} -} - -func (c *Conn) RandrSetOutputPrimaryChecked(Window Id, Output Id) 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 Id, Output Id) []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 Id) RandrGetOutputPrimaryCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.randrGetOutputPrimaryRequest(Window), cookie) - return RandrGetOutputPrimaryCookie{cookie} -} - -func (c *Conn) RandrGetOutputPrimaryUnchecked(Window Id) 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 Id -} - -// 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 = Id(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 Id) []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/render.go b/nexgb/render.go deleted file mode 100644 index 069ce76..0000000 --- a/nexgb/render.go +++ /dev/null @@ -1,3506 +0,0 @@ -package xgb - -/* - This file was generated by render.xml on May 5 2012 6:07:02pm 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" - -// 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' - -// Skipping definition for base type 'Float' - -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 -) - -// Skipping resource definition of 'Glyphset' - -// Skipping resource definition of 'Picture' - -// Skipping resource definition of 'Pictformat' - -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 Id - Type byte - Depth byte - // padding: 2 bytes - Direct RenderDirectformat - Colormap Id -} - -// Struct read RenderPictforminfo -func ReadRenderPictforminfo(buf []byte, v *RenderPictforminfo) int { - b := 0 - - v.Id = Id(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 = Id(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 Id -} - -// Struct read RenderPictvisual -func ReadRenderPictvisual(buf []byte, v *RenderPictvisual) int { - b := 0 - - v.Visual = Visualid(Get32(buf[b:])) - b += 4 - - v.Format = Id(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 Id - 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 = Id(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 Id - Delay uint32 -} - -// Struct read RenderAnimcursorelt -func ReadRenderAnimcursorelt(buf []byte, v *RenderAnimcursorelt) int { - b := 0 - - v.Cursor = Id(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() Id { - 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() { - newErrorFuncs[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() Id { - 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() { - newErrorFuncs[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() Id { - 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() { - newErrorFuncs[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() Id { - 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() { - newErrorFuncs[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() Id { - 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() { - newErrorFuncs[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 Id) RenderQueryPictIndexValuesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.renderQueryPictIndexValuesRequest(Format), cookie) - return RenderQueryPictIndexValuesCookie{cookie} -} - -func (c *Conn) RenderQueryPictIndexValuesUnchecked(Format Id) 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 Id) []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 Id, Drawable Id, Format Id, 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 Id, Drawable Id, Format Id, 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 Id, Drawable Id, Format Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id) RenderFreePictureCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderFreePictureRequest(Picture), cookie) - return RenderFreePictureCookie{cookie} -} - -func (c *Conn) RenderFreePictureChecked(Picture Id) 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 Id) []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 Id, Mask Id, Dst Id, 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 Id, Mask Id, Dst Id, 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 Id, Mask Id, Dst Id, 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 Id, Dst Id, MaskFormat Id, 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 Id, Dst Id, MaskFormat Id, 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 Id, Dst Id, MaskFormat Id, 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 Id, Dst Id, MaskFormat Id, 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 Id, Dst Id, MaskFormat Id, 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 Id, Dst Id, MaskFormat Id, 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 Id, Dst Id, MaskFormat Id, 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 Id, Dst Id, MaskFormat Id, 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 Id, Dst Id, MaskFormat Id, 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 Id, Dst Id, MaskFormat Id, 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 Id, Dst Id, MaskFormat Id, 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 Id, Dst Id, MaskFormat Id, 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 Id, Format Id) RenderCreateGlyphSetCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderCreateGlyphSetRequest(Gsid, Format), cookie) - return RenderCreateGlyphSetCookie{cookie} -} - -func (c *Conn) RenderCreateGlyphSetChecked(Gsid Id, Format Id) 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 Id, Format Id) []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 Id, Existing Id) RenderReferenceGlyphSetCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderReferenceGlyphSetRequest(Gsid, Existing), cookie) - return RenderReferenceGlyphSetCookie{cookie} -} - -func (c *Conn) RenderReferenceGlyphSetChecked(Gsid Id, Existing Id) 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 Id, Existing Id) []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 Id) RenderFreeGlyphSetCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderFreeGlyphSetRequest(Glyphset), cookie) - return RenderFreeGlyphSetCookie{cookie} -} - -func (c *Conn) RenderFreeGlyphSetChecked(Glyphset Id) 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 Id) []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 Id, 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 Id, 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 Id, 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 Id, Glyphs []RenderGlyph) RenderFreeGlyphsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderFreeGlyphsRequest(Glyphset, Glyphs), cookie) - return RenderFreeGlyphsCookie{cookie} -} - -func (c *Conn) RenderFreeGlyphsChecked(Glyphset Id, 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 Id, 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 Id, Dst Id, MaskFormat Id, Glyphset Id, 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 Id, Dst Id, MaskFormat Id, Glyphset Id, 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 Id, Dst Id, MaskFormat Id, Glyphset Id, 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 Id, Dst Id, MaskFormat Id, Glyphset Id, 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 Id, Dst Id, MaskFormat Id, Glyphset Id, 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 Id, Dst Id, MaskFormat Id, Glyphset Id, 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 Id, Dst Id, MaskFormat Id, Glyphset Id, 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 Id, Dst Id, MaskFormat Id, Glyphset Id, 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 Id, Dst Id, MaskFormat Id, Glyphset Id, 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 Id, 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 Id, 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 Id, 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 Id, Source Id, 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 Id, Source Id, 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 Id, Source Id, 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 Id, Transform RenderTransform) RenderSetPictureTransformCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderSetPictureTransformRequest(Picture, Transform), cookie) - return RenderSetPictureTransformCookie{cookie} -} - -func (c *Conn) RenderSetPictureTransformChecked(Picture Id, 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 Id, 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 Id) RenderQueryFiltersCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.renderQueryFiltersRequest(Drawable), cookie) - return RenderQueryFiltersCookie{cookie} -} - -func (c *Conn) RenderQueryFiltersUnchecked(Drawable Id) 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 Id) []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 Id, 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 Id, 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 Id, 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 Id, Cursors []RenderAnimcursorelt) RenderCreateAnimCursorCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderCreateAnimCursorRequest(Cid, Cursors), cookie) - return RenderCreateAnimCursorCookie{cookie} -} - -func (c *Conn) RenderCreateAnimCursorChecked(Cid Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, Color RenderColor) RenderCreateSolidFillCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.renderCreateSolidFillRequest(Picture, Color), cookie) - return RenderCreateSolidFillCookie{cookie} -} - -func (c *Conn) RenderCreateSolidFillChecked(Picture Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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/xgbgen/expression.go b/nexgb/xgbgen/expression.go index 721ebfd..0966b58 100644 --- a/nexgb/xgbgen/expression.go +++ b/nexgb/xgbgen/expression.go @@ -18,7 +18,7 @@ type Expression interface { // Eval evaluates a concrete expression. It is an error to call Eval // on any expression that is not concrete (or contains any sub-expression // that is not concrete). - Eval() uint + Eval() int // Reduce attempts to evaluate any concrete sub-expressions. // i.e., (1 + 2 * (5 + 1 + someSizeOfStruct) reduces to @@ -45,7 +45,7 @@ func (e *Function) Concrete() bool { return false } -func (e *Function) Eval() uint { +func (e *Function) Eval() int { log.Fatalf("Cannot evaluate a 'Function'. It is not concrete.") panic("unreachable") } @@ -95,7 +95,7 @@ func (e *BinaryOp) Concrete() bool { return e.Expr1.Concrete() && e.Expr2.Concrete() } -func (e *BinaryOp) Eval() uint { +func (e *BinaryOp) Eval() int { switch e.Op { case "+": return e.Expr1.Eval() + e.Expr2.Eval() @@ -108,7 +108,7 @@ func (e *BinaryOp) Eval() uint { case "&": return e.Expr1.Eval() & e.Expr2.Eval() case "<<": - return e.Expr1.Eval() << e.Expr2.Eval() + return int(uint(e.Expr1.Eval()) << uint(e.Expr2.Eval())) } log.Fatalf("Invalid binary operator '%s' for expression.", e.Op) @@ -161,7 +161,7 @@ func (e *UnaryOp) Concrete() bool { return e.Expr.Concrete() } -func (e *UnaryOp) Eval() uint { +func (e *UnaryOp) Eval() int { switch e.Op { case "~": return ^e.Expr.Eval() @@ -196,8 +196,8 @@ func (e *Padding) Concrete() bool { return e.Expr.Concrete() } -func (e *Padding) Eval() uint { - return uint(pad(int(e.Expr.Eval()))) +func (e *Padding) Eval() int { + return pad(e.Expr.Eval()) } func (e *Padding) Reduce(prefix string) string { @@ -225,8 +225,8 @@ func (e *PopCount) Concrete() bool { return e.Expr.Concrete() } -func (e *PopCount) Eval() uint { - return popCount(e.Expr.Eval()) +func (e *PopCount) Eval() int { + return int(popCount(uint(e.Expr.Eval()))) } func (e *PopCount) Reduce(prefix string) string { @@ -246,14 +246,14 @@ func (e *PopCount) Initialize(p *Protocol) { // Value represents some constant integer. type Value struct { - v uint + v int } func (e *Value) Concrete() bool { return true } -func (e *Value) Eval() uint { +func (e *Value) Eval() int { return e.v } @@ -269,15 +269,15 @@ func (e *Value) Initialize(p *Protocol) {} // Bit represents some bit whose value is computed by '1 << bit'. type Bit struct { - b uint + b int } func (e *Bit) Concrete() bool { return true } -func (e *Bit) Eval() uint { - return 1 << e.b +func (e *Bit) Eval() int { + return int(1 << uint(e.b)) } func (e *Bit) Reduce(prefix string) string { @@ -300,7 +300,7 @@ func (e *FieldRef) Concrete() bool { return false } -func (e *FieldRef) Eval() uint { +func (e *FieldRef) Eval() int { log.Fatalf("Cannot evaluate a 'FieldRef'. It is not concrete.") panic("unreachable") } @@ -333,7 +333,7 @@ func (e *EnumRef) Concrete() bool { return false } -func (e *EnumRef) Eval() uint { +func (e *EnumRef) Eval() int { log.Fatalf("Cannot evaluate an 'EnumRef'. It is not concrete.") panic("unreachable") } @@ -361,7 +361,7 @@ func (e *SumOf) Concrete() bool { return false } -func (e *SumOf) Eval() uint { +func (e *SumOf) Eval() int { log.Fatalf("Cannot evaluate a 'SumOf'. It is not concrete.") panic("unreachable") } diff --git a/nexgb/xgbgen/field.go b/nexgb/xgbgen/field.go index 725f3de..4452408 100644 --- a/nexgb/xgbgen/field.go +++ b/nexgb/xgbgen/field.go @@ -142,8 +142,7 @@ func (f *ListField) Length() Size { // special function written in go_struct.go to compute the size (since the // size in this case can only be computed recursively). func (f *ListField) Size() Size { - simpleLen := &Function{ - Name: "pad", + simpleLen := &Padding{ Expr: newBinaryOp("*", f.Length().Expression, f.Type.Size().Expression), } diff --git a/nexgb/xgbgen/go.go b/nexgb/xgbgen/go.go index df12e69..e0d4579 100644 --- a/nexgb/xgbgen/go.go +++ b/nexgb/xgbgen/go.go @@ -150,15 +150,21 @@ func (f *ExprField) Write(c *Context, prefix string) { // 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") + c.Putln("%s %s", f.MaskName, f.SrcType()) + c.Putln("%s []uint32", f.ListName) } 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") + ReadSimpleSingleField(c, + fmt.Sprintf("%s%s", prefix, f.MaskName), f.MaskType) + c.Putln("") + 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("b += 4") + c.Putln("}") + c.Putln("b = pad(b)") } func (f *ValueField) Write(c *Context, prefix string) { diff --git a/nexgb/xgbgen/go_struct.go b/nexgb/xgbgen/go_struct.go index 1e43199..9884194 100644 --- a/nexgb/xgbgen/go_struct.go +++ b/nexgb/xgbgen/go_struct.go @@ -104,7 +104,11 @@ func (s *Struct) WriteListSize(c *Context) { c.Putln("// Struct list size %s", s.SrcName()) c.Putln("func %sListSize(list []%s) int {", s.SrcName(), s.SrcName()) c.Putln("size := 0") - c.Putln("for _, item := range list {") + if s.Size().Expression.Concrete() { + c.Putln("for _ = range list {") + } else { + c.Putln("for _, item := range list {") + } c.Putln("size += %s", s.Size().Reduce("item.")) c.Putln("}") c.Putln("return size") diff --git a/nexgb/xgbgen/size.go b/nexgb/xgbgen/size.go index d8d3ac3..8836892 100644 --- a/nexgb/xgbgen/size.go +++ b/nexgb/xgbgen/size.go @@ -11,7 +11,7 @@ type Size struct { // newFixedSize creates a new Size with some fixed and known value. func newFixedSize(fixed uint) Size { - return Size{&Value{v: fixed}} + return Size{&Value{v: int(fixed)}} } // newExpressionSize creates a new Size with some expression. diff --git a/nexgb/xgbgen/translation.go b/nexgb/xgbgen/translation.go index b650bc4..90cd0f3 100644 --- a/nexgb/xgbgen/translation.go +++ b/nexgb/xgbgen/translation.go @@ -89,7 +89,7 @@ func (xml *XML) Translate() *Protocol { if !ok { continue } - nextValue := uint(0) + nextValue := 0 for _, item := range enum.Items { if item.Expr == nil { item.Expr = &Value{v: nextValue} @@ -267,16 +267,16 @@ func (x *XMLExpression) Translate() Expression { Expr: x.Exprs[0].Translate(), } case "value": - val, err := strconv.Atoi(x.Data) + val, err := strconv.Atoi(strings.TrimSpace(x.Data)) if err != nil { log.Panicf("Could not convert '%s' in 'value' expression to int.", x.Data) } return &Value{ - v: uint(val), + v: val, } case "bit": - bit, err := strconv.Atoi(x.Data) + bit, err := strconv.Atoi(strings.TrimSpace(x.Data)) if err != nil { log.Panicf("Could not convert '%s' in 'bit' expression to int.", x.Data) @@ -286,7 +286,7 @@ func (x *XMLExpression) Translate() Expression { " is %d", bit) } return &Bit{ - b: uint(bit), + b: bit, } case "fieldref": return &FieldRef{ diff --git a/nexgb/xinerama.go b/nexgb/xinerama.go deleted file mode 100644 index c2e031c..0000000 --- a/nexgb/xinerama.go +++ /dev/null @@ -1,629 +0,0 @@ -package xgb - -/* - This file was generated by xinerama.xml on May 5 2012 5:56:52pm 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" - -// 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 'Id' - -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -// '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 - - buf[b] = Major - b += 1 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - buf[b] = Minor - b += 1 - - return buf -} - -// Request XineramaGetState -// size: 8 -type XineramaGetStateCookie struct { - *cookie -} - -func (c *Conn) XineramaGetState(Window Id) XineramaGetStateCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xineramaGetStateRequest(Window), cookie) - return XineramaGetStateCookie{cookie} -} - -func (c *Conn) XineramaGetStateUnchecked(Window Id) 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 Id -} - -// 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 = Id(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 Id) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINERAMA"] - b += 1 - - buf[b] = 1 // request opcode - b += 1 - - Put32(buf[b:], uint32(Window)) - b += 4 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request XineramaGetScreenCount -// size: 8 -type XineramaGetScreenCountCookie struct { - *cookie -} - -func (c *Conn) XineramaGetScreenCount(Window Id) XineramaGetScreenCountCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xineramaGetScreenCountRequest(Window), cookie) - return XineramaGetScreenCountCookie{cookie} -} - -func (c *Conn) XineramaGetScreenCountUnchecked(Window Id) 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 Id -} - -// 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 = Id(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 Id) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.extensions["XINERAMA"] - b += 1 - - buf[b] = 2 // request opcode - b += 1 - - Put32(buf[b:], uint32(Window)) - b += 4 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - return buf -} - -// Request XineramaGetScreenSize -// size: 12 -type XineramaGetScreenSizeCookie struct { - *cookie -} - -func (c *Conn) XineramaGetScreenSize(Window Id, Screen uint32) XineramaGetScreenSizeCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.xineramaGetScreenSizeRequest(Window, Screen), cookie) - return XineramaGetScreenSizeCookie{cookie} -} - -func (c *Conn) XineramaGetScreenSizeUnchecked(Window Id, 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 Id - 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 = Id(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 Id, 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 - - Put32(buf[b:], uint32(Window)) - b += 4 - - Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - 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/xproto.go b/nexgb/xproto.go deleted file mode 100644 index 32fa6dd..0000000 --- a/nexgb/xproto.go +++ /dev/null @@ -1,14420 +0,0 @@ -package xgb - -/* - This file was generated by xproto.xml on May 5 2012 5:43:45pm EDT. - This file is automatically generated. Edit at your peril! -*/ - -// 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 'Id' - -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -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 (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 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 (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 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 (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 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 (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 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 (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: 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 (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 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 (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 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 (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 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 (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 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 (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 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 (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 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 (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 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 (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 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 (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 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 (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 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 (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 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 (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 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 (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 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 (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 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 (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 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 (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 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 (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 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 (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 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 (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 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 (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 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 (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 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 (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() 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: 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 Id, Parent Id, 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 Id, Parent Id, 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 Id, Parent Id, 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 Id, 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 Id, 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 Id, 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 Id) GetWindowAttributesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.getWindowAttributesRequest(Window), cookie) - return GetWindowAttributesCookie{cookie} -} - -func (c *Conn) GetWindowAttributesUnchecked(Window Id) 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 Id - 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 = 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 -} - -func (cook GetWindowAttributesCookie) Check() error { - return cook.check() -} - -// Write request to wire for GetWindowAttributes -func (c *Conn) getWindowAttributesRequest(Window Id) []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 Id) DestroyWindowCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.destroyWindowRequest(Window), cookie) - return DestroyWindowCookie{cookie} -} - -func (c *Conn) DestroyWindowChecked(Window Id) 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 Id) []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 Id) DestroySubwindowsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.destroySubwindowsRequest(Window), cookie) - return DestroySubwindowsCookie{cookie} -} - -func (c *Conn) DestroySubwindowsChecked(Window Id) 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 Id) []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 Id) ChangeSaveSetCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.changeSaveSetRequest(Mode, Window), cookie) - return ChangeSaveSetCookie{cookie} -} - -func (c *Conn) ChangeSaveSetChecked(Mode byte, Window Id) 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 Id) []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 Id, Parent Id, 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 Id, Parent Id, 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 Id, Parent Id, 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 Id) MapWindowCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.mapWindowRequest(Window), cookie) - return MapWindowCookie{cookie} -} - -func (c *Conn) MapWindowChecked(Window Id) 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 Id) []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 Id) MapSubwindowsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.mapSubwindowsRequest(Window), cookie) - return MapSubwindowsCookie{cookie} -} - -func (c *Conn) MapSubwindowsChecked(Window Id) 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 Id) []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 Id) UnmapWindowCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.unmapWindowRequest(Window), cookie) - return UnmapWindowCookie{cookie} -} - -func (c *Conn) UnmapWindowChecked(Window Id) 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 Id) []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 Id) UnmapSubwindowsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.unmapSubwindowsRequest(Window), cookie) - return UnmapSubwindowsCookie{cookie} -} - -func (c *Conn) UnmapSubwindowsChecked(Window Id) 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 Id) []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 Id, 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 Id, 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 Id, 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 Id) CirculateWindowCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.circulateWindowRequest(Direction, Window), cookie) - return CirculateWindowCookie{cookie} -} - -func (c *Conn) CirculateWindowChecked(Direction byte, Window Id) 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 Id) []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 Id) GetGeometryCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.getGeometryRequest(Drawable), cookie) - return GetGeometryCookie{cookie} -} - -func (c *Conn) GetGeometryUnchecked(Drawable Id) 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 Id - 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 = 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 -} - -func (cook GetGeometryCookie) Check() error { - return cook.check() -} - -// Write request to wire for GetGeometry -func (c *Conn) getGeometryRequest(Drawable Id) []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 Id) QueryTreeCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.queryTreeRequest(Window), cookie) - return QueryTreeCookie{cookie} -} - -func (c *Conn) QueryTreeUnchecked(Window Id) 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 Id - Parent Id - ChildrenLen uint16 - // padding: 14 bytes - Children []Id // 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 = 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 -} - -func (cook QueryTreeCookie) Check() error { - return cook.check() -} - -// Write request to wire for QueryTree -func (c *Conn) queryTreeRequest(Window Id) []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 Id -} - -// 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 = Id(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 Id) GetAtomNameCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.getAtomNameRequest(Atom), cookie) - return GetAtomNameCookie{cookie} -} - -func (c *Conn) GetAtomNameUnchecked(Atom Id) 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 Id) []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 Id, Property Id, Type Id, 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 Id, Property Id, Type Id, 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 Id, Property Id, Type Id, 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 Id, Property Id) DeletePropertyCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.deletePropertyRequest(Window, Property), cookie) - return DeletePropertyCookie{cookie} -} - -func (c *Conn) DeletePropertyChecked(Window Id, Property Id) 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 Id, Property Id) []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 Id, Property Id, Type Id, 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 Id, Property Id, Type Id, 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 Id - 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 = 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 -} - -func (cook GetPropertyCookie) Check() error { - return cook.check() -} - -// Write request to wire for GetProperty -func (c *Conn) getPropertyRequest(Delete bool, Window Id, Property Id, Type Id, 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 Id) ListPropertiesCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.listPropertiesRequest(Window), cookie) - return ListPropertiesCookie{cookie} -} - -func (c *Conn) ListPropertiesUnchecked(Window Id) 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 []Id // 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([]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 -} - -func (cook ListPropertiesCookie) Check() error { - return cook.check() -} - -// Write request to wire for ListProperties -func (c *Conn) listPropertiesRequest(Window Id) []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 Id, Selection Id, Time Timestamp) SetSelectionOwnerCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.setSelectionOwnerRequest(Owner, Selection, Time), cookie) - return SetSelectionOwnerCookie{cookie} -} - -func (c *Conn) SetSelectionOwnerChecked(Owner Id, Selection Id, 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 Id, Selection Id, 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 Id) GetSelectionOwnerCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.getSelectionOwnerRequest(Selection), cookie) - return GetSelectionOwnerCookie{cookie} -} - -func (c *Conn) GetSelectionOwnerUnchecked(Selection Id) 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 Id -} - -// 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 = Id(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 Id) []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 Id, Selection Id, Target Id, Property Id, 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 Id, Selection Id, Target Id, Property Id, 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 Id, Selection Id, Target Id, Property Id, 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: pad((12 + pad(32))) -type SendEventCookie struct { - *cookie -} - -// Write request to wire for SendEvent -func (c *Conn) SendEvent(Propagate bool, Destination Id, 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 Id, 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 Id, EventMask uint32, Event string) []byte { - size := pad((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)) - - return buf -} - -// Request GrabPointer -// size: 24 -type GrabPointerCookie struct { - *cookie -} - -func (c *Conn) GrabPointer(OwnerEvents bool, GrabWindow Id, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Id, Cursor Id, 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 Id, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Id, Cursor Id, 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 Id, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Id, Cursor Id, 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 Id, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Id, Cursor Id, 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 Id, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Id, Cursor Id, 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 Id, EventMask uint16, PointerMode byte, KeyboardMode byte, ConfineTo Id, Cursor Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id) QueryPointerCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.queryPointerRequest(Window), cookie) - return QueryPointerCookie{cookie} -} - -func (c *Conn) QueryPointerUnchecked(Window Id) 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 Id - Child Id - 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 = 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 -} - -func (cook QueryPointerCookie) Check() error { - return cook.check() -} - -// Write request to wire for QueryPointer -func (c *Conn) queryPointerRequest(Window Id) []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 Id, 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 Id, 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 Id, 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 Id, DstWindow Id, 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 Id, DstWindow Id, 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 Id - 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 = Id(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 Id, DstWindow Id, 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 Id, DstWindow Id, 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 Id, DstWindow Id, 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 Id, DstWindow Id, 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 Id, 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 Id, 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 Id, 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 Id -} - -// 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 = Id(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: (8 + pad(32)) -type QueryKeymapReply struct { - Sequence uint16 - Length uint32 - // padding: 1 bytes - Keys []byte // size: pad(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 Id, 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 Id, 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 Id, 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 Id) CloseFontCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.closeFontRequest(Font), cookie) - return CloseFontCookie{cookie} -} - -func (c *Conn) CloseFontChecked(Font Id) 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 Id) []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 Id) QueryFontCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.queryFontRequest(Font), cookie) - return QueryFontCookie{cookie} -} - -func (c *Conn) QueryFontUnchecked(Font Id) 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 Id) []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 Id, 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 Id, 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 Id, 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 Id, Drawable Id, 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 Id, Drawable Id, 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 Id, Drawable Id, 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 Id) FreePixmapCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.freePixmapRequest(Pixmap), cookie) - return FreePixmapCookie{cookie} -} - -func (c *Conn) FreePixmapChecked(Pixmap Id) 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 Id) []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 Id, Drawable Id, 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 Id, Drawable Id, 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 Id, Drawable Id, 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 Id, 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 Id, 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 Id, 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 Id, DstGc Id, ValueMask uint32) CopyGCCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.copyGCRequest(SrcGc, DstGc, ValueMask), cookie) - return CopyGCCookie{cookie} -} - -func (c *Conn) CopyGCChecked(SrcGc Id, DstGc Id, 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 Id, DstGc Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id) FreeGCCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.freeGCRequest(Gc), cookie) - return FreeGCCookie{cookie} -} - -func (c *Conn) FreeGCChecked(Gc Id) 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 Id) []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 Id, 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 Id, 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 Id, 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 Id, DstDrawable Id, Gc Id, 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 Id, DstDrawable Id, Gc Id, 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 Id, DstDrawable Id, Gc Id, 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 Id, DstDrawable Id, Gc Id, 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 Id, DstDrawable Id, Gc Id, 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 Id, DstDrawable Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, Segments []Segment) PolySegmentCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.polySegmentRequest(Drawable, Gc, Segments), cookie) - return PolySegmentCookie{cookie} -} - -func (c *Conn) PolySegmentChecked(Drawable Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, Rectangles []Rectangle) PolyRectangleCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.polyRectangleRequest(Drawable, Gc, Rectangles), cookie) - return PolyRectangleCookie{cookie} -} - -func (c *Conn) PolyRectangleChecked(Drawable Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, Arcs []Arc) PolyArcCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.polyArcRequest(Drawable, Gc, Arcs), cookie) - return PolyArcCookie{cookie} -} - -func (c *Conn) PolyArcChecked(Drawable Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, Rectangles []Rectangle) PolyFillRectangleCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.polyFillRectangleRequest(Drawable, Gc, Rectangles), cookie) - return PolyFillRectangleCookie{cookie} -} - -func (c *Conn) PolyFillRectangleChecked(Drawable Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, Arcs []Arc) PolyFillArcCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.polyFillArcRequest(Drawable, Gc, Arcs), cookie) - return PolyFillArcCookie{cookie} -} - -func (c *Conn) PolyFillArcChecked(Drawable Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, 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 Id, 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 Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Gc Id, 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 Id, Window Id, 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 Id, Window Id, 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 Id, Window Id, 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 Id) FreeColormapCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.freeColormapRequest(Cmap), cookie) - return FreeColormapCookie{cookie} -} - -func (c *Conn) FreeColormapChecked(Cmap Id) 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 Id) []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 Id, SrcCmap Id) CopyColormapAndFreeCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.copyColormapAndFreeRequest(Mid, SrcCmap), cookie) - return CopyColormapAndFreeCookie{cookie} -} - -func (c *Conn) CopyColormapAndFreeChecked(Mid Id, SrcCmap Id) 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 Id, SrcCmap Id) []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 Id) InstallColormapCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.installColormapRequest(Cmap), cookie) - return InstallColormapCookie{cookie} -} - -func (c *Conn) InstallColormapChecked(Cmap Id) 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 Id) []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 Id) UninstallColormapCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.uninstallColormapRequest(Cmap), cookie) - return UninstallColormapCookie{cookie} -} - -func (c *Conn) UninstallColormapChecked(Cmap Id) 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 Id) []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 Id) ListInstalledColormapsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.listInstalledColormapsRequest(Window), cookie) - return ListInstalledColormapsCookie{cookie} -} - -func (c *Conn) ListInstalledColormapsUnchecked(Window Id) 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 []Id // 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([]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 -} - -func (cook ListInstalledColormapsCookie) Check() error { - return cook.check() -} - -// Write request to wire for ListInstalledColormaps -func (c *Conn) listInstalledColormapsRequest(Window Id) []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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, Items []Coloritem) StoreColorsCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.storeColorsRequest(Cmap, Items), cookie) - return StoreColorsCookie{cookie} -} - -func (c *Conn) StoreColorsChecked(Cmap Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, Pixels []uint32) QueryColorsCookie { - cookie := c.newCookie(true, true) - c.newRequest(c.queryColorsRequest(Cmap, Pixels), cookie) - return QueryColorsCookie{cookie} -} - -func (c *Conn) QueryColorsUnchecked(Cmap Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, Source Id, Mask Id, 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 Id, Source Id, Mask Id, 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 Id, Source Id, Mask Id, 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 Id, SourceFont Id, MaskFont Id, 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 Id, SourceFont Id, MaskFont Id, 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 Id, SourceFont Id, MaskFont Id, 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 Id) FreeCursorCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.freeCursorRequest(Cursor), cookie) - return FreeCursorCookie{cookie} -} - -func (c *Conn) FreeCursorChecked(Cursor Id) 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 Id) []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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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 Id, 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: (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) -} - -// 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 Id, AtomsLen uint16, Delta int16, Atoms []Id) RotatePropertiesCookie { - cookie := c.newCookie(false, false) - c.newRequest(c.rotatePropertiesRequest(Window, AtomsLen, Delta, Atoms), cookie) - return RotatePropertiesCookie{cookie} -} - -func (c *Conn) RotatePropertiesChecked(Window Id, AtomsLen uint16, Delta int16, Atoms []Id) 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 Id, AtomsLen uint16, Delta int16, Atoms []Id) []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 -} -- cgit v1.2.3-70-g09d2 From a548d9d0f7b889627c43b18811357fad88760b2d Mon Sep 17 00:00:00 2001 From: aarzilli Date: Fri, 2 May 2014 15:09:23 +0200 Subject: Fix Issue #21: automatic calculation of alignment padding after lists --- nexgb/dri2/dri2.go | 7 +- nexgb/examples/randr/main.go | 2 +- nexgb/glx/glx.go | 93 ++++-------------- nexgb/randr/randr.go | 199 ++++++++++++++++++++++----------------- nexgb/record/record.go | 35 ++++--- nexgb/render/render.go | 112 +++++++++++++--------- nexgb/res/res.go | 16 ++-- nexgb/xcmisc/xcmisc.go | 1 - nexgb/xevie/xevie.go | 2 +- nexgb/xf86dri/xf86dri.go | 8 +- nexgb/xf86vidmode/xf86vidmode.go | 52 +++++----- nexgb/xfixes/xfixes.go | 12 +-- nexgb/xgbgen/aligngap.go | 130 +++++++++++++++++++++++++ nexgb/xgbgen/context.go | 2 + nexgb/xgbgen/field.go | 32 ++++--- nexgb/xgbgen/go.go | 18 +++- nexgb/xgbgen/go_list.go | 10 +- nexgb/xgbgen/go_request_reply.go | 30 ++++-- nexgb/xgbgen/go_struct.go | 2 +- nexgb/xgbgen/request_reply.go | 12 +-- nexgb/xgbgen/size.go | 13 +-- nexgb/xgbgen/translation.go | 2 +- nexgb/xgbgen/type.go | 12 +-- nexgb/xinerama/xinerama.go | 2 +- nexgb/xprint/xprint.go | 20 +--- nexgb/xproto/xproto.go | 169 ++++++++++++++++----------------- nexgb/xproto/xproto_test.go | 17 ++++ nexgb/xselinux/xselinux.go | 20 ++-- nexgb/xv/xv.go | 67 +++++++------ nexgb/xvmc/xvmc.go | 7 +- 30 files changed, 630 insertions(+), 474 deletions(-) create mode 100644 nexgb/xgbgen/aligngap.go (limited to 'nexgb/xgbgen/size.go') diff --git a/nexgb/dri2/dri2.go b/nexgb/dri2/dri2.go index 6cec3d0..5ad0306 100644 --- a/nexgb/dri2/dri2.go +++ b/nexgb/dri2/dri2.go @@ -76,7 +76,7 @@ func (v AttachFormat) Bytes() []byte { xgb.Put32(buf[b:], v.Format) b += 4 - return buf + return buf[:b] } // AttachFormatListBytes writes a list of AttachFormat values to a byte slice. @@ -281,7 +281,7 @@ func (v DRI2Buffer) Bytes() []byte { xgb.Put32(buf[b:], v.Flags) b += 4 - return buf + return buf[:b] } // DRI2BufferListBytes writes a list of DRI2Buffer values to a byte slice. @@ -567,7 +567,7 @@ func connectReply(buf []byte) *ConnectReply { 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)))) + b += int((((int(v.DriverNameLength) + 3) & -4) - int(v.DriverNameLength))) { byteString := make([]byte, v.DeviceNameLength) @@ -914,7 +914,6 @@ func getBuffersRequest(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Atta xgb.Put32(buf[b:], Attachments[i]) b += 4 } - b = xgb.Pad(b) return buf } diff --git a/nexgb/examples/randr/main.go b/nexgb/examples/randr/main.go index 414ef8d..ac6fb7a 100644 --- a/nexgb/examples/randr/main.go +++ b/nexgb/examples/randr/main.go @@ -63,7 +63,7 @@ func main() { if err != nil { log.Fatal(err) } - fmt.Printf("X: %d, Y: %d, Width: %d, Height: %d\n", + fmt.Printf("%v, X: %d, Y: %d, Width: %d, Height: %d\n", info.X, info.Y, info.Width, info.Height) } diff --git a/nexgb/glx/glx.go b/nexgb/glx/glx.go index 979d577..0951765 100644 --- a/nexgb/glx/glx.go +++ b/nexgb/glx/glx.go @@ -1097,7 +1097,6 @@ func areTexturesResidentReply(buf []byte) *AreTexturesResidentReply { } b += 1 } - b = xgb.Pad(b) return v } @@ -1128,7 +1127,6 @@ func areTexturesResidentRequest(c *xgb.Conn, ContextTag ContextTag, N int32, Tex xgb.Put32(buf[b:], Textures[i]) b += 4 } - b = xgb.Pad(b) return buf } @@ -1192,7 +1190,6 @@ func changeDrawableAttributesRequest(c *xgb.Conn, Drawable Drawable, NumAttribs xgb.Put32(buf[b:], Attribs[i]) b += 4 } - b = xgb.Pad(b) return buf } @@ -1256,7 +1253,7 @@ func clientInfoRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, St b += 4 copy(buf[b:], String[:StrLen]) - b += xgb.Pad(int(StrLen)) + b += int(StrLen) return buf } @@ -1475,7 +1472,6 @@ func createContextAttribsARBRequest(c *xgb.Conn, Context Context, Fbconfig Fbcon xgb.Put32(buf[b:], Attribs[i]) b += 4 } - b = xgb.Pad(b) return buf } @@ -1685,7 +1681,6 @@ func createPbufferRequest(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Pbuffer xgb.Put32(buf[b:], Attribs[i]) b += 4 } - b = xgb.Pad(b) return buf } @@ -1758,7 +1753,6 @@ func createPixmapRequest(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Pixmap x xgb.Put32(buf[b:], Attribs[i]) b += 4 } - b = xgb.Pad(b) return buf } @@ -1831,7 +1825,6 @@ func createWindowRequest(c *xgb.Conn, Screen uint32, Fbconfig Fbconfig, Window x xgb.Put32(buf[b:], Attribs[i]) b += 4 } - b = xgb.Pad(b) return buf } @@ -1956,7 +1949,6 @@ func deleteQueriesARBRequest(c *xgb.Conn, ContextTag ContextTag, N int32, Ids [] xgb.Put32(buf[b:], Ids[i]) b += 4 } - b = xgb.Pad(b) return buf } @@ -2020,7 +2012,6 @@ func deleteTexturesRequest(c *xgb.Conn, ContextTag ContextTag, N int32, Textures xgb.Put32(buf[b:], Textures[i]) b += 4 } - b = xgb.Pad(b) return buf } @@ -2714,7 +2705,6 @@ func genQueriesARBReply(buf []byte) *GenQueriesARBReply { v.Data[i] = xgb.Get32(buf[b:]) b += 4 } - b = xgb.Pad(b) return v } @@ -2812,7 +2802,6 @@ func genTexturesReply(buf []byte) *GenTexturesReply { v.Data[i] = xgb.Get32(buf[b:]) b += 4 } - b = xgb.Pad(b) return v } @@ -2929,7 +2918,6 @@ func getBooleanvReply(buf []byte) *GetBooleanvReply { } b += 1 } - b = xgb.Pad(b) return v } @@ -3027,7 +3015,6 @@ func getClipPlaneReply(buf []byte) *GetClipPlaneReply { v.Data[i] = Float64(xgb.Get64(buf[b:])) b += 8 } - b = xgb.Pad(b) return v } @@ -3129,7 +3116,7 @@ func getColorTableReply(buf []byte) *GetColorTableReply { 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))) + b += int((int(v.Length) * 4)) return v } @@ -3251,7 +3238,6 @@ func getColorTableParameterfvReply(buf []byte) *GetColorTableParameterfvReply { v.Data[i] = Float32(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) return v } @@ -3363,7 +3349,6 @@ func getColorTableParameterivReply(buf []byte) *GetColorTableParameterivReply { v.Data[i] = int32(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) return v } @@ -3468,7 +3453,7 @@ func getCompressedTexImageARBReply(buf []byte) *GetCompressedTexImageARBReply { 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))) + b += int((int(v.Length) * 4)) return v } @@ -3577,7 +3562,7 @@ func getConvolutionFilterReply(buf []byte) *GetConvolutionFilterReply { 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))) + b += int((int(v.Length) * 4)) return v } @@ -3699,7 +3684,6 @@ func getConvolutionParameterfvReply(buf []byte) *GetConvolutionParameterfvReply v.Data[i] = Float32(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) return v } @@ -3811,7 +3795,6 @@ func getConvolutionParameterivReply(buf []byte) *GetConvolutionParameterivReply v.Data[i] = int32(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) return v } @@ -3923,7 +3906,6 @@ func getDoublevReply(buf []byte) *GetDoublevReply { v.Data[i] = Float64(xgb.Get64(buf[b:])) b += 8 } - b = xgb.Pad(b) return v } @@ -4025,7 +4007,6 @@ func getDrawableAttributesReply(buf []byte) *GetDrawableAttributesReply { v.Attribs[i] = xgb.Get32(buf[b:]) b += 4 } - b = xgb.Pad(b) return v } @@ -4216,7 +4197,6 @@ func getFBConfigsReply(buf []byte) *GetFBConfigsReply { v.PropertyList[i] = xgb.Get32(buf[b:]) b += 4 } - b = xgb.Pad(b) return v } @@ -4322,7 +4302,6 @@ func getFloatvReply(buf []byte) *GetFloatvReply { v.Data[i] = Float32(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) return v } @@ -4424,7 +4403,7 @@ func getHistogramReply(buf []byte) *GetHistogramReply { 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))) + b += int((int(v.Length) * 4)) return v } @@ -4553,7 +4532,6 @@ func getHistogramParameterfvReply(buf []byte) *GetHistogramParameterfvReply { v.Data[i] = Float32(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) return v } @@ -4665,7 +4643,6 @@ func getHistogramParameterivReply(buf []byte) *GetHistogramParameterivReply { v.Data[i] = int32(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) return v } @@ -4777,7 +4754,6 @@ func getIntegervReply(buf []byte) *GetIntegervReply { v.Data[i] = int32(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) return v } @@ -4886,7 +4862,6 @@ func getLightfvReply(buf []byte) *GetLightfvReply { v.Data[i] = Float32(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) return v } @@ -4998,7 +4973,6 @@ func getLightivReply(buf []byte) *GetLightivReply { v.Data[i] = int32(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) return v } @@ -5110,7 +5084,6 @@ func getMapdvReply(buf []byte) *GetMapdvReply { v.Data[i] = Float64(xgb.Get64(buf[b:])) b += 8 } - b = xgb.Pad(b) return v } @@ -5222,7 +5195,6 @@ func getMapfvReply(buf []byte) *GetMapfvReply { v.Data[i] = Float32(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) return v } @@ -5334,7 +5306,6 @@ func getMapivReply(buf []byte) *GetMapivReply { v.Data[i] = int32(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) return v } @@ -5446,7 +5417,6 @@ func getMaterialfvReply(buf []byte) *GetMaterialfvReply { v.Data[i] = Float32(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) return v } @@ -5558,7 +5528,6 @@ func getMaterialivReply(buf []byte) *GetMaterialivReply { v.Data[i] = int32(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) return v } @@ -5656,7 +5625,7 @@ func getMinmaxReply(buf []byte) *GetMinmaxReply { 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))) + b += int((int(v.Length) * 4)) return v } @@ -5785,7 +5754,6 @@ func getMinmaxParameterfvReply(buf []byte) *GetMinmaxParameterfvReply { v.Data[i] = Float32(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) return v } @@ -5897,7 +5865,6 @@ func getMinmaxParameterivReply(buf []byte) *GetMinmaxParameterivReply { v.Data[i] = int32(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) return v } @@ -6009,7 +5976,6 @@ func getPixelMapfvReply(buf []byte) *GetPixelMapfvReply { v.Data[i] = Float32(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) return v } @@ -6118,7 +6084,6 @@ func getPixelMapuivReply(buf []byte) *GetPixelMapuivReply { v.Data[i] = xgb.Get32(buf[b:]) b += 4 } - b = xgb.Pad(b) return v } @@ -6227,7 +6192,6 @@ func getPixelMapusvReply(buf []byte) *GetPixelMapusvReply { v.Data[i] = xgb.Get16(buf[b:]) b += 2 } - b = xgb.Pad(b) return v } @@ -6322,7 +6286,7 @@ func getPolygonStippleReply(buf []byte) *GetPolygonStippleReply { 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))) + b += int((int(v.Length) * 4)) return v } @@ -6435,7 +6399,6 @@ func getQueryObjectivARBReply(buf []byte) *GetQueryObjectivARBReply { v.Data[i] = int32(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) return v } @@ -6547,7 +6510,6 @@ func getQueryObjectuivARBReply(buf []byte) *GetQueryObjectuivARBReply { v.Data[i] = xgb.Get32(buf[b:]) b += 4 } - b = xgb.Pad(b) return v } @@ -6659,7 +6621,6 @@ func getQueryivARBReply(buf []byte) *GetQueryivARBReply { v.Data[i] = int32(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) return v } @@ -6768,7 +6729,7 @@ func getSeparableFilterReply(buf []byte) *GetSeparableFilterReply { 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))) + b += int((int(v.Length) * 4)) return v } @@ -6995,7 +6956,6 @@ func getTexEnvfvReply(buf []byte) *GetTexEnvfvReply { v.Data[i] = Float32(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) return v } @@ -7107,7 +7067,6 @@ func getTexEnvivReply(buf []byte) *GetTexEnvivReply { v.Data[i] = int32(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) return v } @@ -7219,7 +7178,6 @@ func getTexGendvReply(buf []byte) *GetTexGendvReply { v.Data[i] = Float64(xgb.Get64(buf[b:])) b += 8 } - b = xgb.Pad(b) return v } @@ -7331,7 +7289,6 @@ func getTexGenfvReply(buf []byte) *GetTexGenfvReply { v.Data[i] = Float32(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) return v } @@ -7443,7 +7400,6 @@ func getTexGenivReply(buf []byte) *GetTexGenivReply { v.Data[i] = int32(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) return v } @@ -7556,7 +7512,7 @@ func getTexImageReply(buf []byte) *GetTexImageReply { 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))) + b += int((int(v.Length) * 4)) return v } @@ -7681,7 +7637,6 @@ func getTexLevelParameterfvReply(buf []byte) *GetTexLevelParameterfvReply { v.Data[i] = Float32(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) return v } @@ -7796,7 +7751,6 @@ func getTexLevelParameterivReply(buf []byte) *GetTexLevelParameterivReply { v.Data[i] = int32(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) return v } @@ -7911,7 +7865,6 @@ func getTexParameterfvReply(buf []byte) *GetTexParameterfvReply { v.Data[i] = Float32(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) return v } @@ -8023,7 +7976,6 @@ func getTexParameterivReply(buf []byte) *GetTexParameterivReply { v.Data[i] = int32(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) return v } @@ -8132,7 +8084,6 @@ func getVisualConfigsReply(buf []byte) *GetVisualConfigsReply { v.PropertyList[i] = xgb.Get32(buf[b:]) b += 4 } - b = xgb.Pad(b) return v } @@ -8979,7 +8930,6 @@ func queryContextReply(buf []byte) *QueryContextReply { v.Attribs[i] = xgb.Get32(buf[b:]) b += 4 } - b = xgb.Pad(b) return v } @@ -9368,7 +9318,7 @@ func readPixelsReply(buf []byte) *ReadPixelsReply { 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))) + b += int((int(v.Length) * 4)) return v } @@ -9480,7 +9430,7 @@ func renderRequest(c *xgb.Conn, ContextTag ContextTag, Data []byte) []byte { b += 4 copy(buf[b:], Data[:len(Data)]) - b += xgb.Pad(int(len(Data))) + b += int(len(Data)) return buf } @@ -9547,7 +9497,7 @@ func renderLargeRequest(c *xgb.Conn, ContextTag ContextTag, RequestNum uint16, R b += 4 copy(buf[b:], Data[:DataLen]) - b += xgb.Pad(int(DataLen)) + b += int(DataLen) return buf } @@ -9632,7 +9582,6 @@ func renderModeReply(buf []byte) *RenderModeReply { v.Data[i] = xgb.Get32(buf[b:]) b += 4 } - b = xgb.Pad(b) return v } @@ -9788,13 +9737,12 @@ func setClientInfo2ARBRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uin xgb.Put32(buf[b:], GlVersions[i]) b += 4 } - b = xgb.Pad(b) copy(buf[b:], GlExtensionString[:GlStrLen]) - b += xgb.Pad(int(GlStrLen)) + b += int(GlStrLen) copy(buf[b:], GlxExtensionString[:GlxStrLen]) - b += xgb.Pad(int(GlxStrLen)) + b += int(GlxStrLen) return buf } @@ -9867,13 +9815,12 @@ func setClientInfoARBRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint xgb.Put32(buf[b:], GlVersions[i]) b += 4 } - b = xgb.Pad(b) copy(buf[b:], GlExtensionString[:GlStrLen]) - b += xgb.Pad(int(GlStrLen)) + b += int(GlStrLen) copy(buf[b:], GlxExtensionString[:GlxStrLen]) - b += xgb.Pad(int(GlxStrLen)) + b += int(GlxStrLen) return buf } @@ -10059,7 +10006,7 @@ func vendorPrivateRequest(c *xgb.Conn, VendorCode uint32, ContextTag ContextTag, b += 4 copy(buf[b:], Data[:len(Data)]) - b += xgb.Pad(int(len(Data))) + b += int(len(Data)) return buf } @@ -10131,11 +10078,11 @@ func vendorPrivateWithReplyReply(buf []byte) *VendorPrivateWithReplyReply { v.Data1 = make([]byte, 24) copy(v.Data1[:24], buf[b:]) - b += xgb.Pad(int(24)) + b += 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))) + b += int((int(v.Length) * 4)) return v } @@ -10163,7 +10110,7 @@ func vendorPrivateWithReplyRequest(c *xgb.Conn, VendorCode uint32, ContextTag Co b += 4 copy(buf[b:], Data[:len(Data)]) - b += xgb.Pad(int(len(Data))) + b += int(len(Data)) return buf } diff --git a/nexgb/randr/randr.go b/nexgb/randr/randr.go index db45a23..20dc62a 100644 --- a/nexgb/randr/randr.go +++ b/nexgb/randr/randr.go @@ -331,7 +331,7 @@ func (v CrtcChange) Bytes() []byte { xgb.Put16(buf[b:], v.Height) b += 2 - return buf + return buf[:b] } // CrtcChangeListBytes writes a list of CrtcChange values to a byte slice. @@ -489,7 +489,7 @@ func (v ModeInfo) Bytes() []byte { xgb.Put32(buf[b:], v.ModeFlags) b += 4 - return buf + return buf[:b] } // ModeInfoListBytes writes a list of ModeInfo values to a byte slice. @@ -504,6 +504,15 @@ func ModeInfoListBytes(buf []byte, list []ModeInfo) int { return xgb.Pad(b) } +const ( + NotifyCrtcChange = 0 + NotifyOutputChange = 1 + NotifyOutputProperty = 2 + NotifyProviderChange = 3 + NotifyProviderProperty = 4 + NotifyResourceChange = 5 +) + // Notify is the event number for a NotifyEvent. const Notify = 1 @@ -572,15 +581,6 @@ func init() { xgb.NewExtEventFuncs["RANDR"][1] = NotifyEventNew } -const ( - NotifyCrtcChange = 0 - NotifyOutputChange = 1 - NotifyOutputProperty = 2 - NotifyProviderChange = 3 - NotifyProviderProperty = 4 - NotifyResourceChange = 5 -) - // 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). @@ -1034,7 +1034,7 @@ func (v OutputChange) Bytes() []byte { buf[b] = v.SubpixelOrder b += 1 - return buf + return buf[:b] } // OutputChangeListBytes writes a list of OutputChange values to a byte slice. @@ -1114,7 +1114,7 @@ func (v OutputProperty) Bytes() []byte { b += 11 // padding - return buf + return buf[:b] } // OutputPropertyListBytes writes a list of OutputProperty values to a byte slice. @@ -1197,7 +1197,7 @@ func (v ProviderChange) Bytes() []byte { b += 16 // padding - return buf + return buf[:b] } // ProviderChangeListBytes writes a list of ProviderChange values to a byte slice. @@ -1277,7 +1277,7 @@ func (v ProviderProperty) Bytes() []byte { b += 11 // padding - return buf + return buf[:b] } // ProviderPropertyListBytes writes a list of ProviderProperty values to a byte slice. @@ -1309,7 +1309,6 @@ func RefreshRatesRead(buf []byte, v *RefreshRates) int { v.Rates[i] = xgb.Get16(buf[b:]) b += 2 } - b = xgb.Pad(b) return b } @@ -1336,9 +1335,8 @@ func (v RefreshRates) Bytes() []byte { xgb.Put16(buf[b:], v.Rates[i]) b += 2 } - b = xgb.Pad(b) - return buf + return buf[:b] } // RefreshRatesListBytes writes a list of RefreshRates values to a byte slice. @@ -1406,7 +1404,7 @@ func (v ResourceChange) Bytes() []byte { b += 20 // padding - return buf + return buf[:b] } // ResourceChangeListBytes writes a list of ResourceChange values to a byte slice. @@ -1621,7 +1619,7 @@ func (v ScreenSize) Bytes() []byte { xgb.Put16(buf[b:], v.Mheight) b += 2 - return buf + return buf[:b] } // ScreenSizeListBytes writes a list of ScreenSize values to a byte slice. @@ -1802,7 +1800,7 @@ func changeOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Ato b += 4 copy(buf[b:], Data[:((int(NumUnits)*int(Format))/8)]) - b += xgb.Pad(int(((int(NumUnits) * int(Format)) / 8))) + b += int(((int(NumUnits) * int(Format)) / 8)) return buf } @@ -1877,7 +1875,7 @@ func changeProviderPropertyRequest(c *xgb.Conn, Provider Provider, Property xpro b += 4 copy(buf[b:], Data[:(int(NumItems)*(int(Format)/8))]) - b += xgb.Pad(int((int(NumItems) * (int(Format) / 8)))) + b += int((int(NumItems) * (int(Format) / 8))) return buf } @@ -1957,7 +1955,6 @@ func configureOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto. xgb.Put32(buf[b:], uint32(Values[i])) b += 4 } - b = xgb.Pad(b) return buf } @@ -2037,7 +2034,6 @@ func configureProviderPropertyRequest(c *xgb.Conn, Provider Provider, Property x xgb.Put32(buf[b:], uint32(Values[i])) b += 4 } - b = xgb.Pad(b) return buf } @@ -2137,7 +2133,7 @@ func createModeRequest(c *xgb.Conn, Window xproto.Window, ModeInfo ModeInfo, Nam } copy(buf[b:], Name[:len(Name)]) - b += xgb.Pad(int(len(Name))) + b += int(len(Name)) return buf } @@ -2405,9 +2401,11 @@ type GetCrtcGammaReply struct { // padding: 1 bytes Size uint16 // padding: 22 bytes - Red []uint16 // size: xgb.Pad((int(Size) * 2)) + Red []uint16 // size: xgb.Pad((int(Size) * 2)) + // alignment gap to multiple of 2 Green []uint16 // size: xgb.Pad((int(Size) * 2)) - Blue []uint16 // size: xgb.Pad((int(Size) * 2)) + // alignment gap to multiple of 2 + Blue []uint16 // size: xgb.Pad((int(Size) * 2)) } // Reply blocks and returns the reply data for a GetCrtcGamma request. @@ -2445,21 +2443,22 @@ func getCrtcGammaReply(buf []byte) *GetCrtcGammaReply { v.Red[i] = xgb.Get16(buf[b:]) b += 2 } - b = xgb.Pad(b) + + b = (b + 1) & ^1 // alignment gap 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) + + b = (b + 1) & ^1 // alignment gap 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 } @@ -2620,7 +2619,8 @@ type GetCrtcInfoReply struct { NumOutputs uint16 NumPossibleOutputs uint16 Outputs []Output // size: xgb.Pad((int(NumOutputs) * 4)) - Possible []Output // size: xgb.Pad((int(NumPossibleOutputs) * 4)) + // alignment gap to multiple of 4 + Possible []Output // size: xgb.Pad((int(NumPossibleOutputs) * 4)) } // Reply blocks and returns the reply data for a GetCrtcInfo request. @@ -2684,14 +2684,14 @@ func getCrtcInfoReply(buf []byte) *GetCrtcInfoReply { v.Outputs[i] = Output(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) + + b = (b + 3) & ^3 // alignment gap 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 } @@ -2762,10 +2762,12 @@ type GetCrtcTransformReply struct { PendingNparams uint16 CurrentLen uint16 CurrentNparams uint16 - PendingFilterName string // size: xgb.Pad((int(PendingLen) * 1)) + PendingFilterName string // size: xgb.Pad((int(PendingLen) * 1)) + // alignment gap to multiple of 4 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)) + // alignment gap to multiple of 4 + CurrentParams []render.Fixed // size: xgb.Pad((int(CurrentNparams) * 4)) } // Reply blocks and returns the reply data for a GetCrtcTransform request. @@ -2829,12 +2831,13 @@ func getCrtcTransformReply(buf []byte) *GetCrtcTransformReply { b += int(v.PendingLen) } + b = (b + 3) & ^3 // alignment gap + 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) @@ -2843,12 +2846,13 @@ func getCrtcTransformReply(buf []byte) *GetCrtcTransformReply { b += int(v.CurrentLen) } + b = (b + 3) & ^3 // alignment gap + 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 } @@ -2918,10 +2922,12 @@ type GetOutputInfoReply struct { 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)) + Crtcs []Crtc // size: xgb.Pad((int(NumCrtcs) * 4)) + // alignment gap to multiple of 4 + Modes []Mode // size: xgb.Pad((int(NumModes) * 4)) + // alignment gap to multiple of 4 + Clones []Output // size: xgb.Pad((int(NumClones) * 4)) + Name []byte // size: xgb.Pad((int(NameLen) * 1)) } // Reply blocks and returns the reply data for a GetOutputInfo request. @@ -2988,25 +2994,26 @@ func getOutputInfoReply(buf []byte) *GetOutputInfoReply { v.Crtcs[i] = Crtc(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) + + b = (b + 3) & ^3 // alignment gap 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) + + b = (b + 3) & ^3 // alignment gap 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)) + b += int(v.NameLen) return v } @@ -3202,7 +3209,7 @@ func getOutputPropertyReply(buf []byte) *GetOutputPropertyReply { 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)))) + b += int((int(v.NumItems) * (int(v.Format) / 8))) return v } @@ -3433,11 +3440,14 @@ type GetProviderInfoReply struct { NumAssociatedProviders uint16 NameLen uint16 // padding: 8 bytes - Crtcs []Crtc // size: xgb.Pad((int(NumCrtcs) * 4)) - Outputs []Output // size: xgb.Pad((int(NumOutputs) * 4)) - AssociatedProviders []Provider // size: xgb.Pad((int(NumAssociatedProviders) * 4)) - AssociatedCapability []uint32 // size: xgb.Pad((int(NumAssociatedProviders) * 4)) - Name string // size: xgb.Pad((int(NameLen) * 1)) + Crtcs []Crtc // size: xgb.Pad((int(NumCrtcs) * 4)) + // alignment gap to multiple of 4 + Outputs []Output // size: xgb.Pad((int(NumOutputs) * 4)) + // alignment gap to multiple of 4 + AssociatedProviders []Provider // size: xgb.Pad((int(NumAssociatedProviders) * 4)) + // alignment gap to multiple of 4 + AssociatedCapability []uint32 // size: xgb.Pad((int(NumAssociatedProviders) * 4)) + Name string // size: xgb.Pad((int(NameLen) * 1)) } // Reply blocks and returns the reply data for a GetProviderInfo request. @@ -3491,28 +3501,30 @@ func getProviderInfoReply(buf []byte) *GetProviderInfoReply { v.Crtcs[i] = Crtc(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) + + b = (b + 3) & ^3 // alignment gap 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) + + b = (b + 3) & ^3 // alignment gap v.AssociatedProviders = make([]Provider, v.NumAssociatedProviders) for i := 0; i < int(v.NumAssociatedProviders); i++ { v.AssociatedProviders[i] = Provider(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) + + b = (b + 3) & ^3 // alignment gap v.AssociatedCapability = make([]uint32, v.NumAssociatedProviders) for i := 0; i < int(v.NumAssociatedProviders); i++ { v.AssociatedCapability[i] = xgb.Get32(buf[b:]) b += 4 } - b = xgb.Pad(b) { byteString := make([]byte, v.NameLen) @@ -3627,7 +3639,7 @@ func getProviderPropertyReply(buf []byte) *GetProviderPropertyReply { 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)))) + b += int((int(v.NumItems) * (int(v.Format) / 8))) return v } @@ -3758,7 +3770,6 @@ func getProvidersReply(buf []byte) *GetProvidersReply { v.Providers[i] = Provider(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) return v } @@ -3826,7 +3837,8 @@ type GetScreenInfoReply struct { Rate uint16 NInfo uint16 // padding: 2 bytes - Sizes []ScreenSize // size: xgb.Pad((int(NSizes) * 8)) + Sizes []ScreenSize // size: xgb.Pad((int(NSizes) * 8)) + // alignment gap to multiple of 2 Rates []RefreshRates // size: RefreshRatesListSize(Rates) } @@ -3885,6 +3897,8 @@ func getScreenInfoReply(buf []byte) *GetScreenInfoReply { v.Sizes = make([]ScreenSize, v.NSizes) b += ScreenSizeReadList(buf[b:], v.Sizes) + b = (b + 1) & ^1 // alignment gap + v.Rates = make([]RefreshRates, (int(v.NInfo) - int(v.NSizes))) b += RefreshRatesReadList(buf[b:], v.Rates) @@ -3952,10 +3966,12 @@ type GetScreenResourcesReply struct { 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)) + Crtcs []Crtc // size: xgb.Pad((int(NumCrtcs) * 4)) + // alignment gap to multiple of 4 + Outputs []Output // size: xgb.Pad((int(NumOutputs) * 4)) + // alignment gap to multiple of 4 + Modes []ModeInfo // size: xgb.Pad((int(NumModes) * 32)) + Names []byte // size: xgb.Pad((int(NamesLen) * 1)) } // Reply blocks and returns the reply data for a GetScreenResources request. @@ -4008,21 +4024,23 @@ func getScreenResourcesReply(buf []byte) *GetScreenResourcesReply { v.Crtcs[i] = Crtc(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) + + b = (b + 3) & ^3 // alignment gap 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) + + b = (b + 3) & ^3 // alignment gap 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)) + b += int(v.NamesLen) return v } @@ -4088,10 +4106,12 @@ type GetScreenResourcesCurrentReply struct { 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)) + Crtcs []Crtc // size: xgb.Pad((int(NumCrtcs) * 4)) + // alignment gap to multiple of 4 + Outputs []Output // size: xgb.Pad((int(NumOutputs) * 4)) + // alignment gap to multiple of 4 + Modes []ModeInfo // size: xgb.Pad((int(NumModes) * 32)) + Names []byte // size: xgb.Pad((int(NamesLen) * 1)) } // Reply blocks and returns the reply data for a GetScreenResourcesCurrent request. @@ -4144,21 +4164,23 @@ func getScreenResourcesCurrentReply(buf []byte) *GetScreenResourcesCurrentReply v.Crtcs[i] = Crtc(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) + + b = (b + 3) & ^3 // alignment gap 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) + + b = (b + 3) & ^3 // alignment gap 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)) + b += int(v.NamesLen) return v } @@ -4360,7 +4382,6 @@ func listOutputPropertiesReply(buf []byte) *ListOutputPropertiesReply { v.Atoms[i] = xproto.Atom(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) return v } @@ -4459,7 +4480,6 @@ func listProviderPropertiesReply(buf []byte) *ListProviderPropertiesReply { v.Atoms[i] = xproto.Atom(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) return v } @@ -4578,7 +4598,6 @@ func queryOutputPropertyReply(buf []byte) *QueryOutputPropertyReply { v.ValidValues[i] = int32(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) return v } @@ -4700,7 +4719,6 @@ func queryProviderPropertyReply(buf []byte) *QueryProviderPropertyReply { v.ValidValues[i] = int32(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) return v } @@ -5001,7 +5019,6 @@ func setCrtcConfigRequest(c *xgb.Conn, Crtc Crtc, Timestamp xproto.Timestamp, Co xgb.Put32(buf[b:], uint32(Outputs[i])) b += 4 } - b = xgb.Pad(b) return buf } @@ -5042,7 +5059,7 @@ func (cook SetCrtcGammaCookie) Check() error { // 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)))) + size := xgb.Pad((((((12 + xgb.Pad((int(Size) * 2))) + 2) + xgb.Pad((int(Size) * 2))) + 2) + xgb.Pad((int(Size) * 2)))) b := 0 buf := make([]byte, size) @@ -5052,7 +5069,7 @@ func setCrtcGammaRequest(c *xgb.Conn, Crtc Crtc, Size uint16, Red []uint16, Gree buf[b] = 24 // request opcode b += 1 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + blen := b b += 2 xgb.Put32(buf[b:], uint32(Crtc)) @@ -5067,21 +5084,24 @@ func setCrtcGammaRequest(c *xgb.Conn, Crtc Crtc, Size uint16, Red []uint16, Gree xgb.Put16(buf[b:], Red[i]) b += 2 } - b = xgb.Pad(b) + + b = (b + 1) & ^1 // alignment gap for i := 0; i < int(Size); i++ { xgb.Put16(buf[b:], Green[i]) b += 2 } - b = xgb.Pad(b) + + b = (b + 1) & ^1 // alignment gap for i := 0; i < int(Size); i++ { xgb.Put16(buf[b:], Blue[i]) b += 2 } - b = xgb.Pad(b) - return buf + b = xgb.Pad(b) + xgb.Put16(buf[blen:], uint16(b/4)) // write request size in 4-byte units + return buf[:b] } // SetCrtcTransformCookie is a cookie used only for SetCrtcTransform requests. @@ -5120,7 +5140,7 @@ func (cook SetCrtcTransformCookie) Check() error { // 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)))) + size := xgb.Pad((((48 + xgb.Pad((int(FilterLen) * 1))) + 4) + xgb.Pad((len(FilterParams) * 4)))) b := 0 buf := make([]byte, size) @@ -5130,7 +5150,7 @@ func setCrtcTransformRequest(c *xgb.Conn, Crtc Crtc, Transform render.Transform, buf[b] = 26 // request opcode b += 1 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + blen := b b += 2 xgb.Put32(buf[b:], uint32(Crtc)) @@ -5148,15 +5168,18 @@ func setCrtcTransformRequest(c *xgb.Conn, Crtc Crtc, Transform render.Transform, b += 2 // padding copy(buf[b:], FilterName[:FilterLen]) - b += xgb.Pad(int(FilterLen)) + b += int(FilterLen) + + b = (b + 3) & ^3 // alignment gap for i := 0; i < int(len(FilterParams)); i++ { xgb.Put32(buf[b:], uint32(FilterParams[i])) b += 4 } - b = xgb.Pad(b) - return buf + b = xgb.Pad(b) + xgb.Put16(buf[blen:], uint16(b/4)) // write request size in 4-byte units + return buf[:b] } // SetOutputPrimaryCookie is a cookie used only for SetOutputPrimary requests. diff --git a/nexgb/record/record.go b/nexgb/record/record.go index 3777422..30be090 100644 --- a/nexgb/record/record.go +++ b/nexgb/record/record.go @@ -133,7 +133,7 @@ func (v ClientInfo) Bytes() []byte { b += RangeListBytes(buf[b:], v.Ranges) - return buf + return buf[:b] } // ClientInfoListBytes writes a list of ClientInfo values to a byte slice. @@ -222,7 +222,7 @@ func (v ExtRange) Bytes() []byte { b += len(structBytes) } - return buf + return buf[:b] } // ExtRangeListBytes writes a list of ExtRange values to a byte slice. @@ -368,7 +368,7 @@ func (v Range) Bytes() []byte { } b += 1 - return buf + return buf[:b] } // RangeListBytes writes a list of Range values to a byte slice. @@ -422,7 +422,7 @@ func (v Range16) Bytes() []byte { xgb.Put16(buf[b:], v.Last) b += 2 - return buf + return buf[:b] } // Range16ListBytes writes a list of Range16 values to a byte slice. @@ -476,7 +476,7 @@ func (v Range8) Bytes() []byte { buf[b] = v.Last b += 1 - return buf + return buf[:b] } // Range8ListBytes writes a list of Range8 values to a byte slice. @@ -551,7 +551,7 @@ func (cook CreateContextCookie) Check() error { // 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)))) + size := xgb.Pad((((20 + xgb.Pad((int(NumClientSpecs) * 4))) + 4) + xgb.Pad((int(NumRanges) * 24)))) b := 0 buf := make([]byte, size) @@ -561,7 +561,7 @@ func createContextRequest(c *xgb.Conn, Context Context, ElementHeader ElementHea buf[b] = 1 // request opcode b += 1 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + blen := b b += 2 xgb.Put32(buf[b:], uint32(Context)) @@ -582,11 +582,14 @@ func createContextRequest(c *xgb.Conn, Context Context, ElementHeader ElementHea xgb.Put32(buf[b:], uint32(ClientSpecs[i])) b += 4 } - b = xgb.Pad(b) + + b = (b + 3) & ^3 // alignment gap b += RangeListBytes(buf[b:], Ranges) - return buf + b = xgb.Pad(b) + xgb.Put16(buf[blen:], uint16(b/4)) // write request size in 4-byte units + return buf[:b] } // DisableContextCookie is a cookie used only for DisableContext requests. @@ -737,7 +740,7 @@ func enableContextReply(buf []byte) *EnableContextReply { 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))) + b += int((int(v.Length) * 4)) return v } @@ -1057,7 +1060,7 @@ func (cook RegisterClientsCookie) Check() error { // 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)))) + size := xgb.Pad((((20 + xgb.Pad((int(NumClientSpecs) * 4))) + 4) + xgb.Pad((int(NumRanges) * 24)))) b := 0 buf := make([]byte, size) @@ -1067,7 +1070,7 @@ func registerClientsRequest(c *xgb.Conn, Context Context, ElementHeader ElementH buf[b] = 2 // request opcode b += 1 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + blen := b b += 2 xgb.Put32(buf[b:], uint32(Context)) @@ -1088,11 +1091,14 @@ func registerClientsRequest(c *xgb.Conn, Context Context, ElementHeader ElementH xgb.Put32(buf[b:], uint32(ClientSpecs[i])) b += 4 } - b = xgb.Pad(b) + + b = (b + 3) & ^3 // alignment gap b += RangeListBytes(buf[b:], Ranges) - return buf + b = xgb.Pad(b) + xgb.Put16(buf[blen:], uint16(b/4)) // write request size in 4-byte units + return buf[:b] } // UnregisterClientsCookie is a cookie used only for UnregisterClients requests. @@ -1154,7 +1160,6 @@ func unregisterClientsRequest(c *xgb.Conn, Context Context, NumClientSpecs uint3 xgb.Put32(buf[b:], uint32(ClientSpecs[i])) b += 4 } - b = xgb.Pad(b) return buf } diff --git a/nexgb/render/render.go b/nexgb/render/render.go index 80f4be7..f90065b 100644 --- a/nexgb/render/render.go +++ b/nexgb/render/render.go @@ -76,7 +76,7 @@ func (v Animcursorelt) Bytes() []byte { xgb.Put32(buf[b:], v.Delay) b += 4 - return buf + return buf[:b] } // AnimcursoreltListBytes writes a list of Animcursorelt values to a byte slice. @@ -144,7 +144,7 @@ func (v Color) Bytes() []byte { xgb.Put16(buf[b:], v.Alpha) b += 2 - return buf + return buf[:b] } // ColorListBytes writes a list of Color values to a byte slice. @@ -256,7 +256,7 @@ func (v Directformat) Bytes() []byte { xgb.Put16(buf[b:], v.AlphaMask) b += 2 - return buf + return buf[:b] } // DirectformatListBytes writes a list of Directformat values to a byte slice. @@ -434,7 +434,7 @@ func (v Glyphinfo) Bytes() []byte { xgb.Put16(buf[b:], uint16(v.YOff)) b += 2 - return buf + return buf[:b] } // GlyphinfoListBytes writes a list of Glyphinfo values to a byte slice. @@ -519,7 +519,7 @@ func (v Indexvalue) Bytes() []byte { xgb.Put16(buf[b:], v.Alpha) b += 2 - return buf + return buf[:b] } // IndexvalueListBytes writes a list of Indexvalue values to a byte slice. @@ -579,7 +579,7 @@ func (v Linefix) Bytes() []byte { b += len(structBytes) } - return buf + return buf[:b] } // LinefixListBytes writes a list of Linefix values to a byte slice. @@ -802,7 +802,7 @@ func (v Pictdepth) Bytes() []byte { b += PictvisualListBytes(buf[b:], v.Visuals) - return buf + return buf[:b] } // PictdepthListBytes writes a list of Pictdepth values to a byte slice. @@ -904,7 +904,7 @@ func (v Pictforminfo) Bytes() []byte { xgb.Put32(buf[b:], uint32(v.Colormap)) b += 4 - return buf + return buf[:b] } // PictforminfoListBytes writes a list of Pictforminfo values to a byte slice. @@ -964,7 +964,7 @@ func (v Pictscreen) Bytes() []byte { b += PictdepthListBytes(buf[b:], v.Depths) - return buf + return buf[:b] } // PictscreenListBytes writes a list of Pictscreen values to a byte slice. @@ -1087,7 +1087,7 @@ func (v Pictvisual) Bytes() []byte { xgb.Put32(buf[b:], uint32(v.Format)) b += 4 - return buf + return buf[:b] } // PictvisualListBytes writes a list of Pictvisual values to a byte slice. @@ -1141,7 +1141,7 @@ func (v Pointfix) Bytes() []byte { xgb.Put32(buf[b:], uint32(v.Y)) b += 4 - return buf + return buf[:b] } // PointfixListBytes writes a list of Pointfix values to a byte slice. @@ -1219,7 +1219,7 @@ func (v Spanfix) Bytes() []byte { xgb.Put32(buf[b:], uint32(v.Y)) b += 4 - return buf + return buf[:b] } // SpanfixListBytes writes a list of Spanfix values to a byte slice. @@ -1331,7 +1331,7 @@ func (v Transform) Bytes() []byte { xgb.Put32(buf[b:], uint32(v.Matrix33)) b += 4 - return buf + return buf[:b] } // TransformListBytes writes a list of Transform values to a byte slice. @@ -1391,7 +1391,7 @@ func (v Trap) Bytes() []byte { b += len(structBytes) } - return buf + return buf[:b] } // TrapListBytes writes a list of Trap values to a byte slice. @@ -1465,7 +1465,7 @@ func (v Trapezoid) Bytes() []byte { b += len(structBytes) } - return buf + return buf[:b] } // TrapezoidListBytes writes a list of Trapezoid values to a byte slice. @@ -1535,7 +1535,7 @@ func (v Triangle) Bytes() []byte { b += len(structBytes) } - return buf + return buf[:b] } // TriangleListBytes writes a list of Triangle values to a byte slice. @@ -1610,7 +1610,7 @@ func (cook AddGlyphsCookie) Check() error { // 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)))) + size := xgb.Pad(((((12 + xgb.Pad((int(GlyphsLen) * 4))) + 4) + xgb.Pad((int(GlyphsLen) * 12))) + xgb.Pad((len(Data) * 1)))) b := 0 buf := make([]byte, size) @@ -1620,7 +1620,7 @@ func addGlyphsRequest(c *xgb.Conn, Glyphset Glyphset, GlyphsLen uint32, Glyphids buf[b] = 20 // request opcode b += 1 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + blen := b b += 2 xgb.Put32(buf[b:], uint32(Glyphset)) @@ -1633,14 +1633,17 @@ func addGlyphsRequest(c *xgb.Conn, Glyphset Glyphset, GlyphsLen uint32, Glyphids xgb.Put32(buf[b:], Glyphids[i]) b += 4 } - b = xgb.Pad(b) + + b = (b + 3) & ^3 // alignment gap b += GlyphinfoListBytes(buf[b:], Glyphs) copy(buf[b:], Data[:len(Data)]) - b += xgb.Pad(int(len(Data))) + b += int(len(Data)) - return buf + b = xgb.Pad(b) + xgb.Put16(buf[blen:], uint16(b/4)) // write request size in 4-byte units + return buf[:b] } // AddTrapsCookie is a cookie used only for AddTraps requests. @@ -1932,7 +1935,7 @@ func compositeGlyphs16Request(c *xgb.Conn, Op byte, Src Picture, Dst Picture, Ma b += 2 copy(buf[b:], Glyphcmds[:len(Glyphcmds)]) - b += xgb.Pad(int(len(Glyphcmds))) + b += int(len(Glyphcmds)) return buf } @@ -2010,7 +2013,7 @@ func compositeGlyphs32Request(c *xgb.Conn, Op byte, Src Picture, Dst Picture, Ma b += 2 copy(buf[b:], Glyphcmds[:len(Glyphcmds)]) - b += xgb.Pad(int(len(Glyphcmds))) + b += int(len(Glyphcmds)) return buf } @@ -2088,7 +2091,7 @@ func compositeGlyphs8Request(c *xgb.Conn, Op byte, Src Picture, Dst Picture, Mas b += 2 copy(buf[b:], Glyphcmds[:len(Glyphcmds)]) - b += xgb.Pad(int(len(Glyphcmds))) + b += int(len(Glyphcmds)) return buf } @@ -2186,7 +2189,7 @@ func (cook CreateConicalGradientCookie) Check() error { // 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)))) + size := xgb.Pad((((24 + xgb.Pad((int(NumStops) * 4))) + 4) + xgb.Pad((int(NumStops) * 8)))) b := 0 buf := make([]byte, size) @@ -2196,7 +2199,7 @@ func createConicalGradientRequest(c *xgb.Conn, Picture Picture, Center Pointfix, buf[b] = 36 // request opcode b += 1 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + blen := b b += 2 xgb.Put32(buf[b:], uint32(Picture)) @@ -2218,11 +2221,14 @@ func createConicalGradientRequest(c *xgb.Conn, Picture Picture, Center Pointfix, xgb.Put32(buf[b:], uint32(Stops[i])) b += 4 } - b = xgb.Pad(b) + + b = (b + 3) & ^3 // alignment gap b += ColorListBytes(buf[b:], Colors) - return buf + b = xgb.Pad(b) + xgb.Put16(buf[blen:], uint16(b/4)) // write request size in 4-byte units + return buf[:b] } // CreateCursorCookie is a cookie used only for CreateCursor requests. @@ -2383,7 +2389,7 @@ func (cook CreateLinearGradientCookie) Check() error { // 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)))) + size := xgb.Pad((((28 + xgb.Pad((int(NumStops) * 4))) + 4) + xgb.Pad((int(NumStops) * 8)))) b := 0 buf := make([]byte, size) @@ -2393,7 +2399,7 @@ func createLinearGradientRequest(c *xgb.Conn, Picture Picture, P1 Pointfix, P2 P buf[b] = 34 // request opcode b += 1 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + blen := b b += 2 xgb.Put32(buf[b:], uint32(Picture)) @@ -2418,11 +2424,14 @@ func createLinearGradientRequest(c *xgb.Conn, Picture Picture, P1 Pointfix, P2 P xgb.Put32(buf[b:], uint32(Stops[i])) b += 4 } - b = xgb.Pad(b) + + b = (b + 3) & ^3 // alignment gap b += ColorListBytes(buf[b:], Colors) - return buf + b = xgb.Pad(b) + xgb.Put16(buf[blen:], uint16(b/4)) // write request size in 4-byte units + return buf[:b] } // CreatePictureCookie is a cookie used only for CreatePicture requests. @@ -2530,7 +2539,7 @@ func (cook CreateRadialGradientCookie) Check() error { // 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)))) + size := xgb.Pad((((36 + xgb.Pad((int(NumStops) * 4))) + 4) + xgb.Pad((int(NumStops) * 8)))) b := 0 buf := make([]byte, size) @@ -2540,7 +2549,7 @@ func createRadialGradientRequest(c *xgb.Conn, Picture Picture, Inner Pointfix, O buf[b] = 35 // request opcode b += 1 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + blen := b b += 2 xgb.Put32(buf[b:], uint32(Picture)) @@ -2571,11 +2580,14 @@ func createRadialGradientRequest(c *xgb.Conn, Picture Picture, Inner Pointfix, O xgb.Put32(buf[b:], uint32(Stops[i])) b += 4 } - b = xgb.Pad(b) + + b = (b + 3) & ^3 // alignment gap b += ColorListBytes(buf[b:], Colors) - return buf + b = xgb.Pad(b) + xgb.Put16(buf[blen:], uint16(b/4)) // write request size in 4-byte units + return buf[:b] } // CreateSolidFillCookie is a cookie used only for CreateSolidFill requests. @@ -2818,7 +2830,6 @@ func freeGlyphsRequest(c *xgb.Conn, Glyphset Glyphset, Glyphs []Glyph) []byte { xgb.Put32(buf[b:], uint32(Glyphs[i])) b += 4 } - b = xgb.Pad(b) return buf } @@ -2955,7 +2966,6 @@ func queryFiltersReply(buf []byte) *QueryFiltersReply { 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) @@ -3023,9 +3033,11 @@ type QueryPictFormatsReply struct { 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)) + Formats []Pictforminfo // size: xgb.Pad((int(NumFormats) * 28)) + // alignment gap to multiple of 4 + Screens []Pictscreen // size: PictscreenListSize(Screens) + // alignment gap to multiple of 4 + Subpixels []uint32 // size: xgb.Pad((int(NumSubpixel) * 4)) } // Reply blocks and returns the reply data for a QueryPictFormats request. @@ -3073,15 +3085,18 @@ func queryPictFormatsReply(buf []byte) *QueryPictFormatsReply { v.Formats = make([]Pictforminfo, v.NumFormats) b += PictforminfoReadList(buf[b:], v.Formats) + b = (b + 3) & ^3 // alignment gap + v.Screens = make([]Pictscreen, v.NumScreens) b += PictscreenReadList(buf[b:], v.Screens) + b = (b + 3) & ^3 // alignment gap + 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 } @@ -3455,7 +3470,7 @@ func (cook SetPictureFilterCookie) Check() error { // 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)))) + size := xgb.Pad((((12 + xgb.Pad((int(FilterLen) * 1))) + 4) + xgb.Pad((len(Values) * 4)))) b := 0 buf := make([]byte, size) @@ -3465,7 +3480,7 @@ func setPictureFilterRequest(c *xgb.Conn, Picture Picture, FilterLen uint16, Fil buf[b] = 30 // request opcode b += 1 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + blen := b b += 2 xgb.Put32(buf[b:], uint32(Picture)) @@ -3477,15 +3492,18 @@ func setPictureFilterRequest(c *xgb.Conn, Picture Picture, FilterLen uint16, Fil b += 2 // padding copy(buf[b:], Filter[:FilterLen]) - b += xgb.Pad(int(FilterLen)) + b += int(FilterLen) + + b = (b + 3) & ^3 // alignment gap for i := 0; i < int(len(Values)); i++ { xgb.Put32(buf[b:], uint32(Values[i])) b += 4 } - b = xgb.Pad(b) - return buf + b = xgb.Pad(b) + xgb.Put16(buf[blen:], uint16(b/4)) // write request size in 4-byte units + return buf[:b] } // SetPictureTransformCookie is a cookie used only for SetPictureTransform requests. diff --git a/nexgb/res/res.go b/nexgb/res/res.go index 8311f95..dd53857 100644 --- a/nexgb/res/res.go +++ b/nexgb/res/res.go @@ -76,7 +76,7 @@ func (v Client) Bytes() []byte { xgb.Put32(buf[b:], v.ResourceMask) b += 4 - return buf + return buf[:b] } // ClientListBytes writes a list of Client values to a byte slice. @@ -135,7 +135,7 @@ func (v ClientIdSpec) Bytes() []byte { xgb.Put32(buf[b:], v.Mask) b += 4 - return buf + return buf[:b] } // ClientIdSpecListBytes writes a list of ClientIdSpec values to a byte slice. @@ -171,7 +171,6 @@ func ClientIdValueRead(buf []byte, v *ClientIdValue) int { v.Value[i] = xgb.Get32(buf[b:]) b += 4 } - b = xgb.Pad(b) return b } @@ -204,9 +203,8 @@ func (v ClientIdValue) Bytes() []byte { xgb.Put32(buf[b:], v.Value[i]) b += 4 } - b = xgb.Pad(b) - return buf + return buf[:b] } // ClientIdValueListBytes writes a list of ClientIdValue values to a byte slice. @@ -269,7 +267,7 @@ func (v ResourceIdSpec) Bytes() []byte { xgb.Put32(buf[b:], v.Type) b += 4 - return buf + return buf[:b] } // ResourceIdSpecListBytes writes a list of ResourceIdSpec values to a byte slice. @@ -340,7 +338,7 @@ func (v ResourceSizeSpec) Bytes() []byte { xgb.Put32(buf[b:], v.UseCount) b += 4 - return buf + return buf[:b] } // ResourceSizeSpecListBytes writes a list of ResourceSizeSpec values to a byte slice. @@ -403,7 +401,7 @@ func (v ResourceSizeValue) Bytes() []byte { b += ResourceSizeSpecListBytes(buf[b:], v.CrossReferences) - return buf + return buf[:b] } // ResourceSizeValueListBytes writes a list of ResourceSizeValue values to a byte slice. @@ -466,7 +464,7 @@ func (v Type) Bytes() []byte { xgb.Put32(buf[b:], v.Count) b += 4 - return buf + return buf[:b] } // TypeListBytes writes a list of Type values to a byte slice. diff --git a/nexgb/xcmisc/xcmisc.go b/nexgb/xcmisc/xcmisc.go index 5cff5f1..2240ee1 100644 --- a/nexgb/xcmisc/xcmisc.go +++ b/nexgb/xcmisc/xcmisc.go @@ -228,7 +228,6 @@ func getXIDListReply(buf []byte) *GetXIDListReply { v.Ids[i] = xgb.Get32(buf[b:]) b += 4 } - b = xgb.Pad(b) return v } diff --git a/nexgb/xevie/xevie.go b/nexgb/xevie/xevie.go index f77d405..7e18f8d 100644 --- a/nexgb/xevie/xevie.go +++ b/nexgb/xevie/xevie.go @@ -72,7 +72,7 @@ func (v Event) Bytes() []byte { b += 32 // padding - return buf + return buf[:b] } // EventListBytes writes a list of Event values to a byte slice. diff --git a/nexgb/xf86dri/xf86dri.go b/nexgb/xf86dri/xf86dri.go index d88cc5d..6a07e41 100644 --- a/nexgb/xf86dri/xf86dri.go +++ b/nexgb/xf86dri/xf86dri.go @@ -90,7 +90,7 @@ func (v DrmClipRect) Bytes() []byte { xgb.Put16(buf[b:], uint16(v.X3)) b += 2 - return buf + return buf[:b] } // DrmClipRectListBytes writes a list of DrmClipRect values to a byte slice. @@ -776,7 +776,6 @@ func getDeviceInfoReply(buf []byte) *GetDeviceInfoReply { v.DevicePrivate[i] = xgb.Get32(buf[b:]) b += 4 } - b = xgb.Pad(b) return v } @@ -846,7 +845,8 @@ type GetDrawableInfoReply struct { BackY int16 NumBackClipRects uint32 ClipRects []DrmClipRect // size: xgb.Pad((int(NumClipRects) * 8)) - BackClipRects []DrmClipRect // size: xgb.Pad((int(NumBackClipRects) * 8)) + // alignment gap to multiple of 4 + BackClipRects []DrmClipRect // size: xgb.Pad((int(NumBackClipRects) * 8)) } // Reply blocks and returns the reply data for a GetDrawableInfo request. @@ -907,6 +907,8 @@ func getDrawableInfoReply(buf []byte) *GetDrawableInfoReply { v.ClipRects = make([]DrmClipRect, v.NumClipRects) b += DrmClipRectReadList(buf[b:], v.ClipRects) + b = (b + 3) & ^3 // alignment gap + v.BackClipRects = make([]DrmClipRect, v.NumBackClipRects) b += DrmClipRectReadList(buf[b:], v.BackClipRects) diff --git a/nexgb/xf86vidmode/xf86vidmode.go b/nexgb/xf86vidmode/xf86vidmode.go index 8abb44e..5b0f1f8 100644 --- a/nexgb/xf86vidmode/xf86vidmode.go +++ b/nexgb/xf86vidmode/xf86vidmode.go @@ -408,7 +408,7 @@ func (v ModeInfo) Bytes() []byte { xgb.Put32(buf[b:], v.Privsize) b += 4 - return buf + return buf[:b] } // ModeInfoListBytes writes a list of ModeInfo values to a byte slice. @@ -676,7 +676,7 @@ func addModeLineRequest(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay b += 12 // padding copy(buf[b:], Private[:Privsize]) - b += xgb.Pad(int(Privsize)) + b += int(Privsize) return buf } @@ -774,7 +774,7 @@ func deleteModeLineRequest(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdispl b += 4 copy(buf[b:], Private[:Privsize]) - b += xgb.Pad(int(Privsize)) + b += int(Privsize) return buf } @@ -956,7 +956,6 @@ func getDotClocksReply(buf []byte) *GetDotClocksReply { v.Clock[i] = xgb.Get32(buf[b:]) b += 4 } - b = xgb.Pad(b) return v } @@ -1120,9 +1119,11 @@ type GetGammaRampReply struct { // padding: 1 bytes Size uint16 // padding: 22 bytes - Red []uint16 // size: xgb.Pad((((int(Size) + 1) & -2) * 2)) + Red []uint16 // size: xgb.Pad((((int(Size) + 1) & -2) * 2)) + // alignment gap to multiple of 2 Green []uint16 // size: xgb.Pad((((int(Size) + 1) & -2) * 2)) - Blue []uint16 // size: xgb.Pad((((int(Size) + 1) & -2) * 2)) + // alignment gap to multiple of 2 + Blue []uint16 // size: xgb.Pad((((int(Size) + 1) & -2) * 2)) } // Reply blocks and returns the reply data for a GetGammaRamp request. @@ -1160,21 +1161,22 @@ func getGammaRampReply(buf []byte) *GetGammaRampReply { v.Red[i] = xgb.Get16(buf[b:]) b += 2 } - b = xgb.Pad(b) + + b = (b + 1) & ^1 // alignment gap 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) + + b = (b + 1) & ^1 // alignment gap 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 } @@ -1413,7 +1415,7 @@ func getModeLineReply(buf []byte) *GetModeLineReply { v.Private = make([]byte, v.Privsize) copy(v.Private[:v.Privsize], buf[b:]) - b += xgb.Pad(int(v.Privsize)) + b += int(v.Privsize) return v } @@ -1479,7 +1481,8 @@ type GetMonitorReply struct { NumHsync byte NumVsync byte // padding: 20 bytes - Hsync []Syncrange // size: xgb.Pad((int(NumHsync) * 4)) + Hsync []Syncrange // size: xgb.Pad((int(NumHsync) * 4)) + // alignment gap to multiple of 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)) @@ -1530,14 +1533,14 @@ func getMonitorReply(buf []byte) *GetMonitorReply { v.Hsync[i] = Syncrange(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) + + b = (b + 3) & ^3 // alignment gap 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) @@ -1548,7 +1551,7 @@ func getMonitorReply(buf []byte) *GetMonitorReply { 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)))) + b += int((((int(v.VendorLength) + 3) & -4) - int(v.VendorLength))) { byteString := make([]byte, v.ModelLength) @@ -1922,7 +1925,7 @@ func modModeLineRequest(c *xgb.Conn, Screen uint32, Hdisplay uint16, Hsyncstart b += 4 copy(buf[b:], Private[:Privsize]) - b += xgb.Pad(int(Privsize)) + b += int(Privsize) return buf } @@ -2178,7 +2181,7 @@ func (cook SetGammaRampCookie) Check() error { // 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)))) + size := xgb.Pad((((((8 + xgb.Pad((((int(Size) + 1) & -2) * 2))) + 2) + xgb.Pad((((int(Size) + 1) & -2) * 2))) + 2) + xgb.Pad((((int(Size) + 1) & -2) * 2)))) b := 0 buf := make([]byte, size) @@ -2188,7 +2191,7 @@ func setGammaRampRequest(c *xgb.Conn, Screen uint16, Size uint16, Red []uint16, buf[b] = 18 // request opcode b += 1 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + blen := b b += 2 xgb.Put16(buf[b:], Screen) @@ -2201,21 +2204,24 @@ func setGammaRampRequest(c *xgb.Conn, Screen uint16, Size uint16, Red []uint16, xgb.Put16(buf[b:], Red[i]) b += 2 } - b = xgb.Pad(b) + + b = (b + 1) & ^1 // alignment gap for i := 0; i < int(((int(Size) + 1) & -2)); i++ { xgb.Put16(buf[b:], Green[i]) b += 2 } - b = xgb.Pad(b) + + b = (b + 1) & ^1 // alignment gap for i := 0; i < int(((int(Size) + 1) & -2)); i++ { xgb.Put16(buf[b:], Blue[i]) b += 2 } - b = xgb.Pad(b) - return buf + b = xgb.Pad(b) + xgb.Put16(buf[blen:], uint16(b/4)) // write request size in 4-byte units + return buf[:b] } // SetViewPortCookie is a cookie used only for SetViewPort requests. @@ -2432,7 +2438,7 @@ func switchToModeRequest(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdisplay b += 4 copy(buf[b:], Private[:Privsize]) - b += xgb.Pad(int(Privsize)) + b += int(Privsize) return buf } @@ -2566,7 +2572,7 @@ func validateModeLineRequest(c *xgb.Conn, Screen uint32, Dotclock Dotclock, Hdis b += 4 copy(buf[b:], Private[:Privsize]) - b += xgb.Pad(int(Privsize)) + b += int(Privsize) return buf } diff --git a/nexgb/xfixes/xfixes.go b/nexgb/xfixes/xfixes.go index 9a08c93..ef08c9a 100644 --- a/nexgb/xfixes/xfixes.go +++ b/nexgb/xfixes/xfixes.go @@ -489,7 +489,7 @@ func changeCursorByNameRequest(c *xgb.Conn, Src xproto.Cursor, Nbytes uint16, Na b += 2 // padding copy(buf[b:], Name[:Nbytes]) - b += xgb.Pad(int(Nbytes)) + b += int(Nbytes) return buf } @@ -697,7 +697,6 @@ func createPointerBarrierRequest(c *xgb.Conn, Barrier Barrier, Window xproto.Win xgb.Put16(buf[b:], Devices[i]) b += 2 } - b = xgb.Pad(b) return buf } @@ -1367,7 +1366,6 @@ func getCursorImageReply(buf []byte) *GetCursorImageReply { v.CursorImage[i] = xgb.Get32(buf[b:]) b += 4 } - b = xgb.Pad(b) return v } @@ -1433,7 +1431,8 @@ type GetCursorImageAndNameReply struct { CursorAtom xproto.Atom Nbytes uint16 // padding: 2 bytes - Name string // size: xgb.Pad((int(Nbytes) * 1)) + Name string // size: xgb.Pad((int(Nbytes) * 1)) + // alignment gap to multiple of 4 CursorImage []uint32 // size: xgb.Pad(((int(Width) * int(Height)) * 4)) } @@ -1498,12 +1497,13 @@ func getCursorImageAndNameReply(buf []byte) *GetCursorImageAndNameReply { b += int(v.Nbytes) } + b = (b + 3) & ^3 // alignment gap + 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 } @@ -2143,7 +2143,7 @@ func setCursorNameRequest(c *xgb.Conn, Cursor xproto.Cursor, Nbytes uint16, Name b += 2 // padding copy(buf[b:], Name[:Nbytes]) - b += xgb.Pad(int(Nbytes)) + b += int(Nbytes) return buf } diff --git a/nexgb/xgbgen/aligngap.go b/nexgb/xgbgen/aligngap.go new file mode 100644 index 0000000..1e07e18 --- /dev/null +++ b/nexgb/xgbgen/aligngap.go @@ -0,0 +1,130 @@ +package main + +import ( + "fmt" + "os" +) + +func (p *Protocol) AddAlignGaps() { + for i := range p.Imports { + p.Imports[i].AddAlignGaps() + } + for i := range p.Types { + switch t := p.Types[i].(type) { + case *Struct: + t.Fields = addAlignGapsToFields(t.xmlName, t.Fields) + case *Event: + t.Fields = addAlignGapsToFields(t.xmlName, t.Fields) + case *Error: + t.Fields = addAlignGapsToFields(t.xmlName, t.Fields) + } + } + for i := range p.Requests { + p.Requests[i].Fields = addAlignGapsToFields(p.Requests[i].xmlName, p.Requests[i].Fields) + if p.Requests[i].Reply != nil { + p.Requests[i].Reply.Fields = addAlignGapsToFields(p.Requests[i].xmlName, p.Requests[i].Reply.Fields) + } + } +} + +func addAlignGapsToFields(name string, fields []Field) []Field { + var i int + for i = 0; i < len(fields); i++ { + if _, ok := fields[i].(*ListField); ok { + break + } + } + if i >= len(fields) { + return fields + } + + r := make([]Field, 0, len(fields)+2) + r = append(r, fields[:i]...) + + r = append(r, fields[i]) + for i = i + 1; i < len(fields); i++ { + switch f := fields[i].(type) { + case *ListField: + // ok, add padding + sz := xcbSizeOfType(f.Type) + switch { + case sz == 1: + // nothing + case sz == 2: + r = append(r, &PadField{0, 2}) + case sz == 3: + panic(fmt.Errorf("Alignment is not a power of 2")) + case sz >= 4: + r = append(r, &PadField{0, 4}) + } + + case *LocalField: + // nothing + + default: + fmt.Fprintf(os.Stderr, "Can't add alignment gaps, mix of list and non-list fields: %s\n", name) + return fields + } + r = append(r, fields[i]) + } + + return r +} + +func xcbSizeOfField(fld Field) int { + switch f := fld.(type) { + case *PadField: + return int(f.Bytes) + + case *SingleField: + return xcbSizeOfType(f.Type) + + case *ListField: + return 0 + + case *ExprField: + return xcbSizeOfType(f.Type) + + case *ValueField: + return xcbSizeOfType(f.MaskType) + + case *SwitchField: + return 0 + + default: + return 0 + } +} + +func xcbSizeOfType(typ Type) int { + switch t := typ.(type) { + case *Resource: + return 4 + + case *TypeDef: + return t.Size().Eval() + + case *Base: + return t.Size().Eval() + + case *Struct: + sz := 0 + for i := range t.Fields { + sz += xcbSizeOfField(t.Fields[i]) + } + return sz + + case *Union: + sz := 0 + for i := range t.Fields { + csz := xcbSizeOfField(t.Fields[i]) + if csz > sz { + sz = csz + } + } + return sz + + default: + return 0 + } +} diff --git a/nexgb/xgbgen/context.go b/nexgb/xgbgen/context.go index af0f598..f64f339 100644 --- a/nexgb/xgbgen/context.go +++ b/nexgb/xgbgen/context.go @@ -50,6 +50,8 @@ func (c *Context) Morph(xmlBytes []byte) { // Translate XML types to nice types c.protocol = parsedXml.Translate(nil) + c.protocol.AddAlignGaps() + // Start with Go header. c.Putln("// Package %s is the X client API for the %s extension.", c.protocol.PkgName(), c.protocol.ExtXName) diff --git a/nexgb/xgbgen/field.go b/nexgb/xgbgen/field.go index 16760d4..bf3b3be 100644 --- a/nexgb/xgbgen/field.go +++ b/nexgb/xgbgen/field.go @@ -50,6 +50,7 @@ func (pad *PadField) Initialize(p *Protocol) {} // It is also used in size calculation. type PadField struct { Bytes uint + Align uint16 } func (p *PadField) SrcName() string { @@ -65,7 +66,11 @@ func (f *PadField) SrcType() string { } func (p *PadField) Size() Size { - return newFixedSize(p.Bytes) + if p.Align > 0 { + return newFixedSize(uint(p.Align), false) + } else { + return newFixedSize(p.Bytes, true) + } } // SingleField represents most of the fields in an XML protocol description. @@ -130,9 +135,9 @@ func (f *ListField) Length() Size { Expr: &FieldRef{ Name: f.SrcName(), }, - }) + }, true) } - return newExpressionSize(f.LengthExpr) + return newExpressionSize(f.LengthExpr, true) } // Size computes the *size* of a list (in bytes). @@ -142,8 +147,9 @@ func (f *ListField) Length() Size { // special function written in go_struct.go to compute the size (since the // size in this case can only be computed recursively). func (f *ListField) Size() Size { + elsz := f.Type.Size() simpleLen := &Padding{ - Expr: newBinaryOp("*", f.Length().Expression, f.Type.Size().Expression), + Expr: newBinaryOp("*", f.Length().Expression, elsz.Expression), } switch field := f.Type.(type) { @@ -153,18 +159,18 @@ func (f *ListField) Size() Size { Name: fmt.Sprintf("%sListSize", f.Type.SrcName()), Expr: &FieldRef{Name: f.SrcName()}, } - return newExpressionSize(sizeFun) + return newExpressionSize(sizeFun, elsz.exact) } else { - return newExpressionSize(simpleLen) + return newExpressionSize(simpleLen, elsz.exact) } case *Union: - return newExpressionSize(simpleLen) + return newExpressionSize(simpleLen, elsz.exact) case *Base: - return newExpressionSize(simpleLen) + return newExpressionSize(simpleLen, elsz.exact) case *Resource: - return newExpressionSize(simpleLen) + return newExpressionSize(simpleLen, elsz.exact) case *TypeDef: - return newExpressionSize(simpleLen) + return newExpressionSize(simpleLen, elsz.exact) default: log.Panicf("Cannot compute list size with type '%T'.", f.Type) } @@ -258,7 +264,7 @@ func (f *ValueField) Size() Size { }, }, }, - }) + }, true) return maskSize.Add(listSize) } @@ -270,7 +276,7 @@ func (f *ValueField) ListLength() Size { Name: f.MaskName, }, }, - }) + }, true) } func (f *ValueField) Initialize(p *Protocol) { @@ -303,7 +309,7 @@ func (f *SwitchField) SrcType() string { // expression that finds *which* bitcase fields are included, and sums the // sizes of those fields. func (f *SwitchField) Size() Size { - return newFixedSize(0) + return newFixedSize(0, true) } func (f *SwitchField) Initialize(p *Protocol) { diff --git a/nexgb/xgbgen/go.go b/nexgb/xgbgen/go.go index 6c680e8..ace4e00 100644 --- a/nexgb/xgbgen/go.go +++ b/nexgb/xgbgen/go.go @@ -103,15 +103,27 @@ func (td *TypeDef) Define(c *Context) { // Pad fields func (f *PadField) Define(c *Context) { - c.Putln("// padding: %d bytes", f.Bytes) + if f.Align > 0 { + c.Putln("// alignment gap to multiple of %d", f.Align) + } else { + c.Putln("// padding: %d bytes", f.Bytes) + } } func (f *PadField) Read(c *Context, prefix string) { - c.Putln("b += %s // padding", f.Size()) + if f.Align > 0 { + c.Putln("b = (b + %d) & ^%d // alignment gap", f.Align-1, f.Align-1) + } else { + c.Putln("b += %s // padding", f.Size()) + } } func (f *PadField) Write(c *Context, prefix string) { - c.Putln("b += %s // padding", f.Size()) + if f.Align > 0 { + c.Putln("b = (b + %d) & ^%d // alignment gap", f.Align-1, f.Align-1) + } else { + c.Putln("b += %s // padding", f.Size()) + } } // Local fields diff --git a/nexgb/xgbgen/go_list.go b/nexgb/xgbgen/go_list.go index fa8df69..1e85d9f 100644 --- a/nexgb/xgbgen/go_list.go +++ b/nexgb/xgbgen/go_list.go @@ -21,7 +21,6 @@ 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 = xgb.Pad(b)") case *Base: length := f.LengthExpr.Reduce(prefix) if strings.ToLower(t.XmlName()) == "char" { @@ -38,7 +37,7 @@ func (f *ListField) Read(c *Context, prefix string) { 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 += xgb.Pad(int(%s))", length) + c.Putln("b += int(%s)", length) } else { c.Putln("%s%s = make([]%s, %s)", prefix, f.SrcName(), t.SrcName(), length) @@ -46,7 +45,6 @@ func (f *ListField) Read(c *Context, prefix string) { ReadSimpleSingleField(c, fmt.Sprintf("%s%s[i]", prefix, f.SrcName()), t) c.Putln("}") - c.Putln("b = xgb.Pad(b)") } case *TypeDef: length := f.LengthExpr.Reduce(prefix) @@ -55,7 +53,6 @@ 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 = xgb.Pad(b)") case *Union: c.Putln("%s%s = make([]%s, %s)", prefix, f.SrcName(), t.SrcName(), f.LengthExpr.Reduce(prefix)) @@ -80,18 +77,16 @@ func (f *ListField) Write(c *Context, prefix string) { WriteSimpleSingleField(c, fmt.Sprintf("%s%s[i]", prefix, f.SrcName()), t) c.Putln("}") - 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 += xgb.Pad(int(%s))", length) + c.Putln("b += 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 = xgb.Pad(b)") } case *TypeDef: length := f.Length().Reduce(prefix) @@ -99,7 +94,6 @@ func (f *ListField) Write(c *Context, prefix string) { WriteSimpleSingleField(c, fmt.Sprintf("%s%s[i]", prefix, f.SrcName()), t) c.Putln("}") - 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 a2c6d9c..d82e157 100644 --- a/nexgb/xgbgen/go_request_reply.go +++ b/nexgb/xgbgen/go_request_reply.go @@ -138,18 +138,32 @@ func (r *Request) ReadReply(c *Context) { } func (r *Request) WriteRequest(c *Context) { - writeSize := func() { - c.Putln("xgb.Put16(buf[b:], uint16(size / 4)) " + - "// write request size in 4-byte units") + sz := r.Size(c) + writeSize1 := func() { + if sz.exact { + c.Putln("xgb.Put16(buf[b:], uint16(size / 4)) " + + "// write request size in 4-byte units") + } else { + c.Putln("blen := b") + } c.Putln("b += 2") c.Putln("") } + writeSize2 := func() { + if sz.exact { + c.Putln("return buf") + return + } + c.Putln("b = xgb.Pad(b)") + c.Putln("xgb.Put16(buf[blen:], uint16(b / 4)) // write request size in 4-byte units") + c.Putln("return buf[:b]") + } 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)) + c.Putln("size := %s", sz) c.Putln("b := 0") c.Putln("buf := make([]byte, size)") c.Putln("") @@ -165,18 +179,18 @@ func (r *Request) WriteRequest(c *Context) { if !c.protocol.isExt() { c.Putln("b += 1 // padding") } - writeSize() + writeSize1() } else if c.protocol.isExt() { - writeSize() + writeSize1() } for i, field := range r.Fields { field.Write(c, "") c.Putln("") if i == 0 && !c.protocol.isExt() { - writeSize() + writeSize1() } } - c.Putln("return buf") + writeSize2() c.Putln("}") c.Putln("") } diff --git a/nexgb/xgbgen/go_struct.go b/nexgb/xgbgen/go_struct.go index 0f18084..ee74d90 100644 --- a/nexgb/xgbgen/go_struct.go +++ b/nexgb/xgbgen/go_struct.go @@ -78,7 +78,7 @@ func (s *Struct) Write(c *Context) { field.Write(c, "v.") c.Putln("") } - c.Putln("return buf") + c.Putln("return buf[:b]") c.Putln("}") c.Putln("") } diff --git a/nexgb/xgbgen/request_reply.go b/nexgb/xgbgen/request_reply.go index 11a4e44..ae4eccb 100644 --- a/nexgb/xgbgen/request_reply.go +++ b/nexgb/xgbgen/request_reply.go @@ -91,7 +91,7 @@ func (r *Request) CookieName() string { // 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) + size := newFixedSize(0, true) // If this is a core protocol request, we squeeze in an extra byte of // data (from the fields below) between the opcode and the size of the @@ -99,9 +99,9 @@ func (r *Request) Size(c *Context) Size { // by the opcode of the request (while the first byte is always occupied // by the opcode of the extension). if !c.protocol.isExt() { - size = size.Add(newFixedSize(3)) + size = size.Add(newFixedSize(3, true)) } else { - size = size.Add(newFixedSize(4)) + size = size.Add(newFixedSize(4, true)) } for _, field := range r.Fields { @@ -122,7 +122,7 @@ func (r *Request) Size(c *Context) Size { } return newExpressionSize(&Padding{ Expr: size.Expression, - }) + }, size.exact) } // Reply encapsulates the fields associated with a 'reply' element. @@ -136,10 +136,10 @@ type Reply struct { // 2 bytes: A sequence number // 4 bytes: Number of additional bytes in 4-byte units past initial 32 bytes. func (r *Reply) Size() Size { - size := newFixedSize(0) + size := newFixedSize(0, true) // Account for reply discriminant, sequence number and reply length - size = size.Add(newFixedSize(7)) + size = size.Add(newFixedSize(7, true)) for _, field := range r.Fields { size = size.Add(field.Size()) diff --git a/nexgb/xgbgen/size.go b/nexgb/xgbgen/size.go index 8836892..6e49371 100644 --- a/nexgb/xgbgen/size.go +++ b/nexgb/xgbgen/size.go @@ -7,24 +7,25 @@ package main // for adding and multiplying sizes. type Size struct { Expression + exact bool } // newFixedSize creates a new Size with some fixed and known value. -func newFixedSize(fixed uint) Size { - return Size{&Value{v: int(fixed)}} +func newFixedSize(fixed uint, exact bool) Size { + return Size{&Value{v: int(fixed)}, exact} } // newExpressionSize creates a new Size with some expression. -func newExpressionSize(variable Expression) Size { - return Size{variable} +func newExpressionSize(variable Expression, exact bool) Size { + return Size{variable, exact} } // Add adds s1 and s2 and returns a new Size. func (s1 Size) Add(s2 Size) Size { - return Size{newBinaryOp("+", s1, s2)} + return Size{newBinaryOp("+", s1, s2), s1.exact && s2.exact} } // Multiply mupltiplies s1 and s2 and returns a new Size. func (s1 Size) Multiply(s2 Size) Size { - return Size{newBinaryOp("*", s1, s2)} + return Size{newBinaryOp("*", s1, s2), s1.exact && s2.exact} } diff --git a/nexgb/xgbgen/translation.go b/nexgb/xgbgen/translation.go index b7e67e2..f595e5f 100644 --- a/nexgb/xgbgen/translation.go +++ b/nexgb/xgbgen/translation.go @@ -43,7 +43,7 @@ func (xml *XML) Translate(parent *Protocol) *Protocol { newBaseType := &Base{ srcName: srcName, xmlName: xmlName, - size: newFixedSize(BaseTypeSizes[xmlName]), + size: newFixedSize(BaseTypeSizes[xmlName], true), } protocol.Types = append(protocol.Types, newBaseType) } diff --git a/nexgb/xgbgen/type.go b/nexgb/xgbgen/type.go index ded5be2..59f1a2d 100644 --- a/nexgb/xgbgen/type.go +++ b/nexgb/xgbgen/type.go @@ -154,7 +154,7 @@ func (r *Resource) XmlName() string { } func (r *Resource) Size() Size { - return newFixedSize(BaseTypeSizes["Id"]) + return newFixedSize(BaseTypeSizes["Id"], true) } func (r *Resource) Initialize(p *Protocol) { @@ -201,7 +201,7 @@ func (e *Event) XmlName() string { } func (e *Event) Size() Size { - return newExpressionSize(&Value{v: 32}) + return newExpressionSize(&Value{v: 32}, true) } func (e *Event) Initialize(p *Protocol) { @@ -231,7 +231,7 @@ func (e *EventCopy) XmlName() string { } func (e *EventCopy) Size() Size { - return newExpressionSize(&Value{v: 32}) + return newExpressionSize(&Value{v: 32}, true) } func (e *EventCopy) Initialize(p *Protocol) { @@ -262,7 +262,7 @@ func (e *Error) XmlName() string { } func (e *Error) Size() Size { - return newExpressionSize(&Value{v: 32}) + return newExpressionSize(&Value{v: 32}, true) } func (e *Error) Initialize(p *Protocol) { @@ -296,7 +296,7 @@ func (e *ErrorCopy) XmlName() string { } func (e *ErrorCopy) Size() Size { - return newExpressionSize(&Value{v: 32}) + return newExpressionSize(&Value{v: 32}, true) } func (e *ErrorCopy) Initialize(p *Protocol) { @@ -330,7 +330,7 @@ func (s *Struct) XmlName() string { } func (s *Struct) Size() Size { - size := newFixedSize(0) + size := newFixedSize(0, true) for _, field := range s.Fields { size = size.Add(field.Size()) } diff --git a/nexgb/xinerama/xinerama.go b/nexgb/xinerama/xinerama.go index 28410c6..75c773c 100644 --- a/nexgb/xinerama/xinerama.go +++ b/nexgb/xinerama/xinerama.go @@ -90,7 +90,7 @@ func (v ScreenInfo) Bytes() []byte { xgb.Put16(buf[b:], v.Height) b += 2 - return buf + return buf[:b] } // ScreenInfoListBytes writes a list of ScreenInfo values to a byte slice. diff --git a/nexgb/xprint/xprint.go b/nexgb/xprint/xprint.go index 7a7279f..5ed49a0 100644 --- a/nexgb/xprint/xprint.go +++ b/nexgb/xprint/xprint.go @@ -336,7 +336,6 @@ func PrinterRead(buf []byte, v *Printer) int { v.Name[i] = String8(buf[b]) b += 1 } - b = xgb.Pad(b) v.DescLen = xgb.Get32(buf[b:]) b += 4 @@ -346,7 +345,6 @@ func PrinterRead(buf []byte, v *Printer) int { v.Description[i] = String8(buf[b]) b += 1 } - b = xgb.Pad(b) return b } @@ -373,7 +371,6 @@ func (v Printer) Bytes() []byte { buf[b] = byte(v.Name[i]) b += 1 } - b = xgb.Pad(b) xgb.Put32(buf[b:], v.DescLen) b += 4 @@ -382,9 +379,8 @@ func (v Printer) Bytes() []byte { buf[b] = byte(v.Description[i]) b += 1 } - b = xgb.Pad(b) - return buf + return buf[:b] } // PrinterListBytes writes a list of Printer values to a byte slice. @@ -496,13 +492,11 @@ func createContextRequest(c *xgb.Conn, ContextId uint32, PrinterNameLen uint32, 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 } @@ -1003,7 +997,7 @@ func printGetDocumentDataReply(buf []byte) *PrintGetDocumentDataReply { v.Data = make([]byte, v.DataLen) copy(v.Data[:v.DataLen], buf[b:]) - b += xgb.Pad(int(v.DataLen)) + b += int(v.DataLen) return v } @@ -1193,7 +1187,6 @@ func printGetOneAttributesReply(buf []byte) *PrintGetOneAttributesReply { v.Value[i] = String8(buf[b]) b += 1 } - b = xgb.Pad(b) return v } @@ -1229,7 +1222,6 @@ func printGetOneAttributesRequest(c *xgb.Conn, Context Pcontext, NameLen uint32, buf[b] = byte(Name[i]) b += 1 } - b = xgb.Pad(b) return buf } @@ -1441,13 +1433,11 @@ func printGetPrinterListRequest(c *xgb.Conn, PrinterNameLen uint32, LocaleLen ui 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 } @@ -1707,19 +1697,17 @@ func printPutDocumentDataRequest(c *xgb.Conn, Drawable xproto.Drawable, LenData b += 2 copy(buf[b:], Data[:LenData]) - b += xgb.Pad(int(LenData)) + b += 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 } @@ -1796,7 +1784,6 @@ func printQueryScreensReply(buf []byte) *PrintQueryScreensReply { v.Roots[i] = xproto.Window(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) return v } @@ -2091,7 +2078,6 @@ func printSetAttributesRequest(c *xgb.Conn, Context Pcontext, StringLen uint32, buf[b] = byte(Attributes[i]) b += 1 } - b = xgb.Pad(b) return buf } diff --git a/nexgb/xproto/xproto.go b/nexgb/xproto/xproto.go index 36ab545..728f85f 100644 --- a/nexgb/xproto/xproto.go +++ b/nexgb/xproto/xproto.go @@ -179,7 +179,7 @@ func (v Arc) Bytes() []byte { xgb.Put16(buf[b:], uint16(v.Angle2)) b += 2 - return buf + return buf[:b] } // ArcListBytes writes a list of Arc values to a byte slice. @@ -603,7 +603,7 @@ func (v Char2b) Bytes() []byte { buf[b] = v.Byte2 b += 1 - return buf + return buf[:b] } // Char2bListBytes writes a list of Char2b values to a byte slice. @@ -685,7 +685,7 @@ func (v Charinfo) Bytes() []byte { xgb.Put16(buf[b:], v.Attributes) b += 2 - return buf + return buf[:b] } // CharinfoListBytes writes a list of Charinfo values to a byte slice. @@ -932,7 +932,7 @@ func ClientMessageDataUnionData8New(Data8 []byte) ClientMessageDataUnion { buf := make([]byte, 20) copy(buf[b:], Data8[:20]) - b += xgb.Pad(int(20)) + b += int(20) // Create the Union type v := ClientMessageDataUnion{} @@ -942,7 +942,7 @@ func ClientMessageDataUnionData8New(Data8 []byte) ClientMessageDataUnion { b = 0 // always read the same bytes v.Data8 = make([]byte, 20) copy(v.Data8[:20], buf[b:]) - b += xgb.Pad(int(20)) + b += int(20) b = 0 // always read the same bytes v.Data16 = make([]uint16, 10) @@ -950,7 +950,6 @@ func ClientMessageDataUnionData8New(Data8 []byte) ClientMessageDataUnion { 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) @@ -958,7 +957,6 @@ func ClientMessageDataUnionData8New(Data8 []byte) ClientMessageDataUnion { v.Data32[i] = xgb.Get32(buf[b:]) b += 4 } - b = xgb.Pad(b) return v } @@ -972,7 +970,6 @@ func ClientMessageDataUnionData16New(Data16 []uint16) ClientMessageDataUnion { xgb.Put16(buf[b:], Data16[i]) b += 2 } - b = xgb.Pad(b) // Create the Union type v := ClientMessageDataUnion{} @@ -982,7 +979,7 @@ func ClientMessageDataUnionData16New(Data16 []uint16) ClientMessageDataUnion { b = 0 // always read the same bytes v.Data8 = make([]byte, 20) copy(v.Data8[:20], buf[b:]) - b += xgb.Pad(int(20)) + b += int(20) b = 0 // always read the same bytes v.Data16 = make([]uint16, 10) @@ -990,7 +987,6 @@ func ClientMessageDataUnionData16New(Data16 []uint16) ClientMessageDataUnion { 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) @@ -998,7 +994,6 @@ func ClientMessageDataUnionData16New(Data16 []uint16) ClientMessageDataUnion { v.Data32[i] = xgb.Get32(buf[b:]) b += 4 } - b = xgb.Pad(b) return v } @@ -1012,7 +1007,6 @@ func ClientMessageDataUnionData32New(Data32 []uint32) ClientMessageDataUnion { xgb.Put32(buf[b:], Data32[i]) b += 4 } - b = xgb.Pad(b) // Create the Union type v := ClientMessageDataUnion{} @@ -1022,7 +1016,7 @@ func ClientMessageDataUnionData32New(Data32 []uint32) ClientMessageDataUnion { b = 0 // always read the same bytes v.Data8 = make([]byte, 20) copy(v.Data8[:20], buf[b:]) - b += xgb.Pad(int(20)) + b += int(20) b = 0 // always read the same bytes v.Data16 = make([]uint16, 10) @@ -1030,7 +1024,6 @@ func ClientMessageDataUnionData32New(Data32 []uint32) ClientMessageDataUnion { 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) @@ -1038,7 +1031,6 @@ func ClientMessageDataUnionData32New(Data32 []uint32) ClientMessageDataUnion { v.Data32[i] = xgb.Get32(buf[b:]) b += 4 } - b = xgb.Pad(b) return v } @@ -1050,7 +1042,7 @@ func ClientMessageDataUnionRead(buf []byte, v *ClientMessageDataUnion) 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 += int(20) b = 0 // re-read the same bytes v.Data16 = make([]uint16, 10) @@ -1058,7 +1050,6 @@ func ClientMessageDataUnionRead(buf []byte, v *ClientMessageDataUnion) int { 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) @@ -1066,7 +1057,6 @@ func ClientMessageDataUnionRead(buf []byte, v *ClientMessageDataUnion) int { v.Data32[i] = xgb.Get32(buf[b:]) b += 4 } - b = xgb.Pad(b) return 20 } @@ -1089,7 +1079,7 @@ func (v ClientMessageDataUnion) Bytes() []byte { b := 0 copy(buf[b:], v.Data8[:20]) - b += xgb.Pad(int(20)) + b += int(20) return buf } @@ -1189,7 +1179,7 @@ func (v Coloritem) Bytes() []byte { b += 1 // padding - return buf + return buf[:b] } // ColoritemListBytes writes a list of Coloritem values to a byte slice. @@ -1908,7 +1898,7 @@ func (v DepthInfo) Bytes() []byte { b += VisualInfoListBytes(buf[b:], v.Visuals) - return buf + return buf[:b] } // DepthInfoListBytes writes a list of DepthInfo values to a byte slice. @@ -2580,7 +2570,7 @@ func (v Fontprop) Bytes() []byte { xgb.Put32(buf[b:], v.Value) b += 4 - return buf + return buf[:b] } // FontpropListBytes writes a list of Fontprop values to a byte slice. @@ -2646,7 +2636,7 @@ func (v Format) Bytes() []byte { b += 5 // padding - return buf + return buf[:b] } // FormatListBytes writes a list of Format values to a byte slice. @@ -3072,7 +3062,7 @@ func HostRead(buf []byte, v *Host) int { v.Address = make([]byte, v.AddressLen) copy(v.Address[:v.AddressLen], buf[b:]) - b += xgb.Pad(int(v.AddressLen)) + b += int(v.AddressLen) return b } @@ -3101,9 +3091,9 @@ func (v Host) Bytes() []byte { b += 2 copy(buf[b:], v.Address[:v.AddressLen]) - b += xgb.Pad(int(v.AddressLen)) + b += int(v.AddressLen) - return buf + return buf[:b] } // HostListBytes writes a list of Host values to a byte slice. @@ -3469,7 +3459,7 @@ func KeymapNotifyEventNew(buf []byte) xgb.Event { v.Keys = make([]byte, 31) copy(v.Keys[:31], buf[b:]) - b += xgb.Pad(int(31)) + b += int(31) return v } @@ -3484,7 +3474,7 @@ func (v KeymapNotifyEvent) Bytes() []byte { b += 1 copy(buf[b:], v.Keys[:31]) - b += xgb.Pad(int(31)) + b += int(31) return buf } @@ -4323,7 +4313,7 @@ func (v Point) Bytes() []byte { xgb.Put16(buf[b:], uint16(v.Y)) b += 2 - return buf + return buf[:b] } // PointListBytes writes a list of Point values to a byte slice. @@ -4506,7 +4496,7 @@ func (v Rectangle) Bytes() []byte { xgb.Put16(buf[b:], v.Height) b += 2 - return buf + return buf[:b] } // RectangleListBytes writes a list of Rectangle values to a byte slice. @@ -4831,7 +4821,7 @@ func (v Rgb) Bytes() []byte { b += 2 // padding - return buf + return buf[:b] } // RgbListBytes writes a list of Rgb values to a byte slice. @@ -4997,7 +4987,7 @@ func (v ScreenInfo) Bytes() []byte { b += DepthInfoListBytes(buf[b:], v.AllowedDepths) - return buf + return buf[:b] } // ScreenInfoListBytes writes a list of ScreenInfo values to a byte slice. @@ -5079,7 +5069,7 @@ func (v Segment) Bytes() []byte { xgb.Put16(buf[b:], uint16(v.Y2)) b += 2 - return buf + return buf[:b] } // SegmentListBytes writes a list of Segment values to a byte slice. @@ -5434,9 +5424,9 @@ func (v SetupAuthenticate) Bytes() []byte { b += 2 copy(buf[b:], v.Reason[:(int(v.Length)*4)]) - b += xgb.Pad(int((int(v.Length) * 4))) + b += int((int(v.Length) * 4)) - return buf + return buf[:b] } // SetupAuthenticateListBytes writes a list of SetupAuthenticate values to a byte slice. @@ -5529,9 +5519,9 @@ func (v SetupFailed) Bytes() []byte { b += 2 copy(buf[b:], v.Reason[:v.ReasonLen]) - b += xgb.Pad(int(v.ReasonLen)) + b += int(v.ReasonLen) - return buf + return buf[:b] } // SetupFailedListBytes writes a list of SetupFailed values to a byte slice. @@ -5576,9 +5566,11 @@ type SetupInfo struct { 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) + Vendor string // size: xgb.Pad((int(VendorLen) * 1)) + // alignment gap to multiple of 4 + PixmapFormats []Format // size: xgb.Pad((int(PixmapFormatsLen) * 8)) + // alignment gap to multiple of 4 + Roots []ScreenInfo // size: ScreenInfoListSize(Roots) } // SetupInfoRead reads a byte slice into a SetupInfo value. @@ -5650,9 +5642,13 @@ func SetupInfoRead(buf []byte, v *SetupInfo) int { b += int(v.VendorLen) } + b = (b + 3) & ^3 // alignment gap + v.PixmapFormats = make([]Format, v.PixmapFormatsLen) b += FormatReadList(buf[b:], v.PixmapFormats) + b = (b + 3) & ^3 // alignment gap + v.Roots = make([]ScreenInfo, v.RootsLen) b += ScreenInfoReadList(buf[b:], v.Roots) @@ -5671,7 +5667,7 @@ func SetupInfoReadList(buf []byte, dest []SetupInfo) int { // 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))) + buf := make([]byte, (((((40 + xgb.Pad((int(v.VendorLen) * 1))) + 4) + xgb.Pad((int(v.PixmapFormatsLen) * 8))) + 4) + ScreenInfoListSize(v.Roots))) b := 0 buf[b] = v.Status @@ -5733,13 +5729,17 @@ func (v SetupInfo) Bytes() []byte { b += 4 // padding copy(buf[b:], v.Vendor[:v.VendorLen]) - b += xgb.Pad(int(v.VendorLen)) + b += int(v.VendorLen) + + b = (b + 3) & ^3 // alignment gap b += FormatListBytes(buf[b:], v.PixmapFormats) + b = (b + 3) & ^3 // alignment gap + b += ScreenInfoListBytes(buf[b:], v.Roots) - return buf + return buf[:b] } // SetupInfoListBytes writes a list of SetupInfo values to a byte slice. @@ -5758,7 +5758,7 @@ func SetupInfoListBytes(buf []byte, list []SetupInfo) int { 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)) + size += (((((40 + xgb.Pad((int(item.VendorLen) * 1))) + 4) + xgb.Pad((int(item.PixmapFormatsLen) * 8))) + 4) + ScreenInfoListSize(item.Roots)) } return size } @@ -5850,12 +5850,12 @@ func (v SetupRequest) Bytes() []byte { b += 2 // padding copy(buf[b:], v.AuthorizationProtocolName[:v.AuthorizationProtocolNameLen]) - b += xgb.Pad(int(v.AuthorizationProtocolNameLen)) + b += int(v.AuthorizationProtocolNameLen) copy(buf[b:], v.AuthorizationProtocolData[:v.AuthorizationProtocolDataLen]) - b += xgb.Pad(int(v.AuthorizationProtocolDataLen)) + b += int(v.AuthorizationProtocolDataLen) - return buf + return buf[:b] } // SetupRequestListBytes writes a list of SetupRequest values to a byte slice. @@ -5928,9 +5928,9 @@ func (v Str) Bytes() []byte { b += 1 copy(buf[b:], v.Name[:v.NameLen]) - b += xgb.Pad(int(v.NameLen)) + b += int(v.NameLen) - return buf + return buf[:b] } // StrListBytes writes a list of Str values to a byte slice. @@ -6009,7 +6009,7 @@ func (v Timecoord) Bytes() []byte { xgb.Put16(buf[b:], uint16(v.Y)) b += 2 - return buf + return buf[:b] } // TimecoordListBytes writes a list of Timecoord values to a byte slice. @@ -6352,7 +6352,7 @@ func (v VisualInfo) Bytes() []byte { b += 4 // padding - return buf + return buf[:b] } // VisualInfoListBytes writes a list of VisualInfo values to a byte slice. @@ -6588,7 +6588,8 @@ type AllocColorCellsReply struct { MasksLen uint16 // padding: 20 bytes Pixels []uint32 // size: xgb.Pad((int(PixelsLen) * 4)) - Masks []uint32 // size: xgb.Pad((int(MasksLen) * 4)) + // alignment gap to multiple of 4 + Masks []uint32 // size: xgb.Pad((int(MasksLen) * 4)) } // Reply blocks and returns the reply data for a AllocColorCells request. @@ -6629,14 +6630,14 @@ func allocColorCellsReply(buf []byte) *AllocColorCellsReply { v.Pixels[i] = xgb.Get32(buf[b:]) b += 4 } - b = xgb.Pad(b) + + b = (b + 3) & ^3 // alignment gap 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 } @@ -6754,7 +6755,6 @@ func allocColorPlanesReply(buf []byte) *AllocColorPlanesReply { v.Pixels[i] = xgb.Get32(buf[b:]) b += 4 } - b = xgb.Pad(b) return v } @@ -6905,7 +6905,7 @@ func allocNamedColorRequest(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name str b += 2 // padding copy(buf[b:], Name[:NameLen]) - b += xgb.Pad(int(NameLen)) + b += int(NameLen) return buf } @@ -7169,7 +7169,7 @@ func changeHostsRequest(c *xgb.Conn, Mode byte, Family byte, AddressLen uint16, b += 2 copy(buf[b:], Address[:AddressLen]) - b += xgb.Pad(int(AddressLen)) + b += int(AddressLen) return buf } @@ -7282,7 +7282,6 @@ func changeKeyboardMappingRequest(c *xgb.Conn, KeycodeCount byte, FirstKeycode K xgb.Put32(buf[b:], uint32(Keysyms[i])) b += 4 } - b = xgb.Pad(b) return buf } @@ -7416,7 +7415,7 @@ func changePropertyRequest(c *xgb.Conn, Mode byte, Window Window, Property Atom, b += 4 copy(buf[b:], Data[:((int(DataLen)*int(Format))/8)]) - b += xgb.Pad(int(((int(DataLen) * int(Format)) / 8))) + b += int(((int(DataLen) * int(Format)) / 8)) return buf } @@ -8822,7 +8821,6 @@ func freeColorsRequest(c *xgb.Conn, Cmap Colormap, PlaneMask uint32, Pixels []ui xgb.Put32(buf[b:], Pixels[i]) b += 4 } - b = xgb.Pad(b) return buf } @@ -9316,7 +9314,7 @@ func getImageReply(buf []byte) *GetImageReply { 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))) + b += int((int(v.Length) * 4)) return v } @@ -9516,7 +9514,7 @@ func getKeyboardControlReply(buf []byte) *GetKeyboardControlReply { v.AutoRepeats = make([]byte, 32) copy(v.AutoRepeats[:32], buf[b:]) - b += xgb.Pad(int(32)) + b += int(32) return v } @@ -9601,7 +9599,6 @@ func getKeyboardMappingReply(buf []byte) *GetKeyboardMappingReply { v.Keysyms[i] = Keysym(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) return v } @@ -9693,7 +9690,6 @@ func getModifierMappingReply(buf []byte) *GetModifierMappingReply { v.Keycodes[i] = Keycode(buf[b]) b += 1 } - b = xgb.Pad(b) return v } @@ -9957,7 +9953,7 @@ func getPointerMappingReply(buf []byte) *GetPointerMappingReply { v.Map = make([]byte, v.MapLen) copy(v.Map[:v.MapLen], buf[b:]) - b += xgb.Pad(int(v.MapLen)) + b += int(v.MapLen) return v } @@ -10051,7 +10047,7 @@ func getPropertyReply(buf []byte) *GetPropertyReply { 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)))) + b += int((int(v.ValueLen) * (int(v.Format) / 8))) return v } @@ -10914,7 +10910,7 @@ func imageText8Request(c *xgb.Conn, StringLen byte, Drawable Drawable, Gc Gconte b += 2 copy(buf[b:], String[:StringLen]) - b += xgb.Pad(int(StringLen)) + b += int(StringLen) return buf } @@ -11053,7 +11049,7 @@ func internAtomRequest(c *xgb.Conn, OnlyIfExists bool, NameLen uint16, Name stri b += 2 // padding copy(buf[b:], Name[:NameLen]) - b += xgb.Pad(int(NameLen)) + b += int(NameLen) return buf } @@ -11276,7 +11272,7 @@ func listFontsRequest(c *xgb.Conn, MaxNames uint16, PatternLen uint16, Pattern s b += 2 copy(buf[b:], Pattern[:PatternLen]) - b += xgb.Pad(int(PatternLen)) + b += int(PatternLen) return buf } @@ -11434,7 +11430,7 @@ func listFontsWithInfoRequest(c *xgb.Conn, MaxNames uint16, PatternLen uint16, P b += 2 copy(buf[b:], Pattern[:PatternLen]) - b += xgb.Pad(int(PatternLen)) + b += int(PatternLen) return buf } @@ -11590,7 +11586,6 @@ func listInstalledColormapsReply(buf []byte) *ListInstalledColormapsReply { v.Cmaps[i] = Colormap(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) return v } @@ -11682,7 +11677,6 @@ func listPropertiesReply(buf []byte) *ListPropertiesReply { v.Atoms[i] = Atom(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) return v } @@ -11812,7 +11806,7 @@ func lookupColorRequest(c *xgb.Conn, Cmap Colormap, NameLen uint16, Name string) b += 2 // padding copy(buf[b:], Name[:NameLen]) - b += xgb.Pad(int(NameLen)) + b += int(NameLen) return buf } @@ -12008,7 +12002,7 @@ func openFontRequest(c *xgb.Conn, Fid Font, NameLen uint16, Name string) []byte b += 2 // padding copy(buf[b:], Name[:NameLen]) - b += xgb.Pad(int(NameLen)) + b += int(NameLen) return buf } @@ -12441,7 +12435,7 @@ func polyText16Request(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y i b += 2 copy(buf[b:], Items[:len(Items)]) - b += xgb.Pad(int(len(Items))) + b += int(len(Items)) return buf } @@ -12501,7 +12495,7 @@ func polyText8Request(c *xgb.Conn, Drawable Drawable, Gc Gcontext, X int16, Y in b += 2 copy(buf[b:], Items[:len(Items)]) - b += xgb.Pad(int(len(Items))) + b += int(len(Items)) return buf } @@ -12576,7 +12570,7 @@ func putImageRequest(c *xgb.Conn, Format byte, Drawable Drawable, Gc Gcontext, W b += 2 // padding copy(buf[b:], Data[:len(Data)]) - b += xgb.Pad(int(len(Data))) + b += int(len(Data)) return buf } @@ -12762,7 +12756,6 @@ func queryColorsRequest(c *xgb.Conn, Cmap Colormap, Pixels []uint32) []byte { xgb.Put32(buf[b:], Pixels[i]) b += 4 } - b = xgb.Pad(b) return buf } @@ -12864,7 +12857,7 @@ func queryExtensionRequest(c *xgb.Conn, NameLen uint16, Name string) []byte { b += 2 // padding copy(buf[b:], Name[:NameLen]) - b += xgb.Pad(int(NameLen)) + b += int(NameLen) return buf } @@ -12911,7 +12904,8 @@ type QueryFontReply struct { FontDescent int16 CharInfosLen uint32 Properties []Fontprop // size: xgb.Pad((int(PropertiesLen) * 8)) - CharInfos []Charinfo // size: xgb.Pad((int(CharInfosLen) * 12)) + // alignment gap to multiple of 4 + CharInfos []Charinfo // size: xgb.Pad((int(CharInfosLen) * 12)) } // Reply blocks and returns the reply data for a QueryFont request. @@ -12989,6 +12983,8 @@ func queryFontReply(buf []byte) *QueryFontReply { v.Properties = make([]Fontprop, v.PropertiesLen) b += FontpropReadList(buf[b:], v.Properties) + b = (b + 3) & ^3 // alignment gap + v.CharInfos = make([]Charinfo, v.CharInfosLen) b += CharinfoReadList(buf[b:], v.CharInfos) @@ -13072,7 +13068,7 @@ func queryKeymapReply(buf []byte) *QueryKeymapReply { v.Keys = make([]byte, 32) copy(v.Keys[:32], buf[b:]) - b += xgb.Pad(int(32)) + b += int(32) return v } @@ -13392,7 +13388,6 @@ func queryTreeReply(buf []byte) *QueryTreeReply { v.Children[i] = Window(xgb.Get32(buf[b:])) b += 4 } - b = xgb.Pad(b) return v } @@ -13596,7 +13591,6 @@ func rotatePropertiesRequest(c *xgb.Conn, Window Window, AtomsLen uint16, Delta xgb.Put32(buf[b:], uint32(Atoms[i])) b += 4 } - b = xgb.Pad(b) return buf } @@ -13655,7 +13649,7 @@ func sendEventRequest(c *xgb.Conn, Propagate bool, Destination Window, EventMask b += 4 copy(buf[b:], Event[:32]) - b += xgb.Pad(int(32)) + b += int(32) return buf } @@ -13861,7 +13855,7 @@ func setDashesRequest(c *xgb.Conn, Gc Gcontext, DashOffset uint16, DashesLen uin b += 2 copy(buf[b:], Dashes[:DashesLen]) - b += xgb.Pad(int(DashesLen)) + b += int(DashesLen) return buf } @@ -14047,7 +14041,6 @@ func setModifierMappingRequest(c *xgb.Conn, KeycodesPerModifier byte, Keycodes [ buf[b] = byte(Keycodes[i]) b += 1 } - b = xgb.Pad(b) return buf } @@ -14126,7 +14119,7 @@ func setPointerMappingRequest(c *xgb.Conn, MapLen byte, Map []byte) []byte { b += 2 copy(buf[b:], Map[:MapLen]) - b += xgb.Pad(int(MapLen)) + b += int(MapLen) return buf } @@ -14347,7 +14340,7 @@ func storeNamedColorRequest(c *xgb.Conn, Flags byte, Cmap Colormap, Pixel uint32 b += 2 // padding copy(buf[b:], Name[:NameLen]) - b += xgb.Pad(int(NameLen)) + b += int(NameLen) return buf } diff --git a/nexgb/xproto/xproto_test.go b/nexgb/xproto/xproto_test.go index 44d3285..a5bec71 100644 --- a/nexgb/xproto/xproto_test.go +++ b/nexgb/xproto/xproto_test.go @@ -204,6 +204,23 @@ func TestWindowEvents(t *testing.T) { } } +// Calls GetFontPath function, Issue #12 +func TestGetFontPath(t *testing.T) { + fontPathReply, err := GetFontPath(X).Reply() + if err != nil { + t.Fatalf("GetFontPath: %v", err) + } + _ = fontPathReply +} + +func TestListFonts(t *testing.T) { + listFontsReply, err := ListFonts(X, 10, 1, "*").Reply() + if err != nil { + t.Fatalf("ListFonts: %v", err) + } + _ = listFontsReply +} + /******************************************************************************/ // Benchmarks /******************************************************************************/ diff --git a/nexgb/xselinux/xselinux.go b/nexgb/xselinux/xselinux.go index a4cd35e..87d8f98 100644 --- a/nexgb/xselinux/xselinux.go +++ b/nexgb/xselinux/xselinux.go @@ -100,12 +100,12 @@ func (v ListItem) Bytes() []byte { b += 4 copy(buf[b:], v.ObjectContext[:v.ObjectContextLen]) - b += xgb.Pad(int(v.ObjectContextLen)) + b += int(v.ObjectContextLen) copy(buf[b:], v.DataContext[:v.DataContextLen]) - b += xgb.Pad(int(v.DataContextLen)) + b += int(v.DataContextLen) - return buf + return buf[:b] } // ListItemListBytes writes a list of ListItem values to a byte slice. @@ -1766,7 +1766,7 @@ func setDeviceContextRequest(c *xgb.Conn, Device uint32, ContextLen uint32, Cont b += 4 copy(buf[b:], Context[:ContextLen]) - b += xgb.Pad(int(ContextLen)) + b += int(ContextLen) return buf } @@ -1824,7 +1824,7 @@ func setDeviceCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context strin b += 4 copy(buf[b:], Context[:ContextLen]) - b += xgb.Pad(int(ContextLen)) + b += int(ContextLen) return buf } @@ -1882,7 +1882,7 @@ func setPropertyCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context str b += 4 copy(buf[b:], Context[:ContextLen]) - b += xgb.Pad(int(ContextLen)) + b += int(ContextLen) return buf } @@ -1940,7 +1940,7 @@ func setPropertyUseContextRequest(c *xgb.Conn, ContextLen uint32, Context string b += 4 copy(buf[b:], Context[:ContextLen]) - b += xgb.Pad(int(ContextLen)) + b += int(ContextLen) return buf } @@ -1998,7 +1998,7 @@ func setSelectionCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context st b += 4 copy(buf[b:], Context[:ContextLen]) - b += xgb.Pad(int(ContextLen)) + b += int(ContextLen) return buf } @@ -2056,7 +2056,7 @@ func setSelectionUseContextRequest(c *xgb.Conn, ContextLen uint32, Context strin b += 4 copy(buf[b:], Context[:ContextLen]) - b += xgb.Pad(int(ContextLen)) + b += int(ContextLen) return buf } @@ -2114,7 +2114,7 @@ func setWindowCreateContextRequest(c *xgb.Conn, ContextLen uint32, Context strin b += 4 copy(buf[b:], Context[:ContextLen]) - b += xgb.Pad(int(ContextLen)) + b += int(ContextLen) return buf } diff --git a/nexgb/xv/xv.go b/nexgb/xv/xv.go index ec87d02..1c406b0 100644 --- a/nexgb/xv/xv.go +++ b/nexgb/xv/xv.go @@ -45,7 +45,8 @@ type AdaptorInfo struct { NumFormats uint16 Type byte // padding: 1 bytes - Name string // size: xgb.Pad((int(NameSize) * 1)) + Name string // size: xgb.Pad((int(NameSize) * 1)) + // alignment gap to multiple of 4 Formats []Format // size: xgb.Pad((int(NumFormats) * 8)) } @@ -77,6 +78,8 @@ func AdaptorInfoRead(buf []byte, v *AdaptorInfo) int { b += int(v.NameSize) } + b = (b + 3) & ^3 // alignment gap + v.Formats = make([]Format, v.NumFormats) b += FormatReadList(buf[b:], v.Formats) @@ -95,7 +98,7 @@ func AdaptorInfoReadList(buf []byte, dest []AdaptorInfo) int { // 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)))) + buf := make([]byte, (((12 + xgb.Pad((int(v.NameSize) * 1))) + 4) + xgb.Pad((int(v.NumFormats) * 8)))) b := 0 xgb.Put32(buf[b:], uint32(v.BaseId)) @@ -116,11 +119,13 @@ func (v AdaptorInfo) Bytes() []byte { b += 1 // padding copy(buf[b:], v.Name[:v.NameSize]) - b += xgb.Pad(int(v.NameSize)) + b += int(v.NameSize) + + b = (b + 3) & ^3 // alignment gap b += FormatListBytes(buf[b:], v.Formats) - return buf + return buf[:b] } // AdaptorInfoListBytes writes a list of AdaptorInfo values to a byte slice. @@ -139,7 +144,7 @@ func AdaptorInfoListBytes(buf []byte, list []AdaptorInfo) int { 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))) + size += (((12 + xgb.Pad((int(item.NameSize) * 1))) + 4) + xgb.Pad((int(item.NumFormats) * 8))) } return size } @@ -211,9 +216,9 @@ func (v AttributeInfo) Bytes() []byte { b += 4 copy(buf[b:], v.Name[:v.Size]) - b += xgb.Pad(int(v.Size)) + b += int(v.Size) - return buf + return buf[:b] } // AttributeInfoListBytes writes a list of AttributeInfo values to a byte slice. @@ -462,9 +467,9 @@ func (v EncodingInfo) Bytes() []byte { } copy(buf[b:], v.Name[:v.NameSize]) - b += xgb.Pad(int(v.NameSize)) + b += int(v.NameSize) - return buf + return buf[:b] } // EncodingInfoListBytes writes a list of EncodingInfo values to a byte slice. @@ -532,7 +537,7 @@ func (v Format) Bytes() []byte { b += 3 // padding - return buf + return buf[:b] } // FormatListBytes writes a list of Format values to a byte slice. @@ -563,8 +568,9 @@ type Image struct { 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)) + // alignment gap to multiple of 4 + Offsets []uint32 // size: xgb.Pad((int(NumPlanes) * 4)) + Data []byte // size: xgb.Pad((int(DataSize) * 1)) } // ImageRead reads a byte slice into a Image value. @@ -591,18 +597,18 @@ func ImageRead(buf []byte, v *Image) int { v.Pitches[i] = xgb.Get32(buf[b:]) b += 4 } - b = xgb.Pad(b) + + b = (b + 3) & ^3 // alignment gap 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)) + b += int(v.DataSize) return b } @@ -619,7 +625,7 @@ func ImageReadList(buf []byte, dest []Image) int { // 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)))) + buf := make([]byte, ((((16 + xgb.Pad((int(v.NumPlanes) * 4))) + 4) + xgb.Pad((int(v.NumPlanes) * 4))) + xgb.Pad((int(v.DataSize) * 1)))) b := 0 xgb.Put32(buf[b:], v.Id) @@ -641,18 +647,18 @@ func (v Image) Bytes() []byte { xgb.Put32(buf[b:], v.Pitches[i]) b += 4 } - b = xgb.Pad(b) + + b = (b + 3) & ^3 // alignment gap 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)) + b += int(v.DataSize) - return buf + return buf[:b] } // ImageListBytes writes a list of Image values to a byte slice. @@ -671,7 +677,7 @@ func ImageListBytes(buf []byte, list []Image) int { 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))) + size += ((((16 + xgb.Pad((int(item.NumPlanes) * 4))) + 4) + xgb.Pad((int(item.NumPlanes) * 4))) + xgb.Pad((int(item.DataSize) * 1))) } return size } @@ -723,7 +729,7 @@ func ImageFormatInfoRead(buf []byte, v *ImageFormatInfo) int { v.Guid = make([]byte, 16) copy(v.Guid[:16], buf[b:]) - b += xgb.Pad(int(16)) + b += int(16) v.Bpp = buf[b] b += 1 @@ -781,7 +787,7 @@ func ImageFormatInfoRead(buf []byte, v *ImageFormatInfo) int { v.VcompOrder = make([]byte, 32) copy(v.VcompOrder[:32], buf[b:]) - b += xgb.Pad(int(32)) + b += int(32) v.VscanlineOrder = buf[b] b += 1 @@ -818,7 +824,7 @@ func (v ImageFormatInfo) Bytes() []byte { b += 2 // padding copy(buf[b:], v.Guid[:16]) - b += xgb.Pad(int(16)) + b += int(16) buf[b] = v.Bpp b += 1 @@ -875,14 +881,14 @@ func (v ImageFormatInfo) Bytes() []byte { b += 4 copy(buf[b:], v.VcompOrder[:32]) - b += xgb.Pad(int(32)) + b += int(32) buf[b] = v.VscanlineOrder b += 1 b += 11 // padding - return buf + return buf[:b] } // ImageFormatInfoListBytes writes a list of ImageFormatInfo values to a byte slice. @@ -1052,7 +1058,7 @@ func (v Rational) Bytes() []byte { xgb.Put32(buf[b:], uint32(v.Denominator)) b += 4 - return buf + return buf[:b] } // RationalListBytes writes a list of Rational values to a byte slice. @@ -1730,7 +1736,7 @@ func putImageRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto b += 2 copy(buf[b:], Data[:len(Data)]) - b += xgb.Pad(int(len(Data))) + b += int(len(Data)) return buf } @@ -2335,6 +2341,7 @@ type QueryImageAttributesReply struct { Height uint16 // padding: 12 bytes Pitches []uint32 // size: xgb.Pad((int(NumPlanes) * 4)) + // alignment gap to multiple of 4 Offsets []uint32 // size: xgb.Pad((int(NumPlanes) * 4)) } @@ -2382,14 +2389,14 @@ func queryImageAttributesReply(buf []byte) *QueryImageAttributesReply { v.Pitches[i] = xgb.Get32(buf[b:]) b += 4 } - b = xgb.Pad(b) + + b = (b + 3) & ^3 // alignment gap 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 } diff --git a/nexgb/xvmc/xvmc.go b/nexgb/xvmc/xvmc.go index cd82b33..a574a21 100644 --- a/nexgb/xvmc/xvmc.go +++ b/nexgb/xvmc/xvmc.go @@ -156,7 +156,7 @@ func (v SurfaceInfo) Bytes() []byte { xgb.Put32(buf[b:], v.Flags) b += 4 - return buf + return buf[:b] } // SurfaceInfoListBytes writes a list of SurfaceInfo values to a byte slice. @@ -275,7 +275,6 @@ func createContextReply(buf []byte) *CreateContextReply { v.PrivData[i] = xgb.Get32(buf[b:]) b += 4 } - b = xgb.Pad(b) return v } @@ -397,7 +396,7 @@ func createSubpictureReply(buf []byte) *CreateSubpictureReply { v.ComponentOrder = make([]byte, 4) copy(v.ComponentOrder[:4], buf[b:]) - b += xgb.Pad(int(4)) + b += int(4) b += 12 // padding @@ -406,7 +405,6 @@ func createSubpictureReply(buf []byte) *CreateSubpictureReply { v.PrivData[i] = xgb.Get32(buf[b:]) b += 4 } - b = xgb.Pad(b) return v } @@ -513,7 +511,6 @@ func createSurfaceReply(buf []byte) *CreateSurfaceReply { v.PrivData[i] = xgb.Get32(buf[b:]) b += 4 } - b = xgb.Pad(b) return v } -- cgit v1.2.3-70-g09d2