From 0c50dc6241fa21712e041cfa2bfb9db4ccaef10a Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Thu, 10 May 2012 17:01:42 -0400 Subject: a huge commit. splitting extensions into their own sub-packages. --- nexgb/xv/xv.go | 2746 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 2746 insertions(+) create mode 100644 nexgb/xv/xv.go (limited to 'nexgb/xv') diff --git a/nexgb/xv/xv.go b/nexgb/xv/xv.go new file mode 100644 index 0000000..8faaf83 --- /dev/null +++ b/nexgb/xv/xv.go @@ -0,0 +1,2746 @@ +package xv + +/* + This file was generated by xv.xml on May 10 2012 4:20:29pm EDT. + This file is automatically generated. Edit at your peril! +*/ + +import ( + "github.com/BurntSushi/xgb" + + "github.com/BurntSushi/xgb/shm" + "github.com/BurntSushi/xgb/xproto" +) + +// Init must be called before using the XVideo extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 6, "XVideo").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named XVideo could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["XVideo"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["XVideo"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["XVideo"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["XVideo"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["XVideo"] = make(map[int]xgb.NewErrorFun) +} + +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Bool' + +// Skipping definition for base type 'Float' + +const ( + TypeInputMask = 1 + TypeOutputMask = 2 + TypeVideoMask = 4 + TypeStillMask = 8 + TypeImageMask = 16 +) + +const ( + ImageFormatInfoTypeRgb = 0 + ImageFormatInfoTypeYuv = 1 +) + +const ( + ImageFormatInfoFormatPacked = 0 + ImageFormatInfoFormatPlanar = 1 +) + +const ( + AttributeFlagGettable = 1 + AttributeFlagSettable = 2 +) + +const ( + VideoNotifyReasonStarted = 0 + VideoNotifyReasonStopped = 1 + VideoNotifyReasonBusy = 2 + VideoNotifyReasonPreempted = 3 + VideoNotifyReasonHardError = 4 +) + +const ( + ScanlineOrderTopToBottom = 0 + ScanlineOrderBottomToTop = 1 +) + +const ( + GrabPortStatusSuccess = 0 + GrabPortStatusBadExtension = 1 + GrabPortStatusAlreadyGrabbed = 2 + GrabPortStatusInvalidTime = 3 + GrabPortStatusBadReply = 4 + GrabPortStatusBadAlloc = 5 +) + +type Port uint32 + +func NewPortId(c *xgb.Conn) (Port, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Port(id), nil +} + +type Encoding uint32 + +func NewEncodingId(c *xgb.Conn) (Encoding, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Encoding(id), nil +} + +// 'Rational' struct definition +// Size: 8 +type Rational struct { + Numerator int32 + Denominator int32 +} + +// Struct read Rational +func RationalRead(buf []byte, v *Rational) int { + b := 0 + + v.Numerator = int32(xgb.Get32(buf[b:])) + b += 4 + + v.Denominator = int32(xgb.Get32(buf[b:])) + b += 4 + + return b +} + +// Struct list read Rational +func RationalReadList(buf []byte, dest []Rational) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Rational{} + b += RationalRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Rational +func (v Rational) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Numerator)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Denominator)) + b += 4 + + return buf +} + +// Write struct list Rational +func RationalListBytes(buf []byte, list []Rational) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'Format' struct definition +// Size: 8 +type Format struct { + Visual xproto.Visualid + Depth byte + // padding: 3 bytes +} + +// Struct read Format +func FormatRead(buf []byte, v *Format) int { + b := 0 + + v.Visual = xproto.Visualid(xgb.Get32(buf[b:])) + b += 4 + + v.Depth = buf[b] + b += 1 + + b += 3 // padding + + return b +} + +// Struct list read Format +func FormatReadList(buf []byte, dest []Format) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Format{} + b += FormatRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Format +func (v Format) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Visual)) + b += 4 + + buf[b] = v.Depth + b += 1 + + b += 3 // padding + + return buf +} + +// Write struct list Format +func FormatListBytes(buf []byte, list []Format) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// 'AdaptorInfo' struct definition +// Size: ((12 + xgb.Pad((int(NameSize) * 1))) + xgb.Pad((int(NumFormats) * 8))) +type AdaptorInfo struct { + BaseId Port + NameSize uint16 + NumPorts uint16 + NumFormats uint16 + Type byte + // padding: 1 bytes + Name string // size: xgb.Pad((int(NameSize) * 1)) + Formats []Format // size: xgb.Pad((int(NumFormats) * 8)) +} + +// Struct read AdaptorInfo +func AdaptorInfoRead(buf []byte, v *AdaptorInfo) int { + b := 0 + + v.BaseId = Port(xgb.Get32(buf[b:])) + b += 4 + + v.NameSize = xgb.Get16(buf[b:]) + b += 2 + + v.NumPorts = xgb.Get16(buf[b:]) + b += 2 + + v.NumFormats = xgb.Get16(buf[b:]) + b += 2 + + v.Type = buf[b] + b += 1 + + b += 1 // padding + + { + byteString := make([]byte, v.NameSize) + copy(byteString[:v.NameSize], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.NameSize)) + } + + v.Formats = make([]Format, v.NumFormats) + b += FormatReadList(buf[b:], v.Formats) + + return b +} + +// Struct list read AdaptorInfo +func AdaptorInfoReadList(buf []byte, dest []AdaptorInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = AdaptorInfo{} + b += AdaptorInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write AdaptorInfo +func (v AdaptorInfo) Bytes() []byte { + buf := make([]byte, ((12 + xgb.Pad((int(v.NameSize) * 1))) + xgb.Pad((int(v.NumFormats) * 8)))) + b := 0 + + xgb.Put32(buf[b:], uint32(v.BaseId)) + b += 4 + + xgb.Put16(buf[b:], v.NameSize) + b += 2 + + xgb.Put16(buf[b:], v.NumPorts) + b += 2 + + xgb.Put16(buf[b:], v.NumFormats) + b += 2 + + buf[b] = v.Type + b += 1 + + b += 1 // padding + + copy(buf[b:], v.Name[:v.NameSize]) + b += xgb.Pad(int(v.NameSize)) + + b += FormatListBytes(buf[b:], v.Formats) + + return buf +} + +// Write struct list AdaptorInfo +func AdaptorInfoListBytes(buf []byte, list []AdaptorInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size AdaptorInfo +func AdaptorInfoListSize(list []AdaptorInfo) int { + size := 0 + for _, item := range list { + size += ((12 + xgb.Pad((int(item.NameSize) * 1))) + xgb.Pad((int(item.NumFormats) * 8))) + } + return size +} + +// 'EncodingInfo' struct definition +// Size: (20 + xgb.Pad((int(NameSize) * 1))) +type EncodingInfo struct { + Encoding Encoding + NameSize uint16 + Width uint16 + Height uint16 + // padding: 2 bytes + Rate Rational + Name string // size: xgb.Pad((int(NameSize) * 1)) +} + +// Struct read EncodingInfo +func EncodingInfoRead(buf []byte, v *EncodingInfo) int { + b := 0 + + v.Encoding = Encoding(xgb.Get32(buf[b:])) + b += 4 + + v.NameSize = xgb.Get16(buf[b:]) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + v.Rate = Rational{} + b += RationalRead(buf[b:], &v.Rate) + + { + byteString := make([]byte, v.NameSize) + copy(byteString[:v.NameSize], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.NameSize)) + } + + return b +} + +// Struct list read EncodingInfo +func EncodingInfoReadList(buf []byte, dest []EncodingInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = EncodingInfo{} + b += EncodingInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write EncodingInfo +func (v EncodingInfo) Bytes() []byte { + buf := make([]byte, (20 + xgb.Pad((int(v.NameSize) * 1)))) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Encoding)) + b += 4 + + xgb.Put16(buf[b:], v.NameSize) + b += 2 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + b += 2 // padding + + { + structBytes := v.Rate.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + copy(buf[b:], v.Name[:v.NameSize]) + b += xgb.Pad(int(v.NameSize)) + + return buf +} + +// Write struct list EncodingInfo +func EncodingInfoListBytes(buf []byte, list []EncodingInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size EncodingInfo +func EncodingInfoListSize(list []EncodingInfo) int { + size := 0 + for _, item := range list { + size += (20 + xgb.Pad((int(item.NameSize) * 1))) + } + return size +} + +// 'Image' struct definition +// Size: (((16 + xgb.Pad((int(NumPlanes) * 4))) + xgb.Pad((int(NumPlanes) * 4))) + xgb.Pad((int(DataSize) * 1))) +type Image struct { + Id uint32 + Width uint16 + Height uint16 + DataSize uint32 + NumPlanes uint32 + Pitches []uint32 // size: xgb.Pad((int(NumPlanes) * 4)) + Offsets []uint32 // size: xgb.Pad((int(NumPlanes) * 4)) + Data []byte // size: xgb.Pad((int(DataSize) * 1)) +} + +// Struct read Image +func ImageRead(buf []byte, v *Image) int { + b := 0 + + v.Id = xgb.Get32(buf[b:]) + b += 4 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + v.DataSize = xgb.Get32(buf[b:]) + b += 4 + + v.NumPlanes = xgb.Get32(buf[b:]) + b += 4 + + v.Pitches = make([]uint32, v.NumPlanes) + for i := 0; i < int(v.NumPlanes); i++ { + v.Pitches[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + v.Offsets = make([]uint32, v.NumPlanes) + for i := 0; i < int(v.NumPlanes); i++ { + v.Offsets[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + v.Data = make([]byte, v.DataSize) + copy(v.Data[:v.DataSize], buf[b:]) + b += xgb.Pad(int(v.DataSize)) + + return b +} + +// Struct list read Image +func ImageReadList(buf []byte, dest []Image) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Image{} + b += ImageRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write Image +func (v Image) Bytes() []byte { + buf := make([]byte, (((16 + xgb.Pad((int(v.NumPlanes) * 4))) + xgb.Pad((int(v.NumPlanes) * 4))) + xgb.Pad((int(v.DataSize) * 1)))) + b := 0 + + xgb.Put32(buf[b:], v.Id) + b += 4 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + xgb.Put32(buf[b:], v.DataSize) + b += 4 + + xgb.Put32(buf[b:], v.NumPlanes) + b += 4 + + for i := 0; i < int(v.NumPlanes); i++ { + xgb.Put32(buf[b:], v.Pitches[i]) + b += 4 + } + b = xgb.Pad(b) + + for i := 0; i < int(v.NumPlanes); i++ { + xgb.Put32(buf[b:], v.Offsets[i]) + b += 4 + } + b = xgb.Pad(b) + + copy(buf[b:], v.Data[:v.DataSize]) + b += xgb.Pad(int(v.DataSize)) + + return buf +} + +// Write struct list Image +func ImageListBytes(buf []byte, list []Image) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size Image +func ImageListSize(list []Image) int { + size := 0 + for _, item := range list { + size += (((16 + xgb.Pad((int(item.NumPlanes) * 4))) + xgb.Pad((int(item.NumPlanes) * 4))) + xgb.Pad((int(item.DataSize) * 1))) + } + return size +} + +// 'AttributeInfo' struct definition +// Size: (16 + xgb.Pad((int(Size) * 1))) +type AttributeInfo struct { + Flags uint32 + Min int32 + Max int32 + Size uint32 + Name string // size: xgb.Pad((int(Size) * 1)) +} + +// Struct read AttributeInfo +func AttributeInfoRead(buf []byte, v *AttributeInfo) int { + b := 0 + + v.Flags = xgb.Get32(buf[b:]) + b += 4 + + v.Min = int32(xgb.Get32(buf[b:])) + b += 4 + + v.Max = int32(xgb.Get32(buf[b:])) + b += 4 + + v.Size = xgb.Get32(buf[b:]) + b += 4 + + { + byteString := make([]byte, v.Size) + copy(byteString[:v.Size], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.Size)) + } + + return b +} + +// Struct list read AttributeInfo +func AttributeInfoReadList(buf []byte, dest []AttributeInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = AttributeInfo{} + b += AttributeInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write AttributeInfo +func (v AttributeInfo) Bytes() []byte { + buf := make([]byte, (16 + xgb.Pad((int(v.Size) * 1)))) + b := 0 + + xgb.Put32(buf[b:], v.Flags) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Min)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Max)) + b += 4 + + xgb.Put32(buf[b:], v.Size) + b += 4 + + copy(buf[b:], v.Name[:v.Size]) + b += xgb.Pad(int(v.Size)) + + return buf +} + +// Write struct list AttributeInfo +func AttributeInfoListBytes(buf []byte, list []AttributeInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size AttributeInfo +func AttributeInfoListSize(list []AttributeInfo) int { + size := 0 + for _, item := range list { + size += (16 + xgb.Pad((int(item.Size) * 1))) + } + return size +} + +// 'ImageFormatInfo' struct definition +// Size: 128 +type ImageFormatInfo struct { + Id uint32 + Type byte + ByteOrder byte + // padding: 2 bytes + Guid []byte // size: 16 + Bpp byte + NumPlanes byte + // padding: 2 bytes + Depth byte + // padding: 3 bytes + RedMask uint32 + GreenMask uint32 + BlueMask uint32 + Format byte + // padding: 3 bytes + YSampleBits uint32 + USampleBits uint32 + VSampleBits uint32 + VhorzYPeriod uint32 + VhorzUPeriod uint32 + VhorzVPeriod uint32 + VvertYPeriod uint32 + VvertUPeriod uint32 + VvertVPeriod uint32 + VcompOrder []byte // size: 32 + VscanlineOrder byte + // padding: 11 bytes +} + +// Struct read ImageFormatInfo +func ImageFormatInfoRead(buf []byte, v *ImageFormatInfo) int { + b := 0 + + v.Id = xgb.Get32(buf[b:]) + b += 4 + + v.Type = buf[b] + b += 1 + + v.ByteOrder = buf[b] + b += 1 + + b += 2 // padding + + v.Guid = make([]byte, 16) + copy(v.Guid[:16], buf[b:]) + b += xgb.Pad(int(16)) + + v.Bpp = buf[b] + b += 1 + + v.NumPlanes = buf[b] + b += 1 + + b += 2 // padding + + v.Depth = buf[b] + b += 1 + + b += 3 // padding + + v.RedMask = xgb.Get32(buf[b:]) + b += 4 + + v.GreenMask = xgb.Get32(buf[b:]) + b += 4 + + v.BlueMask = xgb.Get32(buf[b:]) + b += 4 + + v.Format = buf[b] + b += 1 + + b += 3 // padding + + v.YSampleBits = xgb.Get32(buf[b:]) + b += 4 + + v.USampleBits = xgb.Get32(buf[b:]) + b += 4 + + v.VSampleBits = xgb.Get32(buf[b:]) + b += 4 + + v.VhorzYPeriod = xgb.Get32(buf[b:]) + b += 4 + + v.VhorzUPeriod = xgb.Get32(buf[b:]) + b += 4 + + v.VhorzVPeriod = xgb.Get32(buf[b:]) + b += 4 + + v.VvertYPeriod = xgb.Get32(buf[b:]) + b += 4 + + v.VvertUPeriod = xgb.Get32(buf[b:]) + b += 4 + + v.VvertVPeriod = xgb.Get32(buf[b:]) + b += 4 + + v.VcompOrder = make([]byte, 32) + copy(v.VcompOrder[:32], buf[b:]) + b += xgb.Pad(int(32)) + + v.VscanlineOrder = buf[b] + b += 1 + + b += 11 // padding + + return b +} + +// Struct list read ImageFormatInfo +func ImageFormatInfoReadList(buf []byte, dest []ImageFormatInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = ImageFormatInfo{} + b += ImageFormatInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write ImageFormatInfo +func (v ImageFormatInfo) Bytes() []byte { + buf := make([]byte, 128) + b := 0 + + xgb.Put32(buf[b:], v.Id) + b += 4 + + buf[b] = v.Type + b += 1 + + buf[b] = v.ByteOrder + b += 1 + + b += 2 // padding + + copy(buf[b:], v.Guid[:16]) + b += xgb.Pad(int(16)) + + buf[b] = v.Bpp + b += 1 + + buf[b] = v.NumPlanes + b += 1 + + b += 2 // padding + + buf[b] = v.Depth + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], v.RedMask) + b += 4 + + xgb.Put32(buf[b:], v.GreenMask) + b += 4 + + xgb.Put32(buf[b:], v.BlueMask) + b += 4 + + buf[b] = v.Format + b += 1 + + b += 3 // padding + + xgb.Put32(buf[b:], v.YSampleBits) + b += 4 + + xgb.Put32(buf[b:], v.USampleBits) + b += 4 + + xgb.Put32(buf[b:], v.VSampleBits) + b += 4 + + xgb.Put32(buf[b:], v.VhorzYPeriod) + b += 4 + + xgb.Put32(buf[b:], v.VhorzUPeriod) + b += 4 + + xgb.Put32(buf[b:], v.VhorzVPeriod) + b += 4 + + xgb.Put32(buf[b:], v.VvertYPeriod) + b += 4 + + xgb.Put32(buf[b:], v.VvertUPeriod) + b += 4 + + xgb.Put32(buf[b:], v.VvertVPeriod) + b += 4 + + copy(buf[b:], v.VcompOrder[:32]) + b += xgb.Pad(int(32)) + + buf[b] = v.VscanlineOrder + b += 1 + + b += 11 // padding + + return buf +} + +// Write struct list ImageFormatInfo +func ImageFormatInfoListBytes(buf []byte, list []ImageFormatInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Struct list size ImageFormatInfo +func ImageFormatInfoListSize(list []ImageFormatInfo) int { + size := 0 + for _ = range list { + size += 128 + } + return size +} + +// Event definition VideoNotify (0) +// Size: 32 + +const VideoNotify = 0 + +type VideoNotifyEvent struct { + Sequence uint16 + Reason byte + Time xproto.Timestamp + Drawable xproto.Drawable + Port Port +} + +// Event read VideoNotify +func VideoNotifyEventNew(buf []byte) xgb.Event { + v := VideoNotifyEvent{} + b := 1 // don't read event number + + v.Reason = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Drawable = xproto.Drawable(xgb.Get32(buf[b:])) + b += 4 + + v.Port = Port(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Event write VideoNotify +func (v VideoNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 0 + b += 1 + + buf[b] = v.Reason + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Port)) + b += 4 + + return buf +} + +func (v VideoNotifyEvent) ImplementsEvent() {} + +func (v VideoNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v VideoNotifyEvent) String() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Reason: %d", v.Reason)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Drawable: %d", v.Drawable)) + fieldVals = append(fieldVals, xgb.Sprintf("Port: %d", v.Port)) + return "VideoNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XVideo"][0] = VideoNotifyEventNew +} + +// Event definition PortNotify (1) +// Size: 32 + +const PortNotify = 1 + +type PortNotifyEvent struct { + Sequence uint16 + // padding: 1 bytes + Time xproto.Timestamp + Port Port + Attribute xproto.Atom + Value int32 +} + +// Event read PortNotify +func PortNotifyEventNew(buf []byte) xgb.Event { + v := PortNotifyEvent{} + b := 1 // don't read event number + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Port = Port(xgb.Get32(buf[b:])) + b += 4 + + v.Attribute = xproto.Atom(xgb.Get32(buf[b:])) + b += 4 + + v.Value = int32(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Event write PortNotify +func (v PortNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 + + // write event number + buf[b] = 1 + b += 1 + + b += 1 // padding + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Attribute)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Value)) + b += 4 + + return buf +} + +func (v PortNotifyEvent) ImplementsEvent() {} + +func (v PortNotifyEvent) SequenceId() uint16 { + return v.Sequence +} + +func (v PortNotifyEvent) String() string { + fieldVals := make([]string, 0, 5) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Port: %d", v.Port)) + fieldVals = append(fieldVals, xgb.Sprintf("Attribute: %d", v.Attribute)) + fieldVals = append(fieldVals, xgb.Sprintf("Value: %d", v.Value)) + return "PortNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtEventFuncs["XVideo"][1] = PortNotifyEventNew +} + +// Error definition BadPort (0) +// Size: 32 + +const BadBadPort = 0 + +type BadPortError struct { + Sequence uint16 + NiceName string +} + +// Error read BadPort +func BadPortErrorNew(buf []byte) xgb.Error { + v := BadPortError{} + v.NiceName = "BadPort" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err BadPortError) ImplementsError() {} + +func (err BadPortError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadPortError) BadId() uint32 { + return 0 +} + +func (err BadPortError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadPort {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XVideo"][0] = BadPortErrorNew +} + +// Error definition BadEncoding (1) +// Size: 32 + +const BadBadEncoding = 1 + +type BadEncodingError struct { + Sequence uint16 + NiceName string +} + +// Error read BadEncoding +func BadEncodingErrorNew(buf []byte) xgb.Error { + v := BadEncodingError{} + v.NiceName = "BadEncoding" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err BadEncodingError) ImplementsError() {} + +func (err BadEncodingError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadEncodingError) BadId() uint32 { + return 0 +} + +func (err BadEncodingError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadEncoding {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XVideo"][1] = BadEncodingErrorNew +} + +// Error definition BadControl (2) +// Size: 32 + +const BadBadControl = 2 + +type BadControlError struct { + Sequence uint16 + NiceName string +} + +// Error read BadControl +func BadControlErrorNew(buf []byte) xgb.Error { + v := BadControlError{} + v.NiceName = "BadControl" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +func (err BadControlError) ImplementsError() {} + +func (err BadControlError) SequenceId() uint16 { + return err.Sequence +} + +func (err BadControlError) BadId() uint32 { + return 0 +} + +func (err BadControlError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadControl {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XVideo"][2] = BadControlErrorNew +} + +// Request QueryExtension +// size: 4 +type QueryExtensionCookie struct { + *xgb.Cookie +} + +func QueryExtension(c *xgb.Conn) QueryExtensionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryExtensionRequest(c), cookie) + return QueryExtensionCookie{cookie} +} + +func QueryExtensionUnchecked(c *xgb.Conn) QueryExtensionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryExtensionRequest(c), cookie) + return QueryExtensionCookie{cookie} +} + +// Request reply for QueryExtension +// size: 12 +type QueryExtensionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Major uint16 + Minor uint16 +} + +// Waits and reads reply data from request QueryExtension +func (cook QueryExtensionCookie) Reply() (*QueryExtensionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryExtensionReply(buf), nil +} + +// Read reply into structure from buffer for QueryExtension +func queryExtensionReply(buf []byte) *QueryExtensionReply { + v := new(QueryExtensionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Major = xgb.Get16(buf[b:]) + b += 2 + + v.Minor = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Write request to wire for QueryExtension +func queryExtensionRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 0 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request QueryAdaptors +// size: 8 +type QueryAdaptorsCookie struct { + *xgb.Cookie +} + +func QueryAdaptors(c *xgb.Conn, Window xproto.Window) QueryAdaptorsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryAdaptorsRequest(c, Window), cookie) + return QueryAdaptorsCookie{cookie} +} + +func QueryAdaptorsUnchecked(c *xgb.Conn, Window xproto.Window) QueryAdaptorsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryAdaptorsRequest(c, Window), cookie) + return QueryAdaptorsCookie{cookie} +} + +// Request reply for QueryAdaptors +// size: (32 + AdaptorInfoListSize(Info)) +type QueryAdaptorsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumAdaptors uint16 + // padding: 22 bytes + Info []AdaptorInfo // size: AdaptorInfoListSize(Info) +} + +// Waits and reads reply data from request QueryAdaptors +func (cook QueryAdaptorsCookie) Reply() (*QueryAdaptorsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryAdaptorsReply(buf), nil +} + +// Read reply into structure from buffer for QueryAdaptors +func queryAdaptorsReply(buf []byte) *QueryAdaptorsReply { + v := new(QueryAdaptorsReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NumAdaptors = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + v.Info = make([]AdaptorInfo, v.NumAdaptors) + b += AdaptorInfoReadList(buf[b:], v.Info) + + return v +} + +// Write request to wire for QueryAdaptors +func queryAdaptorsRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 1 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + return buf +} + +// Request QueryEncodings +// size: 8 +type QueryEncodingsCookie struct { + *xgb.Cookie +} + +func QueryEncodings(c *xgb.Conn, Port Port) QueryEncodingsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryEncodingsRequest(c, Port), cookie) + return QueryEncodingsCookie{cookie} +} + +func QueryEncodingsUnchecked(c *xgb.Conn, Port Port) QueryEncodingsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryEncodingsRequest(c, Port), cookie) + return QueryEncodingsCookie{cookie} +} + +// Request reply for QueryEncodings +// size: (32 + EncodingInfoListSize(Info)) +type QueryEncodingsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumEncodings uint16 + // padding: 22 bytes + Info []EncodingInfo // size: EncodingInfoListSize(Info) +} + +// Waits and reads reply data from request QueryEncodings +func (cook QueryEncodingsCookie) Reply() (*QueryEncodingsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryEncodingsReply(buf), nil +} + +// Read reply into structure from buffer for QueryEncodings +func queryEncodingsReply(buf []byte) *QueryEncodingsReply { + v := new(QueryEncodingsReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NumEncodings = xgb.Get16(buf[b:]) + b += 2 + + b += 22 // padding + + v.Info = make([]EncodingInfo, v.NumEncodings) + b += EncodingInfoReadList(buf[b:], v.Info) + + return v +} + +// Write request to wire for QueryEncodings +func queryEncodingsRequest(c *xgb.Conn, Port Port) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 2 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + return buf +} + +// Request GrabPort +// size: 12 +type GrabPortCookie struct { + *xgb.Cookie +} + +func GrabPort(c *xgb.Conn, Port Port, Time xproto.Timestamp) GrabPortCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(grabPortRequest(c, Port, Time), cookie) + return GrabPortCookie{cookie} +} + +func GrabPortUnchecked(c *xgb.Conn, Port Port, Time xproto.Timestamp) GrabPortCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(grabPortRequest(c, Port, Time), cookie) + return GrabPortCookie{cookie} +} + +// Request reply for GrabPort +// size: 8 +type GrabPortReply struct { + Sequence uint16 + Length uint32 + Result byte +} + +// Waits and reads reply data from request GrabPort +func (cook GrabPortCookie) Reply() (*GrabPortReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return grabPortReply(buf), nil +} + +// Read reply into structure from buffer for GrabPort +func grabPortReply(buf []byte) *GrabPortReply { + v := new(GrabPortReply) + b := 1 // skip reply determinant + + v.Result = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + return v +} + +// Write request to wire for GrabPort +func grabPortRequest(c *xgb.Conn, Port Port, Time xproto.Timestamp) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 3 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + return buf +} + +// Request UngrabPort +// size: 12 +type UngrabPortCookie struct { + *xgb.Cookie +} + +// Write request to wire for UngrabPort +func UngrabPort(c *xgb.Conn, Port Port, Time xproto.Timestamp) UngrabPortCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(ungrabPortRequest(c, Port, Time), cookie) + return UngrabPortCookie{cookie} +} + +func UngrabPortChecked(c *xgb.Conn, Port Port, Time xproto.Timestamp) UngrabPortCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(ungrabPortRequest(c, Port, Time), cookie) + return UngrabPortCookie{cookie} +} + +func (cook UngrabPortCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for UngrabPort +func ungrabPortRequest(c *xgb.Conn, Port Port, Time xproto.Timestamp) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 4 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + return buf +} + +// Request PutVideo +// size: 32 +type PutVideoCookie struct { + *xgb.Cookie +} + +// Write request to wire for PutVideo +func PutVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutVideoCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(putVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return PutVideoCookie{cookie} +} + +func PutVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutVideoCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(putVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return PutVideoCookie{cookie} +} + +func (cook PutVideoCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PutVideo +func putVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { + size := 32 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 5 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put16(buf[b:], uint16(VidX)) + b += 2 + + xgb.Put16(buf[b:], uint16(VidY)) + b += 2 + + xgb.Put16(buf[b:], VidW) + b += 2 + + xgb.Put16(buf[b:], VidH) + b += 2 + + xgb.Put16(buf[b:], uint16(DrwX)) + b += 2 + + xgb.Put16(buf[b:], uint16(DrwY)) + b += 2 + + xgb.Put16(buf[b:], DrwW) + b += 2 + + xgb.Put16(buf[b:], DrwH) + b += 2 + + return buf +} + +// Request PutStill +// size: 32 +type PutStillCookie struct { + *xgb.Cookie +} + +// Write request to wire for PutStill +func PutStill(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutStillCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(putStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return PutStillCookie{cookie} +} + +func PutStillChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutStillCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(putStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return PutStillCookie{cookie} +} + +func (cook PutStillCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PutStill +func putStillRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { + size := 32 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 6 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put16(buf[b:], uint16(VidX)) + b += 2 + + xgb.Put16(buf[b:], uint16(VidY)) + b += 2 + + xgb.Put16(buf[b:], VidW) + b += 2 + + xgb.Put16(buf[b:], VidH) + b += 2 + + xgb.Put16(buf[b:], uint16(DrwX)) + b += 2 + + xgb.Put16(buf[b:], uint16(DrwY)) + b += 2 + + xgb.Put16(buf[b:], DrwW) + b += 2 + + xgb.Put16(buf[b:], DrwH) + b += 2 + + return buf +} + +// Request GetVideo +// size: 32 +type GetVideoCookie struct { + *xgb.Cookie +} + +// Write request to wire for GetVideo +func GetVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetVideoCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(getVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return GetVideoCookie{cookie} +} + +func GetVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetVideoCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(getVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return GetVideoCookie{cookie} +} + +func (cook GetVideoCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for GetVideo +func getVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { + size := 32 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 7 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put16(buf[b:], uint16(VidX)) + b += 2 + + xgb.Put16(buf[b:], uint16(VidY)) + b += 2 + + xgb.Put16(buf[b:], VidW) + b += 2 + + xgb.Put16(buf[b:], VidH) + b += 2 + + xgb.Put16(buf[b:], uint16(DrwX)) + b += 2 + + xgb.Put16(buf[b:], uint16(DrwY)) + b += 2 + + xgb.Put16(buf[b:], DrwW) + b += 2 + + xgb.Put16(buf[b:], DrwH) + b += 2 + + return buf +} + +// Request GetStill +// size: 32 +type GetStillCookie struct { + *xgb.Cookie +} + +// Write request to wire for GetStill +func GetStill(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetStillCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(getStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return GetStillCookie{cookie} +} + +func GetStillChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetStillCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(getStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return GetStillCookie{cookie} +} + +func (cook GetStillCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for GetStill +func getStillRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { + size := 32 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 8 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put16(buf[b:], uint16(VidX)) + b += 2 + + xgb.Put16(buf[b:], uint16(VidY)) + b += 2 + + xgb.Put16(buf[b:], VidW) + b += 2 + + xgb.Put16(buf[b:], VidH) + b += 2 + + xgb.Put16(buf[b:], uint16(DrwX)) + b += 2 + + xgb.Put16(buf[b:], uint16(DrwY)) + b += 2 + + xgb.Put16(buf[b:], DrwW) + b += 2 + + xgb.Put16(buf[b:], DrwH) + b += 2 + + return buf +} + +// Request StopVideo +// size: 12 +type StopVideoCookie struct { + *xgb.Cookie +} + +// Write request to wire for StopVideo +func StopVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable) StopVideoCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(stopVideoRequest(c, Port, Drawable), cookie) + return StopVideoCookie{cookie} +} + +func StopVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable) StopVideoCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(stopVideoRequest(c, Port, Drawable), cookie) + return StopVideoCookie{cookie} +} + +func (cook StopVideoCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for StopVideo +func stopVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 9 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + return buf +} + +// Request SelectVideoNotify +// size: 12 +type SelectVideoNotifyCookie struct { + *xgb.Cookie +} + +// Write request to wire for SelectVideoNotify +func SelectVideoNotify(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) SelectVideoNotifyCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(selectVideoNotifyRequest(c, Drawable, Onoff), cookie) + return SelectVideoNotifyCookie{cookie} +} + +func SelectVideoNotifyChecked(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) SelectVideoNotifyCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(selectVideoNotifyRequest(c, Drawable, Onoff), cookie) + return SelectVideoNotifyCookie{cookie} +} + +func (cook SelectVideoNotifyCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SelectVideoNotify +func selectVideoNotifyRequest(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 10 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + if Onoff { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding + + return buf +} + +// Request SelectPortNotify +// size: 12 +type SelectPortNotifyCookie struct { + *xgb.Cookie +} + +// Write request to wire for SelectPortNotify +func SelectPortNotify(c *xgb.Conn, Port Port, Onoff bool) SelectPortNotifyCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(selectPortNotifyRequest(c, Port, Onoff), cookie) + return SelectPortNotifyCookie{cookie} +} + +func SelectPortNotifyChecked(c *xgb.Conn, Port Port, Onoff bool) SelectPortNotifyCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(selectPortNotifyRequest(c, Port, Onoff), cookie) + return SelectPortNotifyCookie{cookie} +} + +func (cook SelectPortNotifyCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SelectPortNotify +func selectPortNotifyRequest(c *xgb.Conn, Port Port, Onoff bool) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 11 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + if Onoff { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding + + return buf +} + +// Request QueryBestSize +// size: 20 +type QueryBestSizeCookie struct { + *xgb.Cookie +} + +func QueryBestSize(c *xgb.Conn, Port Port, VidW uint16, VidH uint16, DrwW uint16, DrwH uint16, Motion bool) QueryBestSizeCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryBestSizeRequest(c, Port, VidW, VidH, DrwW, DrwH, Motion), cookie) + return QueryBestSizeCookie{cookie} +} + +func QueryBestSizeUnchecked(c *xgb.Conn, Port Port, VidW uint16, VidH uint16, DrwW uint16, DrwH uint16, Motion bool) QueryBestSizeCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryBestSizeRequest(c, Port, VidW, VidH, DrwW, DrwH, Motion), cookie) + return QueryBestSizeCookie{cookie} +} + +// Request reply for QueryBestSize +// size: 12 +type QueryBestSizeReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ActualWidth uint16 + ActualHeight uint16 +} + +// Waits and reads reply data from request QueryBestSize +func (cook QueryBestSizeCookie) Reply() (*QueryBestSizeReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryBestSizeReply(buf), nil +} + +// Read reply into structure from buffer for QueryBestSize +func queryBestSizeReply(buf []byte) *QueryBestSizeReply { + v := new(QueryBestSizeReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ActualWidth = xgb.Get16(buf[b:]) + b += 2 + + v.ActualHeight = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Write request to wire for QueryBestSize +func queryBestSizeRequest(c *xgb.Conn, Port Port, VidW uint16, VidH uint16, DrwW uint16, DrwH uint16, Motion bool) []byte { + size := 20 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 12 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + xgb.Put16(buf[b:], VidW) + b += 2 + + xgb.Put16(buf[b:], VidH) + b += 2 + + xgb.Put16(buf[b:], DrwW) + b += 2 + + xgb.Put16(buf[b:], DrwH) + b += 2 + + if Motion { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 + + b += 3 // padding + + return buf +} + +// Request SetPortAttribute +// size: 16 +type SetPortAttributeCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetPortAttribute +func SetPortAttribute(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32) SetPortAttributeCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setPortAttributeRequest(c, Port, Attribute, Value), cookie) + return SetPortAttributeCookie{cookie} +} + +func SetPortAttributeChecked(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32) SetPortAttributeCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setPortAttributeRequest(c, Port, Attribute, Value), cookie) + return SetPortAttributeCookie{cookie} +} + +func (cook SetPortAttributeCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetPortAttribute +func setPortAttributeRequest(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 13 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Attribute)) + b += 4 + + xgb.Put32(buf[b:], uint32(Value)) + b += 4 + + return buf +} + +// Request GetPortAttribute +// size: 12 +type GetPortAttributeCookie struct { + *xgb.Cookie +} + +func GetPortAttribute(c *xgb.Conn, Port Port, Attribute xproto.Atom) GetPortAttributeCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getPortAttributeRequest(c, Port, Attribute), cookie) + return GetPortAttributeCookie{cookie} +} + +func GetPortAttributeUnchecked(c *xgb.Conn, Port Port, Attribute xproto.Atom) GetPortAttributeCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getPortAttributeRequest(c, Port, Attribute), cookie) + return GetPortAttributeCookie{cookie} +} + +// Request reply for GetPortAttribute +// size: 12 +type GetPortAttributeReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Value int32 +} + +// Waits and reads reply data from request GetPortAttribute +func (cook GetPortAttributeCookie) Reply() (*GetPortAttributeReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getPortAttributeReply(buf), nil +} + +// Read reply into structure from buffer for GetPortAttribute +func getPortAttributeReply(buf []byte) *GetPortAttributeReply { + v := new(GetPortAttributeReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Value = int32(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Write request to wire for GetPortAttribute +func getPortAttributeRequest(c *xgb.Conn, Port Port, Attribute xproto.Atom) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 14 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Attribute)) + b += 4 + + return buf +} + +// Request QueryPortAttributes +// size: 8 +type QueryPortAttributesCookie struct { + *xgb.Cookie +} + +func QueryPortAttributes(c *xgb.Conn, Port Port) QueryPortAttributesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryPortAttributesRequest(c, Port), cookie) + return QueryPortAttributesCookie{cookie} +} + +func QueryPortAttributesUnchecked(c *xgb.Conn, Port Port) QueryPortAttributesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryPortAttributesRequest(c, Port), cookie) + return QueryPortAttributesCookie{cookie} +} + +// Request reply for QueryPortAttributes +// size: (32 + AttributeInfoListSize(Attributes)) +type QueryPortAttributesReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumAttributes uint32 + TextSize uint32 + // padding: 16 bytes + Attributes []AttributeInfo // size: AttributeInfoListSize(Attributes) +} + +// Waits and reads reply data from request QueryPortAttributes +func (cook QueryPortAttributesCookie) Reply() (*QueryPortAttributesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryPortAttributesReply(buf), nil +} + +// Read reply into structure from buffer for QueryPortAttributes +func queryPortAttributesReply(buf []byte) *QueryPortAttributesReply { + v := new(QueryPortAttributesReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NumAttributes = xgb.Get32(buf[b:]) + b += 4 + + v.TextSize = xgb.Get32(buf[b:]) + b += 4 + + b += 16 // padding + + v.Attributes = make([]AttributeInfo, v.NumAttributes) + b += AttributeInfoReadList(buf[b:], v.Attributes) + + return v +} + +// Write request to wire for QueryPortAttributes +func queryPortAttributesRequest(c *xgb.Conn, Port Port) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 15 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + return buf +} + +// Request ListImageFormats +// size: 8 +type ListImageFormatsCookie struct { + *xgb.Cookie +} + +func ListImageFormats(c *xgb.Conn, Port Port) ListImageFormatsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(listImageFormatsRequest(c, Port), cookie) + return ListImageFormatsCookie{cookie} +} + +func ListImageFormatsUnchecked(c *xgb.Conn, Port Port) ListImageFormatsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(listImageFormatsRequest(c, Port), cookie) + return ListImageFormatsCookie{cookie} +} + +// Request reply for ListImageFormats +// size: (32 + ImageFormatInfoListSize(Format)) +type ListImageFormatsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumFormats uint32 + // padding: 20 bytes + Format []ImageFormatInfo // size: ImageFormatInfoListSize(Format) +} + +// Waits and reads reply data from request ListImageFormats +func (cook ListImageFormatsCookie) Reply() (*ListImageFormatsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listImageFormatsReply(buf), nil +} + +// Read reply into structure from buffer for ListImageFormats +func listImageFormatsReply(buf []byte) *ListImageFormatsReply { + v := new(ListImageFormatsReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NumFormats = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Format = make([]ImageFormatInfo, v.NumFormats) + b += ImageFormatInfoReadList(buf[b:], v.Format) + + return v +} + +// Write request to wire for ListImageFormats +func listImageFormatsRequest(c *xgb.Conn, Port Port) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 16 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + return buf +} + +// Request QueryImageAttributes +// size: 16 +type QueryImageAttributesCookie struct { + *xgb.Cookie +} + +func QueryImageAttributes(c *xgb.Conn, Port Port, Id uint32, Width uint16, Height uint16) QueryImageAttributesCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryImageAttributesRequest(c, Port, Id, Width, Height), cookie) + return QueryImageAttributesCookie{cookie} +} + +func QueryImageAttributesUnchecked(c *xgb.Conn, Port Port, Id uint32, Width uint16, Height uint16) QueryImageAttributesCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryImageAttributesRequest(c, Port, Id, Width, Height), cookie) + return QueryImageAttributesCookie{cookie} +} + +// Request reply for QueryImageAttributes +// size: ((32 + xgb.Pad((int(NumPlanes) * 4))) + xgb.Pad((int(NumPlanes) * 4))) +type QueryImageAttributesReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + NumPlanes uint32 + DataSize uint32 + Width uint16 + Height uint16 + // padding: 12 bytes + Pitches []uint32 // size: xgb.Pad((int(NumPlanes) * 4)) + Offsets []uint32 // size: xgb.Pad((int(NumPlanes) * 4)) +} + +// Waits and reads reply data from request QueryImageAttributes +func (cook QueryImageAttributesCookie) Reply() (*QueryImageAttributesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryImageAttributesReply(buf), nil +} + +// Read reply into structure from buffer for QueryImageAttributes +func queryImageAttributesReply(buf []byte) *QueryImageAttributesReply { + v := new(QueryImageAttributesReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NumPlanes = xgb.Get32(buf[b:]) + b += 4 + + v.DataSize = xgb.Get32(buf[b:]) + b += 4 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + b += 12 // padding + + v.Pitches = make([]uint32, v.NumPlanes) + for i := 0; i < int(v.NumPlanes); i++ { + v.Pitches[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + v.Offsets = make([]uint32, v.NumPlanes) + for i := 0; i < int(v.NumPlanes); i++ { + v.Offsets[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for QueryImageAttributes +func queryImageAttributesRequest(c *xgb.Conn, Port Port, Id uint32, Width uint16, Height uint16) []byte { + size := 16 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 17 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + xgb.Put32(buf[b:], Id) + b += 4 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + return buf +} + +// Request PutImage +// size: xgb.Pad((40 + xgb.Pad((len(Data) * 1)))) +type PutImageCookie struct { + *xgb.Cookie +} + +// Write request to wire for PutImage +func PutImage(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) PutImageCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(putImageRequest(c, Port, Drawable, Gc, Id, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, Data), cookie) + return PutImageCookie{cookie} +} + +func PutImageChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) PutImageCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(putImageRequest(c, Port, Drawable, Gc, Id, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, Data), cookie) + return PutImageCookie{cookie} +} + +func (cook PutImageCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for PutImage +func putImageRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) []byte { + size := xgb.Pad((40 + xgb.Pad((len(Data) * 1)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 18 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put32(buf[b:], Id) + b += 4 + + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 + + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 + + xgb.Put16(buf[b:], SrcW) + b += 2 + + xgb.Put16(buf[b:], SrcH) + b += 2 + + xgb.Put16(buf[b:], uint16(DrwX)) + b += 2 + + xgb.Put16(buf[b:], uint16(DrwY)) + b += 2 + + xgb.Put16(buf[b:], DrwW) + b += 2 + + xgb.Put16(buf[b:], DrwH) + b += 2 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + copy(buf[b:], Data[:len(Data)]) + b += xgb.Pad(int(len(Data))) + + return buf +} + +// Request ShmPutImage +// size: 52 +type ShmPutImageCookie struct { + *xgb.Cookie +} + +// Write request to wire for ShmPutImage +func ShmPutImage(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Shmseg shm.Seg, Id uint32, Offset uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, SendEvent byte) ShmPutImageCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(shmPutImageRequest(c, Port, Drawable, Gc, Shmseg, Id, Offset, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, SendEvent), cookie) + return ShmPutImageCookie{cookie} +} + +func ShmPutImageChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Shmseg shm.Seg, Id uint32, Offset uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, SendEvent byte) ShmPutImageCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(shmPutImageRequest(c, Port, Drawable, Gc, Shmseg, Id, Offset, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, SendEvent), cookie) + return ShmPutImageCookie{cookie} +} + +func (cook ShmPutImageCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ShmPutImage +func shmPutImageRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Shmseg shm.Seg, Id uint32, Offset uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, SendEvent byte) []byte { + size := 52 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 19 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put32(buf[b:], uint32(Shmseg)) + b += 4 + + xgb.Put32(buf[b:], Id) + b += 4 + + xgb.Put32(buf[b:], Offset) + b += 4 + + xgb.Put16(buf[b:], uint16(SrcX)) + b += 2 + + xgb.Put16(buf[b:], uint16(SrcY)) + b += 2 + + xgb.Put16(buf[b:], SrcW) + b += 2 + + xgb.Put16(buf[b:], SrcH) + b += 2 + + xgb.Put16(buf[b:], uint16(DrwX)) + b += 2 + + xgb.Put16(buf[b:], uint16(DrwY)) + b += 2 + + xgb.Put16(buf[b:], DrwW) + b += 2 + + xgb.Put16(buf[b:], DrwH) + b += 2 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + buf[b] = SendEvent + b += 1 + + b += 3 // padding + + return buf +} -- cgit v1.2.3 From a3363755cdfdafdf02d5a772bd47a462e99af057 Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Thu, 10 May 2012 20:06:22 -0400 Subject: adding package header comments --- nexgb/xv/xv.go | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'nexgb/xv') diff --git a/nexgb/xv/xv.go b/nexgb/xv/xv.go index 8faaf83..4e495cf 100644 --- a/nexgb/xv/xv.go +++ b/nexgb/xv/xv.go @@ -1,7 +1,8 @@ +// Package xv is the X client API for the XVideo extension. package xv /* - This file was generated by xv.xml on May 10 2012 4:20:29pm EDT. + This file was generated by xv.xml on May 10 2012 8:04:33pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,16 +41,6 @@ func init() { xgb.NewExtErrorFuncs["XVideo"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - // Skipping definition for base type 'Int8' // Skipping definition for base type 'Card16' @@ -64,6 +55,16 @@ func init() { // Skipping definition for base type 'Float' +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + const ( TypeInputMask = 1 TypeOutputMask = 2 -- cgit v1.2.3 From c00652934e4ec68016a152b9bea10273b0be8726 Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Thu, 10 May 2012 23:57:34 -0400 Subject: better docs --- nexgb/xv/xv.go | 440 ++++++++++++++++++++++++++++++++------------------------- 1 file changed, 251 insertions(+), 189 deletions(-) (limited to 'nexgb/xv') diff --git a/nexgb/xv/xv.go b/nexgb/xv/xv.go index 4e495cf..041b082 100644 --- a/nexgb/xv/xv.go +++ b/nexgb/xv/xv.go @@ -2,7 +2,7 @@ package xv /* - This file was generated by xv.xml on May 10 2012 8:04:33pm EDT. + This file was generated by xv.xml on May 10 2012 11:56:20pm EDT. This file is automatically generated. Edit at your peril! */ @@ -41,10 +41,6 @@ func init() { xgb.NewExtErrorFuncs["XVideo"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Int8' - -// Skipping definition for base type 'Card16' - // Skipping definition for base type 'Char' // Skipping definition for base type 'Card32' @@ -65,6 +61,10 @@ func init() { // Skipping definition for base type 'Byte' +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + const ( TypeInputMask = 1 TypeOutputMask = 2 @@ -130,14 +130,12 @@ func NewEncodingId(c *xgb.Conn) (Encoding, error) { return Encoding(id), nil } -// 'Rational' struct definition -// Size: 8 type Rational struct { Numerator int32 Denominator int32 } -// Struct read Rational +// RationalRead reads a byte slice into a Rational value. func RationalRead(buf []byte, v *Rational) int { b := 0 @@ -150,7 +148,7 @@ func RationalRead(buf []byte, v *Rational) int { return b } -// Struct list read Rational +// RationalReadList reads a byte slice into a list of Rational values. func RationalReadList(buf []byte, dest []Rational) int { b := 0 for i := 0; i < len(dest); i++ { @@ -160,7 +158,7 @@ func RationalReadList(buf []byte, dest []Rational) int { return xgb.Pad(b) } -// Struct write Rational +// Bytes writes a Rational value to a byte slice. func (v Rational) Bytes() []byte { buf := make([]byte, 8) b := 0 @@ -174,7 +172,7 @@ func (v Rational) Bytes() []byte { return buf } -// Write struct list Rational +// RationalListBytes writes a list of %s(MISSING) values to a byte slice. func RationalListBytes(buf []byte, list []Rational) int { b := 0 var structBytes []byte @@ -186,15 +184,13 @@ func RationalListBytes(buf []byte, list []Rational) int { return b } -// 'Format' struct definition -// Size: 8 type Format struct { Visual xproto.Visualid Depth byte // padding: 3 bytes } -// Struct read Format +// FormatRead reads a byte slice into a Format value. func FormatRead(buf []byte, v *Format) int { b := 0 @@ -209,7 +205,7 @@ func FormatRead(buf []byte, v *Format) int { return b } -// Struct list read Format +// FormatReadList reads a byte slice into a list of Format values. func FormatReadList(buf []byte, dest []Format) int { b := 0 for i := 0; i < len(dest); i++ { @@ -219,7 +215,7 @@ func FormatReadList(buf []byte, dest []Format) int { return xgb.Pad(b) } -// Struct write Format +// Bytes writes a Format value to a byte slice. func (v Format) Bytes() []byte { buf := make([]byte, 8) b := 0 @@ -235,7 +231,7 @@ func (v Format) Bytes() []byte { return buf } -// Write struct list Format +// FormatListBytes writes a list of %s(MISSING) values to a byte slice. func FormatListBytes(buf []byte, list []Format) int { b := 0 var structBytes []byte @@ -247,8 +243,6 @@ func FormatListBytes(buf []byte, list []Format) int { return b } -// 'AdaptorInfo' struct definition -// Size: ((12 + xgb.Pad((int(NameSize) * 1))) + xgb.Pad((int(NumFormats) * 8))) type AdaptorInfo struct { BaseId Port NameSize uint16 @@ -260,7 +254,7 @@ type AdaptorInfo struct { Formats []Format // size: xgb.Pad((int(NumFormats) * 8)) } -// Struct read AdaptorInfo +// AdaptorInfoRead reads a byte slice into a AdaptorInfo value. func AdaptorInfoRead(buf []byte, v *AdaptorInfo) int { b := 0 @@ -294,7 +288,7 @@ func AdaptorInfoRead(buf []byte, v *AdaptorInfo) int { return b } -// Struct list read AdaptorInfo +// AdaptorInfoReadList reads a byte slice into a list of AdaptorInfo values. func AdaptorInfoReadList(buf []byte, dest []AdaptorInfo) int { b := 0 for i := 0; i < len(dest); i++ { @@ -304,7 +298,7 @@ func AdaptorInfoReadList(buf []byte, dest []AdaptorInfo) int { return xgb.Pad(b) } -// Struct write AdaptorInfo +// Bytes writes a AdaptorInfo value to a byte slice. func (v AdaptorInfo) Bytes() []byte { buf := make([]byte, ((12 + xgb.Pad((int(v.NameSize) * 1))) + xgb.Pad((int(v.NumFormats) * 8)))) b := 0 @@ -334,7 +328,7 @@ func (v AdaptorInfo) Bytes() []byte { return buf } -// Write struct list AdaptorInfo +// AdaptorInfoListBytes writes a list of %s(MISSING) values to a byte slice. func AdaptorInfoListBytes(buf []byte, list []AdaptorInfo) int { b := 0 var structBytes []byte @@ -346,7 +340,7 @@ func AdaptorInfoListBytes(buf []byte, list []AdaptorInfo) int { return b } -// Struct list size AdaptorInfo +// AdaptorInfoListSize computes the size (bytes) of a list of AdaptorInfo values. func AdaptorInfoListSize(list []AdaptorInfo) int { size := 0 for _, item := range list { @@ -355,8 +349,6 @@ func AdaptorInfoListSize(list []AdaptorInfo) int { return size } -// 'EncodingInfo' struct definition -// Size: (20 + xgb.Pad((int(NameSize) * 1))) type EncodingInfo struct { Encoding Encoding NameSize uint16 @@ -367,7 +359,7 @@ type EncodingInfo struct { Name string // size: xgb.Pad((int(NameSize) * 1)) } -// Struct read EncodingInfo +// EncodingInfoRead reads a byte slice into a EncodingInfo value. func EncodingInfoRead(buf []byte, v *EncodingInfo) int { b := 0 @@ -398,7 +390,7 @@ func EncodingInfoRead(buf []byte, v *EncodingInfo) int { return b } -// Struct list read EncodingInfo +// EncodingInfoReadList reads a byte slice into a list of EncodingInfo values. func EncodingInfoReadList(buf []byte, dest []EncodingInfo) int { b := 0 for i := 0; i < len(dest); i++ { @@ -408,7 +400,7 @@ func EncodingInfoReadList(buf []byte, dest []EncodingInfo) int { return xgb.Pad(b) } -// Struct write EncodingInfo +// Bytes writes a EncodingInfo value to a byte slice. func (v EncodingInfo) Bytes() []byte { buf := make([]byte, (20 + xgb.Pad((int(v.NameSize) * 1)))) b := 0 @@ -439,7 +431,7 @@ func (v EncodingInfo) Bytes() []byte { return buf } -// Write struct list EncodingInfo +// EncodingInfoListBytes writes a list of %s(MISSING) values to a byte slice. func EncodingInfoListBytes(buf []byte, list []EncodingInfo) int { b := 0 var structBytes []byte @@ -451,7 +443,7 @@ func EncodingInfoListBytes(buf []byte, list []EncodingInfo) int { return b } -// Struct list size EncodingInfo +// EncodingInfoListSize computes the size (bytes) of a list of EncodingInfo values. func EncodingInfoListSize(list []EncodingInfo) int { size := 0 for _, item := range list { @@ -460,8 +452,6 @@ func EncodingInfoListSize(list []EncodingInfo) int { return size } -// 'Image' struct definition -// Size: (((16 + xgb.Pad((int(NumPlanes) * 4))) + xgb.Pad((int(NumPlanes) * 4))) + xgb.Pad((int(DataSize) * 1))) type Image struct { Id uint32 Width uint16 @@ -473,7 +463,7 @@ type Image struct { Data []byte // size: xgb.Pad((int(DataSize) * 1)) } -// Struct read Image +// ImageRead reads a byte slice into a Image value. func ImageRead(buf []byte, v *Image) int { b := 0 @@ -513,7 +503,7 @@ func ImageRead(buf []byte, v *Image) int { return b } -// Struct list read Image +// ImageReadList reads a byte slice into a list of Image values. func ImageReadList(buf []byte, dest []Image) int { b := 0 for i := 0; i < len(dest); i++ { @@ -523,7 +513,7 @@ func ImageReadList(buf []byte, dest []Image) int { return xgb.Pad(b) } -// Struct write Image +// Bytes writes a Image value to a byte slice. func (v Image) Bytes() []byte { buf := make([]byte, (((16 + xgb.Pad((int(v.NumPlanes) * 4))) + xgb.Pad((int(v.NumPlanes) * 4))) + xgb.Pad((int(v.DataSize) * 1)))) b := 0 @@ -561,7 +551,7 @@ func (v Image) Bytes() []byte { return buf } -// Write struct list Image +// ImageListBytes writes a list of %s(MISSING) values to a byte slice. func ImageListBytes(buf []byte, list []Image) int { b := 0 var structBytes []byte @@ -573,7 +563,7 @@ func ImageListBytes(buf []byte, list []Image) int { return b } -// Struct list size Image +// ImageListSize computes the size (bytes) of a list of Image values. func ImageListSize(list []Image) int { size := 0 for _, item := range list { @@ -582,8 +572,6 @@ func ImageListSize(list []Image) int { return size } -// 'AttributeInfo' struct definition -// Size: (16 + xgb.Pad((int(Size) * 1))) type AttributeInfo struct { Flags uint32 Min int32 @@ -592,7 +580,7 @@ type AttributeInfo struct { Name string // size: xgb.Pad((int(Size) * 1)) } -// Struct read AttributeInfo +// AttributeInfoRead reads a byte slice into a AttributeInfo value. func AttributeInfoRead(buf []byte, v *AttributeInfo) int { b := 0 @@ -618,7 +606,7 @@ func AttributeInfoRead(buf []byte, v *AttributeInfo) int { return b } -// Struct list read AttributeInfo +// AttributeInfoReadList reads a byte slice into a list of AttributeInfo values. func AttributeInfoReadList(buf []byte, dest []AttributeInfo) int { b := 0 for i := 0; i < len(dest); i++ { @@ -628,7 +616,7 @@ func AttributeInfoReadList(buf []byte, dest []AttributeInfo) int { return xgb.Pad(b) } -// Struct write AttributeInfo +// Bytes writes a AttributeInfo value to a byte slice. func (v AttributeInfo) Bytes() []byte { buf := make([]byte, (16 + xgb.Pad((int(v.Size) * 1)))) b := 0 @@ -651,7 +639,7 @@ func (v AttributeInfo) Bytes() []byte { return buf } -// Write struct list AttributeInfo +// AttributeInfoListBytes writes a list of %s(MISSING) values to a byte slice. func AttributeInfoListBytes(buf []byte, list []AttributeInfo) int { b := 0 var structBytes []byte @@ -663,7 +651,7 @@ func AttributeInfoListBytes(buf []byte, list []AttributeInfo) int { return b } -// Struct list size AttributeInfo +// AttributeInfoListSize computes the size (bytes) of a list of AttributeInfo values. func AttributeInfoListSize(list []AttributeInfo) int { size := 0 for _, item := range list { @@ -672,8 +660,6 @@ func AttributeInfoListSize(list []AttributeInfo) int { return size } -// 'ImageFormatInfo' struct definition -// Size: 128 type ImageFormatInfo struct { Id uint32 Type byte @@ -704,7 +690,7 @@ type ImageFormatInfo struct { // padding: 11 bytes } -// Struct read ImageFormatInfo +// ImageFormatInfoRead reads a byte slice into a ImageFormatInfo value. func ImageFormatInfoRead(buf []byte, v *ImageFormatInfo) int { b := 0 @@ -789,7 +775,7 @@ func ImageFormatInfoRead(buf []byte, v *ImageFormatInfo) int { return b } -// Struct list read ImageFormatInfo +// ImageFormatInfoReadList reads a byte slice into a list of ImageFormatInfo values. func ImageFormatInfoReadList(buf []byte, dest []ImageFormatInfo) int { b := 0 for i := 0; i < len(dest); i++ { @@ -799,7 +785,7 @@ func ImageFormatInfoReadList(buf []byte, dest []ImageFormatInfo) int { return xgb.Pad(b) } -// Struct write ImageFormatInfo +// Bytes writes a ImageFormatInfo value to a byte slice. func (v ImageFormatInfo) Bytes() []byte { buf := make([]byte, 128) b := 0 @@ -883,7 +869,7 @@ func (v ImageFormatInfo) Bytes() []byte { return buf } -// Write struct list ImageFormatInfo +// ImageFormatInfoListBytes writes a list of %s(MISSING) values to a byte slice. func ImageFormatInfoListBytes(buf []byte, list []ImageFormatInfo) int { b := 0 var structBytes []byte @@ -895,7 +881,7 @@ func ImageFormatInfoListBytes(buf []byte, list []ImageFormatInfo) int { return b } -// Struct list size ImageFormatInfo +// ImageFormatInfoListSize computes the size (bytes) of a list of ImageFormatInfo values. func ImageFormatInfoListSize(list []ImageFormatInfo) int { size := 0 for _ = range list { @@ -904,9 +890,7 @@ func ImageFormatInfoListSize(list []ImageFormatInfo) int { return size } -// Event definition VideoNotify (0) -// Size: 32 - +// VideoNotify is the event number for a VideoNotifyEvent. const VideoNotify = 0 type VideoNotifyEvent struct { @@ -917,7 +901,7 @@ type VideoNotifyEvent struct { Port Port } -// Event read VideoNotify +// VideoNotifyEventNew constructs a VideoNotifyEvent value that implements xgb.Event from a byte slice. func VideoNotifyEventNew(buf []byte) xgb.Event { v := VideoNotifyEvent{} b := 1 // don't read event number @@ -940,7 +924,7 @@ func VideoNotifyEventNew(buf []byte) xgb.Event { return v } -// Event write VideoNotify +// Bytes writes a VideoNotifyEvent value to a byte slice. func (v VideoNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -966,12 +950,14 @@ func (v VideoNotifyEvent) Bytes() []byte { return buf } -func (v VideoNotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the VideoNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v VideoNotifyEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of VideoNotifyEvent. func (v VideoNotifyEvent) String() string { fieldVals := make([]string, 0, 4) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -986,9 +972,7 @@ func init() { xgb.NewExtEventFuncs["XVideo"][0] = VideoNotifyEventNew } -// Event definition PortNotify (1) -// Size: 32 - +// PortNotify is the event number for a PortNotifyEvent. const PortNotify = 1 type PortNotifyEvent struct { @@ -1000,7 +984,7 @@ type PortNotifyEvent struct { Value int32 } -// Event read PortNotify +// PortNotifyEventNew constructs a PortNotifyEvent value that implements xgb.Event from a byte slice. func PortNotifyEventNew(buf []byte) xgb.Event { v := PortNotifyEvent{} b := 1 // don't read event number @@ -1025,7 +1009,7 @@ func PortNotifyEventNew(buf []byte) xgb.Event { return v } -// Event write PortNotify +// Bytes writes a PortNotifyEvent value to a byte slice. func (v PortNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -1053,12 +1037,14 @@ func (v PortNotifyEvent) Bytes() []byte { return buf } -func (v PortNotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the PortNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v PortNotifyEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of PortNotifyEvent. func (v PortNotifyEvent) String() string { fieldVals := make([]string, 0, 5) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -1073,9 +1059,7 @@ func init() { xgb.NewExtEventFuncs["XVideo"][1] = PortNotifyEventNew } -// Error definition BadPort (0) -// Size: 32 - +// BadBadPort is the error number for a BadBadPort. const BadBadPort = 0 type BadPortError struct { @@ -1083,7 +1067,7 @@ type BadPortError struct { NiceName string } -// Error read BadPort +// BadPortErrorNew constructs a BadPortError value that implements xgb.Error from a byte slice. func BadPortErrorNew(buf []byte) xgb.Error { v := BadPortError{} v.NiceName = "BadPort" @@ -1097,8 +1081,8 @@ func BadPortErrorNew(buf []byte) xgb.Error { return v } -func (err BadPortError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadBadPort error. +// This is mostly used internally. func (err BadPortError) SequenceId() uint16 { return err.Sequence } @@ -1118,9 +1102,7 @@ func init() { xgb.NewExtErrorFuncs["XVideo"][0] = BadPortErrorNew } -// Error definition BadEncoding (1) -// Size: 32 - +// BadBadEncoding is the error number for a BadBadEncoding. const BadBadEncoding = 1 type BadEncodingError struct { @@ -1128,7 +1110,7 @@ type BadEncodingError struct { NiceName string } -// Error read BadEncoding +// BadEncodingErrorNew constructs a BadEncodingError value that implements xgb.Error from a byte slice. func BadEncodingErrorNew(buf []byte) xgb.Error { v := BadEncodingError{} v.NiceName = "BadEncoding" @@ -1142,8 +1124,8 @@ func BadEncodingErrorNew(buf []byte) xgb.Error { return v } -func (err BadEncodingError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadBadEncoding error. +// This is mostly used internally. func (err BadEncodingError) SequenceId() uint16 { return err.Sequence } @@ -1163,9 +1145,7 @@ func init() { xgb.NewExtErrorFuncs["XVideo"][1] = BadEncodingErrorNew } -// Error definition BadControl (2) -// Size: 32 - +// BadBadControl is the error number for a BadBadControl. const BadBadControl = 2 type BadControlError struct { @@ -1173,7 +1153,7 @@ type BadControlError struct { NiceName string } -// Error read BadControl +// BadControlErrorNew constructs a BadControlError value that implements xgb.Error from a byte slice. func BadControlErrorNew(buf []byte) xgb.Error { v := BadControlError{} v.NiceName = "BadControl" @@ -1187,8 +1167,8 @@ func BadControlErrorNew(buf []byte) xgb.Error { return v } -func (err BadControlError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadBadControl error. +// This is mostly used internally. func (err BadControlError) SequenceId() uint16 { return err.Sequence } @@ -1208,35 +1188,37 @@ func init() { xgb.NewExtErrorFuncs["XVideo"][2] = BadControlErrorNew } -// Request QueryExtension -// size: 4 +// QueryExtensionCookie is a cookie used only for QueryExtension requests. type QueryExtensionCookie struct { *xgb.Cookie } +// QueryExtension sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryExtensionCookie.Reply() func QueryExtension(c *xgb.Conn) QueryExtensionCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryExtensionRequest(c), cookie) return QueryExtensionCookie{cookie} } +// QueryExtensionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryExtensionUnchecked(c *xgb.Conn) QueryExtensionCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryExtensionRequest(c), cookie) return QueryExtensionCookie{cookie} } -// Request reply for QueryExtension -// size: 12 +// QueryExtensionReply represents the data returned from a QueryExtension request. type QueryExtensionReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Major uint16 Minor uint16 } -// Waits and reads reply data from request QueryExtension +// Reply blocks and returns the reply data for a QueryExtension request. func (cook QueryExtensionCookie) Reply() (*QueryExtensionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1248,7 +1230,7 @@ func (cook QueryExtensionCookie) Reply() (*QueryExtensionReply, error) { return queryExtensionReply(buf), nil } -// Read reply into structure from buffer for QueryExtension +// queryExtensionReply reads a byte slice into a QueryExtensionReply value. func queryExtensionReply(buf []byte) *QueryExtensionReply { v := new(QueryExtensionReply) b := 1 // skip reply determinant @@ -1271,6 +1253,7 @@ func queryExtensionReply(buf []byte) *QueryExtensionReply { } // Write request to wire for QueryExtension +// queryExtensionRequest writes a QueryExtension request to a byte slice. func queryExtensionRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -1288,36 +1271,38 @@ func queryExtensionRequest(c *xgb.Conn) []byte { return buf } -// Request QueryAdaptors -// size: 8 +// QueryAdaptorsCookie is a cookie used only for QueryAdaptors requests. type QueryAdaptorsCookie struct { *xgb.Cookie } +// QueryAdaptors sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryAdaptorsCookie.Reply() func QueryAdaptors(c *xgb.Conn, Window xproto.Window) QueryAdaptorsCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryAdaptorsRequest(c, Window), cookie) return QueryAdaptorsCookie{cookie} } +// QueryAdaptorsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryAdaptorsUnchecked(c *xgb.Conn, Window xproto.Window) QueryAdaptorsCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryAdaptorsRequest(c, Window), cookie) return QueryAdaptorsCookie{cookie} } -// Request reply for QueryAdaptors -// size: (32 + AdaptorInfoListSize(Info)) +// QueryAdaptorsReply represents the data returned from a QueryAdaptors request. type QueryAdaptorsReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes NumAdaptors uint16 // padding: 22 bytes Info []AdaptorInfo // size: AdaptorInfoListSize(Info) } -// Waits and reads reply data from request QueryAdaptors +// Reply blocks and returns the reply data for a QueryAdaptors request. func (cook QueryAdaptorsCookie) Reply() (*QueryAdaptorsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1329,7 +1314,7 @@ func (cook QueryAdaptorsCookie) Reply() (*QueryAdaptorsReply, error) { return queryAdaptorsReply(buf), nil } -// Read reply into structure from buffer for QueryAdaptors +// queryAdaptorsReply reads a byte slice into a QueryAdaptorsReply value. func queryAdaptorsReply(buf []byte) *QueryAdaptorsReply { v := new(QueryAdaptorsReply) b := 1 // skip reply determinant @@ -1354,6 +1339,7 @@ func queryAdaptorsReply(buf []byte) *QueryAdaptorsReply { } // Write request to wire for QueryAdaptors +// queryAdaptorsRequest writes a QueryAdaptors request to a byte slice. func queryAdaptorsRequest(c *xgb.Conn, Window xproto.Window) []byte { size := 8 b := 0 @@ -1374,36 +1360,38 @@ func queryAdaptorsRequest(c *xgb.Conn, Window xproto.Window) []byte { return buf } -// Request QueryEncodings -// size: 8 +// QueryEncodingsCookie is a cookie used only for QueryEncodings requests. type QueryEncodingsCookie struct { *xgb.Cookie } +// QueryEncodings sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryEncodingsCookie.Reply() func QueryEncodings(c *xgb.Conn, Port Port) QueryEncodingsCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryEncodingsRequest(c, Port), cookie) return QueryEncodingsCookie{cookie} } +// QueryEncodingsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryEncodingsUnchecked(c *xgb.Conn, Port Port) QueryEncodingsCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryEncodingsRequest(c, Port), cookie) return QueryEncodingsCookie{cookie} } -// Request reply for QueryEncodings -// size: (32 + EncodingInfoListSize(Info)) +// QueryEncodingsReply represents the data returned from a QueryEncodings request. type QueryEncodingsReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes NumEncodings uint16 // padding: 22 bytes Info []EncodingInfo // size: EncodingInfoListSize(Info) } -// Waits and reads reply data from request QueryEncodings +// Reply blocks and returns the reply data for a QueryEncodings request. func (cook QueryEncodingsCookie) Reply() (*QueryEncodingsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1415,7 +1403,7 @@ func (cook QueryEncodingsCookie) Reply() (*QueryEncodingsReply, error) { return queryEncodingsReply(buf), nil } -// Read reply into structure from buffer for QueryEncodings +// queryEncodingsReply reads a byte slice into a QueryEncodingsReply value. func queryEncodingsReply(buf []byte) *QueryEncodingsReply { v := new(QueryEncodingsReply) b := 1 // skip reply determinant @@ -1440,6 +1428,7 @@ func queryEncodingsReply(buf []byte) *QueryEncodingsReply { } // Write request to wire for QueryEncodings +// queryEncodingsRequest writes a QueryEncodings request to a byte slice. func queryEncodingsRequest(c *xgb.Conn, Port Port) []byte { size := 8 b := 0 @@ -1460,33 +1449,35 @@ func queryEncodingsRequest(c *xgb.Conn, Port Port) []byte { return buf } -// Request GrabPort -// size: 12 +// GrabPortCookie is a cookie used only for GrabPort requests. type GrabPortCookie struct { *xgb.Cookie } +// GrabPort sends a checked request. +// If an error occurs, it will be returned with the reply by calling GrabPortCookie.Reply() func GrabPort(c *xgb.Conn, Port Port, Time xproto.Timestamp) GrabPortCookie { cookie := c.NewCookie(true, true) c.NewRequest(grabPortRequest(c, Port, Time), cookie) return GrabPortCookie{cookie} } +// GrabPortUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GrabPortUnchecked(c *xgb.Conn, Port Port, Time xproto.Timestamp) GrabPortCookie { cookie := c.NewCookie(false, true) c.NewRequest(grabPortRequest(c, Port, Time), cookie) return GrabPortCookie{cookie} } -// Request reply for GrabPort -// size: 8 +// GrabPortReply represents the data returned from a GrabPort request. type GrabPortReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply Result byte } -// Waits and reads reply data from request GrabPort +// Reply blocks and returns the reply data for a GrabPort request. func (cook GrabPortCookie) Reply() (*GrabPortReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1498,7 +1489,7 @@ func (cook GrabPortCookie) Reply() (*GrabPortReply, error) { return grabPortReply(buf), nil } -// Read reply into structure from buffer for GrabPort +// grabPortReply reads a byte slice into a GrabPortReply value. func grabPortReply(buf []byte) *GrabPortReply { v := new(GrabPortReply) b := 1 // skip reply determinant @@ -1516,6 +1507,7 @@ func grabPortReply(buf []byte) *GrabPortReply { } // Write request to wire for GrabPort +// grabPortRequest writes a GrabPort request to a byte slice. func grabPortRequest(c *xgb.Conn, Port Port, Time xproto.Timestamp) []byte { size := 12 b := 0 @@ -1539,30 +1531,35 @@ func grabPortRequest(c *xgb.Conn, Port Port, Time xproto.Timestamp) []byte { return buf } -// Request UngrabPort -// size: 12 +// UngrabPortCookie is a cookie used only for UngrabPort requests. type UngrabPortCookie struct { *xgb.Cookie } -// Write request to wire for UngrabPort +// UngrabPort sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func UngrabPort(c *xgb.Conn, Port Port, Time xproto.Timestamp) UngrabPortCookie { cookie := c.NewCookie(false, false) c.NewRequest(ungrabPortRequest(c, Port, Time), cookie) return UngrabPortCookie{cookie} } +// UngrabPortChecked sends a checked request. +// If an error occurs, it can be retrieved using UngrabPortCookie.Check() func UngrabPortChecked(c *xgb.Conn, Port Port, Time xproto.Timestamp) UngrabPortCookie { cookie := c.NewCookie(true, false) c.NewRequest(ungrabPortRequest(c, Port, Time), cookie) return UngrabPortCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook UngrabPortCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for UngrabPort +// ungrabPortRequest writes a UngrabPort request to a byte slice. func ungrabPortRequest(c *xgb.Conn, Port Port, Time xproto.Timestamp) []byte { size := 12 b := 0 @@ -1586,30 +1583,35 @@ func ungrabPortRequest(c *xgb.Conn, Port Port, Time xproto.Timestamp) []byte { return buf } -// Request PutVideo -// size: 32 +// PutVideoCookie is a cookie used only for PutVideo requests. type PutVideoCookie struct { *xgb.Cookie } -// Write request to wire for PutVideo +// PutVideo sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PutVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutVideoCookie { cookie := c.NewCookie(false, false) c.NewRequest(putVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) return PutVideoCookie{cookie} } +// PutVideoChecked sends a checked request. +// If an error occurs, it can be retrieved using PutVideoCookie.Check() func PutVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutVideoCookie { cookie := c.NewCookie(true, false) c.NewRequest(putVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) return PutVideoCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook PutVideoCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for PutVideo +// putVideoRequest writes a PutVideo request to a byte slice. func putVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { size := 32 b := 0 @@ -1660,30 +1662,35 @@ func putVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto return buf } -// Request PutStill -// size: 32 +// PutStillCookie is a cookie used only for PutStill requests. type PutStillCookie struct { *xgb.Cookie } -// Write request to wire for PutStill +// PutStill sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PutStill(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutStillCookie { cookie := c.NewCookie(false, false) c.NewRequest(putStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) return PutStillCookie{cookie} } +// PutStillChecked sends a checked request. +// If an error occurs, it can be retrieved using PutStillCookie.Check() func PutStillChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutStillCookie { cookie := c.NewCookie(true, false) c.NewRequest(putStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) return PutStillCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook PutStillCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for PutStill +// putStillRequest writes a PutStill request to a byte slice. func putStillRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { size := 32 b := 0 @@ -1734,30 +1741,35 @@ func putStillRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto return buf } -// Request GetVideo -// size: 32 +// GetVideoCookie is a cookie used only for GetVideo requests. type GetVideoCookie struct { *xgb.Cookie } -// Write request to wire for GetVideo +// GetVideo sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetVideoCookie { cookie := c.NewCookie(false, false) c.NewRequest(getVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) return GetVideoCookie{cookie} } +// GetVideoChecked sends a checked request. +// If an error occurs, it can be retrieved using GetVideoCookie.Check() func GetVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetVideoCookie { cookie := c.NewCookie(true, false) c.NewRequest(getVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) return GetVideoCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook GetVideoCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for GetVideo +// getVideoRequest writes a GetVideo request to a byte slice. func getVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { size := 32 b := 0 @@ -1808,30 +1820,35 @@ func getVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto return buf } -// Request GetStill -// size: 32 +// GetStillCookie is a cookie used only for GetStill requests. type GetStillCookie struct { *xgb.Cookie } -// Write request to wire for GetStill +// GetStill sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetStill(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetStillCookie { cookie := c.NewCookie(false, false) c.NewRequest(getStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) return GetStillCookie{cookie} } +// GetStillChecked sends a checked request. +// If an error occurs, it can be retrieved using GetStillCookie.Check() func GetStillChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetStillCookie { cookie := c.NewCookie(true, false) c.NewRequest(getStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) return GetStillCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook GetStillCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for GetStill +// getStillRequest writes a GetStill request to a byte slice. func getStillRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { size := 32 b := 0 @@ -1882,30 +1899,35 @@ func getStillRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto return buf } -// Request StopVideo -// size: 12 +// StopVideoCookie is a cookie used only for StopVideo requests. type StopVideoCookie struct { *xgb.Cookie } -// Write request to wire for StopVideo +// StopVideo sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func StopVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable) StopVideoCookie { cookie := c.NewCookie(false, false) c.NewRequest(stopVideoRequest(c, Port, Drawable), cookie) return StopVideoCookie{cookie} } +// StopVideoChecked sends a checked request. +// If an error occurs, it can be retrieved using StopVideoCookie.Check() func StopVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable) StopVideoCookie { cookie := c.NewCookie(true, false) c.NewRequest(stopVideoRequest(c, Port, Drawable), cookie) return StopVideoCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook StopVideoCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for StopVideo +// stopVideoRequest writes a StopVideo request to a byte slice. func stopVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable) []byte { size := 12 b := 0 @@ -1929,30 +1951,35 @@ func stopVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable) []byte { return buf } -// Request SelectVideoNotify -// size: 12 +// SelectVideoNotifyCookie is a cookie used only for SelectVideoNotify requests. type SelectVideoNotifyCookie struct { *xgb.Cookie } -// Write request to wire for SelectVideoNotify +// SelectVideoNotify sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SelectVideoNotify(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) SelectVideoNotifyCookie { cookie := c.NewCookie(false, false) c.NewRequest(selectVideoNotifyRequest(c, Drawable, Onoff), cookie) return SelectVideoNotifyCookie{cookie} } +// SelectVideoNotifyChecked sends a checked request. +// If an error occurs, it can be retrieved using SelectVideoNotifyCookie.Check() func SelectVideoNotifyChecked(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) SelectVideoNotifyCookie { cookie := c.NewCookie(true, false) c.NewRequest(selectVideoNotifyRequest(c, Drawable, Onoff), cookie) return SelectVideoNotifyCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SelectVideoNotifyCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SelectVideoNotify +// selectVideoNotifyRequest writes a SelectVideoNotify request to a byte slice. func selectVideoNotifyRequest(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) []byte { size := 12 b := 0 @@ -1982,30 +2009,35 @@ func selectVideoNotifyRequest(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) return buf } -// Request SelectPortNotify -// size: 12 +// SelectPortNotifyCookie is a cookie used only for SelectPortNotify requests. type SelectPortNotifyCookie struct { *xgb.Cookie } -// Write request to wire for SelectPortNotify +// SelectPortNotify sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SelectPortNotify(c *xgb.Conn, Port Port, Onoff bool) SelectPortNotifyCookie { cookie := c.NewCookie(false, false) c.NewRequest(selectPortNotifyRequest(c, Port, Onoff), cookie) return SelectPortNotifyCookie{cookie} } +// SelectPortNotifyChecked sends a checked request. +// If an error occurs, it can be retrieved using SelectPortNotifyCookie.Check() func SelectPortNotifyChecked(c *xgb.Conn, Port Port, Onoff bool) SelectPortNotifyCookie { cookie := c.NewCookie(true, false) c.NewRequest(selectPortNotifyRequest(c, Port, Onoff), cookie) return SelectPortNotifyCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SelectPortNotifyCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SelectPortNotify +// selectPortNotifyRequest writes a SelectPortNotify request to a byte slice. func selectPortNotifyRequest(c *xgb.Conn, Port Port, Onoff bool) []byte { size := 12 b := 0 @@ -2035,35 +2067,37 @@ func selectPortNotifyRequest(c *xgb.Conn, Port Port, Onoff bool) []byte { return buf } -// Request QueryBestSize -// size: 20 +// QueryBestSizeCookie is a cookie used only for QueryBestSize requests. type QueryBestSizeCookie struct { *xgb.Cookie } +// QueryBestSize sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryBestSizeCookie.Reply() func QueryBestSize(c *xgb.Conn, Port Port, VidW uint16, VidH uint16, DrwW uint16, DrwH uint16, Motion bool) QueryBestSizeCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryBestSizeRequest(c, Port, VidW, VidH, DrwW, DrwH, Motion), cookie) return QueryBestSizeCookie{cookie} } +// QueryBestSizeUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryBestSizeUnchecked(c *xgb.Conn, Port Port, VidW uint16, VidH uint16, DrwW uint16, DrwH uint16, Motion bool) QueryBestSizeCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryBestSizeRequest(c, Port, VidW, VidH, DrwW, DrwH, Motion), cookie) return QueryBestSizeCookie{cookie} } -// Request reply for QueryBestSize -// size: 12 +// QueryBestSizeReply represents the data returned from a QueryBestSize request. type QueryBestSizeReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes ActualWidth uint16 ActualHeight uint16 } -// Waits and reads reply data from request QueryBestSize +// Reply blocks and returns the reply data for a QueryBestSize request. func (cook QueryBestSizeCookie) Reply() (*QueryBestSizeReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -2075,7 +2109,7 @@ func (cook QueryBestSizeCookie) Reply() (*QueryBestSizeReply, error) { return queryBestSizeReply(buf), nil } -// Read reply into structure from buffer for QueryBestSize +// queryBestSizeReply reads a byte slice into a QueryBestSizeReply value. func queryBestSizeReply(buf []byte) *QueryBestSizeReply { v := new(QueryBestSizeReply) b := 1 // skip reply determinant @@ -2098,6 +2132,7 @@ func queryBestSizeReply(buf []byte) *QueryBestSizeReply { } // Write request to wire for QueryBestSize +// queryBestSizeRequest writes a QueryBestSize request to a byte slice. func queryBestSizeRequest(c *xgb.Conn, Port Port, VidW uint16, VidH uint16, DrwW uint16, DrwH uint16, Motion bool) []byte { size := 20 b := 0 @@ -2139,30 +2174,35 @@ func queryBestSizeRequest(c *xgb.Conn, Port Port, VidW uint16, VidH uint16, DrwW return buf } -// Request SetPortAttribute -// size: 16 +// SetPortAttributeCookie is a cookie used only for SetPortAttribute requests. type SetPortAttributeCookie struct { *xgb.Cookie } -// Write request to wire for SetPortAttribute +// SetPortAttribute sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetPortAttribute(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32) SetPortAttributeCookie { cookie := c.NewCookie(false, false) c.NewRequest(setPortAttributeRequest(c, Port, Attribute, Value), cookie) return SetPortAttributeCookie{cookie} } +// SetPortAttributeChecked sends a checked request. +// If an error occurs, it can be retrieved using SetPortAttributeCookie.Check() func SetPortAttributeChecked(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32) SetPortAttributeCookie { cookie := c.NewCookie(true, false) c.NewRequest(setPortAttributeRequest(c, Port, Attribute, Value), cookie) return SetPortAttributeCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetPortAttributeCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetPortAttribute +// setPortAttributeRequest writes a SetPortAttribute request to a byte slice. func setPortAttributeRequest(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32) []byte { size := 16 b := 0 @@ -2189,34 +2229,36 @@ func setPortAttributeRequest(c *xgb.Conn, Port Port, Attribute xproto.Atom, Valu return buf } -// Request GetPortAttribute -// size: 12 +// GetPortAttributeCookie is a cookie used only for GetPortAttribute requests. type GetPortAttributeCookie struct { *xgb.Cookie } +// GetPortAttribute sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPortAttributeCookie.Reply() func GetPortAttribute(c *xgb.Conn, Port Port, Attribute xproto.Atom) GetPortAttributeCookie { cookie := c.NewCookie(true, true) c.NewRequest(getPortAttributeRequest(c, Port, Attribute), cookie) return GetPortAttributeCookie{cookie} } +// GetPortAttributeUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetPortAttributeUnchecked(c *xgb.Conn, Port Port, Attribute xproto.Atom) GetPortAttributeCookie { cookie := c.NewCookie(false, true) c.NewRequest(getPortAttributeRequest(c, Port, Attribute), cookie) return GetPortAttributeCookie{cookie} } -// Request reply for GetPortAttribute -// size: 12 +// GetPortAttributeReply represents the data returned from a GetPortAttribute request. type GetPortAttributeReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Value int32 } -// Waits and reads reply data from request GetPortAttribute +// Reply blocks and returns the reply data for a GetPortAttribute request. func (cook GetPortAttributeCookie) Reply() (*GetPortAttributeReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -2228,7 +2270,7 @@ func (cook GetPortAttributeCookie) Reply() (*GetPortAttributeReply, error) { return getPortAttributeReply(buf), nil } -// Read reply into structure from buffer for GetPortAttribute +// getPortAttributeReply reads a byte slice into a GetPortAttributeReply value. func getPortAttributeReply(buf []byte) *GetPortAttributeReply { v := new(GetPortAttributeReply) b := 1 // skip reply determinant @@ -2248,6 +2290,7 @@ func getPortAttributeReply(buf []byte) *GetPortAttributeReply { } // Write request to wire for GetPortAttribute +// getPortAttributeRequest writes a GetPortAttribute request to a byte slice. func getPortAttributeRequest(c *xgb.Conn, Port Port, Attribute xproto.Atom) []byte { size := 12 b := 0 @@ -2271,29 +2314,31 @@ func getPortAttributeRequest(c *xgb.Conn, Port Port, Attribute xproto.Atom) []by return buf } -// Request QueryPortAttributes -// size: 8 +// QueryPortAttributesCookie is a cookie used only for QueryPortAttributes requests. type QueryPortAttributesCookie struct { *xgb.Cookie } +// QueryPortAttributes sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryPortAttributesCookie.Reply() func QueryPortAttributes(c *xgb.Conn, Port Port) QueryPortAttributesCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryPortAttributesRequest(c, Port), cookie) return QueryPortAttributesCookie{cookie} } +// QueryPortAttributesUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryPortAttributesUnchecked(c *xgb.Conn, Port Port) QueryPortAttributesCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryPortAttributesRequest(c, Port), cookie) return QueryPortAttributesCookie{cookie} } -// Request reply for QueryPortAttributes -// size: (32 + AttributeInfoListSize(Attributes)) +// QueryPortAttributesReply represents the data returned from a QueryPortAttributes request. type QueryPortAttributesReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes NumAttributes uint32 TextSize uint32 @@ -2301,7 +2346,7 @@ type QueryPortAttributesReply struct { Attributes []AttributeInfo // size: AttributeInfoListSize(Attributes) } -// Waits and reads reply data from request QueryPortAttributes +// Reply blocks and returns the reply data for a QueryPortAttributes request. func (cook QueryPortAttributesCookie) Reply() (*QueryPortAttributesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -2313,7 +2358,7 @@ func (cook QueryPortAttributesCookie) Reply() (*QueryPortAttributesReply, error) return queryPortAttributesReply(buf), nil } -// Read reply into structure from buffer for QueryPortAttributes +// queryPortAttributesReply reads a byte slice into a QueryPortAttributesReply value. func queryPortAttributesReply(buf []byte) *QueryPortAttributesReply { v := new(QueryPortAttributesReply) b := 1 // skip reply determinant @@ -2341,6 +2386,7 @@ func queryPortAttributesReply(buf []byte) *QueryPortAttributesReply { } // Write request to wire for QueryPortAttributes +// queryPortAttributesRequest writes a QueryPortAttributes request to a byte slice. func queryPortAttributesRequest(c *xgb.Conn, Port Port) []byte { size := 8 b := 0 @@ -2361,36 +2407,38 @@ func queryPortAttributesRequest(c *xgb.Conn, Port Port) []byte { return buf } -// Request ListImageFormats -// size: 8 +// ListImageFormatsCookie is a cookie used only for ListImageFormats requests. type ListImageFormatsCookie struct { *xgb.Cookie } +// ListImageFormats sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListImageFormatsCookie.Reply() func ListImageFormats(c *xgb.Conn, Port Port) ListImageFormatsCookie { cookie := c.NewCookie(true, true) c.NewRequest(listImageFormatsRequest(c, Port), cookie) return ListImageFormatsCookie{cookie} } +// ListImageFormatsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ListImageFormatsUnchecked(c *xgb.Conn, Port Port) ListImageFormatsCookie { cookie := c.NewCookie(false, true) c.NewRequest(listImageFormatsRequest(c, Port), cookie) return ListImageFormatsCookie{cookie} } -// Request reply for ListImageFormats -// size: (32 + ImageFormatInfoListSize(Format)) +// ListImageFormatsReply represents the data returned from a ListImageFormats request. type ListImageFormatsReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes NumFormats uint32 // padding: 20 bytes Format []ImageFormatInfo // size: ImageFormatInfoListSize(Format) } -// Waits and reads reply data from request ListImageFormats +// Reply blocks and returns the reply data for a ListImageFormats request. func (cook ListImageFormatsCookie) Reply() (*ListImageFormatsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -2402,7 +2450,7 @@ func (cook ListImageFormatsCookie) Reply() (*ListImageFormatsReply, error) { return listImageFormatsReply(buf), nil } -// Read reply into structure from buffer for ListImageFormats +// listImageFormatsReply reads a byte slice into a ListImageFormatsReply value. func listImageFormatsReply(buf []byte) *ListImageFormatsReply { v := new(ListImageFormatsReply) b := 1 // skip reply determinant @@ -2427,6 +2475,7 @@ func listImageFormatsReply(buf []byte) *ListImageFormatsReply { } // Write request to wire for ListImageFormats +// listImageFormatsRequest writes a ListImageFormats request to a byte slice. func listImageFormatsRequest(c *xgb.Conn, Port Port) []byte { size := 8 b := 0 @@ -2447,29 +2496,31 @@ func listImageFormatsRequest(c *xgb.Conn, Port Port) []byte { return buf } -// Request QueryImageAttributes -// size: 16 +// QueryImageAttributesCookie is a cookie used only for QueryImageAttributes requests. type QueryImageAttributesCookie struct { *xgb.Cookie } +// QueryImageAttributes sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryImageAttributesCookie.Reply() func QueryImageAttributes(c *xgb.Conn, Port Port, Id uint32, Width uint16, Height uint16) QueryImageAttributesCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryImageAttributesRequest(c, Port, Id, Width, Height), cookie) return QueryImageAttributesCookie{cookie} } +// QueryImageAttributesUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryImageAttributesUnchecked(c *xgb.Conn, Port Port, Id uint32, Width uint16, Height uint16) QueryImageAttributesCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryImageAttributesRequest(c, Port, Id, Width, Height), cookie) return QueryImageAttributesCookie{cookie} } -// Request reply for QueryImageAttributes -// size: ((32 + xgb.Pad((int(NumPlanes) * 4))) + xgb.Pad((int(NumPlanes) * 4))) +// QueryImageAttributesReply represents the data returned from a QueryImageAttributes request. type QueryImageAttributesReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes NumPlanes uint32 DataSize uint32 @@ -2480,7 +2531,7 @@ type QueryImageAttributesReply struct { Offsets []uint32 // size: xgb.Pad((int(NumPlanes) * 4)) } -// Waits and reads reply data from request QueryImageAttributes +// Reply blocks and returns the reply data for a QueryImageAttributes request. func (cook QueryImageAttributesCookie) Reply() (*QueryImageAttributesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -2492,7 +2543,7 @@ func (cook QueryImageAttributesCookie) Reply() (*QueryImageAttributesReply, erro return queryImageAttributesReply(buf), nil } -// Read reply into structure from buffer for QueryImageAttributes +// queryImageAttributesReply reads a byte slice into a QueryImageAttributesReply value. func queryImageAttributesReply(buf []byte) *QueryImageAttributesReply { v := new(QueryImageAttributesReply) b := 1 // skip reply determinant @@ -2537,6 +2588,7 @@ func queryImageAttributesReply(buf []byte) *QueryImageAttributesReply { } // Write request to wire for QueryImageAttributes +// queryImageAttributesRequest writes a QueryImageAttributes request to a byte slice. func queryImageAttributesRequest(c *xgb.Conn, Port Port, Id uint32, Width uint16, Height uint16) []byte { size := 16 b := 0 @@ -2566,30 +2618,35 @@ func queryImageAttributesRequest(c *xgb.Conn, Port Port, Id uint32, Width uint16 return buf } -// Request PutImage -// size: xgb.Pad((40 + xgb.Pad((len(Data) * 1)))) +// PutImageCookie is a cookie used only for PutImage requests. type PutImageCookie struct { *xgb.Cookie } -// Write request to wire for PutImage +// PutImage sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PutImage(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) PutImageCookie { cookie := c.NewCookie(false, false) c.NewRequest(putImageRequest(c, Port, Drawable, Gc, Id, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, Data), cookie) return PutImageCookie{cookie} } +// PutImageChecked sends a checked request. +// If an error occurs, it can be retrieved using PutImageCookie.Check() func PutImageChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) PutImageCookie { cookie := c.NewCookie(true, false) c.NewRequest(putImageRequest(c, Port, Drawable, Gc, Id, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, Data), cookie) return PutImageCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook PutImageCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for PutImage +// putImageRequest writes a PutImage request to a byte slice. func putImageRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) []byte { size := xgb.Pad((40 + xgb.Pad((len(Data) * 1)))) b := 0 @@ -2652,30 +2709,35 @@ func putImageRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto return buf } -// Request ShmPutImage -// size: 52 +// ShmPutImageCookie is a cookie used only for ShmPutImage requests. type ShmPutImageCookie struct { *xgb.Cookie } -// Write request to wire for ShmPutImage +// ShmPutImage sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ShmPutImage(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Shmseg shm.Seg, Id uint32, Offset uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, SendEvent byte) ShmPutImageCookie { cookie := c.NewCookie(false, false) c.NewRequest(shmPutImageRequest(c, Port, Drawable, Gc, Shmseg, Id, Offset, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, SendEvent), cookie) return ShmPutImageCookie{cookie} } +// ShmPutImageChecked sends a checked request. +// If an error occurs, it can be retrieved using ShmPutImageCookie.Check() func ShmPutImageChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Shmseg shm.Seg, Id uint32, Offset uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, SendEvent byte) ShmPutImageCookie { cookie := c.NewCookie(true, false) c.NewRequest(shmPutImageRequest(c, Port, Drawable, Gc, Shmseg, Id, Offset, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, SendEvent), cookie) return ShmPutImageCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook ShmPutImageCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ShmPutImage +// shmPutImageRequest writes a ShmPutImage request to a byte slice. func shmPutImageRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Shmseg shm.Seg, Id uint32, Offset uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, SendEvent byte) []byte { size := 52 b := 0 -- cgit v1.2.3 From 3e6b3544934cb71e3a3b0edf9bc184241ac1ad7f Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Fri, 11 May 2012 01:58:52 -0400 Subject: add a little more docs for errors --- nexgb/xv/xv.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'nexgb/xv') diff --git a/nexgb/xv/xv.go b/nexgb/xv/xv.go index 041b082..c048e88 100644 --- a/nexgb/xv/xv.go +++ b/nexgb/xv/xv.go @@ -2,7 +2,7 @@ package xv /* - This file was generated by xv.xml on May 10 2012 11:56:20pm EDT. + This file was generated by xv.xml on May 11 2012 1:58:37am EDT. This file is automatically generated. Edit at your peril! */ @@ -41,10 +41,6 @@ func init() { xgb.NewExtErrorFuncs["XVideo"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - // Skipping definition for base type 'Double' // Skipping definition for base type 'Bool' @@ -65,6 +61,10 @@ func init() { // Skipping definition for base type 'Card16' +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Card32' + const ( TypeInputMask = 1 TypeOutputMask = 2 @@ -1087,10 +1087,13 @@ func (err BadPortError) SequenceId() uint16 { return err.Sequence } +// BadId returns the 'BadValue' number if one exists for the BadBadPort error. If no bad value exists, 0 is returned. func (err BadPortError) BadId() uint32 { return 0 } +// Error returns a rudimentary string representation of the BadBadPort error. + func (err BadPortError) Error() string { fieldVals := make([]string, 0, 0) fieldVals = append(fieldVals, "NiceName: "+err.NiceName) @@ -1130,10 +1133,13 @@ func (err BadEncodingError) SequenceId() uint16 { return err.Sequence } +// BadId returns the 'BadValue' number if one exists for the BadBadEncoding error. If no bad value exists, 0 is returned. func (err BadEncodingError) BadId() uint32 { return 0 } +// Error returns a rudimentary string representation of the BadBadEncoding error. + func (err BadEncodingError) Error() string { fieldVals := make([]string, 0, 0) fieldVals = append(fieldVals, "NiceName: "+err.NiceName) @@ -1173,10 +1179,13 @@ func (err BadControlError) SequenceId() uint16 { return err.Sequence } +// BadId returns the 'BadValue' number if one exists for the BadBadControl error. If no bad value exists, 0 is returned. func (err BadControlError) BadId() uint32 { return 0 } +// Error returns a rudimentary string representation of the BadBadControl error. + func (err BadControlError) Error() string { fieldVals := make([]string, 0, 0) fieldVals = append(fieldVals, "NiceName: "+err.NiceName) -- cgit v1.2.3 From 29942bf078c92fea681e42ca5029592526f00718 Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Fri, 11 May 2012 23:58:52 -0400 Subject: panic when an extension request is issued before an extension has been initialized. but give a nice error message for the happy people. --- nexgb/xv/xv.go | 130 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 125 insertions(+), 5 deletions(-) (limited to 'nexgb/xv') diff --git a/nexgb/xv/xv.go b/nexgb/xv/xv.go index c048e88..c6ba384 100644 --- a/nexgb/xv/xv.go +++ b/nexgb/xv/xv.go @@ -2,7 +2,7 @@ package xv /* - This file was generated by xv.xml on May 11 2012 1:58:37am EDT. + This file was generated by xv.xml on May 11 2012 11:57:20pm EDT. This file is automatically generated. Edit at your peril! */ @@ -41,10 +41,6 @@ func init() { xgb.NewExtErrorFuncs["XVideo"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - // Skipping definition for base type 'Float' // Skipping definition for base type 'Card8' @@ -65,6 +61,10 @@ func init() { // Skipping definition for base type 'Card32' +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Bool' + const ( TypeInputMask = 1 TypeOutputMask = 2 @@ -1205,6 +1205,9 @@ type QueryExtensionCookie struct { // QueryExtension sends a checked request. // If an error occurs, it will be returned with the reply by calling QueryExtensionCookie.Reply() func QueryExtension(c *xgb.Conn) QueryExtensionCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'QueryExtension' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, true) c.NewRequest(queryExtensionRequest(c), cookie) return QueryExtensionCookie{cookie} @@ -1213,6 +1216,9 @@ func QueryExtension(c *xgb.Conn) QueryExtensionCookie { // QueryExtensionUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryExtensionUnchecked(c *xgb.Conn) QueryExtensionCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'QueryExtension' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, true) c.NewRequest(queryExtensionRequest(c), cookie) return QueryExtensionCookie{cookie} @@ -1288,6 +1294,9 @@ type QueryAdaptorsCookie struct { // QueryAdaptors sends a checked request. // If an error occurs, it will be returned with the reply by calling QueryAdaptorsCookie.Reply() func QueryAdaptors(c *xgb.Conn, Window xproto.Window) QueryAdaptorsCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'QueryAdaptors' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, true) c.NewRequest(queryAdaptorsRequest(c, Window), cookie) return QueryAdaptorsCookie{cookie} @@ -1296,6 +1305,9 @@ func QueryAdaptors(c *xgb.Conn, Window xproto.Window) QueryAdaptorsCookie { // QueryAdaptorsUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryAdaptorsUnchecked(c *xgb.Conn, Window xproto.Window) QueryAdaptorsCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'QueryAdaptors' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, true) c.NewRequest(queryAdaptorsRequest(c, Window), cookie) return QueryAdaptorsCookie{cookie} @@ -1377,6 +1389,9 @@ type QueryEncodingsCookie struct { // QueryEncodings sends a checked request. // If an error occurs, it will be returned with the reply by calling QueryEncodingsCookie.Reply() func QueryEncodings(c *xgb.Conn, Port Port) QueryEncodingsCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'QueryEncodings' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, true) c.NewRequest(queryEncodingsRequest(c, Port), cookie) return QueryEncodingsCookie{cookie} @@ -1385,6 +1400,9 @@ func QueryEncodings(c *xgb.Conn, Port Port) QueryEncodingsCookie { // QueryEncodingsUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryEncodingsUnchecked(c *xgb.Conn, Port Port) QueryEncodingsCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'QueryEncodings' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, true) c.NewRequest(queryEncodingsRequest(c, Port), cookie) return QueryEncodingsCookie{cookie} @@ -1466,6 +1484,9 @@ type GrabPortCookie struct { // GrabPort sends a checked request. // If an error occurs, it will be returned with the reply by calling GrabPortCookie.Reply() func GrabPort(c *xgb.Conn, Port Port, Time xproto.Timestamp) GrabPortCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'GrabPort' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, true) c.NewRequest(grabPortRequest(c, Port, Time), cookie) return GrabPortCookie{cookie} @@ -1474,6 +1495,9 @@ func GrabPort(c *xgb.Conn, Port Port, Time xproto.Timestamp) GrabPortCookie { // GrabPortUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GrabPortUnchecked(c *xgb.Conn, Port Port, Time xproto.Timestamp) GrabPortCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'GrabPort' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, true) c.NewRequest(grabPortRequest(c, Port, Time), cookie) return GrabPortCookie{cookie} @@ -1548,6 +1572,9 @@ type UngrabPortCookie struct { // UngrabPort sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func UngrabPort(c *xgb.Conn, Port Port, Time xproto.Timestamp) UngrabPortCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'UngrabPort' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, false) c.NewRequest(ungrabPortRequest(c, Port, Time), cookie) return UngrabPortCookie{cookie} @@ -1556,6 +1583,9 @@ func UngrabPort(c *xgb.Conn, Port Port, Time xproto.Timestamp) UngrabPortCookie // UngrabPortChecked sends a checked request. // If an error occurs, it can be retrieved using UngrabPortCookie.Check() func UngrabPortChecked(c *xgb.Conn, Port Port, Time xproto.Timestamp) UngrabPortCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'UngrabPort' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, false) c.NewRequest(ungrabPortRequest(c, Port, Time), cookie) return UngrabPortCookie{cookie} @@ -1600,6 +1630,9 @@ type PutVideoCookie struct { // PutVideo sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PutVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutVideoCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'PutVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, false) c.NewRequest(putVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) return PutVideoCookie{cookie} @@ -1608,6 +1641,9 @@ func PutVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gconte // PutVideoChecked sends a checked request. // If an error occurs, it can be retrieved using PutVideoCookie.Check() func PutVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutVideoCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'PutVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, false) c.NewRequest(putVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) return PutVideoCookie{cookie} @@ -1679,6 +1715,9 @@ type PutStillCookie struct { // PutStill sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PutStill(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutStillCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'PutStill' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, false) c.NewRequest(putStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) return PutStillCookie{cookie} @@ -1687,6 +1726,9 @@ func PutStill(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gconte // PutStillChecked sends a checked request. // If an error occurs, it can be retrieved using PutStillCookie.Check() func PutStillChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutStillCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'PutStill' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, false) c.NewRequest(putStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) return PutStillCookie{cookie} @@ -1758,6 +1800,9 @@ type GetVideoCookie struct { // GetVideo sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetVideoCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'GetVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, false) c.NewRequest(getVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) return GetVideoCookie{cookie} @@ -1766,6 +1811,9 @@ func GetVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gconte // GetVideoChecked sends a checked request. // If an error occurs, it can be retrieved using GetVideoCookie.Check() func GetVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetVideoCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'GetVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, false) c.NewRequest(getVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) return GetVideoCookie{cookie} @@ -1837,6 +1885,9 @@ type GetStillCookie struct { // GetStill sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetStill(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetStillCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'GetStill' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, false) c.NewRequest(getStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) return GetStillCookie{cookie} @@ -1845,6 +1896,9 @@ func GetStill(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gconte // GetStillChecked sends a checked request. // If an error occurs, it can be retrieved using GetStillCookie.Check() func GetStillChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetStillCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'GetStill' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, false) c.NewRequest(getStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) return GetStillCookie{cookie} @@ -1916,6 +1970,9 @@ type StopVideoCookie struct { // StopVideo sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func StopVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable) StopVideoCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'StopVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, false) c.NewRequest(stopVideoRequest(c, Port, Drawable), cookie) return StopVideoCookie{cookie} @@ -1924,6 +1981,9 @@ func StopVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable) StopVideoCookie // StopVideoChecked sends a checked request. // If an error occurs, it can be retrieved using StopVideoCookie.Check() func StopVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable) StopVideoCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'StopVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, false) c.NewRequest(stopVideoRequest(c, Port, Drawable), cookie) return StopVideoCookie{cookie} @@ -1968,6 +2028,9 @@ type SelectVideoNotifyCookie struct { // SelectVideoNotify sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SelectVideoNotify(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) SelectVideoNotifyCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'SelectVideoNotify' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, false) c.NewRequest(selectVideoNotifyRequest(c, Drawable, Onoff), cookie) return SelectVideoNotifyCookie{cookie} @@ -1976,6 +2039,9 @@ func SelectVideoNotify(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) Select // SelectVideoNotifyChecked sends a checked request. // If an error occurs, it can be retrieved using SelectVideoNotifyCookie.Check() func SelectVideoNotifyChecked(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) SelectVideoNotifyCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'SelectVideoNotify' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, false) c.NewRequest(selectVideoNotifyRequest(c, Drawable, Onoff), cookie) return SelectVideoNotifyCookie{cookie} @@ -2026,6 +2092,9 @@ type SelectPortNotifyCookie struct { // SelectPortNotify sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SelectPortNotify(c *xgb.Conn, Port Port, Onoff bool) SelectPortNotifyCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'SelectPortNotify' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, false) c.NewRequest(selectPortNotifyRequest(c, Port, Onoff), cookie) return SelectPortNotifyCookie{cookie} @@ -2034,6 +2103,9 @@ func SelectPortNotify(c *xgb.Conn, Port Port, Onoff bool) SelectPortNotifyCookie // SelectPortNotifyChecked sends a checked request. // If an error occurs, it can be retrieved using SelectPortNotifyCookie.Check() func SelectPortNotifyChecked(c *xgb.Conn, Port Port, Onoff bool) SelectPortNotifyCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'SelectPortNotify' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, false) c.NewRequest(selectPortNotifyRequest(c, Port, Onoff), cookie) return SelectPortNotifyCookie{cookie} @@ -2084,6 +2156,9 @@ type QueryBestSizeCookie struct { // QueryBestSize sends a checked request. // If an error occurs, it will be returned with the reply by calling QueryBestSizeCookie.Reply() func QueryBestSize(c *xgb.Conn, Port Port, VidW uint16, VidH uint16, DrwW uint16, DrwH uint16, Motion bool) QueryBestSizeCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'QueryBestSize' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, true) c.NewRequest(queryBestSizeRequest(c, Port, VidW, VidH, DrwW, DrwH, Motion), cookie) return QueryBestSizeCookie{cookie} @@ -2092,6 +2167,9 @@ func QueryBestSize(c *xgb.Conn, Port Port, VidW uint16, VidH uint16, DrwW uint16 // QueryBestSizeUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryBestSizeUnchecked(c *xgb.Conn, Port Port, VidW uint16, VidH uint16, DrwW uint16, DrwH uint16, Motion bool) QueryBestSizeCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'QueryBestSize' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, true) c.NewRequest(queryBestSizeRequest(c, Port, VidW, VidH, DrwW, DrwH, Motion), cookie) return QueryBestSizeCookie{cookie} @@ -2191,6 +2269,9 @@ type SetPortAttributeCookie struct { // SetPortAttribute sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetPortAttribute(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32) SetPortAttributeCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'SetPortAttribute' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, false) c.NewRequest(setPortAttributeRequest(c, Port, Attribute, Value), cookie) return SetPortAttributeCookie{cookie} @@ -2199,6 +2280,9 @@ func SetPortAttribute(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32 // SetPortAttributeChecked sends a checked request. // If an error occurs, it can be retrieved using SetPortAttributeCookie.Check() func SetPortAttributeChecked(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32) SetPortAttributeCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'SetPortAttribute' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, false) c.NewRequest(setPortAttributeRequest(c, Port, Attribute, Value), cookie) return SetPortAttributeCookie{cookie} @@ -2246,6 +2330,9 @@ type GetPortAttributeCookie struct { // GetPortAttribute sends a checked request. // If an error occurs, it will be returned with the reply by calling GetPortAttributeCookie.Reply() func GetPortAttribute(c *xgb.Conn, Port Port, Attribute xproto.Atom) GetPortAttributeCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'GetPortAttribute' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, true) c.NewRequest(getPortAttributeRequest(c, Port, Attribute), cookie) return GetPortAttributeCookie{cookie} @@ -2254,6 +2341,9 @@ func GetPortAttribute(c *xgb.Conn, Port Port, Attribute xproto.Atom) GetPortAttr // GetPortAttributeUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetPortAttributeUnchecked(c *xgb.Conn, Port Port, Attribute xproto.Atom) GetPortAttributeCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'GetPortAttribute' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, true) c.NewRequest(getPortAttributeRequest(c, Port, Attribute), cookie) return GetPortAttributeCookie{cookie} @@ -2331,6 +2421,9 @@ type QueryPortAttributesCookie struct { // QueryPortAttributes sends a checked request. // If an error occurs, it will be returned with the reply by calling QueryPortAttributesCookie.Reply() func QueryPortAttributes(c *xgb.Conn, Port Port) QueryPortAttributesCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'QueryPortAttributes' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, true) c.NewRequest(queryPortAttributesRequest(c, Port), cookie) return QueryPortAttributesCookie{cookie} @@ -2339,6 +2432,9 @@ func QueryPortAttributes(c *xgb.Conn, Port Port) QueryPortAttributesCookie { // QueryPortAttributesUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryPortAttributesUnchecked(c *xgb.Conn, Port Port) QueryPortAttributesCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'QueryPortAttributes' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, true) c.NewRequest(queryPortAttributesRequest(c, Port), cookie) return QueryPortAttributesCookie{cookie} @@ -2424,6 +2520,9 @@ type ListImageFormatsCookie struct { // ListImageFormats sends a checked request. // If an error occurs, it will be returned with the reply by calling ListImageFormatsCookie.Reply() func ListImageFormats(c *xgb.Conn, Port Port) ListImageFormatsCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'ListImageFormats' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, true) c.NewRequest(listImageFormatsRequest(c, Port), cookie) return ListImageFormatsCookie{cookie} @@ -2432,6 +2531,9 @@ func ListImageFormats(c *xgb.Conn, Port Port) ListImageFormatsCookie { // ListImageFormatsUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ListImageFormatsUnchecked(c *xgb.Conn, Port Port) ListImageFormatsCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'ListImageFormats' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, true) c.NewRequest(listImageFormatsRequest(c, Port), cookie) return ListImageFormatsCookie{cookie} @@ -2513,6 +2615,9 @@ type QueryImageAttributesCookie struct { // QueryImageAttributes sends a checked request. // If an error occurs, it will be returned with the reply by calling QueryImageAttributesCookie.Reply() func QueryImageAttributes(c *xgb.Conn, Port Port, Id uint32, Width uint16, Height uint16) QueryImageAttributesCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'QueryImageAttributes' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, true) c.NewRequest(queryImageAttributesRequest(c, Port, Id, Width, Height), cookie) return QueryImageAttributesCookie{cookie} @@ -2521,6 +2626,9 @@ func QueryImageAttributes(c *xgb.Conn, Port Port, Id uint32, Width uint16, Heigh // QueryImageAttributesUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryImageAttributesUnchecked(c *xgb.Conn, Port Port, Id uint32, Width uint16, Height uint16) QueryImageAttributesCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'QueryImageAttributes' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, true) c.NewRequest(queryImageAttributesRequest(c, Port, Id, Width, Height), cookie) return QueryImageAttributesCookie{cookie} @@ -2635,6 +2743,9 @@ type PutImageCookie struct { // PutImage sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PutImage(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) PutImageCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'PutImage' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, false) c.NewRequest(putImageRequest(c, Port, Drawable, Gc, Id, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, Data), cookie) return PutImageCookie{cookie} @@ -2643,6 +2754,9 @@ func PutImage(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gconte // PutImageChecked sends a checked request. // If an error occurs, it can be retrieved using PutImageCookie.Check() func PutImageChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) PutImageCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'PutImage' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, false) c.NewRequest(putImageRequest(c, Port, Drawable, Gc, Id, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, Data), cookie) return PutImageCookie{cookie} @@ -2726,6 +2840,9 @@ type ShmPutImageCookie struct { // ShmPutImage sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ShmPutImage(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Shmseg shm.Seg, Id uint32, Offset uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, SendEvent byte) ShmPutImageCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'ShmPutImage' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, false) c.NewRequest(shmPutImageRequest(c, Port, Drawable, Gc, Shmseg, Id, Offset, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, SendEvent), cookie) return ShmPutImageCookie{cookie} @@ -2734,6 +2851,9 @@ func ShmPutImage(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gco // ShmPutImageChecked sends a checked request. // If an error occurs, it can be retrieved using ShmPutImageCookie.Check() func ShmPutImageChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Shmseg shm.Seg, Id uint32, Offset uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, SendEvent byte) ShmPutImageCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'ShmPutImage' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, false) c.NewRequest(shmPutImageRequest(c, Port, Drawable, Gc, Shmseg, Id, Offset, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, SendEvent), cookie) return ShmPutImageCookie{cookie} -- cgit v1.2.3 From 4ea94ca0fef7786ce21722cbb02a9cf069bdedd9 Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Sat, 26 May 2012 18:24:52 -0400 Subject: Bug fix in the generator that was outputting %(MISSING) crud. --- nexgb/xv/xv.go | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'nexgb/xv') diff --git a/nexgb/xv/xv.go b/nexgb/xv/xv.go index c6ba384..c3deb75 100644 --- a/nexgb/xv/xv.go +++ b/nexgb/xv/xv.go @@ -2,7 +2,7 @@ package xv /* - This file was generated by xv.xml on May 11 2012 11:57:20pm EDT. + This file was generated by xv.xml on May 26 2012 6:23:14pm EDT. This file is automatically generated. Edit at your peril! */ @@ -41,14 +41,6 @@ func init() { xgb.NewExtErrorFuncs["XVideo"] = 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' @@ -65,6 +57,14 @@ func init() { // Skipping definition for base type 'Bool' +// Skipping definition for base type 'Float' + +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + const ( TypeInputMask = 1 TypeOutputMask = 2 @@ -172,7 +172,7 @@ func (v Rational) Bytes() []byte { return buf } -// RationalListBytes writes a list of %s(MISSING) values to a byte slice. +// RationalListBytes writes a list of Rational values to a byte slice. func RationalListBytes(buf []byte, list []Rational) int { b := 0 var structBytes []byte @@ -231,7 +231,7 @@ func (v Format) Bytes() []byte { return buf } -// FormatListBytes writes a list of %s(MISSING) values to a byte slice. +// FormatListBytes writes a list of Format values to a byte slice. func FormatListBytes(buf []byte, list []Format) int { b := 0 var structBytes []byte @@ -328,7 +328,7 @@ func (v AdaptorInfo) Bytes() []byte { return buf } -// AdaptorInfoListBytes writes a list of %s(MISSING) values to a byte slice. +// AdaptorInfoListBytes writes a list of AdaptorInfo values to a byte slice. func AdaptorInfoListBytes(buf []byte, list []AdaptorInfo) int { b := 0 var structBytes []byte @@ -431,7 +431,7 @@ func (v EncodingInfo) Bytes() []byte { return buf } -// EncodingInfoListBytes writes a list of %s(MISSING) values to a byte slice. +// EncodingInfoListBytes writes a list of EncodingInfo values to a byte slice. func EncodingInfoListBytes(buf []byte, list []EncodingInfo) int { b := 0 var structBytes []byte @@ -551,7 +551,7 @@ func (v Image) Bytes() []byte { return buf } -// ImageListBytes writes a list of %s(MISSING) values to a byte slice. +// ImageListBytes writes a list of Image values to a byte slice. func ImageListBytes(buf []byte, list []Image) int { b := 0 var structBytes []byte @@ -639,7 +639,7 @@ func (v AttributeInfo) Bytes() []byte { return buf } -// AttributeInfoListBytes writes a list of %s(MISSING) values to a byte slice. +// AttributeInfoListBytes writes a list of AttributeInfo values to a byte slice. func AttributeInfoListBytes(buf []byte, list []AttributeInfo) int { b := 0 var structBytes []byte @@ -869,7 +869,7 @@ func (v ImageFormatInfo) Bytes() []byte { return buf } -// ImageFormatInfoListBytes writes a list of %s(MISSING) values to a byte slice. +// ImageFormatInfoListBytes writes a list of ImageFormatInfo values to a byte slice. func ImageFormatInfoListBytes(buf []byte, list []ImageFormatInfo) int { b := 0 var structBytes []byte -- cgit v1.2.3 From a9eae45cb3977bce5983e817d00d4584d176b044 Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Tue, 5 Jun 2012 00:14:34 -0400 Subject: Refresh build. Eh. --- nexgb/xv/xv.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'nexgb/xv') diff --git a/nexgb/xv/xv.go b/nexgb/xv/xv.go index c3deb75..ed10b3b 100644 --- a/nexgb/xv/xv.go +++ b/nexgb/xv/xv.go @@ -2,7 +2,7 @@ package xv /* - This file was generated by xv.xml on May 26 2012 6:23:14pm EDT. + This file was generated by xv.xml on Jun 5 2012 12:12:00am EDT. This file is automatically generated. Edit at your peril! */ @@ -41,6 +41,12 @@ func init() { xgb.NewExtErrorFuncs["XVideo"] = make(map[int]xgb.NewErrorFun) } +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + // Skipping definition for base type 'Void' // Skipping definition for base type 'Byte' @@ -59,12 +65,6 @@ func init() { // Skipping definition for base type 'Float' -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - const ( TypeInputMask = 1 TypeOutputMask = 2 -- cgit v1.2.3 From 0685fb57e14104ee4ad9f70ec94f787a9a22c028 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Sun, 11 Aug 2013 20:43:26 -0400 Subject: Update to latest xproto XML. --- nexgb/xv/xv.go | 2542 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 1271 insertions(+), 1271 deletions(-) (limited to 'nexgb/xv') diff --git a/nexgb/xv/xv.go b/nexgb/xv/xv.go index ed10b3b..f5539b3 100644 --- a/nexgb/xv/xv.go +++ b/nexgb/xv/xv.go @@ -2,7 +2,7 @@ package xv /* - This file was generated by xv.xml on Jun 5 2012 12:12:00am EDT. + This file was generated by xv.xml on Aug 11 2013 8:39:44pm EDT. This file is automatically generated. Edit at your peril! */ @@ -41,208 +41,6 @@ func init() { xgb.NewExtErrorFuncs["XVideo"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - -// Skipping definition for base type 'Int8' - -// Skipping definition for base type 'Card16' - -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - -// Skipping definition for base type 'Float' - -const ( - TypeInputMask = 1 - TypeOutputMask = 2 - TypeVideoMask = 4 - TypeStillMask = 8 - TypeImageMask = 16 -) - -const ( - ImageFormatInfoTypeRgb = 0 - ImageFormatInfoTypeYuv = 1 -) - -const ( - ImageFormatInfoFormatPacked = 0 - ImageFormatInfoFormatPlanar = 1 -) - -const ( - AttributeFlagGettable = 1 - AttributeFlagSettable = 2 -) - -const ( - VideoNotifyReasonStarted = 0 - VideoNotifyReasonStopped = 1 - VideoNotifyReasonBusy = 2 - VideoNotifyReasonPreempted = 3 - VideoNotifyReasonHardError = 4 -) - -const ( - ScanlineOrderTopToBottom = 0 - ScanlineOrderBottomToTop = 1 -) - -const ( - GrabPortStatusSuccess = 0 - GrabPortStatusBadExtension = 1 - GrabPortStatusAlreadyGrabbed = 2 - GrabPortStatusInvalidTime = 3 - GrabPortStatusBadReply = 4 - GrabPortStatusBadAlloc = 5 -) - -type Port uint32 - -func NewPortId(c *xgb.Conn) (Port, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Port(id), nil -} - -type Encoding uint32 - -func NewEncodingId(c *xgb.Conn) (Encoding, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Encoding(id), nil -} - -type Rational struct { - Numerator int32 - Denominator int32 -} - -// RationalRead reads a byte slice into a Rational value. -func RationalRead(buf []byte, v *Rational) int { - b := 0 - - v.Numerator = int32(xgb.Get32(buf[b:])) - b += 4 - - v.Denominator = int32(xgb.Get32(buf[b:])) - b += 4 - - return b -} - -// RationalReadList reads a byte slice into a list of Rational values. -func RationalReadList(buf []byte, dest []Rational) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Rational{} - b += RationalRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a Rational value to a byte slice. -func (v Rational) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - xgb.Put32(buf[b:], uint32(v.Numerator)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Denominator)) - b += 4 - - return buf -} - -// RationalListBytes writes a list of Rational values to a byte slice. -func RationalListBytes(buf []byte, list []Rational) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -type Format struct { - Visual xproto.Visualid - Depth byte - // padding: 3 bytes -} - -// FormatRead reads a byte slice into a Format value. -func FormatRead(buf []byte, v *Format) int { - b := 0 - - v.Visual = xproto.Visualid(xgb.Get32(buf[b:])) - b += 4 - - v.Depth = buf[b] - b += 1 - - b += 3 // padding - - return b -} - -// FormatReadList reads a byte slice into a list of Format values. -func FormatReadList(buf []byte, dest []Format) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = Format{} - b += FormatRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a Format value to a byte slice. -func (v Format) Bytes() []byte { - buf := make([]byte, 8) - b := 0 - - xgb.Put32(buf[b:], uint32(v.Visual)) - b += 4 - - buf[b] = v.Depth - b += 1 - - b += 3 // padding - - return buf -} - -// FormatListBytes writes a list of Format values to a byte slice. -func FormatListBytes(buf []byte, list []Format) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - type AdaptorInfo struct { BaseId Port NameSize uint16 @@ -349,53 +147,294 @@ func AdaptorInfoListSize(list []AdaptorInfo) int { return size } -type EncodingInfo struct { - Encoding Encoding - NameSize uint16 - Width uint16 - Height uint16 - // padding: 2 bytes - Rate Rational - Name string // size: xgb.Pad((int(NameSize) * 1)) +const ( + AttributeFlagGettable = 1 + AttributeFlagSettable = 2 +) + +type AttributeInfo struct { + Flags uint32 + Min int32 + Max int32 + Size uint32 + Name string // size: xgb.Pad((int(Size) * 1)) } -// EncodingInfoRead reads a byte slice into a EncodingInfo value. -func EncodingInfoRead(buf []byte, v *EncodingInfo) int { +// AttributeInfoRead reads a byte slice into a AttributeInfo value. +func AttributeInfoRead(buf []byte, v *AttributeInfo) int { b := 0 - v.Encoding = Encoding(xgb.Get32(buf[b:])) + v.Flags = xgb.Get32(buf[b:]) b += 4 - v.NameSize = xgb.Get16(buf[b:]) - b += 2 - - v.Width = xgb.Get16(buf[b:]) - b += 2 - - v.Height = xgb.Get16(buf[b:]) - b += 2 + v.Min = int32(xgb.Get32(buf[b:])) + b += 4 - b += 2 // padding + v.Max = int32(xgb.Get32(buf[b:])) + b += 4 - v.Rate = Rational{} - b += RationalRead(buf[b:], &v.Rate) + v.Size = xgb.Get32(buf[b:]) + b += 4 { - byteString := make([]byte, v.NameSize) - copy(byteString[:v.NameSize], buf[b:]) + byteString := make([]byte, v.Size) + copy(byteString[:v.Size], buf[b:]) v.Name = string(byteString) - b += xgb.Pad(int(v.NameSize)) + b += xgb.Pad(int(v.Size)) } return b } -// EncodingInfoReadList reads a byte slice into a list of EncodingInfo values. -func EncodingInfoReadList(buf []byte, dest []EncodingInfo) int { +// AttributeInfoReadList reads a byte slice into a list of AttributeInfo values. +func AttributeInfoReadList(buf []byte, dest []AttributeInfo) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = EncodingInfo{} - b += EncodingInfoRead(buf[b:], &dest[i]) + dest[i] = AttributeInfo{} + b += AttributeInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a AttributeInfo value to a byte slice. +func (v AttributeInfo) Bytes() []byte { + buf := make([]byte, (16 + xgb.Pad((int(v.Size) * 1)))) + b := 0 + + xgb.Put32(buf[b:], v.Flags) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Min)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Max)) + b += 4 + + xgb.Put32(buf[b:], v.Size) + b += 4 + + copy(buf[b:], v.Name[:v.Size]) + b += xgb.Pad(int(v.Size)) + + return buf +} + +// AttributeInfoListBytes writes a list of AttributeInfo values to a byte slice. +func AttributeInfoListBytes(buf []byte, list []AttributeInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// AttributeInfoListSize computes the size (bytes) of a list of AttributeInfo values. +func AttributeInfoListSize(list []AttributeInfo) int { + size := 0 + for _, item := range list { + size += (16 + xgb.Pad((int(item.Size) * 1))) + } + return size +} + +// BadBadControl is the error number for a BadBadControl. +const BadBadControl = 2 + +type BadControlError struct { + Sequence uint16 + NiceName string +} + +// BadControlErrorNew constructs a BadControlError value that implements xgb.Error from a byte slice. +func BadControlErrorNew(buf []byte) xgb.Error { + v := BadControlError{} + v.NiceName = "BadControl" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// SequenceId returns the sequence id attached to the BadBadControl error. +// This is mostly used internally. +func (err BadControlError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadBadControl error. If no bad value exists, 0 is returned. +func (err BadControlError) BadId() uint32 { + return 0 +} + +// Error returns a rudimentary string representation of the BadBadControl error. + +func (err BadControlError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadControl {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XVideo"][2] = BadControlErrorNew +} + +// BadBadEncoding is the error number for a BadBadEncoding. +const BadBadEncoding = 1 + +type BadEncodingError struct { + Sequence uint16 + NiceName string +} + +// BadEncodingErrorNew constructs a BadEncodingError value that implements xgb.Error from a byte slice. +func BadEncodingErrorNew(buf []byte) xgb.Error { + v := BadEncodingError{} + v.NiceName = "BadEncoding" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// SequenceId returns the sequence id attached to the BadBadEncoding error. +// This is mostly used internally. +func (err BadEncodingError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadBadEncoding error. If no bad value exists, 0 is returned. +func (err BadEncodingError) BadId() uint32 { + return 0 +} + +// Error returns a rudimentary string representation of the BadBadEncoding error. + +func (err BadEncodingError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadEncoding {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XVideo"][1] = BadEncodingErrorNew +} + +// BadBadPort is the error number for a BadBadPort. +const BadBadPort = 0 + +type BadPortError struct { + Sequence uint16 + NiceName string +} + +// BadPortErrorNew constructs a BadPortError value that implements xgb.Error from a byte slice. +func BadPortErrorNew(buf []byte) xgb.Error { + v := BadPortError{} + v.NiceName = "BadPort" + + b := 1 // skip error determinant + b += 1 // don't read error number + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// SequenceId returns the sequence id attached to the BadBadPort error. +// This is mostly used internally. +func (err BadPortError) SequenceId() uint16 { + return err.Sequence +} + +// BadId returns the 'BadValue' number if one exists for the BadBadPort error. If no bad value exists, 0 is returned. +func (err BadPortError) BadId() uint32 { + return 0 +} + +// Error returns a rudimentary string representation of the BadBadPort error. + +func (err BadPortError) Error() string { + fieldVals := make([]string, 0, 0) + fieldVals = append(fieldVals, "NiceName: "+err.NiceName) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) + return "BadBadPort {" + xgb.StringsJoin(fieldVals, ", ") + "}" +} + +func init() { + xgb.NewExtErrorFuncs["XVideo"][0] = BadPortErrorNew +} + +type Encoding uint32 + +func NewEncodingId(c *xgb.Conn) (Encoding, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Encoding(id), nil +} + +type EncodingInfo struct { + Encoding Encoding + NameSize uint16 + Width uint16 + Height uint16 + // padding: 2 bytes + Rate Rational + Name string // size: xgb.Pad((int(NameSize) * 1)) +} + +// EncodingInfoRead reads a byte slice into a EncodingInfo value. +func EncodingInfoRead(buf []byte, v *EncodingInfo) int { + b := 0 + + v.Encoding = Encoding(xgb.Get32(buf[b:])) + b += 4 + + v.NameSize = xgb.Get16(buf[b:]) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + b += 2 // padding + + v.Rate = Rational{} + b += RationalRead(buf[b:], &v.Rate) + + { + byteString := make([]byte, v.NameSize) + copy(byteString[:v.NameSize], buf[b:]) + v.Name = string(byteString) + b += xgb.Pad(int(v.NameSize)) + } + + return b +} + +// EncodingInfoReadList reads a byte slice into a list of EncodingInfo values. +func EncodingInfoReadList(buf []byte, dest []EncodingInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = EncodingInfo{} + b += EncodingInfoRead(buf[b:], &dest[i]) } return xgb.Pad(b) } @@ -452,6 +491,74 @@ func EncodingInfoListSize(list []EncodingInfo) int { return size } +type Format struct { + Visual xproto.Visualid + Depth byte + // padding: 3 bytes +} + +// FormatRead reads a byte slice into a Format value. +func FormatRead(buf []byte, v *Format) int { + b := 0 + + v.Visual = xproto.Visualid(xgb.Get32(buf[b:])) + b += 4 + + v.Depth = buf[b] + b += 1 + + b += 3 // padding + + return b +} + +// FormatReadList reads a byte slice into a list of Format values. +func FormatReadList(buf []byte, dest []Format) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Format{} + b += FormatRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a Format value to a byte slice. +func (v Format) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put32(buf[b:], uint32(v.Visual)) + b += 4 + + buf[b] = v.Depth + b += 1 + + b += 3 // padding + + return buf +} + +// FormatListBytes writes a list of Format values to a byte slice. +func FormatListBytes(buf []byte, list []Format) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +const ( + GrabPortStatusSuccess = 0 + GrabPortStatusBadExtension = 1 + GrabPortStatusAlreadyGrabbed = 2 + GrabPortStatusInvalidTime = 3 + GrabPortStatusBadReply = 4 + GrabPortStatusBadAlloc = 5 +) + type Image struct { Id uint32 Width uint16 @@ -572,94 +679,6 @@ func ImageListSize(list []Image) int { return size } -type AttributeInfo struct { - Flags uint32 - Min int32 - Max int32 - Size uint32 - Name string // size: xgb.Pad((int(Size) * 1)) -} - -// AttributeInfoRead reads a byte slice into a AttributeInfo value. -func AttributeInfoRead(buf []byte, v *AttributeInfo) int { - b := 0 - - v.Flags = xgb.Get32(buf[b:]) - b += 4 - - v.Min = int32(xgb.Get32(buf[b:])) - b += 4 - - v.Max = int32(xgb.Get32(buf[b:])) - b += 4 - - v.Size = xgb.Get32(buf[b:]) - b += 4 - - { - byteString := make([]byte, v.Size) - copy(byteString[:v.Size], buf[b:]) - v.Name = string(byteString) - b += xgb.Pad(int(v.Size)) - } - - return b -} - -// AttributeInfoReadList reads a byte slice into a list of AttributeInfo values. -func AttributeInfoReadList(buf []byte, dest []AttributeInfo) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = AttributeInfo{} - b += AttributeInfoRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a AttributeInfo value to a byte slice. -func (v AttributeInfo) Bytes() []byte { - buf := make([]byte, (16 + xgb.Pad((int(v.Size) * 1)))) - b := 0 - - xgb.Put32(buf[b:], v.Flags) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Min)) - b += 4 - - xgb.Put32(buf[b:], uint32(v.Max)) - b += 4 - - xgb.Put32(buf[b:], v.Size) - b += 4 - - copy(buf[b:], v.Name[:v.Size]) - b += xgb.Pad(int(v.Size)) - - return buf -} - -// AttributeInfoListBytes writes a list of AttributeInfo values to a byte slice. -func AttributeInfoListBytes(buf []byte, list []AttributeInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -// AttributeInfoListSize computes the size (bytes) of a list of AttributeInfo values. -func AttributeInfoListSize(list []AttributeInfo) int { - size := 0 - for _, item := range list { - size += (16 + xgb.Pad((int(item.Size) * 1))) - } - return size -} - type ImageFormatInfo struct { Id uint32 Type byte @@ -846,130 +865,68 @@ func (v ImageFormatInfo) Bytes() []byte { xgb.Put32(buf[b:], v.VhorzUPeriod) b += 4 - xgb.Put32(buf[b:], v.VhorzVPeriod) - b += 4 - - xgb.Put32(buf[b:], v.VvertYPeriod) - b += 4 - - xgb.Put32(buf[b:], v.VvertUPeriod) - b += 4 - - xgb.Put32(buf[b:], v.VvertVPeriod) - b += 4 - - copy(buf[b:], v.VcompOrder[:32]) - b += xgb.Pad(int(32)) - - buf[b] = v.VscanlineOrder - b += 1 - - b += 11 // padding - - return buf -} - -// ImageFormatInfoListBytes writes a list of ImageFormatInfo values to a byte slice. -func ImageFormatInfoListBytes(buf []byte, list []ImageFormatInfo) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - -// ImageFormatInfoListSize computes the size (bytes) of a list of ImageFormatInfo values. -func ImageFormatInfoListSize(list []ImageFormatInfo) int { - size := 0 - for _ = range list { - size += 128 - } - return size -} - -// VideoNotify is the event number for a VideoNotifyEvent. -const VideoNotify = 0 - -type VideoNotifyEvent struct { - Sequence uint16 - Reason byte - Time xproto.Timestamp - Drawable xproto.Drawable - Port Port -} - -// VideoNotifyEventNew constructs a VideoNotifyEvent value that implements xgb.Event from a byte slice. -func VideoNotifyEventNew(buf []byte) xgb.Event { - v := VideoNotifyEvent{} - b := 1 // don't read event number - - v.Reason = buf[b] - b += 1 - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 - - v.Drawable = xproto.Drawable(xgb.Get32(buf[b:])) - b += 4 - - v.Port = Port(xgb.Get32(buf[b:])) - b += 4 - - return v -} - -// Bytes writes a VideoNotifyEvent value to a byte slice. -func (v VideoNotifyEvent) Bytes() []byte { - buf := make([]byte, 32) - b := 0 - - // write event number - buf[b] = 0 - b += 1 - - buf[b] = v.Reason - b += 1 - - b += 2 // skip sequence number + xgb.Put32(buf[b:], v.VhorzVPeriod) + b += 4 - xgb.Put32(buf[b:], uint32(v.Time)) + xgb.Put32(buf[b:], v.VvertYPeriod) b += 4 - xgb.Put32(buf[b:], uint32(v.Drawable)) + xgb.Put32(buf[b:], v.VvertUPeriod) b += 4 - xgb.Put32(buf[b:], uint32(v.Port)) + xgb.Put32(buf[b:], v.VvertVPeriod) b += 4 + copy(buf[b:], v.VcompOrder[:32]) + b += xgb.Pad(int(32)) + + buf[b] = v.VscanlineOrder + b += 1 + + b += 11 // padding + return buf } -// SequenceId returns the sequence id attached to the VideoNotify event. -// Events without a sequence number (KeymapNotify) return 0. -// This is mostly used internally. -func (v VideoNotifyEvent) SequenceId() uint16 { - return v.Sequence +// ImageFormatInfoListBytes writes a list of ImageFormatInfo values to a byte slice. +func ImageFormatInfoListBytes(buf []byte, list []ImageFormatInfo) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b } -// String is a rudimentary string representation of VideoNotifyEvent. -func (v VideoNotifyEvent) String() string { - fieldVals := make([]string, 0, 4) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) - fieldVals = append(fieldVals, xgb.Sprintf("Reason: %d", v.Reason)) - fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) - fieldVals = append(fieldVals, xgb.Sprintf("Drawable: %d", v.Drawable)) - fieldVals = append(fieldVals, xgb.Sprintf("Port: %d", v.Port)) - return "VideoNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// ImageFormatInfoListSize computes the size (bytes) of a list of ImageFormatInfo values. +func ImageFormatInfoListSize(list []ImageFormatInfo) int { + size := 0 + for _ = range list { + size += 128 + } + return size } -func init() { - xgb.NewExtEventFuncs["XVideo"][0] = VideoNotifyEventNew +const ( + ImageFormatInfoFormatPacked = 0 + ImageFormatInfoFormatPlanar = 1 +) + +const ( + ImageFormatInfoTypeRgb = 0 + ImageFormatInfoTypeYuv = 1 +) + +type Port uint32 + +func NewPortId(c *xgb.Conn) (Port, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Port(id), nil } // PortNotify is the event number for a PortNotifyEvent. @@ -1059,182 +1016,224 @@ func init() { xgb.NewExtEventFuncs["XVideo"][1] = PortNotifyEventNew } -// BadBadPort is the error number for a BadBadPort. -const BadBadPort = 0 - -type BadPortError struct { - Sequence uint16 - NiceName string +type Rational struct { + Numerator int32 + Denominator int32 } -// BadPortErrorNew constructs a BadPortError value that implements xgb.Error from a byte slice. -func BadPortErrorNew(buf []byte) xgb.Error { - v := BadPortError{} - v.NiceName = "BadPort" +// RationalRead reads a byte slice into a Rational value. +func RationalRead(buf []byte, v *Rational) int { + b := 0 - b := 1 // skip error determinant - b += 1 // don't read error number + v.Numerator = int32(xgb.Get32(buf[b:])) + b += 4 - v.Sequence = xgb.Get16(buf[b:]) - b += 2 + v.Denominator = int32(xgb.Get32(buf[b:])) + b += 4 - return v + return b } -// SequenceId returns the sequence id attached to the BadBadPort error. -// This is mostly used internally. -func (err BadPortError) SequenceId() uint16 { - return err.Sequence +// RationalReadList reads a byte slice into a list of Rational values. +func RationalReadList(buf []byte, dest []Rational) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = Rational{} + b += RationalRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) } -// BadId returns the 'BadValue' number if one exists for the BadBadPort error. If no bad value exists, 0 is returned. -func (err BadPortError) BadId() uint32 { - return 0 -} +// Bytes writes a Rational value to a byte slice. +func (v Rational) Bytes() []byte { + buf := make([]byte, 8) + b := 0 -// Error returns a rudimentary string representation of the BadBadPort error. + xgb.Put32(buf[b:], uint32(v.Numerator)) + b += 4 -func (err BadPortError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - return "BadBadPort {" + xgb.StringsJoin(fieldVals, ", ") + "}" + xgb.Put32(buf[b:], uint32(v.Denominator)) + b += 4 + + return buf } -func init() { - xgb.NewExtErrorFuncs["XVideo"][0] = BadPortErrorNew +// RationalListBytes writes a list of Rational values to a byte slice. +func RationalListBytes(buf []byte, list []Rational) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b } -// BadBadEncoding is the error number for a BadBadEncoding. -const BadBadEncoding = 1 +const ( + ScanlineOrderTopToBottom = 0 + ScanlineOrderBottomToTop = 1 +) -type BadEncodingError struct { +const ( + TypeInputMask = 1 + TypeOutputMask = 2 + TypeVideoMask = 4 + TypeStillMask = 8 + TypeImageMask = 16 +) + +// VideoNotify is the event number for a VideoNotifyEvent. +const VideoNotify = 0 + +type VideoNotifyEvent struct { Sequence uint16 - NiceName string + Reason byte + Time xproto.Timestamp + Drawable xproto.Drawable + Port Port } -// BadEncodingErrorNew constructs a BadEncodingError value that implements xgb.Error from a byte slice. -func BadEncodingErrorNew(buf []byte) xgb.Error { - v := BadEncodingError{} - v.NiceName = "BadEncoding" +// VideoNotifyEventNew constructs a VideoNotifyEvent value that implements xgb.Event from a byte slice. +func VideoNotifyEventNew(buf []byte) xgb.Event { + v := VideoNotifyEvent{} + b := 1 // don't read event number - b := 1 // skip error determinant - b += 1 // don't read error number + v.Reason = buf[b] + b += 1 v.Sequence = xgb.Get16(buf[b:]) b += 2 + v.Time = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.Drawable = xproto.Drawable(xgb.Get32(buf[b:])) + b += 4 + + v.Port = Port(xgb.Get32(buf[b:])) + b += 4 + return v } -// SequenceId returns the sequence id attached to the BadBadEncoding error. -// This is mostly used internally. -func (err BadEncodingError) SequenceId() uint16 { - return err.Sequence -} +// Bytes writes a VideoNotifyEvent value to a byte slice. +func (v VideoNotifyEvent) Bytes() []byte { + buf := make([]byte, 32) + b := 0 -// BadId returns the 'BadValue' number if one exists for the BadBadEncoding error. If no bad value exists, 0 is returned. -func (err BadEncodingError) BadId() uint32 { - return 0 + // write event number + buf[b] = 0 + b += 1 + + buf[b] = v.Reason + b += 1 + + b += 2 // skip sequence number + + xgb.Put32(buf[b:], uint32(v.Time)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(v.Port)) + b += 4 + + return buf } -// Error returns a rudimentary string representation of the BadBadEncoding error. +// SequenceId returns the sequence id attached to the VideoNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. +func (v VideoNotifyEvent) SequenceId() uint16 { + return v.Sequence +} -func (err BadEncodingError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - return "BadBadEncoding {" + xgb.StringsJoin(fieldVals, ", ") + "}" +// String is a rudimentary string representation of VideoNotifyEvent. +func (v VideoNotifyEvent) String() string { + fieldVals := make([]string, 0, 4) + fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) + fieldVals = append(fieldVals, xgb.Sprintf("Reason: %d", v.Reason)) + fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time)) + fieldVals = append(fieldVals, xgb.Sprintf("Drawable: %d", v.Drawable)) + fieldVals = append(fieldVals, xgb.Sprintf("Port: %d", v.Port)) + return "VideoNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}" } func init() { - xgb.NewExtErrorFuncs["XVideo"][1] = BadEncodingErrorNew + xgb.NewExtEventFuncs["XVideo"][0] = VideoNotifyEventNew } -// BadBadControl is the error number for a BadBadControl. -const BadBadControl = 2 +const ( + VideoNotifyReasonStarted = 0 + VideoNotifyReasonStopped = 1 + VideoNotifyReasonBusy = 2 + VideoNotifyReasonPreempted = 3 + VideoNotifyReasonHardError = 4 +) -type BadControlError struct { - Sequence uint16 - NiceName string -} +// Skipping definition for base type 'Bool' -// BadControlErrorNew constructs a BadControlError value that implements xgb.Error from a byte slice. -func BadControlErrorNew(buf []byte) xgb.Error { - v := BadControlError{} - v.NiceName = "BadControl" +// Skipping definition for base type 'Byte' + +// Skipping definition for base type 'Card8' - b := 1 // skip error determinant - b += 1 // don't read error number +// Skipping definition for base type 'Char' - v.Sequence = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Void' - return v -} +// Skipping definition for base type 'Double' -// SequenceId returns the sequence id attached to the BadBadControl error. -// This is mostly used internally. -func (err BadControlError) SequenceId() uint16 { - return err.Sequence -} +// Skipping definition for base type 'Float' -// BadId returns the 'BadValue' number if one exists for the BadBadControl error. If no bad value exists, 0 is returned. -func (err BadControlError) BadId() uint32 { - return 0 -} +// Skipping definition for base type 'Int16' -// Error returns a rudimentary string representation of the BadBadControl error. +// Skipping definition for base type 'Int32' -func (err BadControlError) Error() string { - fieldVals := make([]string, 0, 0) - fieldVals = append(fieldVals, "NiceName: "+err.NiceName) - fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence)) - return "BadBadControl {" + xgb.StringsJoin(fieldVals, ", ") + "}" -} +// Skipping definition for base type 'Int8' -func init() { - xgb.NewExtErrorFuncs["XVideo"][2] = BadControlErrorNew -} +// Skipping definition for base type 'Card16' -// QueryExtensionCookie is a cookie used only for QueryExtension requests. -type QueryExtensionCookie struct { +// Skipping definition for base type 'Card32' + +// GetPortAttributeCookie is a cookie used only for GetPortAttribute requests. +type GetPortAttributeCookie struct { *xgb.Cookie } -// QueryExtension sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryExtensionCookie.Reply() -func QueryExtension(c *xgb.Conn) QueryExtensionCookie { +// GetPortAttribute sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPortAttributeCookie.Reply() +func GetPortAttribute(c *xgb.Conn, Port Port, Attribute xproto.Atom) GetPortAttributeCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'QueryExtension' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'GetPortAttribute' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(queryExtensionRequest(c), cookie) - return QueryExtensionCookie{cookie} + c.NewRequest(getPortAttributeRequest(c, Port, Attribute), cookie) + return GetPortAttributeCookie{cookie} } -// QueryExtensionUnchecked sends an unchecked request. +// GetPortAttributeUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryExtensionUnchecked(c *xgb.Conn) QueryExtensionCookie { +func GetPortAttributeUnchecked(c *xgb.Conn, Port Port, Attribute xproto.Atom) GetPortAttributeCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'QueryExtension' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'GetPortAttribute' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(queryExtensionRequest(c), cookie) - return QueryExtensionCookie{cookie} + c.NewRequest(getPortAttributeRequest(c, Port, Attribute), cookie) + return GetPortAttributeCookie{cookie} } -// QueryExtensionReply represents the data returned from a QueryExtension request. -type QueryExtensionReply struct { +// GetPortAttributeReply represents the data returned from a GetPortAttribute request. +type GetPortAttributeReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - Major uint16 - Minor uint16 + Value int32 } -// Reply blocks and returns the reply data for a QueryExtension request. -func (cook QueryExtensionCookie) Reply() (*QueryExtensionReply, error) { +// Reply blocks and returns the reply data for a GetPortAttribute request. +func (cook GetPortAttributeCookie) Reply() (*GetPortAttributeReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1242,12 +1241,12 @@ func (cook QueryExtensionCookie) Reply() (*QueryExtensionReply, error) { if buf == nil { return nil, nil } - return queryExtensionReply(buf), nil + return getPortAttributeReply(buf), nil } -// queryExtensionReply reads a byte slice into a QueryExtensionReply value. -func queryExtensionReply(buf []byte) *QueryExtensionReply { - v := new(QueryExtensionReply) +// getPortAttributeReply reads a byte slice into a GetPortAttributeReply value. +func getPortAttributeReply(buf []byte) *GetPortAttributeReply { + v := new(GetPortAttributeReply) b := 1 // skip reply determinant b += 1 // padding @@ -1258,213 +1257,166 @@ func queryExtensionReply(buf []byte) *QueryExtensionReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Major = xgb.Get16(buf[b:]) - b += 2 - - v.Minor = xgb.Get16(buf[b:]) - b += 2 + v.Value = int32(xgb.Get32(buf[b:])) + b += 4 return v } -// Write request to wire for QueryExtension -// queryExtensionRequest writes a QueryExtension request to a byte slice. -func queryExtensionRequest(c *xgb.Conn) []byte { - size := 4 +// Write request to wire for GetPortAttribute +// getPortAttributeRequest writes a GetPortAttribute request to a byte slice. +func getPortAttributeRequest(c *xgb.Conn, Port Port, Attribute xproto.Atom) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XVIDEO"] b += 1 - buf[b] = 0 // request opcode + buf[b] = 14 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Attribute)) + b += 4 + return buf } -// QueryAdaptorsCookie is a cookie used only for QueryAdaptors requests. -type QueryAdaptorsCookie struct { +// GetStillCookie is a cookie used only for GetStill requests. +type GetStillCookie struct { *xgb.Cookie } -// QueryAdaptors sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryAdaptorsCookie.Reply() -func QueryAdaptors(c *xgb.Conn, Window xproto.Window) QueryAdaptorsCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'QueryAdaptors' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(queryAdaptorsRequest(c, Window), cookie) - return QueryAdaptorsCookie{cookie} -} - -// QueryAdaptorsUnchecked sends an unchecked request. +// GetStill sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryAdaptorsUnchecked(c *xgb.Conn, Window xproto.Window) QueryAdaptorsCookie { +func GetStill(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetStillCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'QueryAdaptors' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'GetStill' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(queryAdaptorsRequest(c, Window), cookie) - return QueryAdaptorsCookie{cookie} -} - -// QueryAdaptorsReply represents the data returned from a QueryAdaptors request. -type QueryAdaptorsReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - NumAdaptors uint16 - // padding: 22 bytes - Info []AdaptorInfo // size: AdaptorInfoListSize(Info) + cookie := c.NewCookie(false, false) + c.NewRequest(getStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return GetStillCookie{cookie} } -// Reply blocks and returns the reply data for a QueryAdaptors request. -func (cook QueryAdaptorsCookie) Reply() (*QueryAdaptorsReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil +// GetStillChecked sends a checked request. +// If an error occurs, it can be retrieved using GetStillCookie.Check() +func GetStillChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetStillCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'GetStill' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } - return queryAdaptorsReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(getStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return GetStillCookie{cookie} } -// queryAdaptorsReply reads a byte slice into a QueryAdaptorsReply value. -func queryAdaptorsReply(buf []byte) *QueryAdaptorsReply { - v := new(QueryAdaptorsReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.NumAdaptors = xgb.Get16(buf[b:]) - b += 2 - - b += 22 // padding - - v.Info = make([]AdaptorInfo, v.NumAdaptors) - b += AdaptorInfoReadList(buf[b:], v.Info) - - return v +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook GetStillCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for QueryAdaptors -// queryAdaptorsRequest writes a QueryAdaptors request to a byte slice. -func queryAdaptorsRequest(c *xgb.Conn, Window xproto.Window) []byte { - size := 8 +// Write request to wire for GetStill +// getStillRequest writes a GetStill request to a byte slice. +func getStillRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { + size := 32 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XVIDEO"] b += 1 - buf[b] = 1 // request opcode + 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)) + xgb.Put32(buf[b:], uint32(Port)) b += 4 - return buf -} - -// QueryEncodingsCookie is a cookie used only for QueryEncodings requests. -type QueryEncodingsCookie struct { - *xgb.Cookie -} - -// QueryEncodings sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryEncodingsCookie.Reply() -func QueryEncodings(c *xgb.Conn, Port Port) QueryEncodingsCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'QueryEncodings' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(queryEncodingsRequest(c, Port), cookie) - return QueryEncodingsCookie{cookie} -} + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 -// QueryEncodingsUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryEncodingsUnchecked(c *xgb.Conn, Port Port) QueryEncodingsCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'QueryEncodings' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(queryEncodingsRequest(c, Port), cookie) - return QueryEncodingsCookie{cookie} -} + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 -// QueryEncodingsReply represents the data returned from a QueryEncodings request. -type QueryEncodingsReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - NumEncodings uint16 - // padding: 22 bytes - Info []EncodingInfo // size: EncodingInfoListSize(Info) -} + xgb.Put16(buf[b:], uint16(VidX)) + b += 2 -// Reply blocks and returns the reply data for a QueryEncodings request. -func (cook QueryEncodingsCookie) Reply() (*QueryEncodingsReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return queryEncodingsReply(buf), nil -} + xgb.Put16(buf[b:], uint16(VidY)) + b += 2 -// queryEncodingsReply reads a byte slice into a QueryEncodingsReply value. -func queryEncodingsReply(buf []byte) *QueryEncodingsReply { - v := new(QueryEncodingsReply) - b := 1 // skip reply determinant + xgb.Put16(buf[b:], VidW) + b += 2 - b += 1 // padding + xgb.Put16(buf[b:], VidH) + b += 2 - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(DrwX)) b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 + xgb.Put16(buf[b:], uint16(DrwY)) + b += 2 - v.NumEncodings = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], DrwW) b += 2 - b += 22 // padding + xgb.Put16(buf[b:], DrwH) + b += 2 - v.Info = make([]EncodingInfo, v.NumEncodings) - b += EncodingInfoReadList(buf[b:], v.Info) + return buf +} - return v +// GetVideoCookie is a cookie used only for GetVideo requests. +type GetVideoCookie struct { + *xgb.Cookie } -// Write request to wire for QueryEncodings -// queryEncodingsRequest writes a QueryEncodings request to a byte slice. -func queryEncodingsRequest(c *xgb.Conn, Port Port) []byte { - size := 8 +// GetVideo sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetVideoCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'GetVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(getVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return GetVideoCookie{cookie} +} + +// GetVideoChecked sends a checked request. +// If an error occurs, it can be retrieved using GetVideoCookie.Check() +func GetVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetVideoCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'GetVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(getVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return GetVideoCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook GetVideoCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for GetVideo +// getVideoRequest writes a GetVideo request to a byte slice. +func getVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { + size := 32 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XVIDEO"] b += 1 - buf[b] = 2 // request opcode + buf[b] = 7 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1473,6 +1425,36 @@ func queryEncodingsRequest(c *xgb.Conn, Port Port) []byte { xgb.Put32(buf[b:], uint32(Port)) b += 4 + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], uint32(Gc)) + b += 4 + + xgb.Put16(buf[b:], uint16(VidX)) + b += 2 + + xgb.Put16(buf[b:], uint16(VidY)) + b += 2 + + xgb.Put16(buf[b:], VidW) + b += 2 + + xgb.Put16(buf[b:], VidH) + b += 2 + + xgb.Put16(buf[b:], uint16(DrwX)) + b += 2 + + xgb.Put16(buf[b:], uint16(DrwY)) + b += 2 + + xgb.Put16(buf[b:], DrwW) + b += 2 + + xgb.Put16(buf[b:], DrwH) + b += 2 + return buf } @@ -1564,108 +1546,90 @@ func grabPortRequest(c *xgb.Conn, Port Port, Time xproto.Timestamp) []byte { return buf } -// UngrabPortCookie is a cookie used only for UngrabPort requests. -type UngrabPortCookie struct { +// ListImageFormatsCookie is a cookie used only for ListImageFormats requests. +type ListImageFormatsCookie struct { *xgb.Cookie } -// UngrabPort sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func UngrabPort(c *xgb.Conn, Port Port, Time xproto.Timestamp) UngrabPortCookie { +// ListImageFormats sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListImageFormatsCookie.Reply() +func ListImageFormats(c *xgb.Conn, Port Port) ListImageFormatsCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'UngrabPort' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'ListImageFormats' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(ungrabPortRequest(c, Port, Time), cookie) - return UngrabPortCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(listImageFormatsRequest(c, Port), cookie) + return ListImageFormatsCookie{cookie} } -// UngrabPortChecked sends a checked request. -// If an error occurs, it can be retrieved using UngrabPortCookie.Check() -func UngrabPortChecked(c *xgb.Conn, Port Port, Time xproto.Timestamp) UngrabPortCookie { +// ListImageFormatsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func ListImageFormatsUnchecked(c *xgb.Conn, Port Port) ListImageFormatsCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'UngrabPort' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'ListImageFormats' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(ungrabPortRequest(c, Port, Time), cookie) - return UngrabPortCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(listImageFormatsRequest(c, Port), cookie) + return ListImageFormatsCookie{cookie} } -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook UngrabPortCookie) Check() error { - return cook.Cookie.Check() +// ListImageFormatsReply represents the data returned from a ListImageFormats request. +type ListImageFormatsReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + NumFormats uint32 + // padding: 20 bytes + Format []ImageFormatInfo // size: ImageFormatInfoListSize(Format) } -// Write request to wire for UngrabPort -// ungrabPortRequest writes a UngrabPort request to a byte slice. -func ungrabPortRequest(c *xgb.Conn, Port Port, Time xproto.Timestamp) []byte { - size := 12 - b := 0 - buf := make([]byte, size) +// Reply blocks and returns the reply data for a ListImageFormats request. +func (cook ListImageFormatsCookie) Reply() (*ListImageFormatsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return listImageFormatsReply(buf), nil +} - buf[b] = c.Extensions["XVIDEO"] - b += 1 +// listImageFormatsReply reads a byte slice into a ListImageFormatsReply value. +func listImageFormatsReply(buf []byte) *ListImageFormatsReply { + v := new(ListImageFormatsReply) + b := 1 // skip reply determinant - buf[b] = 4 // request opcode - b += 1 + b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(Port)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put32(buf[b:], uint32(Time)) + v.NumFormats = xgb.Get32(buf[b:]) b += 4 - return buf -} - -// PutVideoCookie is a cookie used only for PutVideo requests. -type PutVideoCookie struct { - *xgb.Cookie -} - -// PutVideo sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PutVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutVideoCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'PutVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(putVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) - return PutVideoCookie{cookie} -} + b += 20 // padding -// PutVideoChecked sends a checked request. -// If an error occurs, it can be retrieved using PutVideoCookie.Check() -func PutVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutVideoCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'PutVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(putVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) - return PutVideoCookie{cookie} -} + v.Format = make([]ImageFormatInfo, v.NumFormats) + b += ImageFormatInfoReadList(buf[b:], v.Format) -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook PutVideoCookie) Check() error { - return cook.Cookie.Check() + return v } -// Write request to wire for PutVideo -// putVideoRequest writes a PutVideo request to a byte slice. -func putVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { - size := 32 +// Write request to wire for ListImageFormats +// listImageFormatsRequest writes a ListImageFormats request to a byte slice. +func listImageFormatsRequest(c *xgb.Conn, Port Port) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XVIDEO"] b += 1 - buf[b] = 5 // request opcode + buf[b] = 16 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1674,83 +1638,53 @@ func putVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto xgb.Put32(buf[b:], uint32(Port)) b += 4 - xgb.Put32(buf[b:], uint32(Drawable)) - b += 4 - - xgb.Put32(buf[b:], uint32(Gc)) - b += 4 - - xgb.Put16(buf[b:], uint16(VidX)) - b += 2 - - xgb.Put16(buf[b:], uint16(VidY)) - b += 2 - - xgb.Put16(buf[b:], VidW) - b += 2 - - xgb.Put16(buf[b:], VidH) - b += 2 - - xgb.Put16(buf[b:], uint16(DrwX)) - b += 2 - - xgb.Put16(buf[b:], uint16(DrwY)) - b += 2 - - xgb.Put16(buf[b:], DrwW) - b += 2 - - xgb.Put16(buf[b:], DrwH) - b += 2 - return buf } -// PutStillCookie is a cookie used only for PutStill requests. -type PutStillCookie struct { +// PutImageCookie is a cookie used only for PutImage requests. +type PutImageCookie struct { *xgb.Cookie } -// PutStill sends an unchecked request. +// PutImage sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PutStill(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutStillCookie { +func PutImage(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) PutImageCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'PutStill' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'PutImage' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(putStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) - return PutStillCookie{cookie} + c.NewRequest(putImageRequest(c, Port, Drawable, Gc, Id, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, Data), cookie) + return PutImageCookie{cookie} } -// PutStillChecked sends a checked request. -// If an error occurs, it can be retrieved using PutStillCookie.Check() -func PutStillChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutStillCookie { +// PutImageChecked sends a checked request. +// If an error occurs, it can be retrieved using PutImageCookie.Check() +func PutImageChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) PutImageCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'PutStill' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'PutImage' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(putStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) - return PutStillCookie{cookie} + c.NewRequest(putImageRequest(c, Port, Drawable, Gc, Id, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, Data), cookie) + return PutImageCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook PutStillCookie) Check() error { +func (cook PutImageCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for PutStill -// putStillRequest writes a PutStill request to a byte slice. -func putStillRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { - size := 32 +// Write request to wire for PutImage +// putImageRequest writes a PutImage request to a byte slice. +func putImageRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) []byte { + size := xgb.Pad((40 + xgb.Pad((len(Data) * 1)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XVIDEO"] b += 1 - buf[b] = 6 // request opcode + buf[b] = 18 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1765,16 +1699,19 @@ func putStillRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto xgb.Put32(buf[b:], uint32(Gc)) b += 4 - xgb.Put16(buf[b:], uint16(VidX)) + xgb.Put32(buf[b:], Id) + b += 4 + + xgb.Put16(buf[b:], uint16(SrcX)) b += 2 - xgb.Put16(buf[b:], uint16(VidY)) + xgb.Put16(buf[b:], uint16(SrcY)) b += 2 - xgb.Put16(buf[b:], VidW) + xgb.Put16(buf[b:], SrcW) b += 2 - xgb.Put16(buf[b:], VidH) + xgb.Put16(buf[b:], SrcH) b += 2 xgb.Put16(buf[b:], uint16(DrwX)) @@ -1789,45 +1726,54 @@ func putStillRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto xgb.Put16(buf[b:], DrwH) b += 2 + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + copy(buf[b:], Data[:len(Data)]) + b += xgb.Pad(int(len(Data))) + return buf } -// GetVideoCookie is a cookie used only for GetVideo requests. -type GetVideoCookie struct { +// PutStillCookie is a cookie used only for PutStill requests. +type PutStillCookie struct { *xgb.Cookie } -// GetVideo sends an unchecked request. +// PutStill sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetVideoCookie { +func PutStill(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutStillCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'GetVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'PutStill' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(getVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) - return GetVideoCookie{cookie} + c.NewRequest(putStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return PutStillCookie{cookie} } -// GetVideoChecked sends a checked request. -// If an error occurs, it can be retrieved using GetVideoCookie.Check() -func GetVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetVideoCookie { +// PutStillChecked sends a checked request. +// If an error occurs, it can be retrieved using PutStillCookie.Check() +func PutStillChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutStillCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'GetVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'PutStill' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(getVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) - return GetVideoCookie{cookie} + c.NewRequest(putStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return PutStillCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook GetVideoCookie) Check() error { +func (cook PutStillCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for GetVideo -// getVideoRequest writes a GetVideo request to a byte slice. -func getVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { +// Write request to wire for PutStill +// putStillRequest writes a PutStill request to a byte slice. +func putStillRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { size := 32 b := 0 buf := make([]byte, size) @@ -1835,7 +1781,7 @@ func getVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto buf[b] = c.Extensions["XVIDEO"] b += 1 - buf[b] = 7 // request opcode + buf[b] = 6 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1877,42 +1823,42 @@ func getVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto return buf } -// GetStillCookie is a cookie used only for GetStill requests. -type GetStillCookie struct { +// PutVideoCookie is a cookie used only for PutVideo requests. +type PutVideoCookie struct { *xgb.Cookie } -// GetStill sends an unchecked request. +// PutVideo sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetStill(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetStillCookie { +func PutVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutVideoCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'GetStill' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'PutVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(getStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) - return GetStillCookie{cookie} + c.NewRequest(putVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return PutVideoCookie{cookie} } -// GetStillChecked sends a checked request. -// If an error occurs, it can be retrieved using GetStillCookie.Check() -func GetStillChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetStillCookie { +// PutVideoChecked sends a checked request. +// If an error occurs, it can be retrieved using PutVideoCookie.Check() +func PutVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutVideoCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'GetStill' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'PutVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(getStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) - return GetStillCookie{cookie} + c.NewRequest(putVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie) + return PutVideoCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook GetStillCookie) Check() error { +func (cook PutVideoCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for GetStill -// getStillRequest writes a GetStill request to a byte slice. -func getStillRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { +// Write request to wire for PutVideo +// putVideoRequest writes a PutVideo request to a byte slice. +func putVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte { size := 32 b := 0 buf := make([]byte, size) @@ -1920,7 +1866,7 @@ func getStillRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto buf[b] = c.Extensions["XVIDEO"] b += 1 - buf[b] = 8 // request opcode + buf[b] = 5 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1962,189 +1908,98 @@ func getStillRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto return buf } -// StopVideoCookie is a cookie used only for StopVideo requests. -type StopVideoCookie struct { +// QueryAdaptorsCookie is a cookie used only for QueryAdaptors requests. +type QueryAdaptorsCookie struct { *xgb.Cookie } -// StopVideo sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func StopVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable) StopVideoCookie { +// QueryAdaptors sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryAdaptorsCookie.Reply() +func QueryAdaptors(c *xgb.Conn, Window xproto.Window) QueryAdaptorsCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'StopVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryAdaptors' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(stopVideoRequest(c, Port, Drawable), cookie) - return StopVideoCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(queryAdaptorsRequest(c, Window), cookie) + return QueryAdaptorsCookie{cookie} } -// StopVideoChecked sends a checked request. -// If an error occurs, it can be retrieved using StopVideoCookie.Check() -func StopVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable) StopVideoCookie { +// QueryAdaptorsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func QueryAdaptorsUnchecked(c *xgb.Conn, Window xproto.Window) QueryAdaptorsCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'StopVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryAdaptors' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(stopVideoRequest(c, Port, Drawable), cookie) - return StopVideoCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook StopVideoCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for StopVideo -// stopVideoRequest writes a StopVideo request to a byte slice. -func stopVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XVIDEO"] - b += 1 - - buf[b] = 9 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Port)) - b += 4 - - xgb.Put32(buf[b:], uint32(Drawable)) - b += 4 - - return buf + cookie := c.NewCookie(false, true) + c.NewRequest(queryAdaptorsRequest(c, Window), cookie) + return QueryAdaptorsCookie{cookie} } -// SelectVideoNotifyCookie is a cookie used only for SelectVideoNotify requests. -type SelectVideoNotifyCookie struct { - *xgb.Cookie +// QueryAdaptorsReply represents the data returned from a QueryAdaptors request. +type QueryAdaptorsReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + NumAdaptors uint16 + // padding: 22 bytes + Info []AdaptorInfo // size: AdaptorInfoListSize(Info) } -// SelectVideoNotify sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SelectVideoNotify(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) SelectVideoNotifyCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'SelectVideoNotify' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") +// Reply blocks and returns the reply data for a QueryAdaptors request. +func (cook QueryAdaptorsCookie) Reply() (*QueryAdaptorsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err } - cookie := c.NewCookie(false, false) - c.NewRequest(selectVideoNotifyRequest(c, Drawable, Onoff), cookie) - return SelectVideoNotifyCookie{cookie} -} - -// SelectVideoNotifyChecked sends a checked request. -// If an error occurs, it can be retrieved using SelectVideoNotifyCookie.Check() -func SelectVideoNotifyChecked(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) SelectVideoNotifyCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'SelectVideoNotify' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + if buf == nil { + return nil, nil } - cookie := c.NewCookie(true, false) - c.NewRequest(selectVideoNotifyRequest(c, Drawable, Onoff), cookie) - return SelectVideoNotifyCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook SelectVideoNotifyCookie) Check() error { - return cook.Cookie.Check() + return queryAdaptorsReply(buf), nil } -// Write request to wire for SelectVideoNotify -// selectVideoNotifyRequest writes a SelectVideoNotify request to a byte slice. -func selectVideoNotifyRequest(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XVIDEO"] - b += 1 +// queryAdaptorsReply reads a byte slice into a QueryAdaptorsReply value. +func queryAdaptorsReply(buf []byte) *QueryAdaptorsReply { + v := new(QueryAdaptorsReply) + b := 1 // skip reply determinant - buf[b] = 10 // request opcode - b += 1 + b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(Drawable)) - b += 4 - - if Onoff { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 3 // padding - - return buf -} + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 -// SelectPortNotifyCookie is a cookie used only for SelectPortNotify requests. -type SelectPortNotifyCookie struct { - *xgb.Cookie -} + v.NumAdaptors = xgb.Get16(buf[b:]) + b += 2 -// SelectPortNotify sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SelectPortNotify(c *xgb.Conn, Port Port, Onoff bool) SelectPortNotifyCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'SelectPortNotify' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(selectPortNotifyRequest(c, Port, Onoff), cookie) - return SelectPortNotifyCookie{cookie} -} + b += 22 // padding -// SelectPortNotifyChecked sends a checked request. -// If an error occurs, it can be retrieved using SelectPortNotifyCookie.Check() -func SelectPortNotifyChecked(c *xgb.Conn, Port Port, Onoff bool) SelectPortNotifyCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'SelectPortNotify' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(selectPortNotifyRequest(c, Port, Onoff), cookie) - return SelectPortNotifyCookie{cookie} -} + v.Info = make([]AdaptorInfo, v.NumAdaptors) + b += AdaptorInfoReadList(buf[b:], v.Info) -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook SelectPortNotifyCookie) Check() error { - return cook.Cookie.Check() + return v } -// Write request to wire for SelectPortNotify -// selectPortNotifyRequest writes a SelectPortNotify request to a byte slice. -func selectPortNotifyRequest(c *xgb.Conn, Port Port, Onoff bool) []byte { - size := 12 +// Write request to wire for QueryAdaptors +// queryAdaptorsRequest writes a QueryAdaptors request to a byte slice. +func queryAdaptorsRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XVIDEO"] b += 1 - buf[b] = 11 // request opcode + 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(Port)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - if Onoff { - buf[b] = 1 - } else { - buf[b] = 0 - } - b += 1 - - b += 3 // padding - return buf } @@ -2261,198 +2116,45 @@ func queryBestSizeRequest(c *xgb.Conn, Port Port, VidW uint16, VidH uint16, DrwW return buf } -// SetPortAttributeCookie is a cookie used only for SetPortAttribute requests. -type SetPortAttributeCookie struct { - *xgb.Cookie -} - -// SetPortAttribute sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetPortAttribute(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32) SetPortAttributeCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'SetPortAttribute' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(setPortAttributeRequest(c, Port, Attribute, Value), cookie) - return SetPortAttributeCookie{cookie} -} - -// SetPortAttributeChecked sends a checked request. -// If an error occurs, it can be retrieved using SetPortAttributeCookie.Check() -func SetPortAttributeChecked(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32) SetPortAttributeCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'SetPortAttribute' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(setPortAttributeRequest(c, Port, Attribute, Value), cookie) - return SetPortAttributeCookie{cookie} -} - -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook SetPortAttributeCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for SetPortAttribute -// setPortAttributeRequest writes a SetPortAttribute request to a byte slice. -func setPortAttributeRequest(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32) []byte { - size := 16 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XVIDEO"] - b += 1 - - buf[b] = 13 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Port)) - b += 4 - - xgb.Put32(buf[b:], uint32(Attribute)) - b += 4 - - xgb.Put32(buf[b:], uint32(Value)) - b += 4 - - return buf -} - -// GetPortAttributeCookie is a cookie used only for GetPortAttribute requests. -type GetPortAttributeCookie struct { - *xgb.Cookie -} - -// GetPortAttribute sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetPortAttributeCookie.Reply() -func GetPortAttribute(c *xgb.Conn, Port Port, Attribute xproto.Atom) GetPortAttributeCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'GetPortAttribute' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getPortAttributeRequest(c, Port, Attribute), cookie) - return GetPortAttributeCookie{cookie} -} - -// GetPortAttributeUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetPortAttributeUnchecked(c *xgb.Conn, Port Port, Attribute xproto.Atom) GetPortAttributeCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'GetPortAttribute' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(getPortAttributeRequest(c, Port, Attribute), cookie) - return GetPortAttributeCookie{cookie} -} - -// GetPortAttributeReply represents the data returned from a GetPortAttribute request. -type GetPortAttributeReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - Value int32 -} - -// Reply blocks and returns the reply data for a GetPortAttribute request. -func (cook GetPortAttributeCookie) Reply() (*GetPortAttributeReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getPortAttributeReply(buf), nil -} - -// getPortAttributeReply reads a byte slice into a GetPortAttributeReply value. -func getPortAttributeReply(buf []byte) *GetPortAttributeReply { - v := new(GetPortAttributeReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.Value = int32(xgb.Get32(buf[b:])) - b += 4 - - return v -} - -// Write request to wire for GetPortAttribute -// getPortAttributeRequest writes a GetPortAttribute request to a byte slice. -func getPortAttributeRequest(c *xgb.Conn, Port Port, Attribute xproto.Atom) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XVIDEO"] - b += 1 - - buf[b] = 14 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Port)) - b += 4 - - xgb.Put32(buf[b:], uint32(Attribute)) - b += 4 - - return buf -} - -// QueryPortAttributesCookie is a cookie used only for QueryPortAttributes requests. -type QueryPortAttributesCookie struct { +// QueryEncodingsCookie is a cookie used only for QueryEncodings requests. +type QueryEncodingsCookie struct { *xgb.Cookie } -// QueryPortAttributes sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryPortAttributesCookie.Reply() -func QueryPortAttributes(c *xgb.Conn, Port Port) QueryPortAttributesCookie { +// QueryEncodings sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryEncodingsCookie.Reply() +func QueryEncodings(c *xgb.Conn, Port Port) QueryEncodingsCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'QueryPortAttributes' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryEncodings' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(queryPortAttributesRequest(c, Port), cookie) - return QueryPortAttributesCookie{cookie} + c.NewRequest(queryEncodingsRequest(c, Port), cookie) + return QueryEncodingsCookie{cookie} } -// QueryPortAttributesUnchecked sends an unchecked request. +// QueryEncodingsUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryPortAttributesUnchecked(c *xgb.Conn, Port Port) QueryPortAttributesCookie { +func QueryEncodingsUnchecked(c *xgb.Conn, Port Port) QueryEncodingsCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'QueryPortAttributes' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryEncodings' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(queryPortAttributesRequest(c, Port), cookie) - return QueryPortAttributesCookie{cookie} + c.NewRequest(queryEncodingsRequest(c, Port), cookie) + return QueryEncodingsCookie{cookie} } -// QueryPortAttributesReply represents the data returned from a QueryPortAttributes request. -type QueryPortAttributesReply struct { +// QueryEncodingsReply represents the data returned from a QueryEncodings request. +type QueryEncodingsReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - NumAttributes uint32 - TextSize uint32 - // padding: 16 bytes - Attributes []AttributeInfo // size: AttributeInfoListSize(Attributes) + NumEncodings uint16 + // padding: 22 bytes + Info []EncodingInfo // size: EncodingInfoListSize(Info) } -// Reply blocks and returns the reply data for a QueryPortAttributes request. -func (cook QueryPortAttributesCookie) Reply() (*QueryPortAttributesReply, error) { +// Reply blocks and returns the reply data for a QueryEncodings request. +func (cook QueryEncodingsCookie) Reply() (*QueryEncodingsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -2460,12 +2162,12 @@ func (cook QueryPortAttributesCookie) Reply() (*QueryPortAttributesReply, error) if buf == nil { return nil, nil } - return queryPortAttributesReply(buf), nil + return queryEncodingsReply(buf), nil } - -// queryPortAttributesReply reads a byte slice into a QueryPortAttributesReply value. -func queryPortAttributesReply(buf []byte) *QueryPortAttributesReply { - v := new(QueryPortAttributesReply) + +// queryEncodingsReply reads a byte slice into a QueryEncodingsReply value. +func queryEncodingsReply(buf []byte) *QueryEncodingsReply { + v := new(QueryEncodingsReply) b := 1 // skip reply determinant b += 1 // padding @@ -2476,23 +2178,20 @@ func queryPortAttributesReply(buf []byte) *QueryPortAttributesReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.NumAttributes = xgb.Get32(buf[b:]) - b += 4 - - v.TextSize = xgb.Get32(buf[b:]) - b += 4 + v.NumEncodings = xgb.Get16(buf[b:]) + b += 2 - b += 16 // padding + b += 22 // padding - v.Attributes = make([]AttributeInfo, v.NumAttributes) - b += AttributeInfoReadList(buf[b:], v.Attributes) + v.Info = make([]EncodingInfo, v.NumEncodings) + b += EncodingInfoReadList(buf[b:], v.Info) return v } -// Write request to wire for QueryPortAttributes -// queryPortAttributesRequest writes a QueryPortAttributes request to a byte slice. -func queryPortAttributesRequest(c *xgb.Conn, Port Port) []byte { +// Write request to wire for QueryEncodings +// queryEncodingsRequest writes a QueryEncodings request to a byte slice. +func queryEncodingsRequest(c *xgb.Conn, Port Port) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -2500,7 +2199,7 @@ func queryPortAttributesRequest(c *xgb.Conn, Port Port) []byte { buf[b] = c.Extensions["XVIDEO"] b += 1 - buf[b] = 15 // request opcode + buf[b] = 2 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -2512,45 +2211,44 @@ func queryPortAttributesRequest(c *xgb.Conn, Port Port) []byte { return buf } -// ListImageFormatsCookie is a cookie used only for ListImageFormats requests. -type ListImageFormatsCookie struct { +// QueryExtensionCookie is a cookie used only for QueryExtension requests. +type QueryExtensionCookie struct { *xgb.Cookie } -// ListImageFormats sends a checked request. -// If an error occurs, it will be returned with the reply by calling ListImageFormatsCookie.Reply() -func ListImageFormats(c *xgb.Conn, Port Port) ListImageFormatsCookie { +// QueryExtension sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryExtensionCookie.Reply() +func QueryExtension(c *xgb.Conn) QueryExtensionCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'ListImageFormats' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryExtension' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(listImageFormatsRequest(c, Port), cookie) - return ListImageFormatsCookie{cookie} + c.NewRequest(queryExtensionRequest(c), cookie) + return QueryExtensionCookie{cookie} } -// ListImageFormatsUnchecked sends an unchecked request. +// QueryExtensionUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ListImageFormatsUnchecked(c *xgb.Conn, Port Port) ListImageFormatsCookie { +func QueryExtensionUnchecked(c *xgb.Conn) QueryExtensionCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'ListImageFormats' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryExtension' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(listImageFormatsRequest(c, Port), cookie) - return ListImageFormatsCookie{cookie} + c.NewRequest(queryExtensionRequest(c), cookie) + return QueryExtensionCookie{cookie} } -// ListImageFormatsReply represents the data returned from a ListImageFormats request. -type ListImageFormatsReply struct { +// QueryExtensionReply represents the data returned from a QueryExtension request. +type QueryExtensionReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - NumFormats uint32 - // padding: 20 bytes - Format []ImageFormatInfo // size: ImageFormatInfoListSize(Format) + Major uint16 + Minor uint16 } -// Reply blocks and returns the reply data for a ListImageFormats request. -func (cook ListImageFormatsCookie) Reply() (*ListImageFormatsReply, error) { +// Reply blocks and returns the reply data for a QueryExtension request. +func (cook QueryExtensionCookie) Reply() (*QueryExtensionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -2558,12 +2256,12 @@ func (cook ListImageFormatsCookie) Reply() (*ListImageFormatsReply, error) { if buf == nil { return nil, nil } - return listImageFormatsReply(buf), nil + return queryExtensionReply(buf), nil } -// listImageFormatsReply reads a byte slice into a ListImageFormatsReply value. -func listImageFormatsReply(buf []byte) *ListImageFormatsReply { - v := new(ListImageFormatsReply) +// queryExtensionReply reads a byte slice into a QueryExtensionReply value. +func queryExtensionReply(buf []byte) *QueryExtensionReply { + v := new(QueryExtensionReply) b := 1 // skip reply determinant b += 1 // padding @@ -2574,36 +2272,31 @@ func listImageFormatsReply(buf []byte) *ListImageFormatsReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.NumFormats = xgb.Get32(buf[b:]) - b += 4 - - b += 20 // padding + v.Major = xgb.Get16(buf[b:]) + b += 2 - v.Format = make([]ImageFormatInfo, v.NumFormats) - b += ImageFormatInfoReadList(buf[b:], v.Format) + v.Minor = xgb.Get16(buf[b:]) + b += 2 return v } -// Write request to wire for ListImageFormats -// listImageFormatsRequest writes a ListImageFormats request to a byte slice. -func listImageFormatsRequest(c *xgb.Conn, Port Port) []byte { - size := 8 +// Write request to wire for QueryExtension +// queryExtensionRequest writes a QueryExtension request to a byte slice. +func queryExtensionRequest(c *xgb.Conn) []byte { + size := 4 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XVIDEO"] b += 1 - buf[b] = 16 // 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(Port)) - b += 4 - return buf } @@ -2714,7 +2407,170 @@ func queryImageAttributesRequest(c *xgb.Conn, Port Port, Id uint32, Width uint16 buf[b] = c.Extensions["XVIDEO"] b += 1 - buf[b] = 17 // request opcode + buf[b] = 17 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + xgb.Put32(buf[b:], Id) + b += 4 + + xgb.Put16(buf[b:], Width) + b += 2 + + xgb.Put16(buf[b:], Height) + b += 2 + + return buf +} + +// QueryPortAttributesCookie is a cookie used only for QueryPortAttributes requests. +type QueryPortAttributesCookie struct { + *xgb.Cookie +} + +// QueryPortAttributes sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryPortAttributesCookie.Reply() +func QueryPortAttributes(c *xgb.Conn, Port Port) QueryPortAttributesCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'QueryPortAttributes' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(queryPortAttributesRequest(c, Port), cookie) + return QueryPortAttributesCookie{cookie} +} + +// QueryPortAttributesUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func QueryPortAttributesUnchecked(c *xgb.Conn, Port Port) QueryPortAttributesCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'QueryPortAttributes' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(queryPortAttributesRequest(c, Port), cookie) + return QueryPortAttributesCookie{cookie} +} + +// QueryPortAttributesReply represents the data returned from a QueryPortAttributes request. +type QueryPortAttributesReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + NumAttributes uint32 + TextSize uint32 + // padding: 16 bytes + Attributes []AttributeInfo // size: AttributeInfoListSize(Attributes) +} + +// Reply blocks and returns the reply data for a QueryPortAttributes request. +func (cook QueryPortAttributesCookie) Reply() (*QueryPortAttributesReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryPortAttributesReply(buf), nil +} + +// queryPortAttributesReply reads a byte slice into a QueryPortAttributesReply value. +func queryPortAttributesReply(buf []byte) *QueryPortAttributesReply { + v := new(QueryPortAttributesReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.NumAttributes = xgb.Get32(buf[b:]) + b += 4 + + v.TextSize = xgb.Get32(buf[b:]) + b += 4 + + b += 16 // padding + + v.Attributes = make([]AttributeInfo, v.NumAttributes) + b += AttributeInfoReadList(buf[b:], v.Attributes) + + return v +} + +// Write request to wire for QueryPortAttributes +// queryPortAttributesRequest writes a QueryPortAttributes request to a byte slice. +func queryPortAttributesRequest(c *xgb.Conn, Port Port) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 15 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + return buf +} + +// SelectPortNotifyCookie is a cookie used only for SelectPortNotify requests. +type SelectPortNotifyCookie struct { + *xgb.Cookie +} + +// SelectPortNotify sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SelectPortNotify(c *xgb.Conn, Port Port, Onoff bool) SelectPortNotifyCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'SelectPortNotify' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(selectPortNotifyRequest(c, Port, Onoff), cookie) + return SelectPortNotifyCookie{cookie} +} + +// SelectPortNotifyChecked sends a checked request. +// If an error occurs, it can be retrieved using SelectPortNotifyCookie.Check() +func SelectPortNotifyChecked(c *xgb.Conn, Port Port, Onoff bool) SelectPortNotifyCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'SelectPortNotify' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(selectPortNotifyRequest(c, Port, Onoff), cookie) + return SelectPortNotifyCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook SelectPortNotifyCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SelectPortNotify +// selectPortNotifyRequest writes a SelectPortNotify request to a byte slice. +func selectPortNotifyRequest(c *xgb.Conn, Port Port, Onoff bool) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 11 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -2723,111 +2579,139 @@ func queryImageAttributesRequest(c *xgb.Conn, Port Port, Id uint32, Width uint16 xgb.Put32(buf[b:], uint32(Port)) b += 4 - xgb.Put32(buf[b:], Id) - b += 4 - - xgb.Put16(buf[b:], Width) - b += 2 + if Onoff { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 - xgb.Put16(buf[b:], Height) - b += 2 + b += 3 // padding return buf } -// PutImageCookie is a cookie used only for PutImage requests. -type PutImageCookie struct { +// SelectVideoNotifyCookie is a cookie used only for SelectVideoNotify requests. +type SelectVideoNotifyCookie struct { *xgb.Cookie } -// PutImage sends an unchecked request. +// SelectVideoNotify sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func PutImage(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) PutImageCookie { +func SelectVideoNotify(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) SelectVideoNotifyCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'PutImage' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'SelectVideoNotify' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(putImageRequest(c, Port, Drawable, Gc, Id, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, Data), cookie) - return PutImageCookie{cookie} + c.NewRequest(selectVideoNotifyRequest(c, Drawable, Onoff), cookie) + return SelectVideoNotifyCookie{cookie} } -// PutImageChecked sends a checked request. -// If an error occurs, it can be retrieved using PutImageCookie.Check() -func PutImageChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) PutImageCookie { +// SelectVideoNotifyChecked sends a checked request. +// If an error occurs, it can be retrieved using SelectVideoNotifyCookie.Check() +func SelectVideoNotifyChecked(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) SelectVideoNotifyCookie { if _, ok := c.Extensions["XVIDEO"]; !ok { - panic("Cannot issue request 'PutImage' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + panic("Cannot issue request 'SelectVideoNotify' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(putImageRequest(c, Port, Drawable, Gc, Id, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, Data), cookie) - return PutImageCookie{cookie} + c.NewRequest(selectVideoNotifyRequest(c, Drawable, Onoff), cookie) + return SelectVideoNotifyCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook PutImageCookie) Check() error { +func (cook SelectVideoNotifyCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for PutImage -// putImageRequest writes a PutImage request to a byte slice. -func putImageRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) []byte { - size := xgb.Pad((40 + xgb.Pad((len(Data) * 1)))) +// Write request to wire for SelectVideoNotify +// selectVideoNotifyRequest writes a SelectVideoNotify request to a byte slice. +func selectVideoNotifyRequest(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XVIDEO"] b += 1 - buf[b] = 18 // request opcode + buf[b] = 10 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Port)) - b += 4 - xgb.Put32(buf[b:], uint32(Drawable)) b += 4 - xgb.Put32(buf[b:], uint32(Gc)) - b += 4 + if Onoff { + buf[b] = 1 + } else { + buf[b] = 0 + } + b += 1 - xgb.Put32(buf[b:], Id) - b += 4 + b += 3 // padding - xgb.Put16(buf[b:], uint16(SrcX)) - b += 2 + return buf +} - xgb.Put16(buf[b:], uint16(SrcY)) - b += 2 +// SetPortAttributeCookie is a cookie used only for SetPortAttribute requests. +type SetPortAttributeCookie struct { + *xgb.Cookie +} - xgb.Put16(buf[b:], SrcW) - b += 2 +// SetPortAttribute sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SetPortAttribute(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32) SetPortAttributeCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'SetPortAttribute' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(setPortAttributeRequest(c, Port, Attribute, Value), cookie) + return SetPortAttributeCookie{cookie} +} - xgb.Put16(buf[b:], SrcH) - b += 2 +// SetPortAttributeChecked sends a checked request. +// If an error occurs, it can be retrieved using SetPortAttributeCookie.Check() +func SetPortAttributeChecked(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32) SetPortAttributeCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'SetPortAttribute' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(setPortAttributeRequest(c, Port, Attribute, Value), cookie) + return SetPortAttributeCookie{cookie} +} - xgb.Put16(buf[b:], uint16(DrwX)) - b += 2 +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook SetPortAttributeCookie) Check() error { + return cook.Cookie.Check() +} - xgb.Put16(buf[b:], uint16(DrwY)) - b += 2 +// Write request to wire for SetPortAttribute +// setPortAttributeRequest writes a SetPortAttribute request to a byte slice. +func setPortAttributeRequest(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32) []byte { + size := 16 + b := 0 + buf := make([]byte, size) - xgb.Put16(buf[b:], DrwW) - b += 2 + buf[b] = c.Extensions["XVIDEO"] + b += 1 - xgb.Put16(buf[b:], DrwH) - b += 2 + buf[b] = 13 // request opcode + b += 1 - xgb.Put16(buf[b:], Width) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put16(buf[b:], Height) - b += 2 + xgb.Put32(buf[b:], uint32(Port)) + b += 4 - copy(buf[b:], Data[:len(Data)]) - b += xgb.Pad(int(len(Data))) + xgb.Put32(buf[b:], uint32(Attribute)) + b += 4 + + xgb.Put32(buf[b:], uint32(Value)) + b += 4 return buf } @@ -2936,3 +2820,119 @@ func shmPutImageRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xpr return buf } + +// StopVideoCookie is a cookie used only for StopVideo requests. +type StopVideoCookie struct { + *xgb.Cookie +} + +// StopVideo sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func StopVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable) StopVideoCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'StopVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(stopVideoRequest(c, Port, Drawable), cookie) + return StopVideoCookie{cookie} +} + +// StopVideoChecked sends a checked request. +// If an error occurs, it can be retrieved using StopVideoCookie.Check() +func StopVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable) StopVideoCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'StopVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(stopVideoRequest(c, Port, Drawable), cookie) + return StopVideoCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook StopVideoCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for StopVideo +// stopVideoRequest writes a StopVideo request to a byte slice. +func stopVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 9 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Drawable)) + b += 4 + + return buf +} + +// UngrabPortCookie is a cookie used only for UngrabPort requests. +type UngrabPortCookie struct { + *xgb.Cookie +} + +// UngrabPort sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func UngrabPort(c *xgb.Conn, Port Port, Time xproto.Timestamp) UngrabPortCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'UngrabPort' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(ungrabPortRequest(c, Port, Time), cookie) + return UngrabPortCookie{cookie} +} + +// UngrabPortChecked sends a checked request. +// If an error occurs, it can be retrieved using UngrabPortCookie.Check() +func UngrabPortChecked(c *xgb.Conn, Port Port, Time xproto.Timestamp) UngrabPortCookie { + if _, ok := c.Extensions["XVIDEO"]; !ok { + panic("Cannot issue request 'UngrabPort' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(ungrabPortRequest(c, Port, Time), cookie) + return UngrabPortCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook UngrabPortCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for UngrabPort +// ungrabPortRequest writes a UngrabPort request to a byte slice. +func ungrabPortRequest(c *xgb.Conn, Port Port, Time xproto.Timestamp) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XVIDEO"] + b += 1 + + buf[b] = 4 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], uint32(Port)) + b += 4 + + xgb.Put32(buf[b:], uint32(Time)) + b += 4 + + return buf +} -- cgit v1.2.3 From b06a8ca97625c1134449c3af65d9ac3fb251a613 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Sun, 11 Aug 2013 20:45:36 -0400 Subject: Don't needlessly change source files every time. --- nexgb/xv/xv.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'nexgb/xv') diff --git a/nexgb/xv/xv.go b/nexgb/xv/xv.go index f5539b3..0a88632 100644 --- a/nexgb/xv/xv.go +++ b/nexgb/xv/xv.go @@ -1,10 +1,7 @@ // Package xv is the X client API for the XVideo extension. package xv -/* - This file was generated by xv.xml on Aug 11 2013 8:39:44pm EDT. - This file is automatically generated. Edit at your peril! -*/ +// This file is automatically generated from xv.xml. Edit at your peril! import ( "github.com/BurntSushi/xgb" -- cgit v1.2.3 From 38b293e74db6631873d5dfd74cf731eb7b76737d Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Sun, 11 Aug 2013 20:54:15 -0400 Subject: Padding on a list is on the length of the list. There was a bug where padding was being computed on each element of the list. Close #5. --- nexgb/xv/xv.go | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'nexgb/xv') diff --git a/nexgb/xv/xv.go b/nexgb/xv/xv.go index 0a88632..5eefe77 100644 --- a/nexgb/xv/xv.go +++ b/nexgb/xv/xv.go @@ -130,9 +130,9 @@ func AdaptorInfoListBytes(buf []byte, list []AdaptorInfo) int { for _, item := range list { structBytes = item.Bytes() copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) + b += len(structBytes) } - return b + return xgb.Pad(b) } // AdaptorInfoListSize computes the size (bytes) of a list of AdaptorInfo values. @@ -223,9 +223,9 @@ func AttributeInfoListBytes(buf []byte, list []AttributeInfo) int { for _, item := range list { structBytes = item.Bytes() copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) + b += len(structBytes) } - return b + return xgb.Pad(b) } // AttributeInfoListSize computes the size (bytes) of a list of AttributeInfo values. @@ -474,9 +474,9 @@ func EncodingInfoListBytes(buf []byte, list []EncodingInfo) int { for _, item := range list { structBytes = item.Bytes() copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) + b += len(structBytes) } - return b + return xgb.Pad(b) } // EncodingInfoListSize computes the size (bytes) of a list of EncodingInfo values. @@ -542,9 +542,9 @@ func FormatListBytes(buf []byte, list []Format) int { for _, item := range list { structBytes = item.Bytes() copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) + b += len(structBytes) } - return b + return xgb.Pad(b) } const ( @@ -662,9 +662,9 @@ func ImageListBytes(buf []byte, list []Image) int { for _, item := range list { structBytes = item.Bytes() copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) + b += len(structBytes) } - return b + return xgb.Pad(b) } // ImageListSize computes the size (bytes) of a list of Image values. @@ -892,9 +892,9 @@ func ImageFormatInfoListBytes(buf []byte, list []ImageFormatInfo) int { for _, item := range list { structBytes = item.Bytes() copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) + b += len(structBytes) } - return b + return xgb.Pad(b) } // ImageFormatInfoListSize computes the size (bytes) of a list of ImageFormatInfo values. @@ -1062,9 +1062,9 @@ func RationalListBytes(buf []byte, list []Rational) int { for _, item := range list { structBytes = item.Bytes() copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) + b += len(structBytes) } - return b + return xgb.Pad(b) } const ( -- cgit v1.2.3 From 2dc9914b5e6b74c353771e56e90dfd2dd33e0202 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Sat, 28 Dec 2013 09:33:09 -0500 Subject: When writing, don't pad the length of bytes produced from inner structs/unions. Each type should take care of its own padding. Close #14. --- nexgb/xv/xv.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nexgb/xv') diff --git a/nexgb/xv/xv.go b/nexgb/xv/xv.go index 5eefe77..d79a594 100644 --- a/nexgb/xv/xv.go +++ b/nexgb/xv/xv.go @@ -458,7 +458,7 @@ func (v EncodingInfo) Bytes() []byte { { structBytes := v.Rate.Bytes() copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) + b += len(structBytes) } copy(buf[b:], v.Name[:v.NameSize]) -- cgit v1.2.3 From 33509dbeb0acd7abbbb9e8c434d0c3f0ce8a3230 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Sat, 28 Dec 2013 10:02:18 -0500 Subject: It appears that the "Str" type (which is built into the core X protocol) doesn't specify any padding. So it has to be treated as a special case. Close #12. --- nexgb/xv/xv.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'nexgb/xv') diff --git a/nexgb/xv/xv.go b/nexgb/xv/xv.go index d79a594..32bdd9e 100644 --- a/nexgb/xv/xv.go +++ b/nexgb/xv/xv.go @@ -74,7 +74,7 @@ func AdaptorInfoRead(buf []byte, v *AdaptorInfo) int { byteString := make([]byte, v.NameSize) copy(byteString[:v.NameSize], buf[b:]) v.Name = string(byteString) - b += xgb.Pad(int(v.NameSize)) + b += int(v.NameSize) } v.Formats = make([]Format, v.NumFormats) @@ -177,7 +177,7 @@ func AttributeInfoRead(buf []byte, v *AttributeInfo) int { byteString := make([]byte, v.Size) copy(byteString[:v.Size], buf[b:]) v.Name = string(byteString) - b += xgb.Pad(int(v.Size)) + b += int(v.Size) } return b @@ -420,7 +420,7 @@ func EncodingInfoRead(buf []byte, v *EncodingInfo) int { byteString := make([]byte, v.NameSize) copy(byteString[:v.NameSize], buf[b:]) v.Name = string(byteString) - b += xgb.Pad(int(v.NameSize)) + b += int(v.NameSize) } return b -- cgit v1.2.3 From 76f9adb5991081e27ebc6eec82db6bdba36c910f Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Sat, 28 Dec 2013 10:13:20 -0500 Subject: Use consistent extension names. Close #6. --- nexgb/xv/xv.go | 120 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 60 insertions(+), 60 deletions(-) (limited to 'nexgb/xv') diff --git a/nexgb/xv/xv.go b/nexgb/xv/xv.go index 32bdd9e..ec87d02 100644 --- a/nexgb/xv/xv.go +++ b/nexgb/xv/xv.go @@ -1202,7 +1202,7 @@ type GetPortAttributeCookie struct { // GetPortAttribute sends a checked request. // If an error occurs, it will be returned with the reply by calling GetPortAttributeCookie.Reply() func GetPortAttribute(c *xgb.Conn, Port Port, Attribute xproto.Atom) GetPortAttributeCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'GetPortAttribute' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) @@ -1213,7 +1213,7 @@ func GetPortAttribute(c *xgb.Conn, Port Port, Attribute xproto.Atom) GetPortAttr // GetPortAttributeUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetPortAttributeUnchecked(c *xgb.Conn, Port Port, Attribute xproto.Atom) GetPortAttributeCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'GetPortAttribute' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) @@ -1267,7 +1267,7 @@ func getPortAttributeRequest(c *xgb.Conn, Port Port, Attribute xproto.Atom) []by b := 0 buf := make([]byte, size) - buf[b] = c.Extensions["XVIDEO"] + buf[b] = c.Extensions["XVideo"] b += 1 buf[b] = 14 // request opcode @@ -1293,7 +1293,7 @@ type GetStillCookie struct { // GetStill sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetStill(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetStillCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'GetStill' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) @@ -1304,7 +1304,7 @@ func GetStill(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gconte // GetStillChecked sends a checked request. // If an error occurs, it can be retrieved using GetStillCookie.Check() func GetStillChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetStillCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'GetStill' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) @@ -1325,7 +1325,7 @@ func getStillRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto b := 0 buf := make([]byte, size) - buf[b] = c.Extensions["XVIDEO"] + buf[b] = c.Extensions["XVideo"] b += 1 buf[b] = 8 // request opcode @@ -1378,7 +1378,7 @@ type GetVideoCookie struct { // GetVideo sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetVideoCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'GetVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) @@ -1389,7 +1389,7 @@ func GetVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gconte // GetVideoChecked sends a checked request. // If an error occurs, it can be retrieved using GetVideoCookie.Check() func GetVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetVideoCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'GetVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) @@ -1410,7 +1410,7 @@ func getVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto b := 0 buf := make([]byte, size) - buf[b] = c.Extensions["XVIDEO"] + buf[b] = c.Extensions["XVideo"] b += 1 buf[b] = 7 // request opcode @@ -1463,7 +1463,7 @@ type GrabPortCookie struct { // GrabPort sends a checked request. // If an error occurs, it will be returned with the reply by calling GrabPortCookie.Reply() func GrabPort(c *xgb.Conn, Port Port, Time xproto.Timestamp) GrabPortCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'GrabPort' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) @@ -1474,7 +1474,7 @@ func GrabPort(c *xgb.Conn, Port Port, Time xproto.Timestamp) GrabPortCookie { // GrabPortUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GrabPortUnchecked(c *xgb.Conn, Port Port, Time xproto.Timestamp) GrabPortCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'GrabPort' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) @@ -1525,7 +1525,7 @@ func grabPortRequest(c *xgb.Conn, Port Port, Time xproto.Timestamp) []byte { b := 0 buf := make([]byte, size) - buf[b] = c.Extensions["XVIDEO"] + buf[b] = c.Extensions["XVideo"] b += 1 buf[b] = 3 // request opcode @@ -1551,7 +1551,7 @@ type ListImageFormatsCookie struct { // ListImageFormats sends a checked request. // If an error occurs, it will be returned with the reply by calling ListImageFormatsCookie.Reply() func ListImageFormats(c *xgb.Conn, Port Port) ListImageFormatsCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'ListImageFormats' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) @@ -1562,7 +1562,7 @@ func ListImageFormats(c *xgb.Conn, Port Port) ListImageFormatsCookie { // ListImageFormatsUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ListImageFormatsUnchecked(c *xgb.Conn, Port Port) ListImageFormatsCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'ListImageFormats' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) @@ -1623,7 +1623,7 @@ func listImageFormatsRequest(c *xgb.Conn, Port Port) []byte { b := 0 buf := make([]byte, size) - buf[b] = c.Extensions["XVIDEO"] + buf[b] = c.Extensions["XVideo"] b += 1 buf[b] = 16 // request opcode @@ -1646,7 +1646,7 @@ type PutImageCookie struct { // PutImage sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PutImage(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) PutImageCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'PutImage' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) @@ -1657,7 +1657,7 @@ func PutImage(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gconte // PutImageChecked sends a checked request. // If an error occurs, it can be retrieved using PutImageCookie.Check() func PutImageChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) PutImageCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'PutImage' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) @@ -1678,7 +1678,7 @@ func putImageRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto b := 0 buf := make([]byte, size) - buf[b] = c.Extensions["XVIDEO"] + buf[b] = c.Extensions["XVideo"] b += 1 buf[b] = 18 // request opcode @@ -1743,7 +1743,7 @@ type PutStillCookie struct { // PutStill sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PutStill(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutStillCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'PutStill' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) @@ -1754,7 +1754,7 @@ func PutStill(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gconte // PutStillChecked sends a checked request. // If an error occurs, it can be retrieved using PutStillCookie.Check() func PutStillChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutStillCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'PutStill' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) @@ -1775,7 +1775,7 @@ func putStillRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto b := 0 buf := make([]byte, size) - buf[b] = c.Extensions["XVIDEO"] + buf[b] = c.Extensions["XVideo"] b += 1 buf[b] = 6 // request opcode @@ -1828,7 +1828,7 @@ type PutVideoCookie struct { // PutVideo sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PutVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutVideoCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'PutVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) @@ -1839,7 +1839,7 @@ func PutVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gconte // PutVideoChecked sends a checked request. // If an error occurs, it can be retrieved using PutVideoCookie.Check() func PutVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutVideoCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'PutVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) @@ -1860,7 +1860,7 @@ func putVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto b := 0 buf := make([]byte, size) - buf[b] = c.Extensions["XVIDEO"] + buf[b] = c.Extensions["XVideo"] b += 1 buf[b] = 5 // request opcode @@ -1913,7 +1913,7 @@ type QueryAdaptorsCookie struct { // QueryAdaptors sends a checked request. // If an error occurs, it will be returned with the reply by calling QueryAdaptorsCookie.Reply() func QueryAdaptors(c *xgb.Conn, Window xproto.Window) QueryAdaptorsCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'QueryAdaptors' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) @@ -1924,7 +1924,7 @@ func QueryAdaptors(c *xgb.Conn, Window xproto.Window) QueryAdaptorsCookie { // QueryAdaptorsUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryAdaptorsUnchecked(c *xgb.Conn, Window xproto.Window) QueryAdaptorsCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'QueryAdaptors' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) @@ -1985,7 +1985,7 @@ func queryAdaptorsRequest(c *xgb.Conn, Window xproto.Window) []byte { b := 0 buf := make([]byte, size) - buf[b] = c.Extensions["XVIDEO"] + buf[b] = c.Extensions["XVideo"] b += 1 buf[b] = 1 // request opcode @@ -2008,7 +2008,7 @@ type QueryBestSizeCookie struct { // QueryBestSize sends a checked request. // If an error occurs, it will be returned with the reply by calling QueryBestSizeCookie.Reply() func QueryBestSize(c *xgb.Conn, Port Port, VidW uint16, VidH uint16, DrwW uint16, DrwH uint16, Motion bool) QueryBestSizeCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'QueryBestSize' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) @@ -2019,7 +2019,7 @@ func QueryBestSize(c *xgb.Conn, Port Port, VidW uint16, VidH uint16, DrwW uint16 // QueryBestSizeUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryBestSizeUnchecked(c *xgb.Conn, Port Port, VidW uint16, VidH uint16, DrwW uint16, DrwH uint16, Motion bool) QueryBestSizeCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'QueryBestSize' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) @@ -2077,7 +2077,7 @@ func queryBestSizeRequest(c *xgb.Conn, Port Port, VidW uint16, VidH uint16, DrwW b := 0 buf := make([]byte, size) - buf[b] = c.Extensions["XVIDEO"] + buf[b] = c.Extensions["XVideo"] b += 1 buf[b] = 12 // request opcode @@ -2121,7 +2121,7 @@ type QueryEncodingsCookie struct { // QueryEncodings sends a checked request. // If an error occurs, it will be returned with the reply by calling QueryEncodingsCookie.Reply() func QueryEncodings(c *xgb.Conn, Port Port) QueryEncodingsCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'QueryEncodings' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) @@ -2132,7 +2132,7 @@ func QueryEncodings(c *xgb.Conn, Port Port) QueryEncodingsCookie { // QueryEncodingsUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryEncodingsUnchecked(c *xgb.Conn, Port Port) QueryEncodingsCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'QueryEncodings' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) @@ -2193,7 +2193,7 @@ func queryEncodingsRequest(c *xgb.Conn, Port Port) []byte { b := 0 buf := make([]byte, size) - buf[b] = c.Extensions["XVIDEO"] + buf[b] = c.Extensions["XVideo"] b += 1 buf[b] = 2 // request opcode @@ -2216,7 +2216,7 @@ type QueryExtensionCookie struct { // QueryExtension sends a checked request. // If an error occurs, it will be returned with the reply by calling QueryExtensionCookie.Reply() func QueryExtension(c *xgb.Conn) QueryExtensionCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'QueryExtension' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) @@ -2227,7 +2227,7 @@ func QueryExtension(c *xgb.Conn) QueryExtensionCookie { // QueryExtensionUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryExtensionUnchecked(c *xgb.Conn) QueryExtensionCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'QueryExtension' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) @@ -2285,7 +2285,7 @@ func queryExtensionRequest(c *xgb.Conn) []byte { b := 0 buf := make([]byte, size) - buf[b] = c.Extensions["XVIDEO"] + buf[b] = c.Extensions["XVideo"] b += 1 buf[b] = 0 // request opcode @@ -2305,7 +2305,7 @@ type QueryImageAttributesCookie struct { // QueryImageAttributes sends a checked request. // If an error occurs, it will be returned with the reply by calling QueryImageAttributesCookie.Reply() func QueryImageAttributes(c *xgb.Conn, Port Port, Id uint32, Width uint16, Height uint16) QueryImageAttributesCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'QueryImageAttributes' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) @@ -2316,7 +2316,7 @@ func QueryImageAttributes(c *xgb.Conn, Port Port, Id uint32, Width uint16, Heigh // QueryImageAttributesUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryImageAttributesUnchecked(c *xgb.Conn, Port Port, Id uint32, Width uint16, Height uint16) QueryImageAttributesCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'QueryImageAttributes' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) @@ -2401,7 +2401,7 @@ func queryImageAttributesRequest(c *xgb.Conn, Port Port, Id uint32, Width uint16 b := 0 buf := make([]byte, size) - buf[b] = c.Extensions["XVIDEO"] + buf[b] = c.Extensions["XVideo"] b += 1 buf[b] = 17 // request opcode @@ -2433,7 +2433,7 @@ type QueryPortAttributesCookie struct { // QueryPortAttributes sends a checked request. // If an error occurs, it will be returned with the reply by calling QueryPortAttributesCookie.Reply() func QueryPortAttributes(c *xgb.Conn, Port Port) QueryPortAttributesCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'QueryPortAttributes' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) @@ -2444,7 +2444,7 @@ func QueryPortAttributes(c *xgb.Conn, Port Port) QueryPortAttributesCookie { // QueryPortAttributesUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryPortAttributesUnchecked(c *xgb.Conn, Port Port) QueryPortAttributesCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'QueryPortAttributes' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) @@ -2509,7 +2509,7 @@ func queryPortAttributesRequest(c *xgb.Conn, Port Port) []byte { b := 0 buf := make([]byte, size) - buf[b] = c.Extensions["XVIDEO"] + buf[b] = c.Extensions["XVideo"] b += 1 buf[b] = 15 // request opcode @@ -2532,7 +2532,7 @@ type SelectPortNotifyCookie struct { // SelectPortNotify sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SelectPortNotify(c *xgb.Conn, Port Port, Onoff bool) SelectPortNotifyCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'SelectPortNotify' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) @@ -2543,7 +2543,7 @@ func SelectPortNotify(c *xgb.Conn, Port Port, Onoff bool) SelectPortNotifyCookie // SelectPortNotifyChecked sends a checked request. // If an error occurs, it can be retrieved using SelectPortNotifyCookie.Check() func SelectPortNotifyChecked(c *xgb.Conn, Port Port, Onoff bool) SelectPortNotifyCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'SelectPortNotify' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) @@ -2564,7 +2564,7 @@ func selectPortNotifyRequest(c *xgb.Conn, Port Port, Onoff bool) []byte { b := 0 buf := make([]byte, size) - buf[b] = c.Extensions["XVIDEO"] + buf[b] = c.Extensions["XVideo"] b += 1 buf[b] = 11 // request opcode @@ -2596,7 +2596,7 @@ type SelectVideoNotifyCookie struct { // SelectVideoNotify sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SelectVideoNotify(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) SelectVideoNotifyCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'SelectVideoNotify' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) @@ -2607,7 +2607,7 @@ func SelectVideoNotify(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) Select // SelectVideoNotifyChecked sends a checked request. // If an error occurs, it can be retrieved using SelectVideoNotifyCookie.Check() func SelectVideoNotifyChecked(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) SelectVideoNotifyCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'SelectVideoNotify' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) @@ -2628,7 +2628,7 @@ func selectVideoNotifyRequest(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) b := 0 buf := make([]byte, size) - buf[b] = c.Extensions["XVIDEO"] + buf[b] = c.Extensions["XVideo"] b += 1 buf[b] = 10 // request opcode @@ -2660,7 +2660,7 @@ type SetPortAttributeCookie struct { // SetPortAttribute sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetPortAttribute(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32) SetPortAttributeCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'SetPortAttribute' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) @@ -2671,7 +2671,7 @@ func SetPortAttribute(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32 // SetPortAttributeChecked sends a checked request. // If an error occurs, it can be retrieved using SetPortAttributeCookie.Check() func SetPortAttributeChecked(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32) SetPortAttributeCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'SetPortAttribute' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) @@ -2692,7 +2692,7 @@ func setPortAttributeRequest(c *xgb.Conn, Port Port, Attribute xproto.Atom, Valu b := 0 buf := make([]byte, size) - buf[b] = c.Extensions["XVIDEO"] + buf[b] = c.Extensions["XVideo"] b += 1 buf[b] = 13 // request opcode @@ -2721,7 +2721,7 @@ type ShmPutImageCookie struct { // ShmPutImage sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ShmPutImage(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Shmseg shm.Seg, Id uint32, Offset uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, SendEvent byte) ShmPutImageCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'ShmPutImage' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) @@ -2732,7 +2732,7 @@ func ShmPutImage(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gco // ShmPutImageChecked sends a checked request. // If an error occurs, it can be retrieved using ShmPutImageCookie.Check() func ShmPutImageChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Shmseg shm.Seg, Id uint32, Offset uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, SendEvent byte) ShmPutImageCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'ShmPutImage' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) @@ -2753,7 +2753,7 @@ func shmPutImageRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xpr b := 0 buf := make([]byte, size) - buf[b] = c.Extensions["XVIDEO"] + buf[b] = c.Extensions["XVideo"] b += 1 buf[b] = 19 // request opcode @@ -2826,7 +2826,7 @@ type StopVideoCookie struct { // StopVideo sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func StopVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable) StopVideoCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'StopVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) @@ -2837,7 +2837,7 @@ func StopVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable) StopVideoCookie // StopVideoChecked sends a checked request. // If an error occurs, it can be retrieved using StopVideoCookie.Check() func StopVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable) StopVideoCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'StopVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) @@ -2858,7 +2858,7 @@ func stopVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable) []byte { b := 0 buf := make([]byte, size) - buf[b] = c.Extensions["XVIDEO"] + buf[b] = c.Extensions["XVideo"] b += 1 buf[b] = 9 // request opcode @@ -2884,7 +2884,7 @@ type UngrabPortCookie struct { // UngrabPort sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func UngrabPort(c *xgb.Conn, Port Port, Time xproto.Timestamp) UngrabPortCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'UngrabPort' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) @@ -2895,7 +2895,7 @@ func UngrabPort(c *xgb.Conn, Port Port, Time xproto.Timestamp) UngrabPortCookie // UngrabPortChecked sends a checked request. // If an error occurs, it can be retrieved using UngrabPortCookie.Check() func UngrabPortChecked(c *xgb.Conn, Port Port, Time xproto.Timestamp) UngrabPortCookie { - if _, ok := c.Extensions["XVIDEO"]; !ok { + if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'UngrabPort' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) @@ -2916,7 +2916,7 @@ func ungrabPortRequest(c *xgb.Conn, Port Port, Time xproto.Timestamp) []byte { b := 0 buf := make([]byte, size) - buf[b] = c.Extensions["XVIDEO"] + buf[b] = c.Extensions["XVideo"] b += 1 buf[b] = 4 // request opcode -- cgit v1.2.3 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/xv/xv.go | 67 ++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 30 deletions(-) (limited to 'nexgb/xv') 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 } -- cgit v1.2.3 From becaf43dcb3e9832c3eb951ff9908ed697868152 Mon Sep 17 00:00:00 2001 From: aarzilli Date: Tue, 1 Mar 2016 15:41:38 +0100 Subject: Read/Write mutex for Extensions map --- nexgb/xv/xv.go | 135 +++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 127 insertions(+), 8 deletions(-) (limited to 'nexgb/xv') diff --git a/nexgb/xv/xv.go b/nexgb/xv/xv.go index 1c406b0..f0d3f3a 100644 --- a/nexgb/xv/xv.go +++ b/nexgb/xv/xv.go @@ -20,16 +20,15 @@ func Init(c *xgb.Conn) error { return xgb.Errorf("No extension named XVideo could be found on on the server.") } - xgb.ExtLock.Lock() + c.ExtLock.Lock() c.Extensions["XVideo"] = reply.MajorOpcode + c.ExtLock.Unlock() for evNum, fun := range xgb.NewExtEventFuncs["XVideo"] { xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun } for errNum, fun := range xgb.NewExtErrorFuncs["XVideo"] { xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun } - xgb.ExtLock.Unlock() - return nil } @@ -46,7 +45,7 @@ type AdaptorInfo struct { Type byte // padding: 1 bytes Name string // size: xgb.Pad((int(NameSize) * 1)) - // alignment gap to multiple of 4 + // padding: 0 bytes Formats []Format // size: xgb.Pad((int(NumFormats) * 8)) } @@ -78,7 +77,7 @@ func AdaptorInfoRead(buf []byte, v *AdaptorInfo) int { b += int(v.NameSize) } - b = (b + 3) & ^3 // alignment gap + b += 0 // padding v.Formats = make([]Format, v.NumFormats) b += FormatReadList(buf[b:], v.Formats) @@ -98,7 +97,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))) + 4) + xgb.Pad((int(v.NumFormats) * 8)))) + buf := make([]byte, (((12 + xgb.Pad((int(v.NameSize) * 1))) + 0) + xgb.Pad((int(v.NumFormats) * 8)))) b := 0 xgb.Put32(buf[b:], uint32(v.BaseId)) @@ -121,7 +120,7 @@ func (v AdaptorInfo) Bytes() []byte { copy(buf[b:], v.Name[:v.NameSize]) b += int(v.NameSize) - b = (b + 3) & ^3 // alignment gap + b += 0 // padding b += FormatListBytes(buf[b:], v.Formats) @@ -144,7 +143,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))) + 4) + xgb.Pad((int(item.NumFormats) * 8))) + size += (((12 + xgb.Pad((int(item.NameSize) * 1))) + 0) + xgb.Pad((int(item.NumFormats) * 8))) } return size } @@ -1208,6 +1207,8 @@ type GetPortAttributeCookie struct { // GetPortAttribute sends a checked request. // If an error occurs, it will be returned with the reply by calling GetPortAttributeCookie.Reply() func GetPortAttribute(c *xgb.Conn, Port Port, Attribute xproto.Atom) GetPortAttributeCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'GetPortAttribute' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -1219,6 +1220,8 @@ func GetPortAttribute(c *xgb.Conn, Port Port, Attribute xproto.Atom) GetPortAttr // GetPortAttributeUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetPortAttributeUnchecked(c *xgb.Conn, Port Port, Attribute xproto.Atom) GetPortAttributeCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'GetPortAttribute' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -1273,7 +1276,9 @@ func getPortAttributeRequest(c *xgb.Conn, Port Port, Attribute xproto.Atom) []by b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XVideo"] + c.ExtLock.RUnlock() b += 1 buf[b] = 14 // request opcode @@ -1299,6 +1304,8 @@ type GetStillCookie struct { // GetStill sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetStill(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetStillCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'GetStill' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -1310,6 +1317,8 @@ func GetStill(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gconte // GetStillChecked sends a checked request. // If an error occurs, it can be retrieved using GetStillCookie.Check() func GetStillChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetStillCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'GetStill' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -1331,7 +1340,9 @@ func getStillRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XVideo"] + c.ExtLock.RUnlock() b += 1 buf[b] = 8 // request opcode @@ -1384,6 +1395,8 @@ type GetVideoCookie struct { // GetVideo sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetVideoCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'GetVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -1395,6 +1408,8 @@ func GetVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gconte // GetVideoChecked sends a checked request. // If an error occurs, it can be retrieved using GetVideoCookie.Check() func GetVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetVideoCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'GetVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -1416,7 +1431,9 @@ func getVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XVideo"] + c.ExtLock.RUnlock() b += 1 buf[b] = 7 // request opcode @@ -1469,6 +1486,8 @@ type GrabPortCookie struct { // GrabPort sends a checked request. // If an error occurs, it will be returned with the reply by calling GrabPortCookie.Reply() func GrabPort(c *xgb.Conn, Port Port, Time xproto.Timestamp) GrabPortCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'GrabPort' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -1480,6 +1499,8 @@ func GrabPort(c *xgb.Conn, Port Port, Time xproto.Timestamp) GrabPortCookie { // GrabPortUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GrabPortUnchecked(c *xgb.Conn, Port Port, Time xproto.Timestamp) GrabPortCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'GrabPort' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -1531,7 +1552,9 @@ func grabPortRequest(c *xgb.Conn, Port Port, Time xproto.Timestamp) []byte { b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XVideo"] + c.ExtLock.RUnlock() b += 1 buf[b] = 3 // request opcode @@ -1557,6 +1580,8 @@ type ListImageFormatsCookie struct { // ListImageFormats sends a checked request. // If an error occurs, it will be returned with the reply by calling ListImageFormatsCookie.Reply() func ListImageFormats(c *xgb.Conn, Port Port) ListImageFormatsCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'ListImageFormats' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -1568,6 +1593,8 @@ func ListImageFormats(c *xgb.Conn, Port Port) ListImageFormatsCookie { // ListImageFormatsUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ListImageFormatsUnchecked(c *xgb.Conn, Port Port) ListImageFormatsCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'ListImageFormats' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -1629,7 +1656,9 @@ func listImageFormatsRequest(c *xgb.Conn, Port Port) []byte { b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XVideo"] + c.ExtLock.RUnlock() b += 1 buf[b] = 16 // request opcode @@ -1652,6 +1681,8 @@ type PutImageCookie struct { // PutImage sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PutImage(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) PutImageCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'PutImage' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -1663,6 +1694,8 @@ func PutImage(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gconte // PutImageChecked sends a checked request. // If an error occurs, it can be retrieved using PutImageCookie.Check() func PutImageChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) PutImageCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'PutImage' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -1684,7 +1717,9 @@ func putImageRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XVideo"] + c.ExtLock.RUnlock() b += 1 buf[b] = 18 // request opcode @@ -1749,6 +1784,8 @@ type PutStillCookie struct { // PutStill sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PutStill(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutStillCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'PutStill' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -1760,6 +1797,8 @@ func PutStill(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gconte // PutStillChecked sends a checked request. // If an error occurs, it can be retrieved using PutStillCookie.Check() func PutStillChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutStillCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'PutStill' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -1781,7 +1820,9 @@ func putStillRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XVideo"] + c.ExtLock.RUnlock() b += 1 buf[b] = 6 // request opcode @@ -1834,6 +1875,8 @@ type PutVideoCookie struct { // PutVideo sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func PutVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutVideoCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'PutVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -1845,6 +1888,8 @@ func PutVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gconte // PutVideoChecked sends a checked request. // If an error occurs, it can be retrieved using PutVideoCookie.Check() func PutVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutVideoCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'PutVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -1866,7 +1911,9 @@ func putVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XVideo"] + c.ExtLock.RUnlock() b += 1 buf[b] = 5 // request opcode @@ -1919,6 +1966,8 @@ type QueryAdaptorsCookie struct { // QueryAdaptors sends a checked request. // If an error occurs, it will be returned with the reply by calling QueryAdaptorsCookie.Reply() func QueryAdaptors(c *xgb.Conn, Window xproto.Window) QueryAdaptorsCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'QueryAdaptors' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -1930,6 +1979,8 @@ func QueryAdaptors(c *xgb.Conn, Window xproto.Window) QueryAdaptorsCookie { // QueryAdaptorsUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryAdaptorsUnchecked(c *xgb.Conn, Window xproto.Window) QueryAdaptorsCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'QueryAdaptors' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -1991,7 +2042,9 @@ func queryAdaptorsRequest(c *xgb.Conn, Window xproto.Window) []byte { b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XVideo"] + c.ExtLock.RUnlock() b += 1 buf[b] = 1 // request opcode @@ -2014,6 +2067,8 @@ type QueryBestSizeCookie struct { // QueryBestSize sends a checked request. // If an error occurs, it will be returned with the reply by calling QueryBestSizeCookie.Reply() func QueryBestSize(c *xgb.Conn, Port Port, VidW uint16, VidH uint16, DrwW uint16, DrwH uint16, Motion bool) QueryBestSizeCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'QueryBestSize' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -2025,6 +2080,8 @@ func QueryBestSize(c *xgb.Conn, Port Port, VidW uint16, VidH uint16, DrwW uint16 // QueryBestSizeUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryBestSizeUnchecked(c *xgb.Conn, Port Port, VidW uint16, VidH uint16, DrwW uint16, DrwH uint16, Motion bool) QueryBestSizeCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'QueryBestSize' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -2083,7 +2140,9 @@ func queryBestSizeRequest(c *xgb.Conn, Port Port, VidW uint16, VidH uint16, DrwW b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XVideo"] + c.ExtLock.RUnlock() b += 1 buf[b] = 12 // request opcode @@ -2127,6 +2186,8 @@ type QueryEncodingsCookie struct { // QueryEncodings sends a checked request. // If an error occurs, it will be returned with the reply by calling QueryEncodingsCookie.Reply() func QueryEncodings(c *xgb.Conn, Port Port) QueryEncodingsCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'QueryEncodings' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -2138,6 +2199,8 @@ func QueryEncodings(c *xgb.Conn, Port Port) QueryEncodingsCookie { // QueryEncodingsUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryEncodingsUnchecked(c *xgb.Conn, Port Port) QueryEncodingsCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'QueryEncodings' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -2199,7 +2262,9 @@ func queryEncodingsRequest(c *xgb.Conn, Port Port) []byte { b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XVideo"] + c.ExtLock.RUnlock() b += 1 buf[b] = 2 // request opcode @@ -2222,6 +2287,8 @@ type QueryExtensionCookie struct { // QueryExtension sends a checked request. // If an error occurs, it will be returned with the reply by calling QueryExtensionCookie.Reply() func QueryExtension(c *xgb.Conn) QueryExtensionCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'QueryExtension' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -2233,6 +2300,8 @@ func QueryExtension(c *xgb.Conn) QueryExtensionCookie { // QueryExtensionUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryExtensionUnchecked(c *xgb.Conn) QueryExtensionCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'QueryExtension' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -2291,7 +2360,9 @@ func queryExtensionRequest(c *xgb.Conn) []byte { b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XVideo"] + c.ExtLock.RUnlock() b += 1 buf[b] = 0 // request opcode @@ -2311,6 +2382,8 @@ type QueryImageAttributesCookie struct { // QueryImageAttributes sends a checked request. // If an error occurs, it will be returned with the reply by calling QueryImageAttributesCookie.Reply() func QueryImageAttributes(c *xgb.Conn, Port Port, Id uint32, Width uint16, Height uint16) QueryImageAttributesCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'QueryImageAttributes' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -2322,6 +2395,8 @@ func QueryImageAttributes(c *xgb.Conn, Port Port, Id uint32, Width uint16, Heigh // QueryImageAttributesUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryImageAttributesUnchecked(c *xgb.Conn, Port Port, Id uint32, Width uint16, Height uint16) QueryImageAttributesCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'QueryImageAttributes' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -2408,7 +2483,9 @@ func queryImageAttributesRequest(c *xgb.Conn, Port Port, Id uint32, Width uint16 b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XVideo"] + c.ExtLock.RUnlock() b += 1 buf[b] = 17 // request opcode @@ -2440,6 +2517,8 @@ type QueryPortAttributesCookie struct { // QueryPortAttributes sends a checked request. // If an error occurs, it will be returned with the reply by calling QueryPortAttributesCookie.Reply() func QueryPortAttributes(c *xgb.Conn, Port Port) QueryPortAttributesCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'QueryPortAttributes' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -2451,6 +2530,8 @@ func QueryPortAttributes(c *xgb.Conn, Port Port) QueryPortAttributesCookie { // QueryPortAttributesUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryPortAttributesUnchecked(c *xgb.Conn, Port Port) QueryPortAttributesCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'QueryPortAttributes' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -2516,7 +2597,9 @@ func queryPortAttributesRequest(c *xgb.Conn, Port Port) []byte { b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XVideo"] + c.ExtLock.RUnlock() b += 1 buf[b] = 15 // request opcode @@ -2539,6 +2622,8 @@ type SelectPortNotifyCookie struct { // SelectPortNotify sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SelectPortNotify(c *xgb.Conn, Port Port, Onoff bool) SelectPortNotifyCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'SelectPortNotify' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -2550,6 +2635,8 @@ func SelectPortNotify(c *xgb.Conn, Port Port, Onoff bool) SelectPortNotifyCookie // SelectPortNotifyChecked sends a checked request. // If an error occurs, it can be retrieved using SelectPortNotifyCookie.Check() func SelectPortNotifyChecked(c *xgb.Conn, Port Port, Onoff bool) SelectPortNotifyCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'SelectPortNotify' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -2571,7 +2658,9 @@ func selectPortNotifyRequest(c *xgb.Conn, Port Port, Onoff bool) []byte { b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XVideo"] + c.ExtLock.RUnlock() b += 1 buf[b] = 11 // request opcode @@ -2603,6 +2692,8 @@ type SelectVideoNotifyCookie struct { // SelectVideoNotify sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SelectVideoNotify(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) SelectVideoNotifyCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'SelectVideoNotify' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -2614,6 +2705,8 @@ func SelectVideoNotify(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) Select // SelectVideoNotifyChecked sends a checked request. // If an error occurs, it can be retrieved using SelectVideoNotifyCookie.Check() func SelectVideoNotifyChecked(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) SelectVideoNotifyCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'SelectVideoNotify' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -2635,7 +2728,9 @@ func selectVideoNotifyRequest(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XVideo"] + c.ExtLock.RUnlock() b += 1 buf[b] = 10 // request opcode @@ -2667,6 +2762,8 @@ type SetPortAttributeCookie struct { // SetPortAttribute sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetPortAttribute(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32) SetPortAttributeCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'SetPortAttribute' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -2678,6 +2775,8 @@ func SetPortAttribute(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32 // SetPortAttributeChecked sends a checked request. // If an error occurs, it can be retrieved using SetPortAttributeCookie.Check() func SetPortAttributeChecked(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32) SetPortAttributeCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'SetPortAttribute' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -2699,7 +2798,9 @@ func setPortAttributeRequest(c *xgb.Conn, Port Port, Attribute xproto.Atom, Valu b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XVideo"] + c.ExtLock.RUnlock() b += 1 buf[b] = 13 // request opcode @@ -2728,6 +2829,8 @@ type ShmPutImageCookie struct { // ShmPutImage sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ShmPutImage(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Shmseg shm.Seg, Id uint32, Offset uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, SendEvent byte) ShmPutImageCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'ShmPutImage' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -2739,6 +2842,8 @@ func ShmPutImage(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gco // ShmPutImageChecked sends a checked request. // If an error occurs, it can be retrieved using ShmPutImageCookie.Check() func ShmPutImageChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Shmseg shm.Seg, Id uint32, Offset uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, SendEvent byte) ShmPutImageCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'ShmPutImage' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -2760,7 +2865,9 @@ func shmPutImageRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xpr b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XVideo"] + c.ExtLock.RUnlock() b += 1 buf[b] = 19 // request opcode @@ -2833,6 +2940,8 @@ type StopVideoCookie struct { // StopVideo sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func StopVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable) StopVideoCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'StopVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -2844,6 +2953,8 @@ func StopVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable) StopVideoCookie // StopVideoChecked sends a checked request. // If an error occurs, it can be retrieved using StopVideoCookie.Check() func StopVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable) StopVideoCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'StopVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -2865,7 +2976,9 @@ func stopVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable) []byte { b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XVideo"] + c.ExtLock.RUnlock() b += 1 buf[b] = 9 // request opcode @@ -2891,6 +3004,8 @@ type UngrabPortCookie struct { // UngrabPort sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func UngrabPort(c *xgb.Conn, Port Port, Time xproto.Timestamp) UngrabPortCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'UngrabPort' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -2902,6 +3017,8 @@ func UngrabPort(c *xgb.Conn, Port Port, Time xproto.Timestamp) UngrabPortCookie // UngrabPortChecked sends a checked request. // If an error occurs, it can be retrieved using UngrabPortCookie.Check() func UngrabPortChecked(c *xgb.Conn, Port Port, Time xproto.Timestamp) UngrabPortCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XVideo"]; !ok { panic("Cannot issue request 'UngrabPort' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.") } @@ -2923,7 +3040,9 @@ func ungrabPortRequest(c *xgb.Conn, Port Port, Time xproto.Timestamp) []byte { b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XVideo"] + c.ExtLock.RUnlock() b += 1 buf[b] = 4 // request opcode -- cgit v1.2.3 From 3906399e7c2a40fbaf355de572cf50a314083f64 Mon Sep 17 00:00:00 2001 From: aarzilli Date: Wed, 18 Jan 2017 10:52:16 +0100 Subject: Regenerated from xcb-proto 1.12 --- nexgb/xv/xv.go | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) (limited to 'nexgb/xv') diff --git a/nexgb/xv/xv.go b/nexgb/xv/xv.go index f0d3f3a..69a0549 100644 --- a/nexgb/xv/xv.go +++ b/nexgb/xv/xv.go @@ -45,7 +45,7 @@ type AdaptorInfo struct { Type byte // padding: 1 bytes Name string // size: xgb.Pad((int(NameSize) * 1)) - // padding: 0 bytes + // alignment gap to multiple of 4 Formats []Format // size: xgb.Pad((int(NumFormats) * 8)) } @@ -77,7 +77,7 @@ func AdaptorInfoRead(buf []byte, v *AdaptorInfo) int { b += int(v.NameSize) } - b += 0 // padding + b = (b + 3) & ^3 // alignment gap v.Formats = make([]Format, v.NumFormats) b += FormatReadList(buf[b:], v.Formats) @@ -97,7 +97,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))) + 0) + 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)) @@ -120,7 +120,7 @@ func (v AdaptorInfo) Bytes() []byte { copy(buf[b:], v.Name[:v.NameSize]) b += int(v.NameSize) - b += 0 // padding + b = (b + 3) & ^3 // alignment gap b += FormatListBytes(buf[b:], v.Formats) @@ -143,7 +143,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))) + 0) + xgb.Pad((int(item.NumFormats) * 8))) + size += (((12 + xgb.Pad((int(item.NameSize) * 1))) + 4) + xgb.Pad((int(item.NumFormats) * 8))) } return size } @@ -159,6 +159,7 @@ type AttributeInfo struct { Max int32 Size uint32 Name string // size: xgb.Pad((int(Size) * 1)) + // alignment gap to multiple of 4 } // AttributeInfoRead reads a byte slice into a AttributeInfo value. @@ -184,6 +185,8 @@ func AttributeInfoRead(buf []byte, v *AttributeInfo) int { b += int(v.Size) } + b = (b + 3) & ^3 // alignment gap + return b } @@ -199,7 +202,7 @@ func AttributeInfoReadList(buf []byte, dest []AttributeInfo) int { // Bytes writes a AttributeInfo value to a byte slice. func (v AttributeInfo) Bytes() []byte { - buf := make([]byte, (16 + xgb.Pad((int(v.Size) * 1)))) + buf := make([]byte, ((16 + xgb.Pad((int(v.Size) * 1))) + 4)) b := 0 xgb.Put32(buf[b:], v.Flags) @@ -217,6 +220,8 @@ func (v AttributeInfo) Bytes() []byte { copy(buf[b:], v.Name[:v.Size]) b += int(v.Size) + b = (b + 3) & ^3 // alignment gap + return buf[:b] } @@ -236,7 +241,7 @@ func AttributeInfoListBytes(buf []byte, list []AttributeInfo) int { func AttributeInfoListSize(list []AttributeInfo) int { size := 0 for _, item := range list { - size += (16 + xgb.Pad((int(item.Size) * 1))) + size += ((16 + xgb.Pad((int(item.Size) * 1))) + 4) } return size } @@ -397,6 +402,7 @@ type EncodingInfo struct { // padding: 2 bytes Rate Rational Name string // size: xgb.Pad((int(NameSize) * 1)) + // alignment gap to multiple of 4 } // EncodingInfoRead reads a byte slice into a EncodingInfo value. @@ -427,6 +433,8 @@ func EncodingInfoRead(buf []byte, v *EncodingInfo) int { b += int(v.NameSize) } + b = (b + 3) & ^3 // alignment gap + return b } @@ -442,7 +450,7 @@ func EncodingInfoReadList(buf []byte, dest []EncodingInfo) int { // Bytes writes a EncodingInfo value to a byte slice. func (v EncodingInfo) Bytes() []byte { - buf := make([]byte, (20 + xgb.Pad((int(v.NameSize) * 1)))) + buf := make([]byte, ((20 + xgb.Pad((int(v.NameSize) * 1))) + 4)) b := 0 xgb.Put32(buf[b:], uint32(v.Encoding)) @@ -468,6 +476,8 @@ func (v EncodingInfo) Bytes() []byte { copy(buf[b:], v.Name[:v.NameSize]) b += int(v.NameSize) + b = (b + 3) & ^3 // alignment gap + return buf[:b] } @@ -487,7 +497,7 @@ func EncodingInfoListBytes(buf []byte, list []EncodingInfo) int { func EncodingInfoListSize(list []EncodingInfo) int { size := 0 for _, item := range list { - size += (20 + xgb.Pad((int(item.NameSize) * 1))) + size += ((20 + xgb.Pad((int(item.NameSize) * 1))) + 4) } return size } @@ -567,9 +577,8 @@ type Image struct { DataSize uint32 NumPlanes uint32 Pitches []uint32 // size: xgb.Pad((int(NumPlanes) * 4)) - // alignment gap to multiple of 4 - Offsets []uint32 // size: xgb.Pad((int(NumPlanes) * 4)) - Data []byte // size: xgb.Pad((int(DataSize) * 1)) + 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. @@ -597,8 +606,6 @@ func ImageRead(buf []byte, v *Image) int { b += 4 } - 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:]) @@ -624,7 +631,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))) + 4) + xgb.Pad((int(v.NumPlanes) * 4))) + xgb.Pad((int(v.DataSize) * 1)))) + buf := make([]byte, (((16 + xgb.Pad((int(v.NumPlanes) * 4))) + xgb.Pad((int(v.NumPlanes) * 4))) + xgb.Pad((int(v.DataSize) * 1)))) b := 0 xgb.Put32(buf[b:], v.Id) @@ -647,8 +654,6 @@ func (v Image) Bytes() []byte { b += 4 } - b = (b + 3) & ^3 // alignment gap - for i := 0; i < int(v.NumPlanes); i++ { xgb.Put32(buf[b:], v.Offsets[i]) b += 4 @@ -676,7 +681,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))) + 4) + xgb.Pad((int(item.NumPlanes) * 4))) + xgb.Pad((int(item.DataSize) * 1))) + size += (((16 + xgb.Pad((int(item.NumPlanes) * 4))) + xgb.Pad((int(item.NumPlanes) * 4))) + xgb.Pad((int(item.DataSize) * 1))) } return size } @@ -2416,7 +2421,6 @@ 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)) } @@ -2465,8 +2469,6 @@ func queryImageAttributesReply(buf []byte) *QueryImageAttributesReply { b += 4 } - 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:]) -- cgit v1.2.3