// 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] = 3 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], uint32(Context)) b += 4 xgb.Put32(buf[b:], NumClientSpecs) b += 4 for i := 0; i < int(NumClientSpecs); i++ { xgb.Put32(buf[b:], uint32(ClientSpecs[i])) b += 4 } b = xgb.Pad(b) return buf }
// Write request to wire for QueryResourceBytes // queryResourceBytesRequest writes a QueryResourceBytes request to a byte slice. func queryResourceBytesRequest(c *xgb.Conn, Client uint32, NumSpecs uint32, Specs []ResourceIdSpec) []byte { size := xgb.Pad((12 + xgb.Pad((int(NumSpecs) * 8)))) b := 0 buf := make([]byte, size) c.ExtLock.RLock() buf[b] = c.Extensions["X-Resource"] c.ExtLock.RUnlock() 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:], Client) b += 4 xgb.Put32(buf[b:], NumSpecs) b += 4 b += ResourceIdSpecListBytes(buf[b:], Specs) return buf }
// Write request to wire for GetBuffersWithFormat // getBuffersWithFormatRequest writes a GetBuffersWithFormat request to a byte slice. func getBuffersWithFormatRequest(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Attachments []AttachFormat) []byte { size := xgb.Pad((12 + xgb.Pad((len(Attachments) * 8)))) b := 0 buf := make([]byte, size) c.ExtLock.RLock() buf[b] = c.Extensions["DRI2"] c.ExtLock.RUnlock() b += 1 buf[b] = 7 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], uint32(Drawable)) b += 4 xgb.Put32(buf[b:], Count) b += 4 b += AttachFormatListBytes(buf[b:], Attachments) return buf }
// Write request to wire for GetBuffers // getBuffersRequest writes a GetBuffers request to a byte slice. func getBuffersRequest(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Attachments []uint32) []byte { size := xgb.Pad((12 + xgb.Pad((len(Attachments) * 4)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["DRI2"] b += 1 buf[b] = 5 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], uint32(Drawable)) b += 4 xgb.Put32(buf[b:], Count) b += 4 for i := 0; i < int(len(Attachments)); i++ { xgb.Put32(buf[b:], Attachments[i]) b += 4 } b = xgb.Pad(b) return buf }
// Write request to wire for SetAttributes // setAttributesRequest writes a SetAttributes request to a byte slice. func setAttributesRequest(c *xgb.Conn, Drawable xproto.Drawable, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class byte, Depth byte, Visual xproto.Visualid, ValueMask uint32, ValueList []uint32) []byte { size := xgb.Pad((24 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) b := 0 buf := make([]byte, size) c.ExtLock.RLock() buf[b] = c.Extensions["MIT-SCREEN-SAVER"] c.ExtLock.RUnlock() b += 1 buf[b] = 3 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], uint32(Drawable)) b += 4 xgb.Put16(buf[b:], uint16(X)) b += 2 xgb.Put16(buf[b:], uint16(Y)) b += 2 xgb.Put16(buf[b:], Width) b += 2 xgb.Put16(buf[b:], Height) b += 2 xgb.Put16(buf[b:], BorderWidth) b += 2 buf[b] = Class b += 1 buf[b] = Depth b += 1 xgb.Put32(buf[b:], uint32(Visual)) b += 4 xgb.Put32(buf[b:], ValueMask) b += 4 for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { xgb.Put32(buf[b:], ValueList[i]) b += 4 } b = xgb.Pad(b) return buf }
// createContextReply reads a byte slice into a CreateContextReply value. func createContextReply(buf []byte) *CreateContextReply { v := new(CreateContextReply) b := 1 // skip reply determinant b += 1 // padding v.Sequence = xgb.Get16(buf[b:]) b += 2 v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 v.WidthActual = xgb.Get16(buf[b:]) b += 2 v.HeightActual = xgb.Get16(buf[b:]) b += 2 v.FlagsReturn = xgb.Get32(buf[b:]) b += 4 b += 20 // padding v.PrivData = make([]uint32, v.Length) for i := 0; i < int(v.Length); i++ { v.PrivData[i] = xgb.Get32(buf[b:]) b += 4 } b = xgb.Pad(b) return v }
// ClientIdValueListSize computes the size (bytes) of a list of ClientIdValue values. func ClientIdValueListSize(list []ClientIdValue) int { size := 0 for _, item := range list { size += (12 + xgb.Pad((int(item.Length) * 4))) } return size }
// Write request to wire for Send // sendRequest writes a Send request to a byte slice. func sendRequest(c *xgb.Conn, Event Event, DataType uint32) []byte { size := 104 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XEVIE"] b += 1 buf[b] = 3 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 { structBytes := Event.Bytes() copy(buf[b:], structBytes) b += xgb.Pad(len(structBytes)) } xgb.Put32(buf[b:], DataType) b += 4 b += 64 // padding return buf }
// getXIDListReply reads a byte slice into a GetXIDListReply value. func getXIDListReply(buf []byte) *GetXIDListReply { v := new(GetXIDListReply) b := 1 // skip reply determinant b += 1 // padding v.Sequence = xgb.Get16(buf[b:]) b += 2 v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 v.IdsLen = xgb.Get32(buf[b:]) b += 4 b += 20 // padding v.Ids = make([]uint32, v.IdsLen) for i := 0; i < int(v.IdsLen); i++ { v.Ids[i] = xgb.Get32(buf[b:]) b += 4 } b = xgb.Pad(b) return v }
// ResourceSizeValueListSize computes the size (bytes) of a list of ResourceSizeValue values. func ResourceSizeValueListSize(list []ResourceSizeValue) int { size := 0 for _, item := range list { size += (24 + xgb.Pad((int(item.NumCrossReferences) * 20))) } return size }
// 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 }
// openConnectionReply reads a byte slice into a OpenConnectionReply value. func openConnectionReply(buf []byte) *OpenConnectionReply { v := new(OpenConnectionReply) b := 1 // skip reply determinant b += 1 // padding v.Sequence = xgb.Get16(buf[b:]) b += 2 v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 v.SareaHandleLow = xgb.Get32(buf[b:]) b += 4 v.SareaHandleHigh = xgb.Get32(buf[b:]) b += 4 v.BusIdLen = xgb.Get32(buf[b:]) b += 4 b += 12 // padding { byteString := make([]byte, v.BusIdLen) copy(byteString[:v.BusIdLen], buf[b:]) v.BusId = string(byteString) b += xgb.Pad(int(v.BusIdLen)) } return v }
// getClientDriverNameReply reads a byte slice into a GetClientDriverNameReply value. func getClientDriverNameReply(buf []byte) *GetClientDriverNameReply { v := new(GetClientDriverNameReply) b := 1 // skip reply determinant b += 1 // padding v.Sequence = xgb.Get16(buf[b:]) b += 2 v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 v.ClientDriverMajorVersion = xgb.Get32(buf[b:]) b += 4 v.ClientDriverMinorVersion = xgb.Get32(buf[b:]) b += 4 v.ClientDriverPatchVersion = xgb.Get32(buf[b:]) b += 4 v.ClientDriverNameLen = xgb.Get32(buf[b:]) b += 4 b += 8 // padding { byteString := make([]byte, v.ClientDriverNameLen) copy(byteString[:v.ClientDriverNameLen], buf[b:]) v.ClientDriverName = string(byteString) b += xgb.Pad(int(v.ClientDriverNameLen)) } return v }
// ResourceIdSpecReadList reads a byte slice into a list of ResourceIdSpec values. func ResourceIdSpecReadList(buf []byte, dest []ResourceIdSpec) int { b := 0 for i := 0; i < len(dest); i++ { dest[i] = ResourceIdSpec{} b += ResourceIdSpecRead(buf[b:], &dest[i]) } return xgb.Pad(b) }
// RangeReadList reads a byte slice into a list of Range values. func RangeReadList(buf []byte, dest []Range) int { b := 0 for i := 0; i < len(dest); i++ { dest[i] = Range{} b += RangeRead(buf[b:], &dest[i]) } return xgb.Pad(b) }
// ResourceSizeValueReadList reads a byte slice into a list of ResourceSizeValue values. func ResourceSizeValueReadList(buf []byte, dest []ResourceSizeValue) int { b := 0 for i := 0; i < len(dest); i++ { dest[i] = ResourceSizeValue{} b += ResourceSizeValueRead(buf[b:], &dest[i]) } return xgb.Pad(b) }
// DrmClipRectReadList reads a byte slice into a list of DrmClipRect values. func DrmClipRectReadList(buf []byte, dest []DrmClipRect) int { b := 0 for i := 0; i < len(dest); i++ { dest[i] = DrmClipRect{} b += DrmClipRectRead(buf[b:], &dest[i]) } return xgb.Pad(b) }
// AttachFormatReadList reads a byte slice into a list of AttachFormat values. func AttachFormatReadList(buf []byte, dest []AttachFormat) int { b := 0 for i := 0; i < len(dest); i++ { dest[i] = AttachFormat{} b += AttachFormatRead(buf[b:], &dest[i]) } return xgb.Pad(b) }
// DRI2BufferReadList reads a byte slice into a list of DRI2Buffer values. func DRI2BufferReadList(buf []byte, dest []DRI2Buffer) int { b := 0 for i := 0; i < len(dest); i++ { dest[i] = DRI2Buffer{} b += DRI2BufferRead(buf[b:], &dest[i]) } return xgb.Pad(b) }
// ScreenInfoReadList reads a byte slice into a list of ScreenInfo values. func ScreenInfoReadList(buf []byte, dest []ScreenInfo) int { b := 0 for i := 0; i < len(dest); i++ { dest[i] = ScreenInfo{} b += ScreenInfoRead(buf[b:], &dest[i]) } return xgb.Pad(b) }
// ClientReadList reads a byte slice into a list of Client values. func ClientReadList(buf []byte, dest []Client) int { b := 0 for i := 0; i < len(dest); i++ { dest[i] = Client{} b += ClientRead(buf[b:], &dest[i]) } return xgb.Pad(b) }
// TypeReadList reads a byte slice into a list of Type values. func TypeReadList(buf []byte, dest []Type) int { b := 0 for i := 0; i < len(dest); i++ { dest[i] = Type{} b += TypeRead(buf[b:], &dest[i]) } return xgb.Pad(b) }
// Bytes writes a ExtRange value to a byte slice. func (v ExtRange) Bytes() []byte { buf := make([]byte, 6) b := 0 { structBytes := v.Major.Bytes() copy(buf[b:], structBytes) b += xgb.Pad(len(structBytes)) } { structBytes := v.Minor.Bytes() copy(buf[b:], structBytes) b += xgb.Pad(len(structBytes)) } return buf }
// ResourceSizeValueListBytes writes a list of ResourceSizeValue values to a byte slice. func ResourceSizeValueListBytes(buf []byte, list []ResourceSizeValue) int { b := 0 var structBytes []byte for _, item := range list { structBytes = item.Bytes() copy(buf[b:], structBytes) b += len(structBytes) } return xgb.Pad(b) }
// ExtRangeListBytes writes a list of ExtRange values to a byte slice. func ExtRangeListBytes(buf []byte, list []ExtRange) int { b := 0 var structBytes []byte for _, item := range list { structBytes = item.Bytes() copy(buf[b:], structBytes) b += xgb.Pad(len(structBytes)) } return b }
// DrmClipRectListBytes writes a list of DrmClipRect values to a byte slice. func DrmClipRectListBytes(buf []byte, list []DrmClipRect) int { b := 0 var structBytes []byte for _, item := range list { structBytes = item.Bytes() copy(buf[b:], structBytes) b += xgb.Pad(len(structBytes)) } return b }
// ScreenInfoListBytes writes a list of ScreenInfo values to a byte slice. func ScreenInfoListBytes(buf []byte, list []ScreenInfo) int { b := 0 var structBytes []byte for _, item := range list { structBytes = item.Bytes() copy(buf[b:], structBytes) b += len(structBytes) } return xgb.Pad(b) }
// ClientListBytes writes a list of Client values to a byte slice. func ClientListBytes(buf []byte, list []Client) int { b := 0 var structBytes []byte for _, item := range list { structBytes = item.Bytes() copy(buf[b:], structBytes) b += len(structBytes) } return xgb.Pad(b) }
// 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 { structBytes = item.Bytes() copy(buf[b:], structBytes) b += xgb.Pad(len(structBytes)) } return b }
// DRI2BufferListBytes writes a list of DRI2Buffer values to a byte slice. func DRI2BufferListBytes(buf []byte, list []DRI2Buffer) int { b := 0 var structBytes []byte for _, item := range list { structBytes = item.Bytes() copy(buf[b:], structBytes) b += len(structBytes) } return xgb.Pad(b) }