diff options
Diffstat (limited to 'nexgb/record')
| -rw-r--r-- | nexgb/record/record.go | 838 | 
1 files changed, 419 insertions, 419 deletions
| diff --git a/nexgb/record/record.go b/nexgb/record/record.go index 4bed730..2bbfe1c 100644 --- a/nexgb/record/record.go +++ b/nexgb/record/record.go @@ -2,7 +2,7 @@  package record  /* -	This file was generated by record.xml on Jun 5 2012 12:11:59am EDT. +	This file was generated by record.xml on Aug 11 2013 8:39:43pm EDT.  	This file is automatically generated. Edit at your peril!  */ @@ -40,100 +40,107 @@ func init() {  	xgb.NewExtErrorFuncs["RECORD"] = make(map[int]xgb.NewErrorFun)  } -// Skipping definition for base type 'Float' - -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' +// BadBadContext is the error number for a BadBadContext. +const BadBadContext = 0 -// Skipping definition for base type 'Int8' +type BadContextError struct { +	Sequence      uint16 +	NiceName      string +	InvalidRecord uint32 +} -// Skipping definition for base type 'Card16' +// BadContextErrorNew constructs a BadContextError value that implements xgb.Error from a byte slice. +func BadContextErrorNew(buf []byte) xgb.Error { +	v := BadContextError{} +	v.NiceName = "BadContext" -// Skipping definition for base type 'Char' +	b := 1 // skip error determinant +	b += 1 // don't read error number -// Skipping definition for base type 'Card32' +	v.Sequence = xgb.Get16(buf[b:]) +	b += 2 -// Skipping definition for base type 'Double' +	v.InvalidRecord = xgb.Get32(buf[b:]) +	b += 4 -// Skipping definition for base type 'Bool' +	return v +} -const ( -	HTypeFromServerTime     = 1 -	HTypeFromClientTime     = 2 -	HTypeFromClientSequence = 4 -) +// SequenceId returns the sequence id attached to the BadBadContext error. +// This is mostly used internally. +func (err BadContextError) SequenceId() uint16 { +	return err.Sequence +} -const ( -	CsCurrentClients = 1 -	CsFutureClients  = 2 -	CsAllClients     = 3 -) +// BadId returns the 'BadValue' number if one exists for the BadBadContext error. If no bad value exists, 0 is returned. +func (err BadContextError) BadId() uint32 { +	return 0 +} -type Context uint32 +// Error returns a rudimentary string representation of the BadBadContext error. -func NewContextId(c *xgb.Conn) (Context, error) { -	id, err := c.NewId() -	if err != nil { -		return 0, err -	} -	return Context(id), nil +func (err BadContextError) Error() string { +	fieldVals := make([]string, 0, 1) +	fieldVals = append(fieldVals, "NiceName: "+err.NiceName) +	fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) +	fieldVals = append(fieldVals, xgb.Sprintf("InvalidRecord: %d", err.InvalidRecord)) +	return "BadBadContext {" + xgb.StringsJoin(fieldVals, ", ") + "}"  } -type ElementHeader byte - -type ClientSpec uint32 +func init() { +	xgb.NewExtErrorFuncs["RECORD"][0] = BadContextErrorNew +} -type Range8 struct { -	First byte -	Last  byte +type ClientInfo struct { +	ClientResource ClientSpec +	NumRanges      uint32 +	Ranges         []Range // size: xgb.Pad((int(NumRanges) * 24))  } -// Range8Read reads a byte slice into a Range8 value. -func Range8Read(buf []byte, v *Range8) int { +// ClientInfoRead reads a byte slice into a ClientInfo value. +func ClientInfoRead(buf []byte, v *ClientInfo) int {  	b := 0 -	v.First = buf[b] -	b += 1 +	v.ClientResource = ClientSpec(xgb.Get32(buf[b:])) +	b += 4 -	v.Last = buf[b] -	b += 1 +	v.NumRanges = xgb.Get32(buf[b:]) +	b += 4 + +	v.Ranges = make([]Range, v.NumRanges) +	b += RangeReadList(buf[b:], v.Ranges)  	return b  } -// Range8ReadList reads a byte slice into a list of Range8 values. -func Range8ReadList(buf []byte, dest []Range8) int { +// ClientInfoReadList reads a byte slice into a list of ClientInfo values. +func ClientInfoReadList(buf []byte, dest []ClientInfo) int {  	b := 0  	for i := 0; i < len(dest); i++ { -		dest[i] = Range8{} -		b += Range8Read(buf[b:], &dest[i]) +		dest[i] = ClientInfo{} +		b += ClientInfoRead(buf[b:], &dest[i])  	}  	return xgb.Pad(b)  } -// Bytes writes a Range8 value to a byte slice. -func (v Range8) Bytes() []byte { -	buf := make([]byte, 2) +// Bytes writes a ClientInfo value to a byte slice. +func (v ClientInfo) Bytes() []byte { +	buf := make([]byte, (8 + xgb.Pad((int(v.NumRanges) * 24))))  	b := 0 -	buf[b] = v.First -	b += 1 +	xgb.Put32(buf[b:], uint32(v.ClientResource)) +	b += 4 -	buf[b] = v.Last -	b += 1 +	xgb.Put32(buf[b:], v.NumRanges) +	b += 4 + +	b += RangeListBytes(buf[b:], v.Ranges)  	return buf  } -// Range8ListBytes writes a list of Range8 values to a byte slice. -func Range8ListBytes(buf []byte, list []Range8) int { +// ClientInfoListBytes writes a list of ClientInfo values to a byte slice. +func ClientInfoListBytes(buf []byte, list []ClientInfo) int {  	b := 0  	var structBytes []byte  	for _, item := range list { @@ -144,59 +151,34 @@ func Range8ListBytes(buf []byte, list []Range8) int {  	return b  } -type Range16 struct { -	First uint16 -	Last  uint16 +// ClientInfoListSize computes the size (bytes) of a list of ClientInfo values. +func ClientInfoListSize(list []ClientInfo) int { +	size := 0 +	for _, item := range list { +		size += (8 + xgb.Pad((int(item.NumRanges) * 24))) +	} +	return size  } -// Range16Read reads a byte slice into a Range16 value. -func Range16Read(buf []byte, v *Range16) int { -	b := 0 - -	v.First = xgb.Get16(buf[b:]) -	b += 2 - -	v.Last = xgb.Get16(buf[b:]) -	b += 2 +type ClientSpec uint32 -	return b -} +type Context uint32 -// Range16ReadList reads a byte slice into a list of Range16 values. -func Range16ReadList(buf []byte, dest []Range16) int { -	b := 0 -	for i := 0; i < len(dest); i++ { -		dest[i] = Range16{} -		b += Range16Read(buf[b:], &dest[i]) +func NewContextId(c *xgb.Conn) (Context, error) { +	id, err := c.NewId() +	if err != nil { +		return 0, err  	} -	return xgb.Pad(b) +	return Context(id), nil  } -// Bytes writes a Range16 value to a byte slice. -func (v Range16) Bytes() []byte { -	buf := make([]byte, 4) -	b := 0 - -	xgb.Put16(buf[b:], v.First) -	b += 2 - -	xgb.Put16(buf[b:], v.Last) -	b += 2 - -	return buf -} +const ( +	CsCurrentClients = 1 +	CsFutureClients  = 2 +	CsAllClients     = 3 +) -// Range16ListBytes writes a list of Range16 values to a byte slice. -func Range16ListBytes(buf []byte, list []Range16) int { -	b := 0 -	var structBytes []byte -	for _, item := range list { -		structBytes = item.Bytes() -		copy(buf[b:], structBytes) -		b += xgb.Pad(len(structBytes)) -	} -	return b -} +type ElementHeader byte  type ExtRange struct {  	Major Range8 @@ -258,6 +240,12 @@ func ExtRangeListBytes(buf []byte, list []ExtRange) int {  	return b  } +const ( +	HTypeFromServerTime     = 1 +	HTypeFromClientTime     = 2 +	HTypeFromClientSequence = 4 +) +  type Range struct {  	CoreRequests    Range8  	CoreReplies     Range8 @@ -398,56 +386,50 @@ func RangeListBytes(buf []byte, list []Range) int {  	return b  } -type ClientInfo struct { -	ClientResource ClientSpec -	NumRanges      uint32 -	Ranges         []Range // size: xgb.Pad((int(NumRanges) * 24)) +type Range16 struct { +	First uint16 +	Last  uint16  } -// ClientInfoRead reads a byte slice into a ClientInfo value. -func ClientInfoRead(buf []byte, v *ClientInfo) int { +// Range16Read reads a byte slice into a Range16 value. +func Range16Read(buf []byte, v *Range16) int {  	b := 0 -	v.ClientResource = ClientSpec(xgb.Get32(buf[b:])) -	b += 4 - -	v.NumRanges = xgb.Get32(buf[b:]) -	b += 4 +	v.First = xgb.Get16(buf[b:]) +	b += 2 -	v.Ranges = make([]Range, v.NumRanges) -	b += RangeReadList(buf[b:], v.Ranges) +	v.Last = xgb.Get16(buf[b:]) +	b += 2  	return b  } -// ClientInfoReadList reads a byte slice into a list of ClientInfo values. -func ClientInfoReadList(buf []byte, dest []ClientInfo) int { +// Range16ReadList reads a byte slice into a list of Range16 values. +func Range16ReadList(buf []byte, dest []Range16) int {  	b := 0  	for i := 0; i < len(dest); i++ { -		dest[i] = ClientInfo{} -		b += ClientInfoRead(buf[b:], &dest[i]) +		dest[i] = Range16{} +		b += Range16Read(buf[b:], &dest[i])  	}  	return xgb.Pad(b)  } -// Bytes writes a ClientInfo value to a byte slice. -func (v ClientInfo) Bytes() []byte { -	buf := make([]byte, (8 + xgb.Pad((int(v.NumRanges) * 24)))) +// Bytes writes a Range16 value to a byte slice. +func (v Range16) Bytes() []byte { +	buf := make([]byte, 4)  	b := 0 -	xgb.Put32(buf[b:], uint32(v.ClientResource)) -	b += 4 - -	xgb.Put32(buf[b:], v.NumRanges) -	b += 4 +	xgb.Put16(buf[b:], v.First) +	b += 2 -	b += RangeListBytes(buf[b:], v.Ranges) +	xgb.Put16(buf[b:], v.Last) +	b += 2  	return buf  } -// ClientInfoListBytes writes a list of ClientInfo values to a byte slice. -func ClientInfoListBytes(buf []byte, list []ClientInfo) int { +// Range16ListBytes writes a list of Range16 values to a byte slice. +func Range16ListBytes(buf []byte, list []Range16) int {  	b := 0  	var structBytes []byte  	for _, item := range list { @@ -458,160 +440,83 @@ func ClientInfoListBytes(buf []byte, list []ClientInfo) int {  	return b  } -// ClientInfoListSize computes the size (bytes) of a list of ClientInfo values. -func ClientInfoListSize(list []ClientInfo) int { -	size := 0 -	for _, item := range list { -		size += (8 + xgb.Pad((int(item.NumRanges) * 24))) -	} -	return size -} - -// BadBadContext is the error number for a BadBadContext. -const BadBadContext = 0 - -type BadContextError struct { -	Sequence      uint16 -	NiceName      string -	InvalidRecord uint32 -} - -// BadContextErrorNew constructs a BadContextError value that implements xgb.Error from a byte slice. -func BadContextErrorNew(buf []byte) xgb.Error { -	v := BadContextError{} -	v.NiceName = "BadContext" - -	b := 1 // skip error determinant -	b += 1 // don't read error number - -	v.Sequence = xgb.Get16(buf[b:]) -	b += 2 - -	v.InvalidRecord = xgb.Get32(buf[b:]) -	b += 4 - -	return v +type Range8 struct { +	First byte +	Last  byte  } -// SequenceId returns the sequence id attached to the BadBadContext error. -// This is mostly used internally. -func (err BadContextError) SequenceId() uint16 { -	return err.Sequence -} +// Range8Read reads a byte slice into a Range8 value. +func Range8Read(buf []byte, v *Range8) int { +	b := 0 -// BadId returns the 'BadValue' number if one exists for the BadBadContext error. If no bad value exists, 0 is returned. -func (err BadContextError) BadId() uint32 { -	return 0 -} +	v.First = buf[b] +	b += 1 -// Error returns a rudimentary string representation of the BadBadContext error. +	v.Last = buf[b] +	b += 1 -func (err BadContextError) Error() string { -	fieldVals := make([]string, 0, 1) -	fieldVals = append(fieldVals, "NiceName: "+err.NiceName) -	fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) -	fieldVals = append(fieldVals, xgb.Sprintf("InvalidRecord: %d", err.InvalidRecord)) -	return "BadBadContext {" + xgb.StringsJoin(fieldVals, ", ") + "}" +	return b  } -func init() { -	xgb.NewExtErrorFuncs["RECORD"][0] = BadContextErrorNew +// Range8ReadList reads a byte slice into a list of Range8 values. +func Range8ReadList(buf []byte, dest []Range8) int { +	b := 0 +	for i := 0; i < len(dest); i++ { +		dest[i] = Range8{} +		b += Range8Read(buf[b:], &dest[i]) +	} +	return xgb.Pad(b)  } -// QueryVersionCookie is a cookie used only for QueryVersion requests. -type QueryVersionCookie struct { -	*xgb.Cookie -} +// Bytes writes a Range8 value to a byte slice. +func (v Range8) Bytes() []byte { +	buf := make([]byte, 2) +	b := 0 -// QueryVersion sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() -func QueryVersion(c *xgb.Conn, MajorVersion uint16, MinorVersion uint16) QueryVersionCookie { -	if _, ok := c.Extensions["RECORD"]; !ok { -		panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") -	} -	cookie := c.NewCookie(true, true) -	c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) -	return QueryVersionCookie{cookie} -} +	buf[b] = v.First +	b += 1 -// QueryVersionUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryVersionUnchecked(c *xgb.Conn, MajorVersion uint16, MinorVersion uint16) QueryVersionCookie { -	if _, ok := c.Extensions["RECORD"]; !ok { -		panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") -	} -	cookie := c.NewCookie(false, true) -	c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) -	return QueryVersionCookie{cookie} -} +	buf[b] = v.Last +	b += 1 -// QueryVersionReply represents the data returned from a QueryVersion request. -type QueryVersionReply struct { -	Sequence uint16 // sequence number of the request for this reply -	Length   uint32 // number of bytes in this reply -	// padding: 1 bytes -	MajorVersion uint16 -	MinorVersion uint16 +	return buf  } -// Reply blocks and returns the reply data for a QueryVersion request. -func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { -	buf, err := cook.Cookie.Reply() -	if err != nil { -		return nil, err -	} -	if buf == nil { -		return nil, nil +// Range8ListBytes writes a list of Range8 values to a byte slice. +func Range8ListBytes(buf []byte, list []Range8) int { +	b := 0 +	var structBytes []byte +	for _, item := range list { +		structBytes = item.Bytes() +		copy(buf[b:], structBytes) +		b += xgb.Pad(len(structBytes))  	} -	return queryVersionReply(buf), nil +	return b  } -// queryVersionReply reads a byte slice into a QueryVersionReply value. -func queryVersionReply(buf []byte) *QueryVersionReply { -	v := new(QueryVersionReply) -	b := 1 // skip reply determinant - -	b += 1 // padding - -	v.Sequence = xgb.Get16(buf[b:]) -	b += 2 +// Skipping definition for base type 'Bool' -	v.Length = xgb.Get32(buf[b:]) // 4-byte units -	b += 4 +// Skipping definition for base type 'Byte' -	v.MajorVersion = xgb.Get16(buf[b:]) -	b += 2 +// Skipping definition for base type 'Card8' -	v.MinorVersion = xgb.Get16(buf[b:]) -	b += 2 +// Skipping definition for base type 'Char' -	return v -} +// Skipping definition for base type 'Void' -// Write request to wire for QueryVersion -// queryVersionRequest writes a QueryVersion request to a byte slice. -func queryVersionRequest(c *xgb.Conn, MajorVersion uint16, MinorVersion uint16) []byte { -	size := 8 -	b := 0 -	buf := make([]byte, size) +// Skipping definition for base type 'Double' -	buf[b] = c.Extensions["RECORD"] -	b += 1 +// Skipping definition for base type 'Float' -	buf[b] = 0 // request opcode -	b += 1 +// Skipping definition for base type 'Int16' -	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units -	b += 2 +// Skipping definition for base type 'Int32' -	xgb.Put16(buf[b:], MajorVersion) -	b += 2 +// Skipping definition for base type 'Int8' -	xgb.Put16(buf[b:], MinorVersion) -	b += 2 +// Skipping definition for base type 'Card16' -	return buf -} +// Skipping definition for base type 'Card32'  // CreateContextCookie is a cookie used only for CreateContext requests.  type CreateContextCookie struct { @@ -687,50 +592,50 @@ func createContextRequest(c *xgb.Conn, Context Context, ElementHeader ElementHea  	return buf  } -// RegisterClientsCookie is a cookie used only for RegisterClients requests. -type RegisterClientsCookie struct { +// DisableContextCookie is a cookie used only for DisableContext requests. +type DisableContextCookie struct {  	*xgb.Cookie  } -// RegisterClients sends an unchecked request. +// DisableContext sends an unchecked request.  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func RegisterClients(c *xgb.Conn, Context Context, ElementHeader ElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []ClientSpec, Ranges []Range) RegisterClientsCookie { +func DisableContext(c *xgb.Conn, Context Context) DisableContextCookie {  	if _, ok := c.Extensions["RECORD"]; !ok { -		panic("Cannot issue request 'RegisterClients' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") +		panic("Cannot issue request 'DisableContext' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.")  	}  	cookie := c.NewCookie(false, false) -	c.NewRequest(registerClientsRequest(c, Context, ElementHeader, NumClientSpecs, NumRanges, ClientSpecs, Ranges), cookie) -	return RegisterClientsCookie{cookie} +	c.NewRequest(disableContextRequest(c, Context), cookie) +	return DisableContextCookie{cookie}  } -// RegisterClientsChecked sends a checked request. -// If an error occurs, it can be retrieved using RegisterClientsCookie.Check() -func RegisterClientsChecked(c *xgb.Conn, Context Context, ElementHeader ElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []ClientSpec, Ranges []Range) RegisterClientsCookie { +// DisableContextChecked sends a checked request. +// If an error occurs, it can be retrieved using DisableContextCookie.Check() +func DisableContextChecked(c *xgb.Conn, Context Context) DisableContextCookie {  	if _, ok := c.Extensions["RECORD"]; !ok { -		panic("Cannot issue request 'RegisterClients' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") +		panic("Cannot issue request 'DisableContext' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.")  	}  	cookie := c.NewCookie(true, false) -	c.NewRequest(registerClientsRequest(c, Context, ElementHeader, NumClientSpecs, NumRanges, ClientSpecs, Ranges), cookie) -	return RegisterClientsCookie{cookie} +	c.NewRequest(disableContextRequest(c, Context), cookie) +	return DisableContextCookie{cookie}  }  // Check returns an error if one occurred for checked requests that are not expecting a reply.  // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook RegisterClientsCookie) Check() error { +func (cook DisableContextCookie) Check() error {  	return cook.Cookie.Check()  } -// Write request to wire for RegisterClients -// registerClientsRequest writes a RegisterClients request to a byte slice. -func registerClientsRequest(c *xgb.Conn, Context Context, ElementHeader ElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []ClientSpec, Ranges []Range) []byte { -	size := xgb.Pad(((20 + xgb.Pad((int(NumClientSpecs) * 4))) + xgb.Pad((int(NumRanges) * 24)))) +// Write request to wire for DisableContext +// disableContextRequest writes a DisableContext request to a byte slice. +func disableContextRequest(c *xgb.Conn, Context Context) []byte { +	size := 8  	b := 0  	buf := make([]byte, size)  	buf[b] = c.Extensions["RECORD"]  	b += 1 -	buf[b] = 2 // request opcode +	buf[b] = 6 // request opcode  	b += 1  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -739,72 +644,173 @@ func registerClientsRequest(c *xgb.Conn, Context Context, ElementHeader ElementH  	xgb.Put32(buf[b:], uint32(Context))  	b += 4 -	buf[b] = byte(ElementHeader) +	return buf +} + +// EnableContextCookie is a cookie used only for EnableContext requests. +type EnableContextCookie struct { +	*xgb.Cookie +} + +// EnableContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling EnableContextCookie.Reply() +func EnableContext(c *xgb.Conn, Context Context) EnableContextCookie { +	if _, ok := c.Extensions["RECORD"]; !ok { +		panic("Cannot issue request 'EnableContext' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") +	} +	cookie := c.NewCookie(true, true) +	c.NewRequest(enableContextRequest(c, Context), cookie) +	return EnableContextCookie{cookie} +} + +// EnableContextUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func EnableContextUnchecked(c *xgb.Conn, Context Context) EnableContextCookie { +	if _, ok := c.Extensions["RECORD"]; !ok { +		panic("Cannot issue request 'EnableContext' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") +	} +	cookie := c.NewCookie(false, true) +	c.NewRequest(enableContextRequest(c, Context), cookie) +	return EnableContextCookie{cookie} +} + +// EnableContextReply represents the data returned from a EnableContext request. +type EnableContextReply struct { +	Sequence      uint16 // sequence number of the request for this reply +	Length        uint32 // number of bytes in this reply +	Category      byte +	ElementHeader ElementHeader +	ClientSwapped bool +	// padding: 2 bytes +	XidBase        uint32 +	ServerTime     uint32 +	RecSequenceNum uint32 +	// padding: 8 bytes +	Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) +} + +// Reply blocks and returns the reply data for a EnableContext request. +func (cook EnableContextCookie) Reply() (*EnableContextReply, error) { +	buf, err := cook.Cookie.Reply() +	if err != nil { +		return nil, err +	} +	if buf == nil { +		return nil, nil +	} +	return enableContextReply(buf), nil +} + +// enableContextReply reads a byte slice into a EnableContextReply value. +func enableContextReply(buf []byte) *EnableContextReply { +	v := new(EnableContextReply) +	b := 1 // skip reply determinant + +	v.Category = buf[b]  	b += 1 -	b += 3 // padding +	v.Sequence = xgb.Get16(buf[b:]) +	b += 2 -	xgb.Put32(buf[b:], NumClientSpecs) +	v.Length = xgb.Get32(buf[b:]) // 4-byte units  	b += 4 -	xgb.Put32(buf[b:], NumRanges) -	b += 4 +	v.ElementHeader = ElementHeader(buf[b]) +	b += 1 -	for i := 0; i < int(NumClientSpecs); i++ { -		xgb.Put32(buf[b:], uint32(ClientSpecs[i])) -		b += 4 +	if buf[b] == 1 { +		v.ClientSwapped = true +	} else { +		v.ClientSwapped = false  	} -	b = xgb.Pad(b) +	b += 1 -	b += RangeListBytes(buf[b:], Ranges) +	b += 2 // padding + +	v.XidBase = xgb.Get32(buf[b:]) +	b += 4 + +	v.ServerTime = xgb.Get32(buf[b:]) +	b += 4 + +	v.RecSequenceNum = xgb.Get32(buf[b:]) +	b += 4 + +	b += 8 // padding + +	v.Data = make([]byte, (int(v.Length) * 4)) +	copy(v.Data[:(int(v.Length)*4)], buf[b:]) +	b += xgb.Pad(int((int(v.Length) * 4))) + +	return v +} + +// Write request to wire for EnableContext +// enableContextRequest writes a EnableContext request to a byte slice. +func enableContextRequest(c *xgb.Conn, Context Context) []byte { +	size := 8 +	b := 0 +	buf := make([]byte, size) + +	buf[b] = c.Extensions["RECORD"] +	b += 1 + +	buf[b] = 5 // request opcode +	b += 1 + +	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units +	b += 2 + +	xgb.Put32(buf[b:], uint32(Context)) +	b += 4  	return buf  } -// UnregisterClientsCookie is a cookie used only for UnregisterClients requests. -type UnregisterClientsCookie struct { +// FreeContextCookie is a cookie used only for FreeContext requests. +type FreeContextCookie struct {  	*xgb.Cookie  } -// UnregisterClients sends an unchecked request. +// FreeContext sends an unchecked request.  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func UnregisterClients(c *xgb.Conn, Context Context, NumClientSpecs uint32, ClientSpecs []ClientSpec) UnregisterClientsCookie { +func FreeContext(c *xgb.Conn, Context Context) FreeContextCookie {  	if _, ok := c.Extensions["RECORD"]; !ok { -		panic("Cannot issue request 'UnregisterClients' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") +		panic("Cannot issue request 'FreeContext' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.")  	}  	cookie := c.NewCookie(false, false) -	c.NewRequest(unregisterClientsRequest(c, Context, NumClientSpecs, ClientSpecs), cookie) -	return UnregisterClientsCookie{cookie} +	c.NewRequest(freeContextRequest(c, Context), cookie) +	return FreeContextCookie{cookie}  } -// UnregisterClientsChecked sends a checked request. -// If an error occurs, it can be retrieved using UnregisterClientsCookie.Check() -func UnregisterClientsChecked(c *xgb.Conn, Context Context, NumClientSpecs uint32, ClientSpecs []ClientSpec) UnregisterClientsCookie { +// FreeContextChecked sends a checked request. +// If an error occurs, it can be retrieved using FreeContextCookie.Check() +func FreeContextChecked(c *xgb.Conn, Context Context) FreeContextCookie {  	if _, ok := c.Extensions["RECORD"]; !ok { -		panic("Cannot issue request 'UnregisterClients' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") +		panic("Cannot issue request 'FreeContext' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.")  	}  	cookie := c.NewCookie(true, false) -	c.NewRequest(unregisterClientsRequest(c, Context, NumClientSpecs, ClientSpecs), cookie) -	return UnregisterClientsCookie{cookie} +	c.NewRequest(freeContextRequest(c, Context), cookie) +	return FreeContextCookie{cookie}  }  // Check returns an error if one occurred for checked requests that are not expecting a reply.  // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook UnregisterClientsCookie) Check() error { +func (cook FreeContextCookie) Check() error {  	return cook.Cookie.Check()  } -// Write request to wire for UnregisterClients -// unregisterClientsRequest writes a UnregisterClients request to a byte slice. -func unregisterClientsRequest(c *xgb.Conn, Context Context, NumClientSpecs uint32, ClientSpecs []ClientSpec) []byte { -	size := xgb.Pad((12 + xgb.Pad((int(NumClientSpecs) * 4)))) +// Write request to wire for FreeContext +// freeContextRequest writes a FreeContext request to a byte slice. +func freeContextRequest(c *xgb.Conn, Context Context) []byte { +	size := 8  	b := 0  	buf := make([]byte, size)  	buf[b] = c.Extensions["RECORD"]  	b += 1 -	buf[b] = 3 // request opcode +	buf[b] = 7 // request opcode  	b += 1  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -813,15 +819,6 @@ func unregisterClientsRequest(c *xgb.Conn, Context Context, NumClientSpecs uint3  	xgb.Put32(buf[b:], uint32(Context))  	b += 4 -	xgb.Put32(buf[b:], NumClientSpecs) -	b += 4 - -	for i := 0; i < int(NumClientSpecs); i++ { -		xgb.Put32(buf[b:], uint32(ClientSpecs[i])) -		b += 4 -	} -	b = xgb.Pad(b) -  	return buf  } @@ -932,50 +929,44 @@ func getContextRequest(c *xgb.Conn, Context Context) []byte {  	return buf  } -// EnableContextCookie is a cookie used only for EnableContext requests. -type EnableContextCookie struct { +// QueryVersionCookie is a cookie used only for QueryVersion requests. +type QueryVersionCookie struct {  	*xgb.Cookie  } -// EnableContext sends a checked request. -// If an error occurs, it will be returned with the reply by calling EnableContextCookie.Reply() -func EnableContext(c *xgb.Conn, Context Context) EnableContextCookie { +// QueryVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() +func QueryVersion(c *xgb.Conn, MajorVersion uint16, MinorVersion uint16) QueryVersionCookie {  	if _, ok := c.Extensions["RECORD"]; !ok { -		panic("Cannot issue request 'EnableContext' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") +		panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.")  	}  	cookie := c.NewCookie(true, true) -	c.NewRequest(enableContextRequest(c, Context), cookie) -	return EnableContextCookie{cookie} +	c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) +	return QueryVersionCookie{cookie}  } -// EnableContextUnchecked sends an unchecked request. +// QueryVersionUnchecked sends an unchecked request.  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func EnableContextUnchecked(c *xgb.Conn, Context Context) EnableContextCookie { +func QueryVersionUnchecked(c *xgb.Conn, MajorVersion uint16, MinorVersion uint16) QueryVersionCookie {  	if _, ok := c.Extensions["RECORD"]; !ok { -		panic("Cannot issue request 'EnableContext' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") +		panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.")  	}  	cookie := c.NewCookie(false, true) -	c.NewRequest(enableContextRequest(c, Context), cookie) -	return EnableContextCookie{cookie} +	c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) +	return QueryVersionCookie{cookie}  } -// EnableContextReply represents the data returned from a EnableContext request. -type EnableContextReply struct { -	Sequence      uint16 // sequence number of the request for this reply -	Length        uint32 // number of bytes in this reply -	Category      byte -	ElementHeader ElementHeader -	ClientSwapped bool -	// padding: 2 bytes -	XidBase        uint32 -	ServerTime     uint32 -	RecSequenceNum uint32 -	// padding: 8 bytes -	Data []byte // size: xgb.Pad(((int(Length) * 4) * 1)) +// QueryVersionReply represents the data returned from a QueryVersion request. +type QueryVersionReply struct { +	Sequence uint16 // sequence number of the request for this reply +	Length   uint32 // number of bytes in this reply +	// padding: 1 bytes +	MajorVersion uint16 +	MinorVersion uint16  } -// Reply blocks and returns the reply data for a EnableContext request. -func (cook EnableContextCookie) Reply() (*EnableContextReply, error) { +// Reply blocks and returns the reply data for a QueryVersion request. +func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) {  	buf, err := cook.Cookie.Reply()  	if err != nil {  		return nil, err @@ -983,16 +974,15 @@ func (cook EnableContextCookie) Reply() (*EnableContextReply, error) {  	if buf == nil {  		return nil, nil  	} -	return enableContextReply(buf), nil +	return queryVersionReply(buf), nil  } -// enableContextReply reads a byte slice into a EnableContextReply value. -func enableContextReply(buf []byte) *EnableContextReply { -	v := new(EnableContextReply) +// queryVersionReply reads a byte slice into a QueryVersionReply value. +func queryVersionReply(buf []byte) *QueryVersionReply { +	v := new(QueryVersionReply)  	b := 1 // skip reply determinant -	v.Category = buf[b] -	b += 1 +	b += 1 // padding  	v.Sequence = xgb.Get16(buf[b:])  	b += 2 @@ -1000,39 +990,18 @@ func enableContextReply(buf []byte) *EnableContextReply {  	v.Length = xgb.Get32(buf[b:]) // 4-byte units  	b += 4 -	v.ElementHeader = ElementHeader(buf[b]) -	b += 1 - -	if buf[b] == 1 { -		v.ClientSwapped = true -	} else { -		v.ClientSwapped = false -	} -	b += 1 - -	b += 2 // padding - -	v.XidBase = xgb.Get32(buf[b:]) -	b += 4 - -	v.ServerTime = xgb.Get32(buf[b:]) -	b += 4 - -	v.RecSequenceNum = xgb.Get32(buf[b:]) -	b += 4 - -	b += 8 // padding +	v.MajorVersion = xgb.Get16(buf[b:]) +	b += 2 -	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))) +	v.MinorVersion = xgb.Get16(buf[b:]) +	b += 2  	return v  } -// Write request to wire for EnableContext -// enableContextRequest writes a EnableContext request to a byte slice. -func enableContextRequest(c *xgb.Conn, Context Context) []byte { +// Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. +func queryVersionRequest(c *xgb.Conn, MajorVersion uint16, MinorVersion uint16) []byte {  	size := 8  	b := 0  	buf := make([]byte, size) @@ -1040,62 +1009,65 @@ func enableContextRequest(c *xgb.Conn, Context Context) []byte {  	buf[b] = c.Extensions["RECORD"]  	b += 1 -	buf[b] = 5 // request opcode +	buf[b] = 0 // request opcode  	b += 1  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units  	b += 2 -	xgb.Put32(buf[b:], uint32(Context)) -	b += 4 +	xgb.Put16(buf[b:], MajorVersion) +	b += 2 + +	xgb.Put16(buf[b:], MinorVersion) +	b += 2  	return buf  } -// DisableContextCookie is a cookie used only for DisableContext requests. -type DisableContextCookie struct { +// RegisterClientsCookie is a cookie used only for RegisterClients requests. +type RegisterClientsCookie struct {  	*xgb.Cookie  } -// DisableContext sends an unchecked request. +// RegisterClients sends an unchecked request.  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func DisableContext(c *xgb.Conn, Context Context) DisableContextCookie { +func RegisterClients(c *xgb.Conn, Context Context, ElementHeader ElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []ClientSpec, Ranges []Range) RegisterClientsCookie {  	if _, ok := c.Extensions["RECORD"]; !ok { -		panic("Cannot issue request 'DisableContext' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") +		panic("Cannot issue request 'RegisterClients' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.")  	}  	cookie := c.NewCookie(false, false) -	c.NewRequest(disableContextRequest(c, Context), cookie) -	return DisableContextCookie{cookie} +	c.NewRequest(registerClientsRequest(c, Context, ElementHeader, NumClientSpecs, NumRanges, ClientSpecs, Ranges), cookie) +	return RegisterClientsCookie{cookie}  } -// DisableContextChecked sends a checked request. -// If an error occurs, it can be retrieved using DisableContextCookie.Check() -func DisableContextChecked(c *xgb.Conn, Context Context) DisableContextCookie { +// RegisterClientsChecked sends a checked request. +// If an error occurs, it can be retrieved using RegisterClientsCookie.Check() +func RegisterClientsChecked(c *xgb.Conn, Context Context, ElementHeader ElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []ClientSpec, Ranges []Range) RegisterClientsCookie {  	if _, ok := c.Extensions["RECORD"]; !ok { -		panic("Cannot issue request 'DisableContext' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") +		panic("Cannot issue request 'RegisterClients' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.")  	}  	cookie := c.NewCookie(true, false) -	c.NewRequest(disableContextRequest(c, Context), cookie) -	return DisableContextCookie{cookie} +	c.NewRequest(registerClientsRequest(c, Context, ElementHeader, NumClientSpecs, NumRanges, ClientSpecs, Ranges), cookie) +	return RegisterClientsCookie{cookie}  }  // Check returns an error if one occurred for checked requests that are not expecting a reply.  // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook DisableContextCookie) Check() error { +func (cook RegisterClientsCookie) Check() error {  	return cook.Cookie.Check()  } -// Write request to wire for DisableContext -// disableContextRequest writes a DisableContext request to a byte slice. -func disableContextRequest(c *xgb.Conn, Context Context) []byte { -	size := 8 +// Write request to wire for RegisterClients +// registerClientsRequest writes a RegisterClients request to a byte slice. +func registerClientsRequest(c *xgb.Conn, Context Context, ElementHeader ElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []ClientSpec, Ranges []Range) []byte { +	size := xgb.Pad(((20 + xgb.Pad((int(NumClientSpecs) * 4))) + xgb.Pad((int(NumRanges) * 24))))  	b := 0  	buf := make([]byte, size)  	buf[b] = c.Extensions["RECORD"]  	b += 1 -	buf[b] = 6 // request opcode +	buf[b] = 2 // request opcode  	b += 1  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1104,53 +1076,72 @@ func disableContextRequest(c *xgb.Conn, Context Context) []byte {  	xgb.Put32(buf[b:], uint32(Context))  	b += 4 +	buf[b] = byte(ElementHeader) +	b += 1 + +	b += 3 // padding + +	xgb.Put32(buf[b:], NumClientSpecs) +	b += 4 + +	xgb.Put32(buf[b:], NumRanges) +	b += 4 + +	for i := 0; i < int(NumClientSpecs); i++ { +		xgb.Put32(buf[b:], uint32(ClientSpecs[i])) +		b += 4 +	} +	b = xgb.Pad(b) + +	b += RangeListBytes(buf[b:], Ranges) +  	return buf  } -// FreeContextCookie is a cookie used only for FreeContext requests. -type FreeContextCookie struct { +// UnregisterClientsCookie is a cookie used only for UnregisterClients requests. +type UnregisterClientsCookie struct {  	*xgb.Cookie  } -// FreeContext sends an unchecked request. +// UnregisterClients sends an unchecked request.  // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func FreeContext(c *xgb.Conn, Context Context) FreeContextCookie { +func UnregisterClients(c *xgb.Conn, Context Context, NumClientSpecs uint32, ClientSpecs []ClientSpec) UnregisterClientsCookie {  	if _, ok := c.Extensions["RECORD"]; !ok { -		panic("Cannot issue request 'FreeContext' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") +		panic("Cannot issue request 'UnregisterClients' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.")  	}  	cookie := c.NewCookie(false, false) -	c.NewRequest(freeContextRequest(c, Context), cookie) -	return FreeContextCookie{cookie} +	c.NewRequest(unregisterClientsRequest(c, Context, NumClientSpecs, ClientSpecs), cookie) +	return UnregisterClientsCookie{cookie}  } -// FreeContextChecked sends a checked request. -// If an error occurs, it can be retrieved using FreeContextCookie.Check() -func FreeContextChecked(c *xgb.Conn, Context Context) FreeContextCookie { +// UnregisterClientsChecked sends a checked request. +// If an error occurs, it can be retrieved using UnregisterClientsCookie.Check() +func UnregisterClientsChecked(c *xgb.Conn, Context Context, NumClientSpecs uint32, ClientSpecs []ClientSpec) UnregisterClientsCookie {  	if _, ok := c.Extensions["RECORD"]; !ok { -		panic("Cannot issue request 'FreeContext' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.") +		panic("Cannot issue request 'UnregisterClients' using the uninitialized extension 'RECORD'. record.Init(connObj) must be called first.")  	}  	cookie := c.NewCookie(true, false) -	c.NewRequest(freeContextRequest(c, Context), cookie) -	return FreeContextCookie{cookie} +	c.NewRequest(unregisterClientsRequest(c, Context, NumClientSpecs, ClientSpecs), cookie) +	return UnregisterClientsCookie{cookie}  }  // Check returns an error if one occurred for checked requests that are not expecting a reply.  // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook FreeContextCookie) Check() error { +func (cook UnregisterClientsCookie) Check() error {  	return cook.Cookie.Check()  } -// Write request to wire for FreeContext -// freeContextRequest writes a FreeContext request to a byte slice. -func freeContextRequest(c *xgb.Conn, Context Context) []byte { -	size := 8 +// Write request to wire for UnregisterClients +// unregisterClientsRequest writes a UnregisterClients request to a byte slice. +func unregisterClientsRequest(c *xgb.Conn, Context Context, NumClientSpecs uint32, ClientSpecs []ClientSpec) []byte { +	size := xgb.Pad((12 + xgb.Pad((int(NumClientSpecs) * 4))))  	b := 0  	buf := make([]byte, size)  	buf[b] = c.Extensions["RECORD"]  	b += 1 -	buf[b] = 7 // request opcode +	buf[b] = 3 // request opcode  	b += 1  	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1159,5 +1150,14 @@ func freeContextRequest(c *xgb.Conn, Context Context) []byte {  	xgb.Put32(buf[b:], uint32(Context))  	b += 4 +	xgb.Put32(buf[b:], NumClientSpecs) +	b += 4 + +	for i := 0; i < int(NumClientSpecs); i++ { +		xgb.Put32(buf[b:], uint32(ClientSpecs[i])) +		b += 4 +	} +	b = xgb.Pad(b) +  	return buf  } | 
