// Write request to wire for WaitSBC // waitSBCRequest writes a WaitSBC request to a byte slice. func waitSBCRequest(c *xgb.Conn, Drawable xproto.Drawable, TargetSbcHi uint32, TargetSbcLo uint32) []byte { size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["DRI2"] b += 1 buf[b] = 11 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], uint32(Drawable)) b += 4 xgb.Put32(buf[b:], TargetSbcHi) b += 4 xgb.Put32(buf[b:], TargetSbcLo) b += 4 return buf }
// Write request to wire for Create // createRequest writes a Create request to a byte slice. func createRequest(c *xgb.Conn, Damage Damage, Drawable xproto.Drawable, Level byte) []byte { size := 16 b := 0 buf := make([]byte, size) c.ExtLock.RLock() buf[b] = c.Extensions["DAMAGE"] c.ExtLock.RUnlock() b += 1 buf[b] = 1 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], uint32(Damage)) b += 4 xgb.Put32(buf[b:], uint32(Drawable)) b += 4 buf[b] = Level b += 1 b += 3 // padding return buf }
// Write request to wire for Subtract // subtractRequest writes a Subtract request to a byte slice. func subtractRequest(c *xgb.Conn, Damage Damage, Repair xfixes.Region, Parts xfixes.Region) []byte { size := 16 b := 0 buf := make([]byte, size) c.ExtLock.RLock() buf[b] = c.Extensions["DAMAGE"] 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(Damage)) b += 4 xgb.Put32(buf[b:], uint32(Repair)) b += 4 xgb.Put32(buf[b:], uint32(Parts)) b += 4 return buf }
// Write request to wire for CreateContext // createContextRequest writes a CreateContext request to a byte slice. func createContextRequest(c *xgb.Conn, ContextId Context, PortId xv.Port, SurfaceId Surface, Width uint16, Height uint16, Flags uint32) []byte { size := 24 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XVIDEO-MOTIONCOMPENSATION"] b += 1 buf[b] = 2 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], uint32(ContextId)) b += 4 xgb.Put32(buf[b:], uint32(PortId)) b += 4 xgb.Put32(buf[b:], uint32(SurfaceId)) b += 4 xgb.Put16(buf[b:], Width) b += 2 xgb.Put16(buf[b:], Height) b += 2 xgb.Put32(buf[b:], Flags) b += 4 return buf }
// 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 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 }
// Bytes writes a SurfaceInfo value to a byte slice. func (v SurfaceInfo) Bytes() []byte { buf := make([]byte, 24) b := 0 xgb.Put32(buf[b:], uint32(v.Id)) b += 4 xgb.Put16(buf[b:], v.ChromaFormat) b += 2 xgb.Put16(buf[b:], v.Pad0) b += 2 xgb.Put16(buf[b:], v.MaxWidth) b += 2 xgb.Put16(buf[b:], v.MaxHeight) b += 2 xgb.Put16(buf[b:], v.SubpictureMaxWidth) b += 2 xgb.Put16(buf[b:], v.SubpictureMaxHeight) b += 2 xgb.Put32(buf[b:], v.McType) b += 4 xgb.Put32(buf[b:], v.Flags) b += 4 return buf }
// Write request to wire for CreateSubpicture // createSubpictureRequest writes a CreateSubpicture request to a byte slice. func createSubpictureRequest(c *xgb.Conn, SubpictureId Subpicture, Context Context, XvimageId uint32, Width uint16, Height uint16) []byte { size := 20 b := 0 buf := make([]byte, size) c.ExtLock.RLock() buf[b] = c.Extensions["XVideo-MotionCompensation"] c.ExtLock.RUnlock() b += 1 buf[b] = 6 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], uint32(SubpictureId)) b += 4 xgb.Put32(buf[b:], uint32(Context)) b += 4 xgb.Put32(buf[b:], XvimageId) b += 4 xgb.Put16(buf[b:], Width) b += 2 xgb.Put16(buf[b:], Height) b += 2 return buf }
// Write request to wire for CreateContext // createContextRequest writes a CreateContext request to a byte slice. func createContextRequest(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) []byte { size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFREE86-DRI"] b += 1 buf[b] = 5 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], Screen) b += 4 xgb.Put32(buf[b:], Visual) b += 4 xgb.Put32(buf[b:], Context) b += 4 return buf }
// Bytes writes a CompletionEvent value to a byte slice. func (v CompletionEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 // write event number buf[b] = 0 b += 1 b += 1 // padding b += 2 // skip sequence number xgb.Put32(buf[b:], uint32(v.Drawable)) b += 4 xgb.Put16(buf[b:], v.MinorEvent) b += 2 buf[b] = v.MajorEvent b += 1 b += 1 // padding xgb.Put32(buf[b:], uint32(v.Shmseg)) b += 4 xgb.Put32(buf[b:], v.Offset) b += 4 return buf }
// Write request to wire for CopyRegion // copyRegionRequest writes a CopyRegion request to a byte slice. func copyRegionRequest(c *xgb.Conn, Drawable xproto.Drawable, Region uint32, Dest uint32, Src uint32) []byte { size := 20 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["DRI2"] b += 1 buf[b] = 6 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], uint32(Drawable)) b += 4 xgb.Put32(buf[b:], Region) b += 4 xgb.Put32(buf[b:], Dest) b += 4 xgb.Put32(buf[b:], Src) b += 4 return buf }
// Write request to wire for CreateSubpicture // createSubpictureRequest writes a CreateSubpicture request to a byte slice. func createSubpictureRequest(c *xgb.Conn, SubpictureId Subpicture, Context Context, XvimageId uint32, Width uint16, Height uint16) []byte { size := 20 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XVIDEO-MOTIONCOMPENSATION"] b += 1 buf[b] = 6 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], uint32(SubpictureId)) b += 4 xgb.Put32(buf[b:], uint32(Context)) b += 4 xgb.Put32(buf[b:], XvimageId) b += 4 xgb.Put16(buf[b:], Width) b += 2 xgb.Put16(buf[b:], Height) b += 2 return buf }
// Write request to wire for CreateSegment // createSegmentRequest writes a CreateSegment request to a byte slice. func createSegmentRequest(c *xgb.Conn, Shmseg Seg, Size uint32, ReadOnly bool) []byte { size := 16 b := 0 buf := make([]byte, size) c.ExtLock.RLock() buf[b] = c.Extensions["MIT-SHM"] 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(Shmseg)) b += 4 xgb.Put32(buf[b:], Size) b += 4 if ReadOnly { buf[b] = 1 } else { buf[b] = 0 } b += 1 b += 3 // padding return buf }
// Write request to wire for Attach // attachRequest writes a Attach request to a byte slice. func attachRequest(c *xgb.Conn, Shmseg Seg, Shmid uint32, ReadOnly bool) []byte { size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["MIT-SHM"] b += 1 buf[b] = 1 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], uint32(Shmseg)) b += 4 xgb.Put32(buf[b:], Shmid) b += 4 if ReadOnly { buf[b] = 1 } else { buf[b] = 0 } b += 1 b += 3 // padding return buf }
// 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 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 }
// Bytes writes a AttachFormat value to a byte slice. func (v AttachFormat) Bytes() []byte { buf := make([]byte, 8) b := 0 xgb.Put32(buf[b:], v.Attachment) b += 4 xgb.Put32(buf[b:], v.Format) b += 4 return buf }
// Write 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 }
// Bytes writes a Client value to a byte slice. func (v Client) Bytes() []byte { buf := make([]byte, 8) b := 0 xgb.Put32(buf[b:], v.ResourceBase) b += 4 xgb.Put32(buf[b:], v.ResourceMask) b += 4 return buf[:b] }
// Bytes writes a Type value to a byte slice. func (v Type) Bytes() []byte { buf := make([]byte, 8) b := 0 xgb.Put32(buf[b:], uint32(v.ResourceType)) b += 4 xgb.Put32(buf[b:], v.Count) b += 4 return buf[:b] }
// Bytes writes a ResourceIdSpec value to a byte slice. func (v ResourceIdSpec) Bytes() []byte { buf := make([]byte, 8) b := 0 xgb.Put32(buf[b:], v.Resource) b += 4 xgb.Put32(buf[b:], v.Type) b += 4 return buf[:b] }
// Bytes writes a ClientIdSpec value to a byte slice. func (v ClientIdSpec) Bytes() []byte { buf := make([]byte, 8) b := 0 xgb.Put32(buf[b:], v.Client) b += 4 xgb.Put32(buf[b:], v.Mask) b += 4 return buf[: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)))) b := 0 xgb.Put32(buf[b:], uint32(v.ClientResource)) b += 4 xgb.Put32(buf[b:], v.NumRanges) b += 4 b += RangeListBytes(buf[b:], v.Ranges) return buf }
// Write 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 }
// Write request to wire for UnredirectWindow // unredirectWindowRequest writes a UnredirectWindow request to a byte slice. func unredirectWindowRequest(c *xgb.Conn, Window xproto.Window, Update byte) []byte { size := 12 b := 0 buf := make([]byte, size) c.ExtLock.RLock() buf[b] = c.Extensions["Composite"] 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(Window)) b += 4 buf[b] = Update b += 1 b += 3 // padding return buf }
// Write request to wire for SelectInput // selectInputRequest writes a SelectInput request to a byte slice. func selectInputRequest(c *xgb.Conn, DestinationWindow xproto.Window, Enable bool) []byte { size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["SHAPE"] b += 1 buf[b] = 6 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], uint32(DestinationWindow)) b += 4 if Enable { buf[b] = 1 } else { buf[b] = 0 } b += 1 b += 3 // padding return buf }
// Write request to wire for Offset // offsetRequest writes a Offset request to a byte slice. func offsetRequest(c *xgb.Conn, DestinationKind Kind, DestinationWindow xproto.Window, XOffset int16, YOffset int16) []byte { size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["SHAPE"] b += 1 buf[b] = 4 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 buf[b] = byte(DestinationKind) b += 1 b += 3 // padding xgb.Put32(buf[b:], uint32(DestinationWindow)) b += 4 xgb.Put16(buf[b:], uint16(XOffset)) b += 2 xgb.Put16(buf[b:], uint16(YOffset)) b += 2 return buf }
// Write request to wire for GetRectangles // getRectanglesRequest writes a GetRectangles request to a byte slice. func getRectanglesRequest(c *xgb.Conn, Window xproto.Window, SourceKind Kind) []byte { size := 12 b := 0 buf := make([]byte, size) c.ExtLock.RLock() buf[b] = c.Extensions["SHAPE"] c.ExtLock.RUnlock() b += 1 buf[b] = 8 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], uint32(Window)) b += 4 buf[b] = byte(SourceKind) b += 1 b += 3 // padding return buf }
// Write request to wire for GetImage // getImageRequest writes a GetImage request to a byte slice. func getImageRequest(c *xgb.Conn, Drawable xproto.Drawable, X int16, Y int16, Width uint16, Height uint16, PlaneMask uint32, Format byte, Shmseg Seg, Offset uint32) []byte { size := 32 b := 0 buf := make([]byte, size) c.ExtLock.RLock() buf[b] = c.Extensions["MIT-SHM"] c.ExtLock.RUnlock() b += 1 buf[b] = 4 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 xgb.Put32(buf[b:], uint32(Drawable)) b += 4 xgb.Put16(buf[b:], uint16(X)) b += 2 xgb.Put16(buf[b:], uint16(Y)) b += 2 xgb.Put16(buf[b:], Width) b += 2 xgb.Put16(buf[b:], Height) b += 2 xgb.Put32(buf[b:], PlaneMask) b += 4 buf[b] = Format b += 1 b += 3 // padding xgb.Put32(buf[b:], uint32(Shmseg)) b += 4 xgb.Put32(buf[b:], Offset) b += 4 return buf }
func (a *atomic) ChangeProp32(w xproto.Window, prop, typ string, data ...uint) error { buf := make([]byte, len(data)*4) for i, datum := range data { xgb.Put32(buf[(i*4):], uint32(datum)) } return a.ChangeProp(w, 32, prop, typ, buf) }