2012-05-11 02:06:22 +02:00
|
|
|
// Package xv is the X client API for the XVideo extension.
|
2012-05-10 23:01:42 +02:00
|
|
|
package xv
|
|
|
|
|
2013-08-12 02:45:36 +02:00
|
|
|
// This file is automatically generated from xv.xml. Edit at your peril!
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
import (
|
2018-09-08 19:57:27 +02:00
|
|
|
xgb "janouch.name/haven/nexgb"
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2018-09-08 19:57:27 +02:00
|
|
|
"janouch.name/haven/nexgb/shm"
|
|
|
|
"janouch.name/haven/nexgb/xproto"
|
2012-05-10 23:01:42 +02:00
|
|
|
)
|
|
|
|
|
2018-09-21 08:37:21 +02:00
|
|
|
const (
|
|
|
|
MajorVersion = 2
|
|
|
|
MinorVersion = 2
|
|
|
|
)
|
|
|
|
|
2012-05-10 23:01:42 +02:00
|
|
|
// 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.")
|
|
|
|
}
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.Lock()
|
2012-05-10 23:01:42 +02:00
|
|
|
c.Extensions["XVideo"] = reply.MajorOpcode
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.Unlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
xgb.NewExtEventFuncs["XVideo"] = make(map[int]xgb.NewEventFun)
|
|
|
|
xgb.NewExtErrorFuncs["XVideo"] = make(map[int]xgb.NewErrorFun)
|
|
|
|
}
|
|
|
|
|
|
|
|
type AdaptorInfo struct {
|
|
|
|
BaseId Port
|
|
|
|
NameSize uint16
|
|
|
|
NumPorts uint16
|
|
|
|
NumFormats uint16
|
|
|
|
Type byte
|
|
|
|
// padding: 1 bytes
|
2014-05-02 15:09:23 +02:00
|
|
|
Name string // size: xgb.Pad((int(NameSize) * 1))
|
2017-01-18 10:52:16 +01:00
|
|
|
// alignment gap to multiple of 4
|
2012-05-10 23:01:42 +02:00
|
|
|
Formats []Format // size: xgb.Pad((int(NumFormats) * 8))
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// AdaptorInfoRead reads a byte slice into a AdaptorInfo value.
|
2012-05-10 23:01:42 +02:00
|
|
|
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)
|
2013-12-28 16:02:18 +01:00
|
|
|
b += int(v.NameSize)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2017-01-18 10:52:16 +01:00
|
|
|
b = (b + 3) & ^3 // alignment gap
|
2014-05-02 15:09:23 +02:00
|
|
|
|
2012-05-10 23:01:42 +02:00
|
|
|
v.Formats = make([]Format, v.NumFormats)
|
|
|
|
b += FormatReadList(buf[b:], v.Formats)
|
|
|
|
|
|
|
|
return b
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// AdaptorInfoReadList reads a byte slice into a list of AdaptorInfo values.
|
2012-05-10 23:01:42 +02:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Bytes writes a AdaptorInfo value to a byte slice.
|
2012-05-10 23:01:42 +02:00
|
|
|
func (v AdaptorInfo) Bytes() []byte {
|
2017-01-18 10:52:16 +01:00
|
|
|
buf := make([]byte, (((12 + xgb.Pad((int(v.NameSize) * 1))) + 4) + xgb.Pad((int(v.NumFormats) * 8))))
|
2012-05-10 23:01:42 +02:00
|
|
|
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])
|
2014-05-02 15:09:23 +02:00
|
|
|
b += int(v.NameSize)
|
|
|
|
|
2017-01-18 10:52:16 +01:00
|
|
|
b = (b + 3) & ^3 // alignment gap
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
b += FormatListBytes(buf[b:], v.Formats)
|
|
|
|
|
2014-05-02 15:09:23 +02:00
|
|
|
return buf[:b]
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2012-05-27 00:24:52 +02:00
|
|
|
// AdaptorInfoListBytes writes a list of AdaptorInfo values to a byte slice.
|
2012-05-10 23:01:42 +02:00
|
|
|
func AdaptorInfoListBytes(buf []byte, list []AdaptorInfo) int {
|
|
|
|
b := 0
|
|
|
|
var structBytes []byte
|
|
|
|
for _, item := range list {
|
|
|
|
structBytes = item.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-08-12 02:54:15 +02:00
|
|
|
b += len(structBytes)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
2013-08-12 02:54:15 +02:00
|
|
|
return xgb.Pad(b)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// AdaptorInfoListSize computes the size (bytes) of a list of AdaptorInfo values.
|
2012-05-10 23:01:42 +02:00
|
|
|
func AdaptorInfoListSize(list []AdaptorInfo) int {
|
|
|
|
size := 0
|
|
|
|
for _, item := range list {
|
2017-01-18 10:52:16 +01:00
|
|
|
size += (((12 + xgb.Pad((int(item.NameSize) * 1))) + 4) + xgb.Pad((int(item.NumFormats) * 8)))
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
return size
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
const (
|
|
|
|
AttributeFlagGettable = 1
|
|
|
|
AttributeFlagSettable = 2
|
|
|
|
)
|
|
|
|
|
|
|
|
type AttributeInfo struct {
|
|
|
|
Flags uint32
|
|
|
|
Min int32
|
|
|
|
Max int32
|
|
|
|
Size uint32
|
|
|
|
Name string // size: xgb.Pad((int(Size) * 1))
|
2017-01-18 10:52:16 +01:00
|
|
|
// alignment gap to multiple of 4
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// AttributeInfoRead reads a byte slice into a AttributeInfo value.
|
|
|
|
func AttributeInfoRead(buf []byte, v *AttributeInfo) int {
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Flags = xgb.Get32(buf[b:])
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Min = int32(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Max = int32(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Size = xgb.Get32(buf[b:])
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
{
|
2013-08-12 02:43:26 +02:00
|
|
|
byteString := make([]byte, v.Size)
|
|
|
|
copy(byteString[:v.Size], buf[b:])
|
2012-05-10 23:01:42 +02:00
|
|
|
v.Name = string(byteString)
|
2013-12-28 16:02:18 +01:00
|
|
|
b += int(v.Size)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2017-01-18 10:52:16 +01:00
|
|
|
b = (b + 3) & ^3 // alignment gap
|
|
|
|
|
2012-05-10 23:01:42 +02:00
|
|
|
return b
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// AttributeInfoReadList reads a byte slice into a list of AttributeInfo values.
|
|
|
|
func AttributeInfoReadList(buf []byte, dest []AttributeInfo) int {
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
for i := 0; i < len(dest); i++ {
|
2013-08-12 02:43:26 +02:00
|
|
|
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 {
|
2017-01-18 10:52:16 +01:00
|
|
|
buf := make([]byte, ((16 + xgb.Pad((int(v.Size) * 1))) + 4))
|
2013-08-12 02:43:26 +02:00
|
|
|
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])
|
2014-05-02 15:09:23 +02:00
|
|
|
b += int(v.Size)
|
2013-08-12 02:43:26 +02:00
|
|
|
|
2017-01-18 10:52:16 +01:00
|
|
|
b = (b + 3) & ^3 // alignment gap
|
|
|
|
|
2014-05-02 15:09:23 +02:00
|
|
|
return buf[:b]
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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)
|
2013-08-12 02:54:15 +02:00
|
|
|
b += len(structBytes)
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
2013-08-12 02:54:15 +02:00
|
|
|
return xgb.Pad(b)
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// AttributeInfoListSize computes the size (bytes) of a list of AttributeInfo values.
|
|
|
|
func AttributeInfoListSize(list []AttributeInfo) int {
|
|
|
|
size := 0
|
|
|
|
for _, item := range list {
|
2017-01-18 10:52:16 +01:00
|
|
|
size += ((16 + xgb.Pad((int(item.Size) * 1))) + 4)
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
|
|
|
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))
|
2017-01-18 10:52:16 +01:00
|
|
|
// alignment gap to multiple of 4
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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)
|
2013-12-28 16:02:18 +01:00
|
|
|
b += int(v.NameSize)
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
|
|
|
|
2017-01-18 10:52:16 +01:00
|
|
|
b = (b + 3) & ^3 // alignment gap
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
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])
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
return xgb.Pad(b)
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Bytes writes a EncodingInfo value to a byte slice.
|
2012-05-10 23:01:42 +02:00
|
|
|
func (v EncodingInfo) Bytes() []byte {
|
2017-01-18 10:52:16 +01:00
|
|
|
buf := make([]byte, ((20 + xgb.Pad((int(v.NameSize) * 1))) + 4))
|
2012-05-10 23:01:42 +02:00
|
|
|
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)
|
2013-12-28 15:33:09 +01:00
|
|
|
b += len(structBytes)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
copy(buf[b:], v.Name[:v.NameSize])
|
2014-05-02 15:09:23 +02:00
|
|
|
b += int(v.NameSize)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2017-01-18 10:52:16 +01:00
|
|
|
b = (b + 3) & ^3 // alignment gap
|
|
|
|
|
2014-05-02 15:09:23 +02:00
|
|
|
return buf[:b]
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2012-05-27 00:24:52 +02:00
|
|
|
// EncodingInfoListBytes writes a list of EncodingInfo values to a byte slice.
|
2012-05-10 23:01:42 +02:00
|
|
|
func EncodingInfoListBytes(buf []byte, list []EncodingInfo) int {
|
|
|
|
b := 0
|
|
|
|
var structBytes []byte
|
|
|
|
for _, item := range list {
|
|
|
|
structBytes = item.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-08-12 02:54:15 +02:00
|
|
|
b += len(structBytes)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
2013-08-12 02:54:15 +02:00
|
|
|
return xgb.Pad(b)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// EncodingInfoListSize computes the size (bytes) of a list of EncodingInfo values.
|
2012-05-10 23:01:42 +02:00
|
|
|
func EncodingInfoListSize(list []EncodingInfo) int {
|
|
|
|
size := 0
|
|
|
|
for _, item := range list {
|
2017-01-18 10:52:16 +01:00
|
|
|
size += ((20 + xgb.Pad((int(item.NameSize) * 1))) + 4)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
return size
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
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
|
|
|
|
|
2014-05-02 15:09:23 +02:00
|
|
|
return buf[:b]
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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)
|
2013-08-12 02:54:15 +02:00
|
|
|
b += len(structBytes)
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
2013-08-12 02:54:15 +02:00
|
|
|
return xgb.Pad(b)
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const (
|
|
|
|
GrabPortStatusSuccess = 0
|
|
|
|
GrabPortStatusBadExtension = 1
|
|
|
|
GrabPortStatusAlreadyGrabbed = 2
|
|
|
|
GrabPortStatusInvalidTime = 3
|
|
|
|
GrabPortStatusBadReply = 4
|
|
|
|
GrabPortStatusBadAlloc = 5
|
|
|
|
)
|
|
|
|
|
2012-05-10 23:01:42 +02:00
|
|
|
type Image struct {
|
|
|
|
Id uint32
|
|
|
|
Width uint16
|
|
|
|
Height uint16
|
|
|
|
DataSize uint32
|
|
|
|
NumPlanes uint32
|
|
|
|
Pitches []uint32 // size: xgb.Pad((int(NumPlanes) * 4))
|
2017-01-18 10:52:16 +01:00
|
|
|
Offsets []uint32 // size: xgb.Pad((int(NumPlanes) * 4))
|
|
|
|
Data []byte // size: xgb.Pad((int(DataSize) * 1))
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// ImageRead reads a byte slice into a Image value.
|
2012-05-10 23:01:42 +02:00
|
|
|
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
|
|
|
|
}
|
2014-05-02 15:09:23 +02:00
|
|
|
|
2012-05-10 23:01:42 +02:00
|
|
|
v.Offsets = make([]uint32, v.NumPlanes)
|
|
|
|
for i := 0; i < int(v.NumPlanes); i++ {
|
|
|
|
v.Offsets[i] = xgb.Get32(buf[b:])
|
|
|
|
b += 4
|
|
|
|
}
|
|
|
|
|
|
|
|
v.Data = make([]byte, v.DataSize)
|
|
|
|
copy(v.Data[:v.DataSize], buf[b:])
|
2014-05-02 15:09:23 +02:00
|
|
|
b += int(v.DataSize)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
return b
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// ImageReadList reads a byte slice into a list of Image values.
|
2012-05-10 23:01:42 +02:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Bytes writes a Image value to a byte slice.
|
2012-05-10 23:01:42 +02:00
|
|
|
func (v Image) Bytes() []byte {
|
2017-01-18 10:52:16 +01:00
|
|
|
buf := make([]byte, (((16 + xgb.Pad((int(v.NumPlanes) * 4))) + xgb.Pad((int(v.NumPlanes) * 4))) + xgb.Pad((int(v.DataSize) * 1))))
|
2012-05-10 23:01:42 +02:00
|
|
|
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
|
|
|
|
}
|
2014-05-02 15:09:23 +02:00
|
|
|
|
2012-05-10 23:01:42 +02:00
|
|
|
for i := 0; i < int(v.NumPlanes); i++ {
|
|
|
|
xgb.Put32(buf[b:], v.Offsets[i])
|
|
|
|
b += 4
|
|
|
|
}
|
|
|
|
|
|
|
|
copy(buf[b:], v.Data[:v.DataSize])
|
2014-05-02 15:09:23 +02:00
|
|
|
b += int(v.DataSize)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2014-05-02 15:09:23 +02:00
|
|
|
return buf[:b]
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2012-05-27 00:24:52 +02:00
|
|
|
// ImageListBytes writes a list of Image values to a byte slice.
|
2012-05-10 23:01:42 +02:00
|
|
|
func ImageListBytes(buf []byte, list []Image) int {
|
|
|
|
b := 0
|
|
|
|
var structBytes []byte
|
|
|
|
for _, item := range list {
|
|
|
|
structBytes = item.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-08-12 02:54:15 +02:00
|
|
|
b += len(structBytes)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
2013-08-12 02:54:15 +02:00
|
|
|
return xgb.Pad(b)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// ImageListSize computes the size (bytes) of a list of Image values.
|
2012-05-10 23:01:42 +02:00
|
|
|
func ImageListSize(list []Image) int {
|
|
|
|
size := 0
|
|
|
|
for _, item := range list {
|
2017-01-18 10:52:16 +01:00
|
|
|
size += (((16 + xgb.Pad((int(item.NumPlanes) * 4))) + xgb.Pad((int(item.NumPlanes) * 4))) + xgb.Pad((int(item.DataSize) * 1)))
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
return size
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// ImageFormatInfoRead reads a byte slice into a ImageFormatInfo value.
|
2012-05-10 23:01:42 +02:00
|
|
|
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:])
|
2014-05-02 15:09:23 +02:00
|
|
|
b += int(16)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
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:])
|
2014-05-02 15:09:23 +02:00
|
|
|
b += int(32)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
v.VscanlineOrder = buf[b]
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
b += 11 // padding
|
|
|
|
|
|
|
|
return b
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// ImageFormatInfoReadList reads a byte slice into a list of ImageFormatInfo values.
|
2012-05-10 23:01:42 +02:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Bytes writes a ImageFormatInfo value to a byte slice.
|
2012-05-10 23:01:42 +02:00
|
|
|
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])
|
2014-05-02 15:09:23 +02:00
|
|
|
b += int(16)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], v.VhorzVPeriod)
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], v.VvertYPeriod)
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], v.VvertUPeriod)
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], v.VvertVPeriod)
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
copy(buf[b:], v.VcompOrder[:32])
|
2014-05-02 15:09:23 +02:00
|
|
|
b += int(32)
|
2013-08-12 02:43:26 +02:00
|
|
|
|
|
|
|
buf[b] = v.VscanlineOrder
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
b += 11 // padding
|
|
|
|
|
2014-05-02 15:09:23 +02:00
|
|
|
return buf[:b]
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// 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)
|
2013-08-12 02:54:15 +02:00
|
|
|
b += len(structBytes)
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
2013-08-12 02:54:15 +02:00
|
|
|
return xgb.Pad(b)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// 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
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
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
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// PortNotify is the event number for a PortNotifyEvent.
|
2012-05-10 23:01:42 +02:00
|
|
|
const PortNotify = 1
|
|
|
|
|
|
|
|
type PortNotifyEvent struct {
|
|
|
|
Sequence uint16
|
|
|
|
// padding: 1 bytes
|
|
|
|
Time xproto.Timestamp
|
|
|
|
Port Port
|
|
|
|
Attribute xproto.Atom
|
|
|
|
Value int32
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// PortNotifyEventNew constructs a PortNotifyEvent value that implements xgb.Event from a byte slice.
|
2012-05-10 23:01:42 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Bytes writes a PortNotifyEvent value to a byte slice.
|
2012-05-10 23:01:42 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// SequenceId returns the sequence id attached to the PortNotify event.
|
|
|
|
// Events without a sequence number (KeymapNotify) return 0.
|
|
|
|
// This is mostly used internally.
|
2012-05-10 23:01:42 +02:00
|
|
|
func (v PortNotifyEvent) SequenceId() uint16 {
|
|
|
|
return v.Sequence
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// String is a rudimentary string representation of PortNotifyEvent.
|
2012-05-10 23:01:42 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
type Rational struct {
|
|
|
|
Numerator int32
|
|
|
|
Denominator int32
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// RationalRead reads a byte slice into a Rational value.
|
|
|
|
func RationalRead(buf []byte, v *Rational) int {
|
|
|
|
b := 0
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Numerator = int32(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Denominator = int32(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
return b
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// 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)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Bytes writes a Rational value to a byte slice.
|
|
|
|
func (v Rational) Bytes() []byte {
|
|
|
|
buf := make([]byte, 8)
|
|
|
|
b := 0
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(v.Numerator))
|
|
|
|
b += 4
|
2012-05-11 07:58:52 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(v.Denominator))
|
|
|
|
b += 4
|
|
|
|
|
2014-05-02 15:09:23 +02:00
|
|
|
return buf[:b]
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// 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)
|
2013-08-12 02:54:15 +02:00
|
|
|
b += len(structBytes)
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
2013-08-12 02:54:15 +02:00
|
|
|
return xgb.Pad(b)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
const (
|
|
|
|
ScanlineOrderTopToBottom = 0
|
|
|
|
ScanlineOrderBottomToTop = 1
|
|
|
|
)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
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 {
|
2012-05-10 23:01:42 +02:00
|
|
|
Sequence uint16
|
2013-08-12 02:43:26 +02:00
|
|
|
Reason byte
|
|
|
|
Time xproto.Timestamp
|
|
|
|
Drawable xproto.Drawable
|
|
|
|
Port Port
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// 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
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Reason = buf[b]
|
|
|
|
b += 1
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
v.Sequence = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
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
|
|
|
|
|
2012-05-10 23:01:42 +02:00
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Bytes writes a VideoNotifyEvent value to a byte slice.
|
|
|
|
func (v VideoNotifyEvent) Bytes() []byte {
|
|
|
|
buf := make([]byte, 32)
|
|
|
|
b := 0
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// 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
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// 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
|
|
|
|
}
|
2012-05-11 07:58:52 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// 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, ", ") + "}"
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.NewExtEventFuncs["XVideo"][0] = VideoNotifyEventNew
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
const (
|
|
|
|
VideoNotifyReasonStarted = 0
|
|
|
|
VideoNotifyReasonStopped = 1
|
|
|
|
VideoNotifyReasonBusy = 2
|
|
|
|
VideoNotifyReasonPreempted = 3
|
|
|
|
VideoNotifyReasonHardError = 4
|
|
|
|
)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Skipping definition for base type 'Bool'
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Skipping definition for base type 'Byte'
|
|
|
|
|
|
|
|
// Skipping definition for base type 'Card8'
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Skipping definition for base type 'Char'
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Skipping definition for base type 'Void'
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Skipping definition for base type 'Double'
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Skipping definition for base type 'Float'
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Skipping definition for base type 'Int16'
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Skipping definition for base type 'Int32'
|
2012-05-11 07:58:52 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Skipping definition for base type 'Int8'
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Skipping definition for base type 'Card16'
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Skipping definition for base type 'Card32'
|
|
|
|
|
|
|
|
// GetPortAttributeCookie is a cookie used only for GetPortAttribute requests.
|
|
|
|
type GetPortAttributeCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetPortAttribute sends a checked request.
|
2018-09-30 16:32:47 +02:00
|
|
|
// If an error occurs, it will be returned with the reply by calling GetPortAttributeCookie.Reply.
|
2013-08-12 02:43:26 +02:00
|
|
|
func GetPortAttribute(c *xgb.Conn, Port Port, Attribute xproto.Atom) GetPortAttributeCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'GetPortAttribute' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(true, true)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(getPortAttributeRequest(c, Port, Attribute), cookie)
|
|
|
|
return GetPortAttributeCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetPortAttributeUnchecked sends an unchecked request.
|
2012-05-11 05:57:34 +02:00
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
2013-08-12 02:43:26 +02:00
|
|
|
func GetPortAttributeUnchecked(c *xgb.Conn, Port Port, Attribute xproto.Atom) GetPortAttributeCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'GetPortAttribute' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(false, true)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(getPortAttributeRequest(c, Port, Attribute), cookie)
|
|
|
|
return GetPortAttributeCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetPortAttributeReply represents the data returned from a GetPortAttribute request.
|
|
|
|
type GetPortAttributeReply struct {
|
2012-05-11 05:57:34 +02:00
|
|
|
Sequence uint16 // sequence number of the request for this reply
|
|
|
|
Length uint32 // number of bytes in this reply
|
2012-05-10 23:01:42 +02:00
|
|
|
// padding: 1 bytes
|
2013-08-12 02:43:26 +02:00
|
|
|
Value int32
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Reply blocks and returns the reply data for a GetPortAttribute request.
|
|
|
|
func (cook GetPortAttributeCookie) Reply() (*GetPortAttributeReply, error) {
|
2012-05-10 23:01:42 +02:00
|
|
|
buf, err := cook.Cookie.Reply()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if buf == nil {
|
|
|
|
return nil, nil
|
|
|
|
}
|
2013-08-12 02:43:26 +02:00
|
|
|
return getPortAttributeReply(buf), nil
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// getPortAttributeReply reads a byte slice into a GetPortAttributeReply value.
|
|
|
|
func getPortAttributeReply(buf []byte) *GetPortAttributeReply {
|
|
|
|
v := new(GetPortAttributeReply)
|
2012-05-10 23:01:42 +02:00
|
|
|
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
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Value = int32(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
2018-09-30 16:32:47 +02:00
|
|
|
// getPortAttributeRequest writes a GetPortAttribute request to a byte slice for transfer.
|
2013-08-12 02:43:26 +02:00
|
|
|
func getPortAttributeRequest(c *xgb.Conn, Port Port, Attribute xproto.Atom) []byte {
|
|
|
|
size := 12
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2013-12-28 16:13:20 +01:00
|
|
|
buf[b] = c.Extensions["XVideo"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 14 // request opcode
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Port))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(Attribute))
|
|
|
|
b += 4
|
|
|
|
|
2012-05-10 23:01:42 +02:00
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetStillCookie is a cookie used only for GetStill requests.
|
|
|
|
type GetStillCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetStill sends an unchecked request.
|
2012-05-11 05:57:34 +02:00
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
2018-09-30 16:32:47 +02:00
|
|
|
func GetStill(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX, VidY int16, VidW, VidH uint16, DrwX, DrwY int16, DrwW, DrwH uint16) GetStillCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'GetStill' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2013-08-12 02:43:26 +02:00
|
|
|
cookie := c.NewCookie(false, false)
|
|
|
|
c.NewRequest(getStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie)
|
|
|
|
return GetStillCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetStillChecked sends a checked request.
|
2018-09-30 16:32:47 +02:00
|
|
|
// 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, VidY int16, VidW, VidH uint16, DrwX, DrwY int16, DrwW, DrwH uint16) GetStillCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'GetStill' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
2013-08-12 02:43:26 +02:00
|
|
|
cookie := c.NewCookie(true, false)
|
|
|
|
c.NewRequest(getStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie)
|
|
|
|
return GetStillCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// 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()
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2018-09-30 16:32:47 +02:00
|
|
|
// getStillRequest writes a GetStill request to a byte slice for transfer.
|
|
|
|
func getStillRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX, VidY int16, VidW, VidH uint16, DrwX, DrwY int16, DrwW, DrwH uint16) []byte {
|
2013-08-12 02:43:26 +02:00
|
|
|
size := 32
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2013-12-28 16:13:20 +01:00
|
|
|
buf[b] = c.Extensions["XVideo"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 8 // request opcode
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Port))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Drawable))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Gc))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], uint16(VidX))
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], uint16(VidY))
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], VidW)
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], VidH)
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], uint16(DrwX))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], uint16(DrwY))
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], DrwW)
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], DrwH)
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
return buf
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetVideoCookie is a cookie used only for GetVideo requests.
|
|
|
|
type GetVideoCookie struct {
|
|
|
|
*xgb.Cookie
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetVideo sends an unchecked request.
|
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
2018-09-30 16:32:47 +02:00
|
|
|
func GetVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX, VidY int16, VidW, VidH uint16, DrwX, DrwY int16, DrwW, DrwH uint16) GetVideoCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
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.
|
2018-09-30 16:32:47 +02:00
|
|
|
// 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, VidY int16, VidW, VidH uint16, DrwX, DrwY int16, DrwW, DrwH uint16) GetVideoCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
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()
|
|
|
|
}
|
|
|
|
|
2018-09-30 16:32:47 +02:00
|
|
|
// getVideoRequest writes a GetVideo request to a byte slice for transfer.
|
|
|
|
func getVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX, VidY int16, VidW, VidH uint16, DrwX, DrwY int16, DrwW, DrwH uint16) []byte {
|
2013-08-12 02:43:26 +02:00
|
|
|
size := 32
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2013-12-28 16:13:20 +01:00
|
|
|
buf[b] = c.Extensions["XVideo"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 7 // request opcode
|
2012-05-10 23:01:42 +02:00
|
|
|
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
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
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
|
|
|
|
|
2012-05-10 23:01:42 +02:00
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// GrabPortCookie is a cookie used only for GrabPort requests.
|
2012-05-10 23:01:42 +02:00
|
|
|
type GrabPortCookie struct {
|
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// GrabPort sends a checked request.
|
2018-09-30 16:32:47 +02:00
|
|
|
// If an error occurs, it will be returned with the reply by calling GrabPortCookie.Reply.
|
2012-05-10 23:01:42 +02:00
|
|
|
func GrabPort(c *xgb.Conn, Port Port, Time xproto.Timestamp) GrabPortCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2012-05-12 05:58:52 +02:00
|
|
|
panic("Cannot issue request 'GrabPort' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(true, true)
|
|
|
|
c.NewRequest(grabPortRequest(c, Port, Time), cookie)
|
|
|
|
return GrabPortCookie{cookie}
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// GrabPortUnchecked sends an unchecked request.
|
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
2012-05-10 23:01:42 +02:00
|
|
|
func GrabPortUnchecked(c *xgb.Conn, Port Port, Time xproto.Timestamp) GrabPortCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2012-05-12 05:58:52 +02:00
|
|
|
panic("Cannot issue request 'GrabPort' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(false, true)
|
|
|
|
c.NewRequest(grabPortRequest(c, Port, Time), cookie)
|
|
|
|
return GrabPortCookie{cookie}
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// GrabPortReply represents the data returned from a GrabPort request.
|
2012-05-10 23:01:42 +02:00
|
|
|
type GrabPortReply struct {
|
2012-05-11 05:57:34 +02:00
|
|
|
Sequence uint16 // sequence number of the request for this reply
|
|
|
|
Length uint32 // number of bytes in this reply
|
2012-05-10 23:01:42 +02:00
|
|
|
Result byte
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Reply blocks and returns the reply data for a GrabPort request.
|
2012-05-10 23:01:42 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// grabPortReply reads a byte slice into a GrabPortReply value.
|
2012-05-10 23:01:42 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2018-09-30 16:32:47 +02:00
|
|
|
// grabPortRequest writes a GrabPort request to a byte slice for transfer.
|
2012-05-10 23:01:42 +02:00
|
|
|
func grabPortRequest(c *xgb.Conn, Port Port, Time xproto.Timestamp) []byte {
|
|
|
|
size := 12
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2013-12-28 16:13:20 +01:00
|
|
|
buf[b] = c.Extensions["XVideo"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// ListImageFormatsCookie is a cookie used only for ListImageFormats requests.
|
|
|
|
type ListImageFormatsCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// ListImageFormats sends a checked request.
|
2018-09-30 16:32:47 +02:00
|
|
|
// If an error occurs, it will be returned with the reply by calling ListImageFormatsCookie.Reply.
|
2013-08-12 02:43:26 +02:00
|
|
|
func ListImageFormats(c *xgb.Conn, Port Port) ListImageFormatsCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'ListImageFormats' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2013-08-12 02:43:26 +02:00
|
|
|
cookie := c.NewCookie(true, true)
|
|
|
|
c.NewRequest(listImageFormatsRequest(c, Port), cookie)
|
|
|
|
return ListImageFormatsCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// 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 {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'ListImageFormats' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2013-08-12 02:43:26 +02:00
|
|
|
cookie := c.NewCookie(false, true)
|
|
|
|
c.NewRequest(listImageFormatsRequest(c, Port), cookie)
|
|
|
|
return ListImageFormatsCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// 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)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// 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
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// listImageFormatsReply reads a byte slice into a ListImageFormatsReply value.
|
|
|
|
func listImageFormatsReply(buf []byte) *ListImageFormatsReply {
|
|
|
|
v := new(ListImageFormatsReply)
|
|
|
|
b := 1 // skip reply determinant
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b += 1 // padding
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Sequence = xgb.Get16(buf[b:])
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Length = xgb.Get32(buf[b:]) // 4-byte units
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.NumFormats = xgb.Get32(buf[b:])
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b += 20 // padding
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Format = make([]ImageFormatInfo, v.NumFormats)
|
|
|
|
b += ImageFormatInfoReadList(buf[b:], v.Format)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
return v
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2018-09-30 16:32:47 +02:00
|
|
|
// listImageFormatsRequest writes a ListImageFormats request to a byte slice for transfer.
|
2013-08-12 02:43:26 +02:00
|
|
|
func listImageFormatsRequest(c *xgb.Conn, Port Port) []byte {
|
|
|
|
size := 8
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2013-12-28 16:13:20 +01:00
|
|
|
buf[b] = c.Extensions["XVideo"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 16 // request opcode
|
2012-05-10 23:01:42 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// PutImageCookie is a cookie used only for PutImage requests.
|
|
|
|
type PutImageCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// PutImage sends an unchecked request.
|
2012-05-11 05:57:34 +02:00
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
2018-09-30 16:32:47 +02:00
|
|
|
func PutImage(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Id uint32, SrcX, SrcY int16, SrcW, SrcH uint16, DrwX, DrwY int16, DrwW, DrwH, Width, Height uint16, Data []byte) PutImageCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'PutImage' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(false, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(putImageRequest(c, Port, Drawable, Gc, Id, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, Data), cookie)
|
|
|
|
return PutImageCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// PutImageChecked sends a checked request.
|
2018-09-30 16:32:47 +02:00
|
|
|
// 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, SrcY int16, SrcW, SrcH uint16, DrwX, DrwY int16, DrwW, DrwH, Width, Height uint16, Data []byte) PutImageCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'PutImage' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(true, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(putImageRequest(c, Port, Drawable, Gc, Id, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, Data), cookie)
|
|
|
|
return PutImageCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// 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.
|
2013-08-12 02:43:26 +02:00
|
|
|
func (cook PutImageCookie) Check() error {
|
2012-05-10 23:01:42 +02:00
|
|
|
return cook.Cookie.Check()
|
|
|
|
}
|
|
|
|
|
2018-09-30 16:32:47 +02:00
|
|
|
// putImageRequest writes a PutImage request to a byte slice for transfer.
|
|
|
|
func putImageRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Id uint32, SrcX, SrcY int16, SrcW, SrcH uint16, DrwX, DrwY int16, DrwW, DrwH, Width, Height uint16, Data []byte) []byte {
|
2013-08-12 02:43:26 +02:00
|
|
|
size := xgb.Pad((40 + xgb.Pad((len(Data) * 1))))
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2013-12-28 16:13:20 +01:00
|
|
|
buf[b] = c.Extensions["XVideo"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 18 // request opcode
|
2012-05-10 23:01:42 +02:00
|
|
|
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
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], Id)
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(SrcX))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], uint16(SrcY))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], SrcW)
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], SrcH)
|
2012-05-10 23:01:42 +02:00
|
|
|
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
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], Width)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], Height)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
copy(buf[b:], Data[:len(Data)])
|
2014-05-02 15:09:23 +02:00
|
|
|
b += int(len(Data))
|
2013-08-12 02:43:26 +02:00
|
|
|
|
2012-05-10 23:01:42 +02:00
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// PutStillCookie is a cookie used only for PutStill requests.
|
|
|
|
type PutStillCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// PutStill sends an unchecked request.
|
2012-05-11 05:57:34 +02:00
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
2018-09-30 16:32:47 +02:00
|
|
|
func PutStill(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX, VidY int16, VidW, VidH uint16, DrwX, DrwY int16, DrwW, DrwH uint16) PutStillCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'PutStill' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(false, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(putStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie)
|
|
|
|
return PutStillCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// PutStillChecked sends a checked request.
|
2018-09-30 16:32:47 +02:00
|
|
|
// 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, VidY int16, VidW, VidH uint16, DrwX, DrwY int16, DrwW, DrwH uint16) PutStillCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'PutStill' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(true, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(putStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie)
|
|
|
|
return PutStillCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// 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.
|
2013-08-12 02:43:26 +02:00
|
|
|
func (cook PutStillCookie) Check() error {
|
2012-05-10 23:01:42 +02:00
|
|
|
return cook.Cookie.Check()
|
|
|
|
}
|
|
|
|
|
2018-09-30 16:32:47 +02:00
|
|
|
// putStillRequest writes a PutStill request to a byte slice for transfer.
|
|
|
|
func putStillRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX, VidY int16, VidW, VidH uint16, DrwX, DrwY int16, DrwW, DrwH uint16) []byte {
|
2012-05-10 23:01:42 +02:00
|
|
|
size := 32
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2013-12-28 16:13:20 +01:00
|
|
|
buf[b] = c.Extensions["XVideo"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 6 // request opcode
|
2012-05-10 23:01:42 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// PutVideoCookie is a cookie used only for PutVideo requests.
|
|
|
|
type PutVideoCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// PutVideo sends an unchecked request.
|
2012-05-11 05:57:34 +02:00
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
2018-09-30 16:32:47 +02:00
|
|
|
func PutVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX, VidY int16, VidW, VidH uint16, DrwX, DrwY int16, DrwW, DrwH uint16) PutVideoCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'PutVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(false, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(putVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie)
|
|
|
|
return PutVideoCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// PutVideoChecked sends a checked request.
|
2018-09-30 16:32:47 +02:00
|
|
|
// 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, VidY int16, VidW, VidH uint16, DrwX, DrwY int16, DrwW, DrwH uint16) PutVideoCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'PutVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(true, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(putVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie)
|
|
|
|
return PutVideoCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// 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.
|
2013-08-12 02:43:26 +02:00
|
|
|
func (cook PutVideoCookie) Check() error {
|
2012-05-10 23:01:42 +02:00
|
|
|
return cook.Cookie.Check()
|
|
|
|
}
|
|
|
|
|
2018-09-30 16:32:47 +02:00
|
|
|
// putVideoRequest writes a PutVideo request to a byte slice for transfer.
|
|
|
|
func putVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX, VidY int16, VidW, VidH uint16, DrwX, DrwY int16, DrwW, DrwH uint16) []byte {
|
2012-05-10 23:01:42 +02:00
|
|
|
size := 32
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2013-12-28 16:13:20 +01:00
|
|
|
buf[b] = c.Extensions["XVideo"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 5 // request opcode
|
2012-05-10 23:01:42 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// QueryAdaptorsCookie is a cookie used only for QueryAdaptors requests.
|
|
|
|
type QueryAdaptorsCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// QueryAdaptors sends a checked request.
|
2018-09-30 16:32:47 +02:00
|
|
|
// If an error occurs, it will be returned with the reply by calling QueryAdaptorsCookie.Reply.
|
2013-08-12 02:43:26 +02:00
|
|
|
func QueryAdaptors(c *xgb.Conn, Window xproto.Window) QueryAdaptorsCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'QueryAdaptors' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2013-08-12 02:43:26 +02:00
|
|
|
cookie := c.NewCookie(true, true)
|
|
|
|
c.NewRequest(queryAdaptorsRequest(c, Window), cookie)
|
|
|
|
return QueryAdaptorsCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// 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 {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'QueryAdaptors' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2013-08-12 02:43:26 +02:00
|
|
|
cookie := c.NewCookie(false, true)
|
|
|
|
c.NewRequest(queryAdaptorsRequest(c, Window), cookie)
|
|
|
|
return QueryAdaptorsCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// 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)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// 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
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2013-08-12 02:43:26 +02:00
|
|
|
if buf == nil {
|
|
|
|
return nil, nil
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2013-08-12 02:43:26 +02:00
|
|
|
return queryAdaptorsReply(buf), nil
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// queryAdaptorsReply reads a byte slice into a QueryAdaptorsReply value.
|
|
|
|
func queryAdaptorsReply(buf []byte) *QueryAdaptorsReply {
|
|
|
|
v := new(QueryAdaptorsReply)
|
|
|
|
b := 1 // skip reply determinant
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b += 1 // padding
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Sequence = xgb.Get16(buf[b:])
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Length = xgb.Get32(buf[b:]) // 4-byte units
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.NumAdaptors = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b += 22 // padding
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Info = make([]AdaptorInfo, v.NumAdaptors)
|
|
|
|
b += AdaptorInfoReadList(buf[b:], v.Info)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
return v
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2018-09-30 16:32:47 +02:00
|
|
|
// queryAdaptorsRequest writes a QueryAdaptors request to a byte slice for transfer.
|
2013-08-12 02:43:26 +02:00
|
|
|
func queryAdaptorsRequest(c *xgb.Conn, Window xproto.Window) []byte {
|
|
|
|
size := 8
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2013-12-28 16:13:20 +01:00
|
|
|
buf[b] = c.Extensions["XVideo"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 1 // request opcode
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Window))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// QueryBestSizeCookie is a cookie used only for QueryBestSize requests.
|
2012-05-10 23:01:42 +02:00
|
|
|
type QueryBestSizeCookie struct {
|
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// QueryBestSize sends a checked request.
|
2018-09-30 16:32:47 +02:00
|
|
|
// If an error occurs, it will be returned with the reply by calling QueryBestSizeCookie.Reply.
|
|
|
|
func QueryBestSize(c *xgb.Conn, Port Port, VidW, VidH, DrwW, DrwH uint16, Motion bool) QueryBestSizeCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2012-05-12 05:58:52 +02:00
|
|
|
panic("Cannot issue request 'QueryBestSize' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(true, true)
|
|
|
|
c.NewRequest(queryBestSizeRequest(c, Port, VidW, VidH, DrwW, DrwH, Motion), cookie)
|
|
|
|
return QueryBestSizeCookie{cookie}
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// QueryBestSizeUnchecked sends an unchecked request.
|
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
2018-09-30 16:32:47 +02:00
|
|
|
func QueryBestSizeUnchecked(c *xgb.Conn, Port Port, VidW, VidH, DrwW, DrwH uint16, Motion bool) QueryBestSizeCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2012-05-12 05:58:52 +02:00
|
|
|
panic("Cannot issue request 'QueryBestSize' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(false, true)
|
|
|
|
c.NewRequest(queryBestSizeRequest(c, Port, VidW, VidH, DrwW, DrwH, Motion), cookie)
|
|
|
|
return QueryBestSizeCookie{cookie}
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// QueryBestSizeReply represents the data returned from a QueryBestSize request.
|
2012-05-10 23:01:42 +02:00
|
|
|
type QueryBestSizeReply struct {
|
2012-05-11 05:57:34 +02:00
|
|
|
Sequence uint16 // sequence number of the request for this reply
|
|
|
|
Length uint32 // number of bytes in this reply
|
2012-05-10 23:01:42 +02:00
|
|
|
// padding: 1 bytes
|
|
|
|
ActualWidth uint16
|
|
|
|
ActualHeight uint16
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Reply blocks and returns the reply data for a QueryBestSize request.
|
2012-05-10 23:01:42 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// queryBestSizeReply reads a byte slice into a QueryBestSizeReply value.
|
2012-05-10 23:01:42 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2018-09-30 16:32:47 +02:00
|
|
|
// queryBestSizeRequest writes a QueryBestSize request to a byte slice for transfer.
|
|
|
|
func queryBestSizeRequest(c *xgb.Conn, Port Port, VidW, VidH, DrwW, DrwH uint16, Motion bool) []byte {
|
2012-05-10 23:01:42 +02:00
|
|
|
size := 20
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2013-12-28 16:13:20 +01:00
|
|
|
buf[b] = c.Extensions["XVideo"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// QueryEncodingsCookie is a cookie used only for QueryEncodings requests.
|
|
|
|
type QueryEncodingsCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// QueryEncodings sends a checked request.
|
2018-09-30 16:32:47 +02:00
|
|
|
// If an error occurs, it will be returned with the reply by calling QueryEncodingsCookie.Reply.
|
2013-08-12 02:43:26 +02:00
|
|
|
func QueryEncodings(c *xgb.Conn, Port Port) QueryEncodingsCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'QueryEncodings' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(true, true)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(queryEncodingsRequest(c, Port), cookie)
|
|
|
|
return QueryEncodingsCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// QueryEncodingsUnchecked sends an unchecked request.
|
2012-05-11 05:57:34 +02:00
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
2013-08-12 02:43:26 +02:00
|
|
|
func QueryEncodingsUnchecked(c *xgb.Conn, Port Port) QueryEncodingsCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'QueryEncodings' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(false, true)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(queryEncodingsRequest(c, Port), cookie)
|
|
|
|
return QueryEncodingsCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// QueryEncodingsReply represents the data returned from a QueryEncodings request.
|
|
|
|
type QueryEncodingsReply struct {
|
2012-05-11 05:57:34 +02:00
|
|
|
Sequence uint16 // sequence number of the request for this reply
|
|
|
|
Length uint32 // number of bytes in this reply
|
2012-05-10 23:01:42 +02:00
|
|
|
// padding: 1 bytes
|
2013-08-12 02:43:26 +02:00
|
|
|
NumEncodings uint16
|
|
|
|
// padding: 22 bytes
|
|
|
|
Info []EncodingInfo // size: EncodingInfoListSize(Info)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Reply blocks and returns the reply data for a QueryEncodings request.
|
|
|
|
func (cook QueryEncodingsCookie) Reply() (*QueryEncodingsReply, error) {
|
2012-05-10 23:01:42 +02:00
|
|
|
buf, err := cook.Cookie.Reply()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if buf == nil {
|
|
|
|
return nil, nil
|
|
|
|
}
|
2013-08-12 02:43:26 +02:00
|
|
|
return queryEncodingsReply(buf), nil
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
2013-08-12 02:43:26 +02:00
|
|
|
|
|
|
|
// queryEncodingsReply reads a byte slice into a QueryEncodingsReply value.
|
|
|
|
func queryEncodingsReply(buf []byte) *QueryEncodingsReply {
|
|
|
|
v := new(QueryEncodingsReply)
|
2012-05-10 23:01:42 +02:00
|
|
|
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
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.NumEncodings = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b += 22 // padding
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Info = make([]EncodingInfo, v.NumEncodings)
|
|
|
|
b += EncodingInfoReadList(buf[b:], v.Info)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
2018-09-30 16:32:47 +02:00
|
|
|
// queryEncodingsRequest writes a QueryEncodings request to a byte slice for transfer.
|
2013-08-12 02:43:26 +02:00
|
|
|
func queryEncodingsRequest(c *xgb.Conn, Port Port) []byte {
|
2012-05-10 23:01:42 +02:00
|
|
|
size := 8
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2013-12-28 16:13:20 +01:00
|
|
|
buf[b] = c.Extensions["XVideo"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 2 // request opcode
|
2012-05-10 23:01:42 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// QueryExtensionCookie is a cookie used only for QueryExtension requests.
|
|
|
|
type QueryExtensionCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// QueryExtension sends a checked request.
|
2018-09-30 16:32:47 +02:00
|
|
|
// If an error occurs, it will be returned with the reply by calling QueryExtensionCookie.Reply.
|
2013-08-12 02:43:26 +02:00
|
|
|
func QueryExtension(c *xgb.Conn) QueryExtensionCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'QueryExtension' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(true, true)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(queryExtensionRequest(c), cookie)
|
|
|
|
return QueryExtensionCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// QueryExtensionUnchecked sends an unchecked request.
|
2012-05-11 05:57:34 +02:00
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
2013-08-12 02:43:26 +02:00
|
|
|
func QueryExtensionUnchecked(c *xgb.Conn) QueryExtensionCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'QueryExtension' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(false, true)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(queryExtensionRequest(c), cookie)
|
|
|
|
return QueryExtensionCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// QueryExtensionReply represents the data returned from a QueryExtension request.
|
|
|
|
type QueryExtensionReply struct {
|
2012-05-11 05:57:34 +02:00
|
|
|
Sequence uint16 // sequence number of the request for this reply
|
|
|
|
Length uint32 // number of bytes in this reply
|
2012-05-10 23:01:42 +02:00
|
|
|
// padding: 1 bytes
|
2013-08-12 02:43:26 +02:00
|
|
|
Major uint16
|
|
|
|
Minor uint16
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Reply blocks and returns the reply data for a QueryExtension request.
|
|
|
|
func (cook QueryExtensionCookie) Reply() (*QueryExtensionReply, error) {
|
2012-05-10 23:01:42 +02:00
|
|
|
buf, err := cook.Cookie.Reply()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if buf == nil {
|
|
|
|
return nil, nil
|
|
|
|
}
|
2013-08-12 02:43:26 +02:00
|
|
|
return queryExtensionReply(buf), nil
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// queryExtensionReply reads a byte slice into a QueryExtensionReply value.
|
|
|
|
func queryExtensionReply(buf []byte) *QueryExtensionReply {
|
|
|
|
v := new(QueryExtensionReply)
|
2012-05-10 23:01:42 +02:00
|
|
|
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
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Major = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Minor = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
2018-09-30 16:32:47 +02:00
|
|
|
// queryExtensionRequest writes a QueryExtension request to a byte slice for transfer.
|
2013-08-12 02:43:26 +02:00
|
|
|
func queryExtensionRequest(c *xgb.Conn) []byte {
|
|
|
|
size := 4
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2013-12-28 16:13:20 +01:00
|
|
|
buf[b] = c.Extensions["XVideo"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 0 // request opcode
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// QueryImageAttributesCookie is a cookie used only for QueryImageAttributes requests.
|
2012-05-10 23:01:42 +02:00
|
|
|
type QueryImageAttributesCookie struct {
|
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// QueryImageAttributes sends a checked request.
|
2018-09-30 16:32:47 +02:00
|
|
|
// 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, Height uint16) QueryImageAttributesCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2012-05-12 05:58:52 +02:00
|
|
|
panic("Cannot issue request 'QueryImageAttributes' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(true, true)
|
|
|
|
c.NewRequest(queryImageAttributesRequest(c, Port, Id, Width, Height), cookie)
|
|
|
|
return QueryImageAttributesCookie{cookie}
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// QueryImageAttributesUnchecked sends an unchecked request.
|
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
2018-09-30 16:32:47 +02:00
|
|
|
func QueryImageAttributesUnchecked(c *xgb.Conn, Port Port, Id uint32, Width, Height uint16) QueryImageAttributesCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2012-05-12 05:58:52 +02:00
|
|
|
panic("Cannot issue request 'QueryImageAttributes' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(false, true)
|
|
|
|
c.NewRequest(queryImageAttributesRequest(c, Port, Id, Width, Height), cookie)
|
|
|
|
return QueryImageAttributesCookie{cookie}
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// QueryImageAttributesReply represents the data returned from a QueryImageAttributes request.
|
2012-05-10 23:01:42 +02:00
|
|
|
type QueryImageAttributesReply struct {
|
2012-05-11 05:57:34 +02:00
|
|
|
Sequence uint16 // sequence number of the request for this reply
|
|
|
|
Length uint32 // number of bytes in this reply
|
2012-05-10 23:01:42 +02:00
|
|
|
// 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))
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Reply blocks and returns the reply data for a QueryImageAttributes request.
|
2012-05-10 23:01:42 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// queryImageAttributesReply reads a byte slice into a QueryImageAttributesReply value.
|
2012-05-10 23:01:42 +02:00
|
|
|
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
|
|
|
|
}
|
2014-05-02 15:09:23 +02:00
|
|
|
|
2012-05-10 23:01:42 +02:00
|
|
|
v.Offsets = make([]uint32, v.NumPlanes)
|
|
|
|
for i := 0; i < int(v.NumPlanes); i++ {
|
|
|
|
v.Offsets[i] = xgb.Get32(buf[b:])
|
|
|
|
b += 4
|
|
|
|
}
|
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
2018-09-30 16:32:47 +02:00
|
|
|
// queryImageAttributesRequest writes a QueryImageAttributes request to a byte slice for transfer.
|
|
|
|
func queryImageAttributesRequest(c *xgb.Conn, Port Port, Id uint32, Width, Height uint16) []byte {
|
2012-05-10 23:01:42 +02:00
|
|
|
size := 16
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2013-12-28 16:13:20 +01:00
|
|
|
buf[b] = c.Extensions["XVideo"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
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.
|
2018-09-30 16:32:47 +02:00
|
|
|
// If an error occurs, it will be returned with the reply by calling QueryPortAttributesCookie.Reply.
|
2013-08-12 02:43:26 +02:00
|
|
|
func QueryPortAttributes(c *xgb.Conn, Port Port) QueryPortAttributesCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
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 {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2018-09-30 16:32:47 +02:00
|
|
|
// queryPortAttributesRequest writes a QueryPortAttributes request to a byte slice for transfer.
|
2013-08-12 02:43:26 +02:00
|
|
|
func queryPortAttributesRequest(c *xgb.Conn, Port Port) []byte {
|
|
|
|
size := 8
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2013-12-28 16:13:20 +01:00
|
|
|
buf[b] = c.Extensions["XVideo"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2013-08-12 02:43:26 +02:00
|
|
|
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 {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
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.
|
2018-09-30 16:32:47 +02:00
|
|
|
// If an error occurs, it can be retrieved using SelectPortNotifyCookie.Check.
|
2013-08-12 02:43:26 +02:00
|
|
|
func SelectPortNotifyChecked(c *xgb.Conn, Port Port, Onoff bool) SelectPortNotifyCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
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()
|
|
|
|
}
|
|
|
|
|
2018-09-30 16:32:47 +02:00
|
|
|
// selectPortNotifyRequest writes a SelectPortNotify request to a byte slice for transfer.
|
2013-08-12 02:43:26 +02:00
|
|
|
func selectPortNotifyRequest(c *xgb.Conn, Port Port, Onoff bool) []byte {
|
|
|
|
size := 12
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2013-12-28 16:13:20 +01:00
|
|
|
buf[b] = c.Extensions["XVideo"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2013-08-12 02:43:26 +02:00
|
|
|
b += 1
|
|
|
|
|
|
|
|
buf[b] = 11 // request opcode
|
2012-05-10 23:01:42 +02:00
|
|
|
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
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
if Onoff {
|
|
|
|
buf[b] = 1
|
|
|
|
} else {
|
|
|
|
buf[b] = 0
|
|
|
|
}
|
|
|
|
b += 1
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b += 3 // padding
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SelectVideoNotifyCookie is a cookie used only for SelectVideoNotify requests.
|
|
|
|
type SelectVideoNotifyCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SelectVideoNotify sends an unchecked request.
|
2012-05-11 05:57:34 +02:00
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
2013-08-12 02:43:26 +02:00
|
|
|
func SelectVideoNotify(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) SelectVideoNotifyCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'SelectVideoNotify' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(false, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(selectVideoNotifyRequest(c, Drawable, Onoff), cookie)
|
|
|
|
return SelectVideoNotifyCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SelectVideoNotifyChecked sends a checked request.
|
2018-09-30 16:32:47 +02:00
|
|
|
// If an error occurs, it can be retrieved using SelectVideoNotifyCookie.Check.
|
2013-08-12 02:43:26 +02:00
|
|
|
func SelectVideoNotifyChecked(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) SelectVideoNotifyCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'SelectVideoNotify' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(true, false)
|
2013-08-12 02:43:26 +02:00
|
|
|
c.NewRequest(selectVideoNotifyRequest(c, Drawable, Onoff), cookie)
|
|
|
|
return SelectVideoNotifyCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// 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.
|
2013-08-12 02:43:26 +02:00
|
|
|
func (cook SelectVideoNotifyCookie) Check() error {
|
2012-05-10 23:01:42 +02:00
|
|
|
return cook.Cookie.Check()
|
|
|
|
}
|
|
|
|
|
2018-09-30 16:32:47 +02:00
|
|
|
// selectVideoNotifyRequest writes a SelectVideoNotify request to a byte slice for transfer.
|
2013-08-12 02:43:26 +02:00
|
|
|
func selectVideoNotifyRequest(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) []byte {
|
|
|
|
size := 12
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2013-12-28 16:13:20 +01:00
|
|
|
buf[b] = c.Extensions["XVideo"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 10 // request opcode
|
2012-05-10 23:01:42 +02:00
|
|
|
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
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
if Onoff {
|
|
|
|
buf[b] = 1
|
|
|
|
} else {
|
|
|
|
buf[b] = 0
|
|
|
|
}
|
|
|
|
b += 1
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b += 3 // padding
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
return buf
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SetPortAttributeCookie is a cookie used only for SetPortAttribute requests.
|
|
|
|
type SetPortAttributeCookie struct {
|
|
|
|
*xgb.Cookie
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// 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 {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
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}
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SetPortAttributeChecked sends a checked request.
|
2018-09-30 16:32:47 +02:00
|
|
|
// If an error occurs, it can be retrieved using SetPortAttributeCookie.Check.
|
2013-08-12 02:43:26 +02:00
|
|
|
func SetPortAttributeChecked(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32) SetPortAttributeCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
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}
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// 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()
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2018-09-30 16:32:47 +02:00
|
|
|
// setPortAttributeRequest writes a SetPortAttribute request to a byte slice for transfer.
|
2013-08-12 02:43:26 +02:00
|
|
|
func setPortAttributeRequest(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32) []byte {
|
|
|
|
size := 16
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2013-12-28 16:13:20 +01:00
|
|
|
buf[b] = c.Extensions["XVideo"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2013-08-12 02:43:26 +02:00
|
|
|
b += 1
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 13 // request opcode
|
|
|
|
b += 1
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Port))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Attribute))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(Value))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// ShmPutImageCookie is a cookie used only for ShmPutImage requests.
|
2012-05-10 23:01:42 +02:00
|
|
|
type ShmPutImageCookie struct {
|
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// ShmPutImage sends an unchecked request.
|
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
2018-09-30 16:32:47 +02:00
|
|
|
func ShmPutImage(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Shmseg shm.Seg, Id, Offset uint32, SrcX, SrcY int16, SrcW, SrcH uint16, DrwX, DrwY int16, DrwW, DrwH, Width, Height uint16, SendEvent byte) ShmPutImageCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2012-05-12 05:58:52 +02:00
|
|
|
panic("Cannot issue request 'ShmPutImage' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
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}
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// ShmPutImageChecked sends a checked request.
|
2018-09-30 16:32:47 +02:00
|
|
|
// 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, Offset uint32, SrcX, SrcY int16, SrcW, SrcH uint16, DrwX, DrwY int16, DrwW, DrwH, Width, Height uint16, SendEvent byte) ShmPutImageCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2012-05-12 05:58:52 +02:00
|
|
|
panic("Cannot issue request 'ShmPutImage' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
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}
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// 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.
|
2012-05-10 23:01:42 +02:00
|
|
|
func (cook ShmPutImageCookie) Check() error {
|
|
|
|
return cook.Cookie.Check()
|
|
|
|
}
|
|
|
|
|
2018-09-30 16:32:47 +02:00
|
|
|
// shmPutImageRequest writes a ShmPutImage request to a byte slice for transfer.
|
|
|
|
func shmPutImageRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Shmseg shm.Seg, Id, Offset uint32, SrcX, SrcY int16, SrcW, SrcH uint16, DrwX, DrwY int16, DrwW, DrwH, Width, Height uint16, SendEvent byte) []byte {
|
2012-05-10 23:01:42 +02:00
|
|
|
size := 52
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2013-12-28 16:13:20 +01:00
|
|
|
buf[b] = c.Extensions["XVideo"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2012-05-10 23:01:42 +02:00
|
|
|
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
|
|
|
|
}
|
2013-08-12 02:43:26 +02:00
|
|
|
|
|
|
|
// 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 {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
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.
|
2018-09-30 16:32:47 +02:00
|
|
|
// If an error occurs, it can be retrieved using StopVideoCookie.Check.
|
2013-08-12 02:43:26 +02:00
|
|
|
func StopVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable) StopVideoCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
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()
|
|
|
|
}
|
|
|
|
|
2018-09-30 16:32:47 +02:00
|
|
|
// stopVideoRequest writes a StopVideo request to a byte slice for transfer.
|
2013-08-12 02:43:26 +02:00
|
|
|
func stopVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable) []byte {
|
|
|
|
size := 12
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2013-12-28 16:13:20 +01:00
|
|
|
buf[b] = c.Extensions["XVideo"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2013-08-12 02:43:26 +02:00
|
|
|
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 {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
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.
|
2018-09-30 16:32:47 +02:00
|
|
|
// If an error occurs, it can be retrieved using UngrabPortCookie.Check.
|
2013-08-12 02:43:26 +02:00
|
|
|
func UngrabPortChecked(c *xgb.Conn, Port Port, Time xproto.Timestamp) UngrabPortCookie {
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
|
|
|
defer c.ExtLock.RUnlock()
|
2013-12-28 16:13:20 +01:00
|
|
|
if _, ok := c.Extensions["XVideo"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
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()
|
|
|
|
}
|
|
|
|
|
2018-09-30 16:32:47 +02:00
|
|
|
// ungrabPortRequest writes a UngrabPort request to a byte slice for transfer.
|
2013-08-12 02:43:26 +02:00
|
|
|
func ungrabPortRequest(c *xgb.Conn, Port Port, Time xproto.Timestamp) []byte {
|
|
|
|
size := 12
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RLock()
|
2013-12-28 16:13:20 +01:00
|
|
|
buf[b] = c.Extensions["XVideo"]
|
2016-03-01 15:41:38 +01:00
|
|
|
c.ExtLock.RUnlock()
|
2013-08-12 02:43:26 +02:00
|
|
|
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
|
|
|
|
}
|