2012-05-11 02:06:22 +02:00
|
|
|
// Package randr is the X client API for the RANDR extension.
|
2012-05-10 23:01:42 +02:00
|
|
|
package randr
|
|
|
|
|
2013-08-12 02:45:36 +02:00
|
|
|
// This file is automatically generated from randr.xml. Edit at your peril!
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/BurntSushi/xgb"
|
|
|
|
|
|
|
|
"github.com/BurntSushi/xgb/render"
|
|
|
|
"github.com/BurntSushi/xgb/xproto"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Init must be called before using the RANDR extension.
|
|
|
|
func Init(c *xgb.Conn) error {
|
|
|
|
reply, err := xproto.QueryExtension(c, 5, "RANDR").Reply()
|
|
|
|
switch {
|
|
|
|
case err != nil:
|
|
|
|
return err
|
|
|
|
case !reply.Present:
|
|
|
|
return xgb.Errorf("No extension named RANDR could be found on on the server.")
|
|
|
|
}
|
|
|
|
|
|
|
|
xgb.ExtLock.Lock()
|
|
|
|
c.Extensions["RANDR"] = reply.MajorOpcode
|
|
|
|
for evNum, fun := range xgb.NewExtEventFuncs["RANDR"] {
|
|
|
|
xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun
|
|
|
|
}
|
|
|
|
for errNum, fun := range xgb.NewExtErrorFuncs["RANDR"] {
|
|
|
|
xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun
|
|
|
|
}
|
|
|
|
xgb.ExtLock.Unlock()
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
xgb.NewExtEventFuncs["RANDR"] = make(map[int]xgb.NewEventFun)
|
|
|
|
xgb.NewExtErrorFuncs["RANDR"] = make(map[int]xgb.NewErrorFun)
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// BadBadCrtc is the error number for a BadBadCrtc.
|
|
|
|
const BadBadCrtc = 1
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
type BadCrtcError struct {
|
|
|
|
Sequence uint16
|
|
|
|
NiceName string
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// BadCrtcErrorNew constructs a BadCrtcError value that implements xgb.Error from a byte slice.
|
|
|
|
func BadCrtcErrorNew(buf []byte) xgb.Error {
|
|
|
|
v := BadCrtcError{}
|
|
|
|
v.NiceName = "BadCrtc"
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b := 1 // skip error determinant
|
|
|
|
b += 1 // don't read error number
|
2012-05-27 00:24:52 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Sequence = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
2012-06-05 06:14:34 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
return v
|
|
|
|
}
|
2012-06-05 06:14:34 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SequenceId returns the sequence id attached to the BadBadCrtc error.
|
|
|
|
// This is mostly used internally.
|
|
|
|
func (err BadCrtcError) SequenceId() uint16 {
|
|
|
|
return err.Sequence
|
|
|
|
}
|
2012-06-05 06:14:34 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// BadId returns the 'BadValue' number if one exists for the BadBadCrtc error. If no bad value exists, 0 is returned.
|
|
|
|
func (err BadCrtcError) BadId() uint32 {
|
|
|
|
return 0
|
|
|
|
}
|
2012-06-05 06:14:34 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Error returns a rudimentary string representation of the BadBadCrtc error.
|
2012-06-05 06:14:34 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
func (err BadCrtcError) Error() string {
|
|
|
|
fieldVals := make([]string, 0, 0)
|
|
|
|
fieldVals = append(fieldVals, "NiceName: "+err.NiceName)
|
|
|
|
fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence))
|
|
|
|
return "BadBadCrtc {" + xgb.StringsJoin(fieldVals, ", ") + "}"
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
func init() {
|
|
|
|
xgb.NewExtErrorFuncs["RANDR"][1] = BadCrtcErrorNew
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// BadBadMode is the error number for a BadBadMode.
|
|
|
|
const BadBadMode = 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
type BadModeError struct {
|
|
|
|
Sequence uint16
|
|
|
|
NiceName string
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// BadModeErrorNew constructs a BadModeError value that implements xgb.Error from a byte slice.
|
|
|
|
func BadModeErrorNew(buf []byte) xgb.Error {
|
|
|
|
v := BadModeError{}
|
|
|
|
v.NiceName = "BadMode"
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b := 1 // skip error determinant
|
|
|
|
b += 1 // don't read error number
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Sequence = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
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
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SequenceId returns the sequence id attached to the BadBadMode error.
|
|
|
|
// This is mostly used internally.
|
|
|
|
func (err BadModeError) SequenceId() uint16 {
|
|
|
|
return err.Sequence
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// BadId returns the 'BadValue' number if one exists for the BadBadMode error. If no bad value exists, 0 is returned.
|
|
|
|
func (err BadModeError) BadId() uint32 {
|
|
|
|
return 0
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Error returns a rudimentary string representation of the BadBadMode error.
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
func (err BadModeError) Error() string {
|
|
|
|
fieldVals := make([]string, 0, 0)
|
|
|
|
fieldVals = append(fieldVals, "NiceName: "+err.NiceName)
|
|
|
|
fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence))
|
|
|
|
return "BadBadMode {" + xgb.StringsJoin(fieldVals, ", ") + "}"
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
func init() {
|
|
|
|
xgb.NewExtErrorFuncs["RANDR"][2] = BadModeErrorNew
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// BadBadOutput is the error number for a BadBadOutput.
|
|
|
|
const BadBadOutput = 0
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
type BadOutputError struct {
|
|
|
|
Sequence uint16
|
|
|
|
NiceName string
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// BadOutputErrorNew constructs a BadOutputError value that implements xgb.Error from a byte slice.
|
|
|
|
func BadOutputErrorNew(buf []byte) xgb.Error {
|
|
|
|
v := BadOutputError{}
|
|
|
|
v.NiceName = "BadOutput"
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b := 1 // skip error determinant
|
|
|
|
b += 1 // don't read error number
|
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
|
|
|
return v
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SequenceId returns the sequence id attached to the BadBadOutput error.
|
|
|
|
// This is mostly used internally.
|
|
|
|
func (err BadOutputError) SequenceId() uint16 {
|
|
|
|
return err.Sequence
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// BadId returns the 'BadValue' number if one exists for the BadBadOutput error. If no bad value exists, 0 is returned.
|
|
|
|
func (err BadOutputError) BadId() uint32 {
|
|
|
|
return 0
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Error returns a rudimentary string representation of the BadBadOutput error.
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
func (err BadOutputError) Error() string {
|
|
|
|
fieldVals := make([]string, 0, 0)
|
|
|
|
fieldVals = append(fieldVals, "NiceName: "+err.NiceName)
|
|
|
|
fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence))
|
|
|
|
return "BadBadOutput {" + xgb.StringsJoin(fieldVals, ", ") + "}"
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
func init() {
|
|
|
|
xgb.NewExtErrorFuncs["RANDR"][0] = BadOutputErrorNew
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-12-28 15:25:18 +01:00
|
|
|
// BadBadProvider is the error number for a BadBadProvider.
|
|
|
|
const BadBadProvider = 3
|
|
|
|
|
|
|
|
type BadProviderError struct {
|
|
|
|
Sequence uint16
|
|
|
|
NiceName string
|
|
|
|
}
|
|
|
|
|
|
|
|
// BadProviderErrorNew constructs a BadProviderError value that implements xgb.Error from a byte slice.
|
|
|
|
func BadProviderErrorNew(buf []byte) xgb.Error {
|
|
|
|
v := BadProviderError{}
|
|
|
|
v.NiceName = "BadProvider"
|
|
|
|
|
|
|
|
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 BadBadProvider error.
|
|
|
|
// This is mostly used internally.
|
|
|
|
func (err BadProviderError) SequenceId() uint16 {
|
|
|
|
return err.Sequence
|
|
|
|
}
|
|
|
|
|
|
|
|
// BadId returns the 'BadValue' number if one exists for the BadBadProvider error. If no bad value exists, 0 is returned.
|
|
|
|
func (err BadProviderError) BadId() uint32 {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
// Error returns a rudimentary string representation of the BadBadProvider error.
|
|
|
|
|
|
|
|
func (err BadProviderError) Error() string {
|
|
|
|
fieldVals := make([]string, 0, 0)
|
|
|
|
fieldVals = append(fieldVals, "NiceName: "+err.NiceName)
|
|
|
|
fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence))
|
|
|
|
return "BadBadProvider {" + xgb.StringsJoin(fieldVals, ", ") + "}"
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
xgb.NewExtErrorFuncs["RANDR"][3] = BadProviderErrorNew
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
const (
|
|
|
|
ConnectionConnected = 0
|
|
|
|
ConnectionDisconnected = 1
|
|
|
|
ConnectionUnknown = 2
|
|
|
|
)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
type Crtc uint32
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
func NewCrtcId(c *xgb.Conn) (Crtc, error) {
|
|
|
|
id, err := c.NewId()
|
|
|
|
if err != nil {
|
|
|
|
return 0, err
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
2013-08-12 02:43:26 +02:00
|
|
|
return Crtc(id), nil
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
type CrtcChange struct {
|
|
|
|
Timestamp xproto.Timestamp
|
|
|
|
Window xproto.Window
|
|
|
|
Crtc Crtc
|
|
|
|
Mode Mode
|
|
|
|
Rotation uint16
|
|
|
|
// padding: 2 bytes
|
|
|
|
X int16
|
|
|
|
Y int16
|
|
|
|
Width uint16
|
|
|
|
Height uint16
|
|
|
|
}
|
|
|
|
|
|
|
|
// CrtcChangeRead reads a byte slice into a CrtcChange value.
|
|
|
|
func CrtcChangeRead(buf []byte, v *CrtcChange) int {
|
|
|
|
b := 0
|
|
|
|
|
|
|
|
v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Window = xproto.Window(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Crtc = Crtc(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Mode = Mode(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Rotation = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
b += 2 // padding
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.X = int16(xgb.Get16(buf[b:]))
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Y = int16(xgb.Get16(buf[b:]))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Width = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.Height = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
return b
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// CrtcChangeReadList reads a byte slice into a list of CrtcChange values.
|
|
|
|
func CrtcChangeReadList(buf []byte, dest []CrtcChange) 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] = CrtcChange{}
|
|
|
|
b += CrtcChangeRead(buf[b:], &dest[i])
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
return xgb.Pad(b)
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Bytes writes a CrtcChange value to a byte slice.
|
|
|
|
func (v CrtcChange) Bytes() []byte {
|
|
|
|
buf := make([]byte, 28)
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(v.Timestamp))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(v.Window))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(v.Crtc))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(v.Mode))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], v.Rotation)
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b += 2 // padding
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(v.X))
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(v.Y))
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], v.Width)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], v.Height)
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// CrtcChangeListBytes writes a list of CrtcChange values to a byte slice.
|
|
|
|
func CrtcChangeListBytes(buf []byte, list []CrtcChange) int {
|
2012-05-10 23:01:42 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
type Mode uint32
|
|
|
|
|
|
|
|
func NewModeId(c *xgb.Conn) (Mode, error) {
|
|
|
|
id, err := c.NewId()
|
|
|
|
if err != nil {
|
|
|
|
return 0, err
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
2013-08-12 02:43:26 +02:00
|
|
|
return Mode(id), nil
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
const (
|
|
|
|
ModeFlagHsyncPositive = 1
|
|
|
|
ModeFlagHsyncNegative = 2
|
|
|
|
ModeFlagVsyncPositive = 4
|
|
|
|
ModeFlagVsyncNegative = 8
|
|
|
|
ModeFlagInterlace = 16
|
|
|
|
ModeFlagDoubleScan = 32
|
|
|
|
ModeFlagCsync = 64
|
|
|
|
ModeFlagCsyncPositive = 128
|
|
|
|
ModeFlagCsyncNegative = 256
|
|
|
|
ModeFlagHskewPresent = 512
|
|
|
|
ModeFlagBcast = 1024
|
|
|
|
ModeFlagPixelMultiplex = 2048
|
|
|
|
ModeFlagDoubleClock = 4096
|
|
|
|
ModeFlagHalveClock = 8192
|
|
|
|
)
|
|
|
|
|
2012-05-10 23:01:42 +02:00
|
|
|
type ModeInfo struct {
|
|
|
|
Id uint32
|
|
|
|
Width uint16
|
|
|
|
Height uint16
|
|
|
|
DotClock uint32
|
|
|
|
HsyncStart uint16
|
|
|
|
HsyncEnd uint16
|
|
|
|
Htotal uint16
|
|
|
|
Hskew uint16
|
|
|
|
VsyncStart uint16
|
|
|
|
VsyncEnd uint16
|
|
|
|
Vtotal uint16
|
|
|
|
NameLen uint16
|
|
|
|
ModeFlags uint32
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// ModeInfoRead reads a byte slice into a ModeInfo value.
|
2012-05-10 23:01:42 +02:00
|
|
|
func ModeInfoRead(buf []byte, v *ModeInfo) 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.DotClock = xgb.Get32(buf[b:])
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.HsyncStart = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.HsyncEnd = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.Htotal = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.Hskew = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.VsyncStart = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.VsyncEnd = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.Vtotal = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.NameLen = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.ModeFlags = xgb.Get32(buf[b:])
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
return b
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// ModeInfoReadList reads a byte slice into a list of ModeInfo values.
|
2012-05-10 23:01:42 +02:00
|
|
|
func ModeInfoReadList(buf []byte, dest []ModeInfo) int {
|
|
|
|
b := 0
|
|
|
|
for i := 0; i < len(dest); i++ {
|
|
|
|
dest[i] = ModeInfo{}
|
|
|
|
b += ModeInfoRead(buf[b:], &dest[i])
|
|
|
|
}
|
|
|
|
return xgb.Pad(b)
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Bytes writes a ModeInfo value to a byte slice.
|
2012-05-10 23:01:42 +02:00
|
|
|
func (v ModeInfo) Bytes() []byte {
|
|
|
|
buf := make([]byte, 32)
|
|
|
|
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.DotClock)
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], v.HsyncStart)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], v.HsyncEnd)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], v.Htotal)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], v.Hskew)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], v.VsyncStart)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], v.VsyncEnd)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], v.Vtotal)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], v.NameLen)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], v.ModeFlags)
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2012-05-27 00:24:52 +02:00
|
|
|
// ModeInfoListBytes writes a list of ModeInfo values to a byte slice.
|
2012-05-10 23:01:42 +02:00
|
|
|
func ModeInfoListBytes(buf []byte, list []ModeInfo) 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
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Notify is the event number for a NotifyEvent.
|
|
|
|
const Notify = 1
|
|
|
|
|
|
|
|
type NotifyEvent struct {
|
|
|
|
Sequence uint16
|
|
|
|
SubCode byte
|
|
|
|
U NotifyDataUnion
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifyEventNew constructs a NotifyEvent value that implements xgb.Event from a byte slice.
|
|
|
|
func NotifyEventNew(buf []byte) xgb.Event {
|
|
|
|
v := NotifyEvent{}
|
|
|
|
b := 1 // don't read event number
|
|
|
|
|
|
|
|
v.SubCode = buf[b]
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
v.Sequence = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.U = NotifyDataUnion{}
|
|
|
|
b += NotifyDataUnionRead(buf[b:], &v.U)
|
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
// Bytes writes a NotifyEvent value to a byte slice.
|
|
|
|
func (v NotifyEvent) Bytes() []byte {
|
|
|
|
buf := make([]byte, 32)
|
|
|
|
b := 0
|
|
|
|
|
|
|
|
// write event number
|
|
|
|
buf[b] = 1
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
buf[b] = v.SubCode
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
b += 2 // skip sequence number
|
|
|
|
|
|
|
|
{
|
|
|
|
unionBytes := v.U.Bytes()
|
|
|
|
copy(buf[b:], unionBytes)
|
2013-12-28 15:33:09 +01:00
|
|
|
b += len(unionBytes)
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
|
|
|
// SequenceId returns the sequence id attached to the Notify event.
|
|
|
|
// Events without a sequence number (KeymapNotify) return 0.
|
|
|
|
// This is mostly used internally.
|
|
|
|
func (v NotifyEvent) SequenceId() uint16 {
|
|
|
|
return v.Sequence
|
|
|
|
}
|
|
|
|
|
|
|
|
// String is a rudimentary string representation of NotifyEvent.
|
|
|
|
func (v NotifyEvent) String() string {
|
|
|
|
fieldVals := make([]string, 0, 2)
|
|
|
|
fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence))
|
|
|
|
fieldVals = append(fieldVals, xgb.Sprintf("SubCode: %d", v.SubCode))
|
|
|
|
return "Notify {" + xgb.StringsJoin(fieldVals, ", ") + "}"
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
xgb.NewExtEventFuncs["RANDR"][1] = NotifyEventNew
|
|
|
|
}
|
|
|
|
|
2013-12-28 16:13:20 +01:00
|
|
|
const (
|
|
|
|
NotifyCrtcChange = 0
|
|
|
|
NotifyOutputChange = 1
|
|
|
|
NotifyOutputProperty = 2
|
|
|
|
NotifyProviderChange = 3
|
|
|
|
NotifyProviderProperty = 4
|
|
|
|
NotifyResourceChange = 5
|
|
|
|
)
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// NotifyDataUnion is a represention of the NotifyDataUnion union type.
|
|
|
|
// Note that to *create* a Union, you should *never* create
|
|
|
|
// this struct directly (unless you know what you're doing).
|
|
|
|
// Instead use one of the following constructors for 'NotifyDataUnion':
|
|
|
|
// NotifyDataUnionCcNew(Cc CrtcChange) NotifyDataUnion
|
|
|
|
// NotifyDataUnionOcNew(Oc OutputChange) NotifyDataUnion
|
|
|
|
// NotifyDataUnionOpNew(Op OutputProperty) NotifyDataUnion
|
2013-12-28 15:25:18 +01:00
|
|
|
// NotifyDataUnionPcNew(Pc ProviderChange) NotifyDataUnion
|
|
|
|
// NotifyDataUnionPpNew(Pp ProviderProperty) NotifyDataUnion
|
|
|
|
// NotifyDataUnionRcNew(Rc ResourceChange) NotifyDataUnion
|
2013-08-12 02:43:26 +02:00
|
|
|
type NotifyDataUnion struct {
|
|
|
|
Cc CrtcChange
|
|
|
|
Oc OutputChange
|
|
|
|
Op OutputProperty
|
2013-12-28 15:25:18 +01:00
|
|
|
Pc ProviderChange
|
|
|
|
Pp ProviderProperty
|
|
|
|
Rc ResourceChange
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// NotifyDataUnionCcNew constructs a new NotifyDataUnion union type with the Cc field.
|
|
|
|
func NotifyDataUnionCcNew(Cc CrtcChange) NotifyDataUnion {
|
|
|
|
var b int
|
|
|
|
buf := make([]byte, 28)
|
|
|
|
|
|
|
|
{
|
|
|
|
structBytes := Cc.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-12-28 15:33:09 +01:00
|
|
|
b += len(structBytes)
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create the Union type
|
|
|
|
v := NotifyDataUnion{}
|
|
|
|
|
|
|
|
// Now copy buf into all fields
|
|
|
|
|
|
|
|
b = 0 // always read the same bytes
|
|
|
|
v.Cc = CrtcChange{}
|
|
|
|
b += CrtcChangeRead(buf[b:], &v.Cc)
|
|
|
|
|
|
|
|
b = 0 // always read the same bytes
|
|
|
|
v.Oc = OutputChange{}
|
|
|
|
b += OutputChangeRead(buf[b:], &v.Oc)
|
|
|
|
|
|
|
|
b = 0 // always read the same bytes
|
|
|
|
v.Op = OutputProperty{}
|
|
|
|
b += OutputPropertyRead(buf[b:], &v.Op)
|
|
|
|
|
2013-12-28 15:25:18 +01:00
|
|
|
b = 0 // always read the same bytes
|
|
|
|
v.Pc = ProviderChange{}
|
|
|
|
b += ProviderChangeRead(buf[b:], &v.Pc)
|
|
|
|
|
|
|
|
b = 0 // always read the same bytes
|
|
|
|
v.Pp = ProviderProperty{}
|
|
|
|
b += ProviderPropertyRead(buf[b:], &v.Pp)
|
|
|
|
|
|
|
|
b = 0 // always read the same bytes
|
|
|
|
v.Rc = ResourceChange{}
|
|
|
|
b += ResourceChangeRead(buf[b:], &v.Rc)
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifyDataUnionOcNew constructs a new NotifyDataUnion union type with the Oc field.
|
|
|
|
func NotifyDataUnionOcNew(Oc OutputChange) NotifyDataUnion {
|
|
|
|
var b int
|
|
|
|
buf := make([]byte, 28)
|
|
|
|
|
|
|
|
{
|
|
|
|
structBytes := Oc.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-12-28 15:33:09 +01:00
|
|
|
b += len(structBytes)
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create the Union type
|
|
|
|
v := NotifyDataUnion{}
|
|
|
|
|
|
|
|
// Now copy buf into all fields
|
|
|
|
|
|
|
|
b = 0 // always read the same bytes
|
|
|
|
v.Cc = CrtcChange{}
|
|
|
|
b += CrtcChangeRead(buf[b:], &v.Cc)
|
|
|
|
|
|
|
|
b = 0 // always read the same bytes
|
|
|
|
v.Oc = OutputChange{}
|
|
|
|
b += OutputChangeRead(buf[b:], &v.Oc)
|
|
|
|
|
|
|
|
b = 0 // always read the same bytes
|
|
|
|
v.Op = OutputProperty{}
|
|
|
|
b += OutputPropertyRead(buf[b:], &v.Op)
|
|
|
|
|
2013-12-28 15:25:18 +01:00
|
|
|
b = 0 // always read the same bytes
|
|
|
|
v.Pc = ProviderChange{}
|
|
|
|
b += ProviderChangeRead(buf[b:], &v.Pc)
|
|
|
|
|
|
|
|
b = 0 // always read the same bytes
|
|
|
|
v.Pp = ProviderProperty{}
|
|
|
|
b += ProviderPropertyRead(buf[b:], &v.Pp)
|
|
|
|
|
|
|
|
b = 0 // always read the same bytes
|
|
|
|
v.Rc = ResourceChange{}
|
|
|
|
b += ResourceChangeRead(buf[b:], &v.Rc)
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
return v
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// NotifyDataUnionOpNew constructs a new NotifyDataUnion union type with the Op field.
|
|
|
|
func NotifyDataUnionOpNew(Op OutputProperty) NotifyDataUnion {
|
|
|
|
var b int
|
|
|
|
buf := make([]byte, 28)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
{
|
|
|
|
structBytes := Op.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-12-28 15:33:09 +01:00
|
|
|
b += len(structBytes)
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Create the Union type
|
|
|
|
v := NotifyDataUnion{}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Now copy buf into all fields
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b = 0 // always read the same bytes
|
|
|
|
v.Cc = CrtcChange{}
|
|
|
|
b += CrtcChangeRead(buf[b:], &v.Cc)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b = 0 // always read the same bytes
|
|
|
|
v.Oc = OutputChange{}
|
|
|
|
b += OutputChangeRead(buf[b:], &v.Oc)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b = 0 // always read the same bytes
|
|
|
|
v.Op = OutputProperty{}
|
|
|
|
b += OutputPropertyRead(buf[b:], &v.Op)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-12-28 15:25:18 +01:00
|
|
|
b = 0 // always read the same bytes
|
|
|
|
v.Pc = ProviderChange{}
|
|
|
|
b += ProviderChangeRead(buf[b:], &v.Pc)
|
|
|
|
|
|
|
|
b = 0 // always read the same bytes
|
|
|
|
v.Pp = ProviderProperty{}
|
|
|
|
b += ProviderPropertyRead(buf[b:], &v.Pp)
|
|
|
|
|
|
|
|
b = 0 // always read the same bytes
|
|
|
|
v.Rc = ResourceChange{}
|
|
|
|
b += ResourceChangeRead(buf[b:], &v.Rc)
|
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifyDataUnionPcNew constructs a new NotifyDataUnion union type with the Pc field.
|
|
|
|
func NotifyDataUnionPcNew(Pc ProviderChange) NotifyDataUnion {
|
|
|
|
var b int
|
|
|
|
buf := make([]byte, 28)
|
|
|
|
|
|
|
|
{
|
|
|
|
structBytes := Pc.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-12-28 15:33:09 +01:00
|
|
|
b += len(structBytes)
|
2013-12-28 15:25:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create the Union type
|
|
|
|
v := NotifyDataUnion{}
|
|
|
|
|
|
|
|
// Now copy buf into all fields
|
|
|
|
|
|
|
|
b = 0 // always read the same bytes
|
|
|
|
v.Cc = CrtcChange{}
|
|
|
|
b += CrtcChangeRead(buf[b:], &v.Cc)
|
|
|
|
|
|
|
|
b = 0 // always read the same bytes
|
|
|
|
v.Oc = OutputChange{}
|
|
|
|
b += OutputChangeRead(buf[b:], &v.Oc)
|
|
|
|
|
|
|
|
b = 0 // always read the same bytes
|
|
|
|
v.Op = OutputProperty{}
|
|
|
|
b += OutputPropertyRead(buf[b:], &v.Op)
|
|
|
|
|
|
|
|
b = 0 // always read the same bytes
|
|
|
|
v.Pc = ProviderChange{}
|
|
|
|
b += ProviderChangeRead(buf[b:], &v.Pc)
|
|
|
|
|
|
|
|
b = 0 // always read the same bytes
|
|
|
|
v.Pp = ProviderProperty{}
|
|
|
|
b += ProviderPropertyRead(buf[b:], &v.Pp)
|
|
|
|
|
|
|
|
b = 0 // always read the same bytes
|
|
|
|
v.Rc = ResourceChange{}
|
|
|
|
b += ResourceChangeRead(buf[b:], &v.Rc)
|
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifyDataUnionPpNew constructs a new NotifyDataUnion union type with the Pp field.
|
|
|
|
func NotifyDataUnionPpNew(Pp ProviderProperty) NotifyDataUnion {
|
|
|
|
var b int
|
|
|
|
buf := make([]byte, 28)
|
|
|
|
|
|
|
|
{
|
|
|
|
structBytes := Pp.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-12-28 15:33:09 +01:00
|
|
|
b += len(structBytes)
|
2013-12-28 15:25:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create the Union type
|
|
|
|
v := NotifyDataUnion{}
|
|
|
|
|
|
|
|
// Now copy buf into all fields
|
|
|
|
|
|
|
|
b = 0 // always read the same bytes
|
|
|
|
v.Cc = CrtcChange{}
|
|
|
|
b += CrtcChangeRead(buf[b:], &v.Cc)
|
|
|
|
|
|
|
|
b = 0 // always read the same bytes
|
|
|
|
v.Oc = OutputChange{}
|
|
|
|
b += OutputChangeRead(buf[b:], &v.Oc)
|
|
|
|
|
|
|
|
b = 0 // always read the same bytes
|
|
|
|
v.Op = OutputProperty{}
|
|
|
|
b += OutputPropertyRead(buf[b:], &v.Op)
|
|
|
|
|
|
|
|
b = 0 // always read the same bytes
|
|
|
|
v.Pc = ProviderChange{}
|
|
|
|
b += ProviderChangeRead(buf[b:], &v.Pc)
|
|
|
|
|
|
|
|
b = 0 // always read the same bytes
|
|
|
|
v.Pp = ProviderProperty{}
|
|
|
|
b += ProviderPropertyRead(buf[b:], &v.Pp)
|
|
|
|
|
|
|
|
b = 0 // always read the same bytes
|
|
|
|
v.Rc = ResourceChange{}
|
|
|
|
b += ResourceChangeRead(buf[b:], &v.Rc)
|
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifyDataUnionRcNew constructs a new NotifyDataUnion union type with the Rc field.
|
|
|
|
func NotifyDataUnionRcNew(Rc ResourceChange) NotifyDataUnion {
|
|
|
|
var b int
|
|
|
|
buf := make([]byte, 28)
|
|
|
|
|
|
|
|
{
|
|
|
|
structBytes := Rc.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-12-28 15:33:09 +01:00
|
|
|
b += len(structBytes)
|
2013-12-28 15:25:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create the Union type
|
|
|
|
v := NotifyDataUnion{}
|
|
|
|
|
|
|
|
// Now copy buf into all fields
|
|
|
|
|
|
|
|
b = 0 // always read the same bytes
|
|
|
|
v.Cc = CrtcChange{}
|
|
|
|
b += CrtcChangeRead(buf[b:], &v.Cc)
|
|
|
|
|
|
|
|
b = 0 // always read the same bytes
|
|
|
|
v.Oc = OutputChange{}
|
|
|
|
b += OutputChangeRead(buf[b:], &v.Oc)
|
|
|
|
|
|
|
|
b = 0 // always read the same bytes
|
|
|
|
v.Op = OutputProperty{}
|
|
|
|
b += OutputPropertyRead(buf[b:], &v.Op)
|
|
|
|
|
|
|
|
b = 0 // always read the same bytes
|
|
|
|
v.Pc = ProviderChange{}
|
|
|
|
b += ProviderChangeRead(buf[b:], &v.Pc)
|
|
|
|
|
|
|
|
b = 0 // always read the same bytes
|
|
|
|
v.Pp = ProviderProperty{}
|
|
|
|
b += ProviderPropertyRead(buf[b:], &v.Pp)
|
|
|
|
|
|
|
|
b = 0 // always read the same bytes
|
|
|
|
v.Rc = ResourceChange{}
|
|
|
|
b += ResourceChangeRead(buf[b:], &v.Rc)
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
return v
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// NotifyDataUnionRead reads a byte slice into a NotifyDataUnion value.
|
|
|
|
func NotifyDataUnionRead(buf []byte, v *NotifyDataUnion) int {
|
|
|
|
var b int
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b = 0 // re-read the same bytes
|
|
|
|
v.Cc = CrtcChange{}
|
|
|
|
b += CrtcChangeRead(buf[b:], &v.Cc)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b = 0 // re-read the same bytes
|
|
|
|
v.Oc = OutputChange{}
|
|
|
|
b += OutputChangeRead(buf[b:], &v.Oc)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b = 0 // re-read the same bytes
|
|
|
|
v.Op = OutputProperty{}
|
|
|
|
b += OutputPropertyRead(buf[b:], &v.Op)
|
|
|
|
|
2013-12-28 15:25:18 +01:00
|
|
|
b = 0 // re-read the same bytes
|
|
|
|
v.Pc = ProviderChange{}
|
|
|
|
b += ProviderChangeRead(buf[b:], &v.Pc)
|
|
|
|
|
|
|
|
b = 0 // re-read the same bytes
|
|
|
|
v.Pp = ProviderProperty{}
|
|
|
|
b += ProviderPropertyRead(buf[b:], &v.Pp)
|
|
|
|
|
|
|
|
b = 0 // re-read the same bytes
|
|
|
|
v.Rc = ResourceChange{}
|
|
|
|
b += ResourceChangeRead(buf[b:], &v.Rc)
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
return 28
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// NotifyDataUnionReadList reads a byte slice into a list of NotifyDataUnion values.
|
|
|
|
func NotifyDataUnionReadList(buf []byte, dest []NotifyDataUnion) 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] = NotifyDataUnion{}
|
|
|
|
b += NotifyDataUnionRead(buf[b:], &dest[i])
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
return xgb.Pad(b)
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Bytes writes a NotifyDataUnion value to a byte slice.
|
|
|
|
// Each field in a union must contain the same data.
|
|
|
|
// So simply pick the first field and write that to the wire.
|
|
|
|
func (v NotifyDataUnion) Bytes() []byte {
|
2012-05-10 23:01:42 +02:00
|
|
|
buf := make([]byte, 28)
|
|
|
|
b := 0
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
{
|
|
|
|
structBytes := v.Cc.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-12-28 15:33:09 +01:00
|
|
|
b += len(structBytes)
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-12-28 15:25:18 +01:00
|
|
|
// NotifyDataUnionListBytes writes a list of NotifyDataUnion values to a byte slice.
|
2013-08-12 02:43:26 +02:00
|
|
|
func NotifyDataUnionListBytes(buf []byte, list []NotifyDataUnion) int {
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
2013-08-12 02:43:26 +02:00
|
|
|
var unionBytes []byte
|
2012-05-10 23:01:42 +02:00
|
|
|
for _, item := range list {
|
2013-08-12 02:43:26 +02:00
|
|
|
unionBytes = item.Bytes()
|
|
|
|
copy(buf[b:], unionBytes)
|
|
|
|
b += xgb.Pad(len(unionBytes))
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
return b
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
const (
|
2013-12-28 15:25:18 +01:00
|
|
|
NotifyMaskScreenChange = 1
|
|
|
|
NotifyMaskCrtcChange = 2
|
|
|
|
NotifyMaskOutputChange = 4
|
|
|
|
NotifyMaskOutputProperty = 8
|
|
|
|
NotifyMaskProviderChange = 16
|
|
|
|
NotifyMaskProviderProperty = 32
|
|
|
|
NotifyMaskResourceChange = 64
|
2013-08-12 02:43:26 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type Output uint32
|
|
|
|
|
|
|
|
func NewOutputId(c *xgb.Conn) (Output, error) {
|
|
|
|
id, err := c.NewId()
|
|
|
|
if err != nil {
|
|
|
|
return 0, err
|
|
|
|
}
|
|
|
|
return Output(id), nil
|
|
|
|
}
|
|
|
|
|
2012-05-10 23:01:42 +02:00
|
|
|
type OutputChange struct {
|
|
|
|
Timestamp xproto.Timestamp
|
|
|
|
ConfigTimestamp xproto.Timestamp
|
|
|
|
Window xproto.Window
|
|
|
|
Output Output
|
|
|
|
Crtc Crtc
|
|
|
|
Mode Mode
|
|
|
|
Rotation uint16
|
|
|
|
Connection byte
|
|
|
|
SubpixelOrder byte
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// OutputChangeRead reads a byte slice into a OutputChange value.
|
2012-05-10 23:01:42 +02:00
|
|
|
func OutputChangeRead(buf []byte, v *OutputChange) int {
|
|
|
|
b := 0
|
|
|
|
|
|
|
|
v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.ConfigTimestamp = xproto.Timestamp(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Window = xproto.Window(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Output = Output(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Crtc = Crtc(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Mode = Mode(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Rotation = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.Connection = buf[b]
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
v.SubpixelOrder = buf[b]
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
return b
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// OutputChangeReadList reads a byte slice into a list of OutputChange values.
|
2012-05-10 23:01:42 +02:00
|
|
|
func OutputChangeReadList(buf []byte, dest []OutputChange) int {
|
|
|
|
b := 0
|
|
|
|
for i := 0; i < len(dest); i++ {
|
|
|
|
dest[i] = OutputChange{}
|
|
|
|
b += OutputChangeRead(buf[b:], &dest[i])
|
|
|
|
}
|
|
|
|
return xgb.Pad(b)
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Bytes writes a OutputChange value to a byte slice.
|
2012-05-10 23:01:42 +02:00
|
|
|
func (v OutputChange) Bytes() []byte {
|
|
|
|
buf := make([]byte, 28)
|
|
|
|
b := 0
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(v.Timestamp))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(v.ConfigTimestamp))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(v.Window))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(v.Output))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(v.Crtc))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(v.Mode))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], v.Rotation)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
buf[b] = v.Connection
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
buf[b] = v.SubpixelOrder
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2012-05-27 00:24:52 +02:00
|
|
|
// OutputChangeListBytes writes a list of OutputChange values to a byte slice.
|
2012-05-10 23:01:42 +02:00
|
|
|
func OutputChangeListBytes(buf []byte, list []OutputChange) 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
|
|
|
}
|
|
|
|
|
|
|
|
type OutputProperty struct {
|
|
|
|
Window xproto.Window
|
|
|
|
Output Output
|
|
|
|
Atom xproto.Atom
|
|
|
|
Timestamp xproto.Timestamp
|
|
|
|
Status byte
|
|
|
|
// padding: 11 bytes
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// OutputPropertyRead reads a byte slice into a OutputProperty value.
|
2012-05-10 23:01:42 +02:00
|
|
|
func OutputPropertyRead(buf []byte, v *OutputProperty) int {
|
|
|
|
b := 0
|
|
|
|
|
|
|
|
v.Window = xproto.Window(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Output = Output(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Atom = xproto.Atom(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Status = buf[b]
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
b += 11 // padding
|
|
|
|
|
|
|
|
return b
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// OutputPropertyReadList reads a byte slice into a list of OutputProperty values.
|
2012-05-10 23:01:42 +02:00
|
|
|
func OutputPropertyReadList(buf []byte, dest []OutputProperty) int {
|
|
|
|
b := 0
|
|
|
|
for i := 0; i < len(dest); i++ {
|
|
|
|
dest[i] = OutputProperty{}
|
|
|
|
b += OutputPropertyRead(buf[b:], &dest[i])
|
|
|
|
}
|
|
|
|
return xgb.Pad(b)
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Bytes writes a OutputProperty value to a byte slice.
|
2012-05-10 23:01:42 +02:00
|
|
|
func (v OutputProperty) Bytes() []byte {
|
|
|
|
buf := make([]byte, 28)
|
|
|
|
b := 0
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(v.Window))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(v.Output))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(v.Atom))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(v.Timestamp))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
buf[b] = v.Status
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
b += 11 // padding
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2012-05-27 00:24:52 +02:00
|
|
|
// OutputPropertyListBytes writes a list of OutputProperty values to a byte slice.
|
2012-05-10 23:01:42 +02:00
|
|
|
func OutputPropertyListBytes(buf []byte, list []OutputProperty) 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
|
|
|
}
|
|
|
|
|
2013-12-28 15:25:18 +01:00
|
|
|
type Provider uint32
|
|
|
|
|
|
|
|
func NewProviderId(c *xgb.Conn) (Provider, error) {
|
|
|
|
id, err := c.NewId()
|
|
|
|
if err != nil {
|
|
|
|
return 0, err
|
|
|
|
}
|
|
|
|
return Provider(id), nil
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-12-28 15:25:18 +01:00
|
|
|
const (
|
|
|
|
ProviderCapabilitySourceOutput = 1
|
|
|
|
ProviderCapabilitySinkOutput = 2
|
|
|
|
ProviderCapabilitySourceOffload = 4
|
|
|
|
ProviderCapabilitySinkOffload = 8
|
|
|
|
)
|
|
|
|
|
|
|
|
type ProviderChange struct {
|
|
|
|
Timestamp xproto.Timestamp
|
|
|
|
Window xproto.Window
|
|
|
|
Provider Provider
|
|
|
|
// padding: 16 bytes
|
|
|
|
}
|
|
|
|
|
|
|
|
// ProviderChangeRead reads a byte slice into a ProviderChange value.
|
|
|
|
func ProviderChangeRead(buf []byte, v *ProviderChange) int {
|
2013-08-12 02:43:26 +02:00
|
|
|
b := 0
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-12-28 15:25:18 +01:00
|
|
|
v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-12-28 15:25:18 +01:00
|
|
|
v.Window = xproto.Window(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Provider = Provider(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
b += 16 // padding
|
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-12-28 15:25:18 +01:00
|
|
|
// ProviderChangeReadList reads a byte slice into a list of ProviderChange values.
|
|
|
|
func ProviderChangeReadList(buf []byte, dest []ProviderChange) int {
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
for i := 0; i < len(dest); i++ {
|
2013-12-28 15:25:18 +01:00
|
|
|
dest[i] = ProviderChange{}
|
|
|
|
b += ProviderChangeRead(buf[b:], &dest[i])
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
return xgb.Pad(b)
|
|
|
|
}
|
|
|
|
|
2013-12-28 15:25:18 +01:00
|
|
|
// Bytes writes a ProviderChange value to a byte slice.
|
|
|
|
func (v ProviderChange) Bytes() []byte {
|
|
|
|
buf := make([]byte, 28)
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
|
2013-12-28 15:25:18 +01:00
|
|
|
xgb.Put32(buf[b:], uint32(v.Timestamp))
|
|
|
|
b += 4
|
2013-08-12 02:43:26 +02:00
|
|
|
|
2013-12-28 15:25:18 +01:00
|
|
|
xgb.Put32(buf[b:], uint32(v.Window))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(v.Provider))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
b += 16 // padding
|
2013-08-12 02:43:26 +02:00
|
|
|
|
2012-05-10 23:01:42 +02:00
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-12-28 15:25:18 +01:00
|
|
|
// ProviderChangeListBytes writes a list of ProviderChange values to a byte slice.
|
|
|
|
func ProviderChangeListBytes(buf []byte, list []ProviderChange) int {
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
2013-08-12 02:43:26 +02:00
|
|
|
var structBytes []byte
|
2012-05-10 23:01:42 +02:00
|
|
|
for _, item := range list {
|
2013-08-12 02:43:26 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2013-12-28 15:25:18 +01:00
|
|
|
type ProviderProperty struct {
|
|
|
|
Window xproto.Window
|
|
|
|
Provider Provider
|
|
|
|
Atom xproto.Atom
|
|
|
|
Timestamp xproto.Timestamp
|
|
|
|
State byte
|
|
|
|
// padding: 11 bytes
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
|
|
|
|
2013-12-28 15:25:18 +01:00
|
|
|
// ProviderPropertyRead reads a byte slice into a ProviderProperty value.
|
|
|
|
func ProviderPropertyRead(buf []byte, v *ProviderProperty) int {
|
|
|
|
b := 0
|
2013-08-12 02:43:26 +02:00
|
|
|
|
2013-12-28 15:25:18 +01:00
|
|
|
v.Window = xproto.Window(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-12-28 15:25:18 +01:00
|
|
|
v.Provider = Provider(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-12-28 15:25:18 +01:00
|
|
|
v.Atom = xproto.Atom(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.State = buf[b]
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
b += 11 // padding
|
|
|
|
|
|
|
|
return b
|
|
|
|
}
|
|
|
|
|
|
|
|
// ProviderPropertyReadList reads a byte slice into a list of ProviderProperty values.
|
|
|
|
func ProviderPropertyReadList(buf []byte, dest []ProviderProperty) int {
|
|
|
|
b := 0
|
|
|
|
for i := 0; i < len(dest); i++ {
|
|
|
|
dest[i] = ProviderProperty{}
|
|
|
|
b += ProviderPropertyRead(buf[b:], &dest[i])
|
|
|
|
}
|
|
|
|
return xgb.Pad(b)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Bytes writes a ProviderProperty value to a byte slice.
|
|
|
|
func (v ProviderProperty) Bytes() []byte {
|
|
|
|
buf := make([]byte, 28)
|
|
|
|
b := 0
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(v.Window))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(v.Provider))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(v.Atom))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(v.Timestamp))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
buf[b] = v.State
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
b += 11 // padding
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
|
|
|
// ProviderPropertyListBytes writes a list of ProviderProperty values to a byte slice.
|
|
|
|
func ProviderPropertyListBytes(buf []byte, list []ProviderProperty) int {
|
|
|
|
b := 0
|
|
|
|
var structBytes []byte
|
|
|
|
for _, item := range list {
|
|
|
|
structBytes = item.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
|
|
|
b += len(structBytes)
|
|
|
|
}
|
|
|
|
return xgb.Pad(b)
|
|
|
|
}
|
|
|
|
|
|
|
|
type RefreshRates struct {
|
|
|
|
NRates uint16
|
|
|
|
Rates []uint16 // size: xgb.Pad((int(NRates) * 2))
|
|
|
|
}
|
|
|
|
|
|
|
|
// RefreshRatesRead reads a byte slice into a RefreshRates value.
|
|
|
|
func RefreshRatesRead(buf []byte, v *RefreshRates) int {
|
|
|
|
b := 0
|
|
|
|
|
|
|
|
v.NRates = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.Rates = make([]uint16, v.NRates)
|
|
|
|
for i := 0; i < int(v.NRates); i++ {
|
|
|
|
v.Rates[i] = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
}
|
|
|
|
b = xgb.Pad(b)
|
|
|
|
|
|
|
|
return b
|
|
|
|
}
|
|
|
|
|
|
|
|
// RefreshRatesReadList reads a byte slice into a list of RefreshRates values.
|
|
|
|
func RefreshRatesReadList(buf []byte, dest []RefreshRates) int {
|
|
|
|
b := 0
|
|
|
|
for i := 0; i < len(dest); i++ {
|
|
|
|
dest[i] = RefreshRates{}
|
|
|
|
b += RefreshRatesRead(buf[b:], &dest[i])
|
|
|
|
}
|
|
|
|
return xgb.Pad(b)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Bytes writes a RefreshRates value to a byte slice.
|
|
|
|
func (v RefreshRates) Bytes() []byte {
|
|
|
|
buf := make([]byte, (2 + xgb.Pad((int(v.NRates) * 2))))
|
|
|
|
b := 0
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], v.NRates)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
for i := 0; i < int(v.NRates); i++ {
|
|
|
|
xgb.Put16(buf[b:], v.Rates[i])
|
|
|
|
b += 2
|
|
|
|
}
|
|
|
|
b = xgb.Pad(b)
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
|
|
|
// RefreshRatesListBytes writes a list of RefreshRates values to a byte slice.
|
|
|
|
func RefreshRatesListBytes(buf []byte, list []RefreshRates) int {
|
|
|
|
b := 0
|
|
|
|
var structBytes []byte
|
|
|
|
for _, item := range list {
|
|
|
|
structBytes = item.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
|
|
|
b += len(structBytes)
|
|
|
|
}
|
|
|
|
return xgb.Pad(b)
|
|
|
|
}
|
|
|
|
|
|
|
|
// RefreshRatesListSize computes the size (bytes) of a list of RefreshRates values.
|
|
|
|
func RefreshRatesListSize(list []RefreshRates) int {
|
|
|
|
size := 0
|
|
|
|
for _, item := range list {
|
|
|
|
size += (2 + xgb.Pad((int(item.NRates) * 2)))
|
|
|
|
}
|
|
|
|
return size
|
|
|
|
}
|
|
|
|
|
|
|
|
type ResourceChange struct {
|
|
|
|
Timestamp xproto.Timestamp
|
|
|
|
Window xproto.Window
|
|
|
|
// padding: 20 bytes
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResourceChangeRead reads a byte slice into a ResourceChange value.
|
|
|
|
func ResourceChangeRead(buf []byte, v *ResourceChange) int {
|
|
|
|
b := 0
|
|
|
|
|
|
|
|
v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Window = xproto.Window(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
b += 20 // padding
|
|
|
|
|
|
|
|
return b
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResourceChangeReadList reads a byte slice into a list of ResourceChange values.
|
|
|
|
func ResourceChangeReadList(buf []byte, dest []ResourceChange) int {
|
|
|
|
b := 0
|
|
|
|
for i := 0; i < len(dest); i++ {
|
|
|
|
dest[i] = ResourceChange{}
|
|
|
|
b += ResourceChangeRead(buf[b:], &dest[i])
|
|
|
|
}
|
|
|
|
return xgb.Pad(b)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Bytes writes a ResourceChange value to a byte slice.
|
|
|
|
func (v ResourceChange) Bytes() []byte {
|
|
|
|
buf := make([]byte, 28)
|
|
|
|
b := 0
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(v.Timestamp))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(v.Window))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
b += 20 // padding
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResourceChangeListBytes writes a list of ResourceChange values to a byte slice.
|
|
|
|
func ResourceChangeListBytes(buf []byte, list []ResourceChange) int {
|
|
|
|
b := 0
|
|
|
|
var structBytes []byte
|
|
|
|
for _, item := range list {
|
|
|
|
structBytes = item.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
|
|
|
b += len(structBytes)
|
|
|
|
}
|
|
|
|
return xgb.Pad(b)
|
|
|
|
}
|
|
|
|
|
|
|
|
const (
|
|
|
|
RotationRotate0 = 1
|
|
|
|
RotationRotate90 = 2
|
|
|
|
RotationRotate180 = 4
|
|
|
|
RotationRotate270 = 8
|
|
|
|
RotationReflectX = 16
|
|
|
|
RotationReflectY = 32
|
|
|
|
)
|
|
|
|
|
|
|
|
// ScreenChangeNotify is the event number for a ScreenChangeNotifyEvent.
|
|
|
|
const ScreenChangeNotify = 0
|
|
|
|
|
|
|
|
type ScreenChangeNotifyEvent struct {
|
|
|
|
Sequence uint16
|
|
|
|
Rotation byte
|
|
|
|
Timestamp xproto.Timestamp
|
|
|
|
ConfigTimestamp xproto.Timestamp
|
|
|
|
Root xproto.Window
|
|
|
|
RequestWindow xproto.Window
|
|
|
|
SizeID uint16
|
|
|
|
SubpixelOrder uint16
|
|
|
|
Width uint16
|
|
|
|
Height uint16
|
|
|
|
Mwidth uint16
|
|
|
|
Mheight uint16
|
|
|
|
}
|
|
|
|
|
|
|
|
// ScreenChangeNotifyEventNew constructs a ScreenChangeNotifyEvent value that implements xgb.Event from a byte slice.
|
2012-05-10 23:01:42 +02:00
|
|
|
func ScreenChangeNotifyEventNew(buf []byte) xgb.Event {
|
|
|
|
v := ScreenChangeNotifyEvent{}
|
|
|
|
b := 1 // don't read event number
|
|
|
|
|
|
|
|
v.Rotation = buf[b]
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
v.Sequence = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.ConfigTimestamp = xproto.Timestamp(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Root = xproto.Window(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.RequestWindow = xproto.Window(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.SizeID = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.SubpixelOrder = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.Width = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.Height = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.Mwidth = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.Mheight = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Bytes writes a ScreenChangeNotifyEvent value to a byte slice.
|
2012-05-10 23:01:42 +02:00
|
|
|
func (v ScreenChangeNotifyEvent) Bytes() []byte {
|
|
|
|
buf := make([]byte, 32)
|
|
|
|
b := 0
|
|
|
|
|
|
|
|
// write event number
|
|
|
|
buf[b] = 0
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
buf[b] = v.Rotation
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
b += 2 // skip sequence number
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(v.Timestamp))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(v.ConfigTimestamp))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(v.Root))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(v.RequestWindow))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], v.SizeID)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], v.SubpixelOrder)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], v.Width)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], v.Height)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], v.Mwidth)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], v.Mheight)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// SequenceId returns the sequence id attached to the ScreenChangeNotify event.
|
|
|
|
// Events without a sequence number (KeymapNotify) return 0.
|
|
|
|
// This is mostly used internally.
|
2012-05-10 23:01:42 +02:00
|
|
|
func (v ScreenChangeNotifyEvent) SequenceId() uint16 {
|
|
|
|
return v.Sequence
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// String is a rudimentary string representation of ScreenChangeNotifyEvent.
|
2012-05-10 23:01:42 +02:00
|
|
|
func (v ScreenChangeNotifyEvent) String() string {
|
|
|
|
fieldVals := make([]string, 0, 11)
|
|
|
|
fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence))
|
|
|
|
fieldVals = append(fieldVals, xgb.Sprintf("Rotation: %d", v.Rotation))
|
|
|
|
fieldVals = append(fieldVals, xgb.Sprintf("Timestamp: %d", v.Timestamp))
|
|
|
|
fieldVals = append(fieldVals, xgb.Sprintf("ConfigTimestamp: %d", v.ConfigTimestamp))
|
|
|
|
fieldVals = append(fieldVals, xgb.Sprintf("Root: %d", v.Root))
|
|
|
|
fieldVals = append(fieldVals, xgb.Sprintf("RequestWindow: %d", v.RequestWindow))
|
|
|
|
fieldVals = append(fieldVals, xgb.Sprintf("SizeID: %d", v.SizeID))
|
|
|
|
fieldVals = append(fieldVals, xgb.Sprintf("SubpixelOrder: %d", v.SubpixelOrder))
|
|
|
|
fieldVals = append(fieldVals, xgb.Sprintf("Width: %d", v.Width))
|
|
|
|
fieldVals = append(fieldVals, xgb.Sprintf("Height: %d", v.Height))
|
|
|
|
fieldVals = append(fieldVals, xgb.Sprintf("Mwidth: %d", v.Mwidth))
|
|
|
|
fieldVals = append(fieldVals, xgb.Sprintf("Mheight: %d", v.Mheight))
|
|
|
|
return "ScreenChangeNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}"
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
xgb.NewExtEventFuncs["RANDR"][0] = ScreenChangeNotifyEventNew
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
type ScreenSize struct {
|
|
|
|
Width uint16
|
|
|
|
Height uint16
|
|
|
|
Mwidth uint16
|
|
|
|
Mheight uint16
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// ScreenSizeRead reads a byte slice into a ScreenSize value.
|
|
|
|
func ScreenSizeRead(buf []byte, v *ScreenSize) int {
|
|
|
|
b := 0
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Width = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Height = xgb.Get16(buf[b:])
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Mwidth = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Mheight = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
return b
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// ScreenSizeReadList reads a byte slice into a list of ScreenSize values.
|
|
|
|
func ScreenSizeReadList(buf []byte, dest []ScreenSize) int {
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
2013-08-12 02:43:26 +02:00
|
|
|
for i := 0; i < len(dest); i++ {
|
|
|
|
dest[i] = ScreenSize{}
|
|
|
|
b += ScreenSizeRead(buf[b:], &dest[i])
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
2013-08-12 02:43:26 +02:00
|
|
|
return xgb.Pad(b)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Bytes writes a ScreenSize value to a byte slice.
|
|
|
|
func (v ScreenSize) 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.Put16(buf[b:], v.Width)
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], v.Height)
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], v.Mwidth)
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], v.Mheight)
|
|
|
|
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
|
|
|
// ScreenSizeListBytes writes a list of ScreenSize values to a byte slice.
|
|
|
|
func ScreenSizeListBytes(buf []byte, list []ScreenSize) 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 (
|
|
|
|
SetConfigSuccess = 0
|
|
|
|
SetConfigInvalidConfigTime = 1
|
|
|
|
SetConfigInvalidTime = 2
|
|
|
|
SetConfigFailed = 3
|
|
|
|
)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-12-28 15:25:18 +01:00
|
|
|
const (
|
|
|
|
TransformUnit = 1
|
|
|
|
TransformScaleUp = 2
|
|
|
|
TransformScaleDown = 4
|
|
|
|
TransformProjective = 8
|
|
|
|
)
|
|
|
|
|
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'
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// 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-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Skipping definition for base type 'Int8'
|
2012-05-11 07:58:52 +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'
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// AddOutputModeCookie is a cookie used only for AddOutputMode requests.
|
|
|
|
type AddOutputModeCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// AddOutputMode 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 AddOutputMode(c *xgb.Conn, Output Output, Mode Mode) AddOutputModeCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'AddOutputMode' using the uninitialized extension 'RANDR'. randr.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(addOutputModeRequest(c, Output, Mode), cookie)
|
|
|
|
return AddOutputModeCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// AddOutputModeChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using AddOutputModeCookie.Check()
|
|
|
|
func AddOutputModeChecked(c *xgb.Conn, Output Output, Mode Mode) AddOutputModeCookie {
|
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
|
|
|
panic("Cannot issue request 'AddOutputMode' using the uninitialized extension 'RANDR'. randr.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(addOutputModeRequest(c, Output, Mode), cookie)
|
|
|
|
return AddOutputModeCookie{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 AddOutputModeCookie) Check() error {
|
|
|
|
return cook.Cookie.Check()
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for AddOutputMode
|
|
|
|
// addOutputModeRequest writes a AddOutputMode request to a byte slice.
|
|
|
|
func addOutputModeRequest(c *xgb.Conn, Output Output, Mode Mode) []byte {
|
2012-05-10 23:01:42 +02:00
|
|
|
size := 12
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
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
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Output))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Mode))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// ChangeOutputPropertyCookie is a cookie used only for ChangeOutputProperty requests.
|
|
|
|
type ChangeOutputPropertyCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// ChangeOutputProperty 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 ChangeOutputProperty(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, Format byte, Mode byte, NumUnits uint32, Data []byte) ChangeOutputPropertyCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'ChangeOutputProperty' using the uninitialized extension 'RANDR'. randr.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(changeOutputPropertyRequest(c, Output, Property, Type, Format, Mode, NumUnits, Data), cookie)
|
|
|
|
return ChangeOutputPropertyCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// ChangeOutputPropertyChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using ChangeOutputPropertyCookie.Check()
|
|
|
|
func ChangeOutputPropertyChecked(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, Format byte, Mode byte, NumUnits uint32, Data []byte) ChangeOutputPropertyCookie {
|
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
|
|
|
panic("Cannot issue request 'ChangeOutputProperty' using the uninitialized extension 'RANDR'. randr.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(changeOutputPropertyRequest(c, Output, Property, Type, Format, Mode, NumUnits, Data), cookie)
|
|
|
|
return ChangeOutputPropertyCookie{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 ChangeOutputPropertyCookie) Check() error {
|
|
|
|
return cook.Cookie.Check()
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for ChangeOutputProperty
|
|
|
|
// changeOutputPropertyRequest writes a ChangeOutputProperty request to a byte slice.
|
|
|
|
func changeOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, Format byte, Mode byte, NumUnits uint32, Data []byte) []byte {
|
|
|
|
size := xgb.Pad((24 + xgb.Pad((((int(NumUnits) * int(Format)) / 8) * 1))))
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 13 // 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(Output))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Property))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Type))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = Format
|
|
|
|
b += 1
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = Mode
|
|
|
|
b += 1
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
b += 2 // padding
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], NumUnits)
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
copy(buf[b:], Data[:((int(NumUnits)*int(Format))/8)])
|
|
|
|
b += xgb.Pad(int(((int(NumUnits) * int(Format)) / 8)))
|
|
|
|
|
2012-05-10 23:01:42 +02:00
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-12-28 15:25:18 +01:00
|
|
|
// ChangeProviderPropertyCookie is a cookie used only for ChangeProviderProperty requests.
|
|
|
|
type ChangeProviderPropertyCookie struct {
|
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
|
|
|
// ChangeProviderProperty sends an unchecked request.
|
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
|
|
|
func ChangeProviderProperty(c *xgb.Conn, Provider Provider, Property xproto.Atom, Type xproto.Atom, Format byte, Mode byte, NumItems uint32, Data []byte) ChangeProviderPropertyCookie {
|
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
|
|
|
panic("Cannot issue request 'ChangeProviderProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.")
|
|
|
|
}
|
|
|
|
cookie := c.NewCookie(false, false)
|
|
|
|
c.NewRequest(changeProviderPropertyRequest(c, Provider, Property, Type, Format, Mode, NumItems, Data), cookie)
|
|
|
|
return ChangeProviderPropertyCookie{cookie}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ChangeProviderPropertyChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using ChangeProviderPropertyCookie.Check()
|
|
|
|
func ChangeProviderPropertyChecked(c *xgb.Conn, Provider Provider, Property xproto.Atom, Type xproto.Atom, Format byte, Mode byte, NumItems uint32, Data []byte) ChangeProviderPropertyCookie {
|
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
|
|
|
panic("Cannot issue request 'ChangeProviderProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.")
|
|
|
|
}
|
|
|
|
cookie := c.NewCookie(true, false)
|
|
|
|
c.NewRequest(changeProviderPropertyRequest(c, Provider, Property, Type, Format, Mode, NumItems, Data), cookie)
|
|
|
|
return ChangeProviderPropertyCookie{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 ChangeProviderPropertyCookie) Check() error {
|
|
|
|
return cook.Cookie.Check()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write request to wire for ChangeProviderProperty
|
|
|
|
// changeProviderPropertyRequest writes a ChangeProviderProperty request to a byte slice.
|
|
|
|
func changeProviderPropertyRequest(c *xgb.Conn, Provider Provider, Property xproto.Atom, Type xproto.Atom, Format byte, Mode byte, NumItems uint32, Data []byte) []byte {
|
|
|
|
size := xgb.Pad((24 + xgb.Pad(((int(NumItems) * (int(Format) / 8)) * 1))))
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
buf[b] = 39 // 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(Provider))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(Property))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(Type))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
buf[b] = Format
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
buf[b] = Mode
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
b += 2 // padding
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], NumItems)
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
copy(buf[b:], Data[:(int(NumItems)*(int(Format)/8))])
|
|
|
|
b += xgb.Pad(int((int(NumItems) * (int(Format) / 8))))
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// ConfigureOutputPropertyCookie is a cookie used only for ConfigureOutputProperty requests.
|
|
|
|
type ConfigureOutputPropertyCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// ConfigureOutputProperty 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 ConfigureOutputProperty(c *xgb.Conn, Output Output, Property xproto.Atom, Pending bool, Range bool, Values []int32) ConfigureOutputPropertyCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'ConfigureOutputProperty' using the uninitialized extension 'RANDR'. randr.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(configureOutputPropertyRequest(c, Output, Property, Pending, Range, Values), cookie)
|
|
|
|
return ConfigureOutputPropertyCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// ConfigureOutputPropertyChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using ConfigureOutputPropertyCookie.Check()
|
|
|
|
func ConfigureOutputPropertyChecked(c *xgb.Conn, Output Output, Property xproto.Atom, Pending bool, Range bool, Values []int32) ConfigureOutputPropertyCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'ConfigureOutputProperty' using the uninitialized extension 'RANDR'. randr.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(configureOutputPropertyRequest(c, Output, Property, Pending, Range, Values), cookie)
|
|
|
|
return ConfigureOutputPropertyCookie{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 ConfigureOutputPropertyCookie) Check() error {
|
2012-05-10 23:01:42 +02:00
|
|
|
return cook.Cookie.Check()
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for ConfigureOutputProperty
|
|
|
|
// configureOutputPropertyRequest writes a ConfigureOutputProperty request to a byte slice.
|
|
|
|
func configureOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom, Pending bool, Range bool, Values []int32) []byte {
|
|
|
|
size := xgb.Pad((16 + xgb.Pad((len(Values) * 4))))
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 12 // 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(Output))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Property))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
if Pending {
|
|
|
|
buf[b] = 1
|
|
|
|
} else {
|
|
|
|
buf[b] = 0
|
|
|
|
}
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
if Range {
|
|
|
|
buf[b] = 1
|
|
|
|
} else {
|
|
|
|
buf[b] = 0
|
|
|
|
}
|
|
|
|
b += 1
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
b += 2 // padding
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
for i := 0; i < int(len(Values)); i++ {
|
|
|
|
xgb.Put32(buf[b:], uint32(Values[i]))
|
|
|
|
b += 4
|
|
|
|
}
|
|
|
|
b = xgb.Pad(b)
|
|
|
|
|
2012-05-10 23:01:42 +02:00
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-12-28 15:25:18 +01:00
|
|
|
// ConfigureProviderPropertyCookie is a cookie used only for ConfigureProviderProperty requests.
|
|
|
|
type ConfigureProviderPropertyCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-12-28 15:25:18 +01:00
|
|
|
// ConfigureProviderProperty sends an unchecked request.
|
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
|
|
|
func ConfigureProviderProperty(c *xgb.Conn, Provider Provider, Property xproto.Atom, Pending bool, Range bool, Values []int32) ConfigureProviderPropertyCookie {
|
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
|
|
|
panic("Cannot issue request 'ConfigureProviderProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.")
|
|
|
|
}
|
|
|
|
cookie := c.NewCookie(false, false)
|
|
|
|
c.NewRequest(configureProviderPropertyRequest(c, Provider, Property, Pending, Range, Values), cookie)
|
|
|
|
return ConfigureProviderPropertyCookie{cookie}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ConfigureProviderPropertyChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using ConfigureProviderPropertyCookie.Check()
|
|
|
|
func ConfigureProviderPropertyChecked(c *xgb.Conn, Provider Provider, Property xproto.Atom, Pending bool, Range bool, Values []int32) ConfigureProviderPropertyCookie {
|
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
|
|
|
panic("Cannot issue request 'ConfigureProviderProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.")
|
|
|
|
}
|
|
|
|
cookie := c.NewCookie(true, false)
|
|
|
|
c.NewRequest(configureProviderPropertyRequest(c, Provider, Property, Pending, Range, Values), cookie)
|
|
|
|
return ConfigureProviderPropertyCookie{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 ConfigureProviderPropertyCookie) Check() error {
|
|
|
|
return cook.Cookie.Check()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write request to wire for ConfigureProviderProperty
|
|
|
|
// configureProviderPropertyRequest writes a ConfigureProviderProperty request to a byte slice.
|
|
|
|
func configureProviderPropertyRequest(c *xgb.Conn, Provider Provider, Property xproto.Atom, Pending bool, Range bool, Values []int32) []byte {
|
|
|
|
size := xgb.Pad((16 + xgb.Pad((len(Values) * 4))))
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
buf[b] = 38 // 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(Provider))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(Property))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
if Pending {
|
|
|
|
buf[b] = 1
|
|
|
|
} else {
|
|
|
|
buf[b] = 0
|
|
|
|
}
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
if Range {
|
|
|
|
buf[b] = 1
|
|
|
|
} else {
|
|
|
|
buf[b] = 0
|
|
|
|
}
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
b += 2 // padding
|
|
|
|
|
|
|
|
for i := 0; i < int(len(Values)); i++ {
|
|
|
|
xgb.Put32(buf[b:], uint32(Values[i]))
|
|
|
|
b += 4
|
|
|
|
}
|
|
|
|
b = xgb.Pad(b)
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
|
|
|
// CreateModeCookie is a cookie used only for CreateMode requests.
|
|
|
|
type CreateModeCookie struct {
|
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
|
|
|
// CreateMode sends a checked request.
|
|
|
|
// If an error occurs, it will be returned with the reply by calling CreateModeCookie.Reply()
|
|
|
|
func CreateMode(c *xgb.Conn, Window xproto.Window, ModeInfo ModeInfo, Name string) CreateModeCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'CreateMode' using the uninitialized extension 'RANDR'. randr.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(createModeRequest(c, Window, ModeInfo, Name), cookie)
|
|
|
|
return CreateModeCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// CreateModeUnchecked 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 CreateModeUnchecked(c *xgb.Conn, Window xproto.Window, ModeInfo ModeInfo, Name string) CreateModeCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'CreateMode' using the uninitialized extension 'RANDR'. randr.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(createModeRequest(c, Window, ModeInfo, Name), cookie)
|
|
|
|
return CreateModeCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// CreateModeReply represents the data returned from a CreateMode request.
|
|
|
|
type CreateModeReply struct {
|
|
|
|
Sequence uint16 // sequence number of the request for this reply
|
|
|
|
Length uint32 // number of bytes in this reply
|
|
|
|
// padding: 1 bytes
|
|
|
|
Mode Mode
|
|
|
|
// padding: 20 bytes
|
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 CreateMode request.
|
|
|
|
func (cook CreateModeCookie) Reply() (*CreateModeReply, 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 createModeReply(buf), nil
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// createModeReply reads a byte slice into a CreateModeReply value.
|
|
|
|
func createModeReply(buf []byte) *CreateModeReply {
|
|
|
|
v := new(CreateModeReply)
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 1 // skip reply determinant
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b += 1 // padding
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
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.Mode = Mode(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
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for CreateMode
|
|
|
|
// createModeRequest writes a CreateMode request to a byte slice.
|
|
|
|
func createModeRequest(c *xgb.Conn, Window xproto.Window, ModeInfo ModeInfo, Name string) []byte {
|
|
|
|
size := xgb.Pad((40 + xgb.Pad((len(Name) * 1))))
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
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(Window))
|
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
{
|
|
|
|
structBytes := ModeInfo.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-12-28 15:33:09 +01:00
|
|
|
b += len(structBytes)
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
copy(buf[b:], Name[:len(Name)])
|
|
|
|
b += xgb.Pad(int(len(Name)))
|
|
|
|
|
2012-05-10 23:01:42 +02:00
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// DeleteOutputModeCookie is a cookie used only for DeleteOutputMode requests.
|
|
|
|
type DeleteOutputModeCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// DeleteOutputMode sends an unchecked request.
|
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
|
|
|
func DeleteOutputMode(c *xgb.Conn, Output Output, Mode Mode) DeleteOutputModeCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'DeleteOutputMode' using the uninitialized extension 'RANDR'. randr.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(deleteOutputModeRequest(c, Output, Mode), cookie)
|
|
|
|
return DeleteOutputModeCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// DeleteOutputModeChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using DeleteOutputModeCookie.Check()
|
|
|
|
func DeleteOutputModeChecked(c *xgb.Conn, Output Output, Mode Mode) DeleteOutputModeCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'DeleteOutputMode' using the uninitialized extension 'RANDR'. randr.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, false)
|
|
|
|
c.NewRequest(deleteOutputModeRequest(c, Output, Mode), cookie)
|
|
|
|
return DeleteOutputModeCookie{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 DeleteOutputModeCookie) Check() error {
|
|
|
|
return cook.Cookie.Check()
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for DeleteOutputMode
|
|
|
|
// deleteOutputModeRequest writes a DeleteOutputMode request to a byte slice.
|
|
|
|
func deleteOutputModeRequest(c *xgb.Conn, Output Output, Mode Mode) []byte {
|
|
|
|
size := 12
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
b += 1
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 19 // request opcode
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
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(Output))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Mode))
|
|
|
|
b += 4
|
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
|
|
|
// DeleteOutputPropertyCookie is a cookie used only for DeleteOutputProperty requests.
|
|
|
|
type DeleteOutputPropertyCookie struct {
|
|
|
|
*xgb.Cookie
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// DeleteOutputProperty sends an unchecked request.
|
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
|
|
|
func DeleteOutputProperty(c *xgb.Conn, Output Output, Property xproto.Atom) DeleteOutputPropertyCookie {
|
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
|
|
|
panic("Cannot issue request 'DeleteOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.")
|
|
|
|
}
|
|
|
|
cookie := c.NewCookie(false, false)
|
|
|
|
c.NewRequest(deleteOutputPropertyRequest(c, Output, Property), cookie)
|
|
|
|
return DeleteOutputPropertyCookie{cookie}
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// DeleteOutputPropertyChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using DeleteOutputPropertyCookie.Check()
|
|
|
|
func DeleteOutputPropertyChecked(c *xgb.Conn, Output Output, Property xproto.Atom) DeleteOutputPropertyCookie {
|
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
|
|
|
panic("Cannot issue request 'DeleteOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.")
|
|
|
|
}
|
|
|
|
cookie := c.NewCookie(true, false)
|
|
|
|
c.NewRequest(deleteOutputPropertyRequest(c, Output, Property), cookie)
|
|
|
|
return DeleteOutputPropertyCookie{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 DeleteOutputPropertyCookie) Check() error {
|
|
|
|
return cook.Cookie.Check()
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for DeleteOutputProperty
|
|
|
|
// deleteOutputPropertyRequest writes a DeleteOutputProperty request to a byte slice.
|
|
|
|
func deleteOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom) []byte {
|
|
|
|
size := 12
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
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(Output))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(Property))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-12-28 15:25:18 +01:00
|
|
|
// DeleteProviderPropertyCookie is a cookie used only for DeleteProviderProperty requests.
|
|
|
|
type DeleteProviderPropertyCookie struct {
|
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeleteProviderProperty sends an unchecked request.
|
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
|
|
|
func DeleteProviderProperty(c *xgb.Conn, Provider Provider, Property xproto.Atom) DeleteProviderPropertyCookie {
|
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
|
|
|
panic("Cannot issue request 'DeleteProviderProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.")
|
|
|
|
}
|
|
|
|
cookie := c.NewCookie(false, false)
|
|
|
|
c.NewRequest(deleteProviderPropertyRequest(c, Provider, Property), cookie)
|
|
|
|
return DeleteProviderPropertyCookie{cookie}
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeleteProviderPropertyChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using DeleteProviderPropertyCookie.Check()
|
|
|
|
func DeleteProviderPropertyChecked(c *xgb.Conn, Provider Provider, Property xproto.Atom) DeleteProviderPropertyCookie {
|
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
|
|
|
panic("Cannot issue request 'DeleteProviderProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.")
|
|
|
|
}
|
|
|
|
cookie := c.NewCookie(true, false)
|
|
|
|
c.NewRequest(deleteProviderPropertyRequest(c, Provider, Property), cookie)
|
|
|
|
return DeleteProviderPropertyCookie{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 DeleteProviderPropertyCookie) Check() error {
|
|
|
|
return cook.Cookie.Check()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write request to wire for DeleteProviderProperty
|
|
|
|
// deleteProviderPropertyRequest writes a DeleteProviderProperty request to a byte slice.
|
|
|
|
func deleteProviderPropertyRequest(c *xgb.Conn, Provider Provider, Property xproto.Atom) []byte {
|
|
|
|
size := 12
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
buf[b] = 40 // 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(Provider))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(Property))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// DestroyModeCookie is a cookie used only for DestroyMode requests.
|
|
|
|
type DestroyModeCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// DestroyMode 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 DestroyMode(c *xgb.Conn, Mode Mode) DestroyModeCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'DestroyMode' using the uninitialized extension 'RANDR'. randr.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(destroyModeRequest(c, Mode), cookie)
|
|
|
|
return DestroyModeCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// DestroyModeChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using DestroyModeCookie.Check()
|
|
|
|
func DestroyModeChecked(c *xgb.Conn, Mode Mode) DestroyModeCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'DestroyMode' using the uninitialized extension 'RANDR'. randr.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(destroyModeRequest(c, Mode), cookie)
|
|
|
|
return DestroyModeCookie{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 DestroyModeCookie) Check() error {
|
2012-05-10 23:01:42 +02:00
|
|
|
return cook.Cookie.Check()
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for DestroyMode
|
|
|
|
// destroyModeRequest writes a DestroyMode request to a byte slice.
|
|
|
|
func destroyModeRequest(c *xgb.Conn, Mode Mode) []byte {
|
|
|
|
size := 8
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 17 // 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(Mode))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetCrtcGammaCookie is a cookie used only for GetCrtcGamma requests.
|
|
|
|
type GetCrtcGammaCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetCrtcGamma sends a checked request.
|
|
|
|
// If an error occurs, it will be returned with the reply by calling GetCrtcGammaCookie.Reply()
|
|
|
|
func GetCrtcGamma(c *xgb.Conn, Crtc Crtc) GetCrtcGammaCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'GetCrtcGamma' using the uninitialized extension 'RANDR'. randr.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(getCrtcGammaRequest(c, Crtc), cookie)
|
|
|
|
return GetCrtcGammaCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetCrtcGammaUnchecked 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 GetCrtcGammaUnchecked(c *xgb.Conn, Crtc Crtc) GetCrtcGammaCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'GetCrtcGamma' using the uninitialized extension 'RANDR'. randr.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(getCrtcGammaRequest(c, Crtc), cookie)
|
|
|
|
return GetCrtcGammaCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetCrtcGammaReply represents the data returned from a GetCrtcGamma request.
|
|
|
|
type GetCrtcGammaReply 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
|
|
|
Size uint16
|
|
|
|
// padding: 22 bytes
|
|
|
|
Red []uint16 // size: xgb.Pad((int(Size) * 2))
|
|
|
|
Green []uint16 // size: xgb.Pad((int(Size) * 2))
|
|
|
|
Blue []uint16 // size: xgb.Pad((int(Size) * 2))
|
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 GetCrtcGamma request.
|
|
|
|
func (cook GetCrtcGammaCookie) Reply() (*GetCrtcGammaReply, 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 getCrtcGammaReply(buf), nil
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// getCrtcGammaReply reads a byte slice into a GetCrtcGammaReply value.
|
|
|
|
func getCrtcGammaReply(buf []byte) *GetCrtcGammaReply {
|
|
|
|
v := new(GetCrtcGammaReply)
|
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.Size = xgb.Get16(buf[b:])
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
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.Red = make([]uint16, v.Size)
|
|
|
|
for i := 0; i < int(v.Size); i++ {
|
|
|
|
v.Red[i] = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
b = xgb.Pad(b)
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Green = make([]uint16, v.Size)
|
|
|
|
for i := 0; i < int(v.Size); i++ {
|
|
|
|
v.Green[i] = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
b = xgb.Pad(b)
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Blue = make([]uint16, v.Size)
|
|
|
|
for i := 0; i < int(v.Size); i++ {
|
|
|
|
v.Blue[i] = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
}
|
|
|
|
b = xgb.Pad(b)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for GetCrtcGamma
|
|
|
|
// getCrtcGammaRequest writes a GetCrtcGamma request to a byte slice.
|
|
|
|
func getCrtcGammaRequest(c *xgb.Conn, Crtc Crtc) []byte {
|
2012-05-10 23:01:42 +02:00
|
|
|
size := 8
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 23 // 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(Crtc))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetCrtcGammaSizeCookie is a cookie used only for GetCrtcGammaSize requests.
|
|
|
|
type GetCrtcGammaSizeCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetCrtcGammaSize sends a checked request.
|
|
|
|
// If an error occurs, it will be returned with the reply by calling GetCrtcGammaSizeCookie.Reply()
|
|
|
|
func GetCrtcGammaSize(c *xgb.Conn, Crtc Crtc) GetCrtcGammaSizeCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'GetCrtcGammaSize' using the uninitialized extension 'RANDR'. randr.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(getCrtcGammaSizeRequest(c, Crtc), cookie)
|
|
|
|
return GetCrtcGammaSizeCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetCrtcGammaSizeUnchecked 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 GetCrtcGammaSizeUnchecked(c *xgb.Conn, Crtc Crtc) GetCrtcGammaSizeCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'GetCrtcGammaSize' using the uninitialized extension 'RANDR'. randr.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(getCrtcGammaSizeRequest(c, Crtc), cookie)
|
|
|
|
return GetCrtcGammaSizeCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetCrtcGammaSizeReply represents the data returned from a GetCrtcGammaSize request.
|
|
|
|
type GetCrtcGammaSizeReply struct {
|
|
|
|
Sequence uint16 // sequence number of the request for this reply
|
|
|
|
Length uint32 // number of bytes in this reply
|
|
|
|
// padding: 1 bytes
|
|
|
|
Size uint16
|
|
|
|
// padding: 22 bytes
|
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 GetCrtcGammaSize request.
|
|
|
|
func (cook GetCrtcGammaSizeCookie) Reply() (*GetCrtcGammaSizeReply, 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 getCrtcGammaSizeReply(buf), nil
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// getCrtcGammaSizeReply reads a byte slice into a GetCrtcGammaSizeReply value.
|
|
|
|
func getCrtcGammaSizeReply(buf []byte) *GetCrtcGammaSizeReply {
|
|
|
|
v := new(GetCrtcGammaSizeReply)
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 1 // skip reply determinant
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b += 1 // padding
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
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.Size = xgb.Get16(buf[b:])
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b += 22 // padding
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for GetCrtcGammaSize
|
|
|
|
// getCrtcGammaSizeRequest writes a GetCrtcGammaSize request to a byte slice.
|
|
|
|
func getCrtcGammaSizeRequest(c *xgb.Conn, Crtc Crtc) []byte {
|
|
|
|
size := 8
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 22 // 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(Crtc))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetCrtcInfoCookie is a cookie used only for GetCrtcInfo requests.
|
|
|
|
type GetCrtcInfoCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetCrtcInfo sends a checked request.
|
|
|
|
// If an error occurs, it will be returned with the reply by calling GetCrtcInfoCookie.Reply()
|
|
|
|
func GetCrtcInfo(c *xgb.Conn, Crtc Crtc, ConfigTimestamp xproto.Timestamp) GetCrtcInfoCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'GetCrtcInfo' using the uninitialized extension 'RANDR'. randr.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(getCrtcInfoRequest(c, Crtc, ConfigTimestamp), cookie)
|
|
|
|
return GetCrtcInfoCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetCrtcInfoUnchecked 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 GetCrtcInfoUnchecked(c *xgb.Conn, Crtc Crtc, ConfigTimestamp xproto.Timestamp) GetCrtcInfoCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'GetCrtcInfo' using the uninitialized extension 'RANDR'. randr.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(getCrtcInfoRequest(c, Crtc, ConfigTimestamp), cookie)
|
|
|
|
return GetCrtcInfoCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetCrtcInfoReply represents the data returned from a GetCrtcInfo request.
|
|
|
|
type GetCrtcInfoReply struct {
|
|
|
|
Sequence uint16 // sequence number of the request for this reply
|
|
|
|
Length uint32 // number of bytes in this reply
|
|
|
|
Status byte
|
|
|
|
Timestamp xproto.Timestamp
|
|
|
|
X int16
|
|
|
|
Y int16
|
|
|
|
Width uint16
|
|
|
|
Height uint16
|
|
|
|
Mode Mode
|
|
|
|
Rotation uint16
|
|
|
|
Rotations uint16
|
|
|
|
NumOutputs uint16
|
|
|
|
NumPossibleOutputs uint16
|
|
|
|
Outputs []Output // size: xgb.Pad((int(NumOutputs) * 4))
|
|
|
|
Possible []Output // size: xgb.Pad((int(NumPossibleOutputs) * 4))
|
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 GetCrtcInfo request.
|
|
|
|
func (cook GetCrtcInfoCookie) Reply() (*GetCrtcInfoReply, 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 getCrtcInfoReply(buf), nil
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// getCrtcInfoReply reads a byte slice into a GetCrtcInfoReply value.
|
|
|
|
func getCrtcInfoReply(buf []byte) *GetCrtcInfoReply {
|
|
|
|
v := new(GetCrtcInfoReply)
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 1 // skip reply determinant
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Status = buf[b]
|
|
|
|
b += 1
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
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.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.X = int16(xgb.Get16(buf[b:]))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Y = int16(xgb.Get16(buf[b:]))
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Width = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.Height = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.Mode = Mode(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Rotation = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.Rotations = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.NumOutputs = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.NumPossibleOutputs = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.Outputs = make([]Output, v.NumOutputs)
|
|
|
|
for i := 0; i < int(v.NumOutputs); i++ {
|
|
|
|
v.Outputs[i] = Output(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
}
|
|
|
|
b = xgb.Pad(b)
|
|
|
|
|
|
|
|
v.Possible = make([]Output, v.NumPossibleOutputs)
|
|
|
|
for i := 0; i < int(v.NumPossibleOutputs); i++ {
|
|
|
|
v.Possible[i] = Output(xgb.Get32(buf[b:]))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
}
|
|
|
|
b = xgb.Pad(b)
|
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for GetCrtcInfo
|
|
|
|
// getCrtcInfoRequest writes a GetCrtcInfo request to a byte slice.
|
|
|
|
func getCrtcInfoRequest(c *xgb.Conn, Crtc Crtc, ConfigTimestamp xproto.Timestamp) []byte {
|
|
|
|
size := 12
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 20 // 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(Crtc))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(ConfigTimestamp))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetCrtcTransformCookie is a cookie used only for GetCrtcTransform requests.
|
|
|
|
type GetCrtcTransformCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetCrtcTransform sends a checked request.
|
|
|
|
// If an error occurs, it will be returned with the reply by calling GetCrtcTransformCookie.Reply()
|
|
|
|
func GetCrtcTransform(c *xgb.Conn, Crtc Crtc) GetCrtcTransformCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'GetCrtcTransform' using the uninitialized extension 'RANDR'. randr.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(getCrtcTransformRequest(c, Crtc), cookie)
|
|
|
|
return GetCrtcTransformCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetCrtcTransformUnchecked 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 GetCrtcTransformUnchecked(c *xgb.Conn, Crtc Crtc) GetCrtcTransformCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'GetCrtcTransform' using the uninitialized extension 'RANDR'. randr.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(getCrtcTransformRequest(c, Crtc), cookie)
|
|
|
|
return GetCrtcTransformCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetCrtcTransformReply represents the data returned from a GetCrtcTransform request.
|
|
|
|
type GetCrtcTransformReply 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
|
|
|
PendingTransform render.Transform
|
|
|
|
HasTransforms bool
|
|
|
|
// padding: 3 bytes
|
|
|
|
CurrentTransform render.Transform
|
|
|
|
// padding: 4 bytes
|
|
|
|
PendingLen uint16
|
|
|
|
PendingNparams uint16
|
|
|
|
CurrentLen uint16
|
|
|
|
CurrentNparams uint16
|
|
|
|
PendingFilterName string // size: xgb.Pad((int(PendingLen) * 1))
|
|
|
|
PendingParams []render.Fixed // size: xgb.Pad((int(PendingNparams) * 4))
|
|
|
|
CurrentFilterName string // size: xgb.Pad((int(CurrentLen) * 1))
|
|
|
|
CurrentParams []render.Fixed // size: xgb.Pad((int(CurrentNparams) * 4))
|
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 GetCrtcTransform request.
|
|
|
|
func (cook GetCrtcTransformCookie) Reply() (*GetCrtcTransformReply, 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 getCrtcTransformReply(buf), nil
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// getCrtcTransformReply reads a byte slice into a GetCrtcTransformReply value.
|
|
|
|
func getCrtcTransformReply(buf []byte) *GetCrtcTransformReply {
|
|
|
|
v := new(GetCrtcTransformReply)
|
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.PendingTransform = render.Transform{}
|
|
|
|
b += render.TransformRead(buf[b:], &v.PendingTransform)
|
|
|
|
|
2012-05-10 23:01:42 +02:00
|
|
|
if buf[b] == 1 {
|
2013-08-12 02:43:26 +02:00
|
|
|
v.HasTransforms = true
|
2012-05-10 23:01:42 +02:00
|
|
|
} else {
|
2013-08-12 02:43:26 +02:00
|
|
|
v.HasTransforms = false
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b += 3 // padding
|
|
|
|
|
|
|
|
v.CurrentTransform = render.Transform{}
|
|
|
|
b += render.TransformRead(buf[b:], &v.CurrentTransform)
|
|
|
|
|
|
|
|
b += 4 // padding
|
|
|
|
|
|
|
|
v.PendingLen = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.PendingNparams = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.CurrentLen = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.CurrentNparams = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
{
|
|
|
|
byteString := make([]byte, v.PendingLen)
|
|
|
|
copy(byteString[:v.PendingLen], buf[b:])
|
|
|
|
v.PendingFilterName = string(byteString)
|
2013-12-28 16:02:18 +01:00
|
|
|
b += int(v.PendingLen)
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.PendingParams = make([]render.Fixed, v.PendingNparams)
|
|
|
|
for i := 0; i < int(v.PendingNparams); i++ {
|
|
|
|
v.PendingParams[i] = render.Fixed(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
2013-08-12 02:43:26 +02:00
|
|
|
b = xgb.Pad(b)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
{
|
|
|
|
byteString := make([]byte, v.CurrentLen)
|
|
|
|
copy(byteString[:v.CurrentLen], buf[b:])
|
|
|
|
v.CurrentFilterName = string(byteString)
|
2013-12-28 16:02:18 +01:00
|
|
|
b += int(v.CurrentLen)
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.CurrentParams = make([]render.Fixed, v.CurrentNparams)
|
|
|
|
for i := 0; i < int(v.CurrentNparams); i++ {
|
|
|
|
v.CurrentParams[i] = render.Fixed(xgb.Get32(buf[b:]))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
}
|
|
|
|
b = xgb.Pad(b)
|
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for GetCrtcTransform
|
|
|
|
// getCrtcTransformRequest writes a GetCrtcTransform request to a byte slice.
|
|
|
|
func getCrtcTransformRequest(c *xgb.Conn, Crtc Crtc) []byte {
|
|
|
|
size := 8
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 27 // 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(Crtc))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetOutputInfoCookie is a cookie used only for GetOutputInfo requests.
|
|
|
|
type GetOutputInfoCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetOutputInfo sends a checked request.
|
|
|
|
// If an error occurs, it will be returned with the reply by calling GetOutputInfoCookie.Reply()
|
|
|
|
func GetOutputInfo(c *xgb.Conn, Output Output, ConfigTimestamp xproto.Timestamp) GetOutputInfoCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'GetOutputInfo' using the uninitialized extension 'RANDR'. randr.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(getOutputInfoRequest(c, Output, ConfigTimestamp), cookie)
|
|
|
|
return GetOutputInfoCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetOutputInfoUnchecked sends an unchecked request.
|
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
|
|
|
func GetOutputInfoUnchecked(c *xgb.Conn, Output Output, ConfigTimestamp xproto.Timestamp) GetOutputInfoCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'GetOutputInfo' using the uninitialized extension 'RANDR'. randr.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(getOutputInfoRequest(c, Output, ConfigTimestamp), cookie)
|
|
|
|
return GetOutputInfoCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetOutputInfoReply represents the data returned from a GetOutputInfo request.
|
|
|
|
type GetOutputInfoReply struct {
|
|
|
|
Sequence uint16 // sequence number of the request for this reply
|
|
|
|
Length uint32 // number of bytes in this reply
|
|
|
|
Status byte
|
|
|
|
Timestamp xproto.Timestamp
|
|
|
|
Crtc Crtc
|
|
|
|
MmWidth uint32
|
|
|
|
MmHeight uint32
|
|
|
|
Connection byte
|
|
|
|
SubpixelOrder byte
|
|
|
|
NumCrtcs uint16
|
|
|
|
NumModes uint16
|
|
|
|
NumPreferred uint16
|
|
|
|
NumClones uint16
|
|
|
|
NameLen uint16
|
|
|
|
Crtcs []Crtc // size: xgb.Pad((int(NumCrtcs) * 4))
|
|
|
|
Modes []Mode // size: xgb.Pad((int(NumModes) * 4))
|
|
|
|
Clones []Output // size: xgb.Pad((int(NumClones) * 4))
|
|
|
|
Name []byte // size: xgb.Pad((int(NameLen) * 1))
|
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 GetOutputInfo request.
|
|
|
|
func (cook GetOutputInfoCookie) Reply() (*GetOutputInfoReply, error) {
|
|
|
|
buf, err := cook.Cookie.Reply()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if buf == nil {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
return getOutputInfoReply(buf), nil
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// getOutputInfoReply reads a byte slice into a GetOutputInfoReply value.
|
|
|
|
func getOutputInfoReply(buf []byte) *GetOutputInfoReply {
|
|
|
|
v := new(GetOutputInfoReply)
|
|
|
|
b := 1 // skip reply determinant
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Status = buf[b]
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
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.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:]))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Crtc = Crtc(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.MmWidth = xgb.Get32(buf[b:])
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.MmHeight = xgb.Get32(buf[b:])
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Connection = buf[b]
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.SubpixelOrder = buf[b]
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.NumCrtcs = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.NumModes = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.NumPreferred = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.NumClones = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.NameLen = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.Crtcs = make([]Crtc, v.NumCrtcs)
|
|
|
|
for i := 0; i < int(v.NumCrtcs); i++ {
|
|
|
|
v.Crtcs[i] = Crtc(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
}
|
|
|
|
b = xgb.Pad(b)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Modes = make([]Mode, v.NumModes)
|
|
|
|
for i := 0; i < int(v.NumModes); i++ {
|
|
|
|
v.Modes[i] = Mode(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2013-08-12 02:43:26 +02:00
|
|
|
b = xgb.Pad(b)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Clones = make([]Output, v.NumClones)
|
|
|
|
for i := 0; i < int(v.NumClones); i++ {
|
|
|
|
v.Clones[i] = Output(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
2012-05-12 05:58:52 +02:00
|
|
|
}
|
2013-08-12 02:43:26 +02:00
|
|
|
b = xgb.Pad(b)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Name = make([]byte, v.NameLen)
|
|
|
|
copy(v.Name[:v.NameLen], buf[b:])
|
|
|
|
b += xgb.Pad(int(v.NameLen))
|
|
|
|
|
|
|
|
return v
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for GetOutputInfo
|
|
|
|
// getOutputInfoRequest writes a GetOutputInfo request to a byte slice.
|
|
|
|
func getOutputInfoRequest(c *xgb.Conn, Output Output, ConfigTimestamp xproto.Timestamp) []byte {
|
|
|
|
size := 12
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 9 // 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(Output))
|
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(ConfigTimestamp))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetOutputPrimaryCookie is a cookie used only for GetOutputPrimary requests.
|
|
|
|
type GetOutputPrimaryCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetOutputPrimary sends a checked request.
|
|
|
|
// If an error occurs, it will be returned with the reply by calling GetOutputPrimaryCookie.Reply()
|
|
|
|
func GetOutputPrimary(c *xgb.Conn, Window xproto.Window) GetOutputPrimaryCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'GetOutputPrimary' using the uninitialized extension 'RANDR'. randr.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(getOutputPrimaryRequest(c, Window), cookie)
|
|
|
|
return GetOutputPrimaryCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetOutputPrimaryUnchecked sends an unchecked request.
|
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
|
|
|
func GetOutputPrimaryUnchecked(c *xgb.Conn, Window xproto.Window) GetOutputPrimaryCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'GetOutputPrimary' using the uninitialized extension 'RANDR'. randr.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(getOutputPrimaryRequest(c, Window), cookie)
|
|
|
|
return GetOutputPrimaryCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetOutputPrimaryReply represents the data returned from a GetOutputPrimary request.
|
|
|
|
type GetOutputPrimaryReply struct {
|
|
|
|
Sequence uint16 // sequence number of the request for this reply
|
|
|
|
Length uint32 // number of bytes in this reply
|
|
|
|
// padding: 1 bytes
|
|
|
|
Output Output
|
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 GetOutputPrimary request.
|
|
|
|
func (cook GetOutputPrimaryCookie) Reply() (*GetOutputPrimaryReply, error) {
|
|
|
|
buf, err := cook.Cookie.Reply()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if buf == nil {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
return getOutputPrimaryReply(buf), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// getOutputPrimaryReply reads a byte slice into a GetOutputPrimaryReply value.
|
|
|
|
func getOutputPrimaryReply(buf []byte) *GetOutputPrimaryReply {
|
|
|
|
v := new(GetOutputPrimaryReply)
|
|
|
|
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.Output = Output(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write request to wire for GetOutputPrimary
|
|
|
|
// getOutputPrimaryRequest writes a GetOutputPrimary request to a byte slice.
|
|
|
|
func getOutputPrimaryRequest(c *xgb.Conn, Window xproto.Window) []byte {
|
|
|
|
size := 8
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 31 // 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
|
|
|
// GetOutputPropertyCookie is a cookie used only for GetOutputProperty requests.
|
2012-05-10 23:01:42 +02:00
|
|
|
type GetOutputPropertyCookie struct {
|
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// GetOutputProperty sends a checked request.
|
|
|
|
// If an error occurs, it will be returned with the reply by calling GetOutputPropertyCookie.Reply()
|
2012-05-10 23:01:42 +02:00
|
|
|
func GetOutputProperty(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, LongOffset uint32, LongLength uint32, Delete bool, Pending bool) GetOutputPropertyCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
|
|
|
panic("Cannot issue request 'GetOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.")
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(true, true)
|
|
|
|
c.NewRequest(getOutputPropertyRequest(c, Output, Property, Type, LongOffset, LongLength, Delete, Pending), cookie)
|
|
|
|
return GetOutputPropertyCookie{cookie}
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// GetOutputPropertyUnchecked 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 GetOutputPropertyUnchecked(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, LongOffset uint32, LongLength uint32, Delete bool, Pending bool) GetOutputPropertyCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
|
|
|
panic("Cannot issue request 'GetOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.")
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(false, true)
|
|
|
|
c.NewRequest(getOutputPropertyRequest(c, Output, Property, Type, LongOffset, LongLength, Delete, Pending), cookie)
|
|
|
|
return GetOutputPropertyCookie{cookie}
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// GetOutputPropertyReply represents the data returned from a GetOutputProperty request.
|
2012-05-10 23:01:42 +02:00
|
|
|
type GetOutputPropertyReply 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
|
|
|
Format byte
|
|
|
|
Type xproto.Atom
|
|
|
|
BytesAfter uint32
|
|
|
|
NumItems uint32
|
|
|
|
// padding: 12 bytes
|
|
|
|
Data []byte // size: xgb.Pad(((int(NumItems) * (int(Format) / 8)) * 1))
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Reply blocks and returns the reply data for a GetOutputProperty request.
|
2012-05-10 23:01:42 +02:00
|
|
|
func (cook GetOutputPropertyCookie) Reply() (*GetOutputPropertyReply, error) {
|
|
|
|
buf, err := cook.Cookie.Reply()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if buf == nil {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
return getOutputPropertyReply(buf), nil
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// getOutputPropertyReply reads a byte slice into a GetOutputPropertyReply value.
|
2012-05-10 23:01:42 +02:00
|
|
|
func getOutputPropertyReply(buf []byte) *GetOutputPropertyReply {
|
|
|
|
v := new(GetOutputPropertyReply)
|
|
|
|
b := 1 // skip reply determinant
|
|
|
|
|
|
|
|
v.Format = buf[b]
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
v.Sequence = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.Length = xgb.Get32(buf[b:]) // 4-byte units
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Type = xproto.Atom(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.BytesAfter = xgb.Get32(buf[b:])
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.NumItems = xgb.Get32(buf[b:])
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
b += 12 // padding
|
|
|
|
|
|
|
|
v.Data = make([]byte, (int(v.NumItems) * (int(v.Format) / 8)))
|
|
|
|
copy(v.Data[:(int(v.NumItems)*(int(v.Format)/8))], buf[b:])
|
|
|
|
b += xgb.Pad(int((int(v.NumItems) * (int(v.Format) / 8))))
|
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write request to wire for GetOutputProperty
|
2012-05-11 05:57:34 +02:00
|
|
|
// getOutputPropertyRequest writes a GetOutputProperty request to a byte slice.
|
2012-05-10 23:01:42 +02:00
|
|
|
func getOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom, Type xproto.Atom, LongOffset uint32, LongLength uint32, Delete bool, Pending bool) []byte {
|
|
|
|
size := 28
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
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(Output))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(Property))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(Type))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], LongOffset)
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], LongLength)
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
if Delete {
|
|
|
|
buf[b] = 1
|
|
|
|
} else {
|
|
|
|
buf[b] = 0
|
|
|
|
}
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
if Pending {
|
|
|
|
buf[b] = 1
|
|
|
|
} else {
|
|
|
|
buf[b] = 0
|
|
|
|
}
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
b += 2 // padding
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetPanningCookie is a cookie used only for GetPanning requests.
|
|
|
|
type GetPanningCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetPanning sends a checked request.
|
|
|
|
// If an error occurs, it will be returned with the reply by calling GetPanningCookie.Reply()
|
|
|
|
func GetPanning(c *xgb.Conn, Crtc Crtc) GetPanningCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'GetPanning' using the uninitialized extension 'RANDR'. randr.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(getPanningRequest(c, Crtc), cookie)
|
|
|
|
return GetPanningCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetPanningUnchecked 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 GetPanningUnchecked(c *xgb.Conn, Crtc Crtc) GetPanningCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'GetPanning' using the uninitialized extension 'RANDR'. randr.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(getPanningRequest(c, Crtc), cookie)
|
|
|
|
return GetPanningCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetPanningReply represents the data returned from a GetPanning request.
|
|
|
|
type GetPanningReply struct {
|
|
|
|
Sequence uint16 // sequence number of the request for this reply
|
|
|
|
Length uint32 // number of bytes in this reply
|
|
|
|
Status byte
|
|
|
|
Timestamp xproto.Timestamp
|
|
|
|
Left uint16
|
|
|
|
Top uint16
|
|
|
|
Width uint16
|
|
|
|
Height uint16
|
|
|
|
TrackLeft uint16
|
|
|
|
TrackTop uint16
|
|
|
|
TrackWidth uint16
|
|
|
|
TrackHeight uint16
|
|
|
|
BorderLeft int16
|
|
|
|
BorderTop int16
|
|
|
|
BorderRight int16
|
|
|
|
BorderBottom int16
|
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 GetPanning request.
|
|
|
|
func (cook GetPanningCookie) Reply() (*GetPanningReply, 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 getPanningReply(buf), nil
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// getPanningReply reads a byte slice into a GetPanningReply value.
|
|
|
|
func getPanningReply(buf []byte) *GetPanningReply {
|
|
|
|
v := new(GetPanningReply)
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 1 // skip reply determinant
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Status = buf[b]
|
|
|
|
b += 1
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
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.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:]))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Left = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Top = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Width = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Height = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.TrackLeft = xgb.Get16(buf[b:])
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.TrackTop = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.TrackWidth = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.TrackHeight = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.BorderLeft = int16(xgb.Get16(buf[b:]))
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.BorderTop = int16(xgb.Get16(buf[b:]))
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.BorderRight = int16(xgb.Get16(buf[b:]))
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.BorderBottom = int16(xgb.Get16(buf[b:]))
|
|
|
|
b += 2
|
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
|
|
|
}
|
|
|
|
|
2013-12-28 15:25:18 +01:00
|
|
|
// Write request to wire for GetPanning
|
|
|
|
// getPanningRequest writes a GetPanning request to a byte slice.
|
|
|
|
func getPanningRequest(c *xgb.Conn, Crtc Crtc) []byte {
|
|
|
|
size := 8
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
buf[b] = 28 // 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(Crtc))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetProviderInfoCookie is a cookie used only for GetProviderInfo requests.
|
|
|
|
type GetProviderInfoCookie struct {
|
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetProviderInfo sends a checked request.
|
|
|
|
// If an error occurs, it will be returned with the reply by calling GetProviderInfoCookie.Reply()
|
|
|
|
func GetProviderInfo(c *xgb.Conn, Provider Provider, ConfigTimestamp xproto.Timestamp) GetProviderInfoCookie {
|
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
|
|
|
panic("Cannot issue request 'GetProviderInfo' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.")
|
|
|
|
}
|
|
|
|
cookie := c.NewCookie(true, true)
|
|
|
|
c.NewRequest(getProviderInfoRequest(c, Provider, ConfigTimestamp), cookie)
|
|
|
|
return GetProviderInfoCookie{cookie}
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetProviderInfoUnchecked sends an unchecked request.
|
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
|
|
|
func GetProviderInfoUnchecked(c *xgb.Conn, Provider Provider, ConfigTimestamp xproto.Timestamp) GetProviderInfoCookie {
|
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
|
|
|
panic("Cannot issue request 'GetProviderInfo' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.")
|
|
|
|
}
|
|
|
|
cookie := c.NewCookie(false, true)
|
|
|
|
c.NewRequest(getProviderInfoRequest(c, Provider, ConfigTimestamp), cookie)
|
|
|
|
return GetProviderInfoCookie{cookie}
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetProviderInfoReply represents the data returned from a GetProviderInfo request.
|
|
|
|
type GetProviderInfoReply struct {
|
|
|
|
Sequence uint16 // sequence number of the request for this reply
|
|
|
|
Length uint32 // number of bytes in this reply
|
|
|
|
Status byte
|
|
|
|
Timestamp xproto.Timestamp
|
|
|
|
Capabilities uint32
|
|
|
|
NumCrtcs uint16
|
|
|
|
NumOutputs uint16
|
|
|
|
NumAssociatedProviders uint16
|
|
|
|
NameLen uint16
|
|
|
|
// padding: 8 bytes
|
|
|
|
Crtcs []Crtc // size: xgb.Pad((int(NumCrtcs) * 4))
|
|
|
|
Outputs []Output // size: xgb.Pad((int(NumOutputs) * 4))
|
|
|
|
AssociatedProviders []Provider // size: xgb.Pad((int(NumAssociatedProviders) * 4))
|
|
|
|
AssociatedCapability []uint32 // size: xgb.Pad((int(NumAssociatedProviders) * 4))
|
|
|
|
Name string // size: xgb.Pad((int(NameLen) * 1))
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reply blocks and returns the reply data for a GetProviderInfo request.
|
|
|
|
func (cook GetProviderInfoCookie) Reply() (*GetProviderInfoReply, error) {
|
|
|
|
buf, err := cook.Cookie.Reply()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if buf == nil {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
return getProviderInfoReply(buf), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// getProviderInfoReply reads a byte slice into a GetProviderInfoReply value.
|
|
|
|
func getProviderInfoReply(buf []byte) *GetProviderInfoReply {
|
|
|
|
v := new(GetProviderInfoReply)
|
|
|
|
b := 1 // skip reply determinant
|
|
|
|
|
|
|
|
v.Status = buf[b]
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
v.Sequence = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.Length = xgb.Get32(buf[b:]) // 4-byte units
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Capabilities = xgb.Get32(buf[b:])
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.NumCrtcs = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.NumOutputs = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.NumAssociatedProviders = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.NameLen = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
b += 8 // padding
|
|
|
|
|
|
|
|
v.Crtcs = make([]Crtc, v.NumCrtcs)
|
|
|
|
for i := 0; i < int(v.NumCrtcs); i++ {
|
|
|
|
v.Crtcs[i] = Crtc(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
}
|
|
|
|
b = xgb.Pad(b)
|
|
|
|
|
|
|
|
v.Outputs = make([]Output, v.NumOutputs)
|
|
|
|
for i := 0; i < int(v.NumOutputs); i++ {
|
|
|
|
v.Outputs[i] = Output(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
}
|
|
|
|
b = xgb.Pad(b)
|
|
|
|
|
|
|
|
v.AssociatedProviders = make([]Provider, v.NumAssociatedProviders)
|
|
|
|
for i := 0; i < int(v.NumAssociatedProviders); i++ {
|
|
|
|
v.AssociatedProviders[i] = Provider(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
}
|
|
|
|
b = xgb.Pad(b)
|
|
|
|
|
|
|
|
v.AssociatedCapability = make([]uint32, v.NumAssociatedProviders)
|
|
|
|
for i := 0; i < int(v.NumAssociatedProviders); i++ {
|
|
|
|
v.AssociatedCapability[i] = xgb.Get32(buf[b:])
|
|
|
|
b += 4
|
|
|
|
}
|
|
|
|
b = xgb.Pad(b)
|
|
|
|
|
|
|
|
{
|
|
|
|
byteString := make([]byte, v.NameLen)
|
|
|
|
copy(byteString[:v.NameLen], buf[b:])
|
|
|
|
v.Name = string(byteString)
|
2013-12-28 16:02:18 +01:00
|
|
|
b += int(v.NameLen)
|
2013-12-28 15:25:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write request to wire for GetProviderInfo
|
|
|
|
// getProviderInfoRequest writes a GetProviderInfo request to a byte slice.
|
|
|
|
func getProviderInfoRequest(c *xgb.Conn, Provider Provider, ConfigTimestamp xproto.Timestamp) []byte {
|
|
|
|
size := 12
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
buf[b] = 33 // 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(Provider))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(ConfigTimestamp))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetProviderPropertyCookie is a cookie used only for GetProviderProperty requests.
|
|
|
|
type GetProviderPropertyCookie struct {
|
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetProviderProperty sends a checked request.
|
|
|
|
// If an error occurs, it will be returned with the reply by calling GetProviderPropertyCookie.Reply()
|
|
|
|
func GetProviderProperty(c *xgb.Conn, Provider Provider, Property xproto.Atom, Type xproto.Atom, LongOffset uint32, LongLength uint32, Delete bool, Pending bool) GetProviderPropertyCookie {
|
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
|
|
|
panic("Cannot issue request 'GetProviderProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.")
|
|
|
|
}
|
|
|
|
cookie := c.NewCookie(true, true)
|
|
|
|
c.NewRequest(getProviderPropertyRequest(c, Provider, Property, Type, LongOffset, LongLength, Delete, Pending), cookie)
|
|
|
|
return GetProviderPropertyCookie{cookie}
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetProviderPropertyUnchecked sends an unchecked request.
|
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
|
|
|
func GetProviderPropertyUnchecked(c *xgb.Conn, Provider Provider, Property xproto.Atom, Type xproto.Atom, LongOffset uint32, LongLength uint32, Delete bool, Pending bool) GetProviderPropertyCookie {
|
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
|
|
|
panic("Cannot issue request 'GetProviderProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.")
|
|
|
|
}
|
|
|
|
cookie := c.NewCookie(false, true)
|
|
|
|
c.NewRequest(getProviderPropertyRequest(c, Provider, Property, Type, LongOffset, LongLength, Delete, Pending), cookie)
|
|
|
|
return GetProviderPropertyCookie{cookie}
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetProviderPropertyReply represents the data returned from a GetProviderProperty request.
|
|
|
|
type GetProviderPropertyReply struct {
|
|
|
|
Sequence uint16 // sequence number of the request for this reply
|
|
|
|
Length uint32 // number of bytes in this reply
|
|
|
|
Format byte
|
|
|
|
Type xproto.Atom
|
|
|
|
BytesAfter uint32
|
|
|
|
NumItems uint32
|
|
|
|
// padding: 12 bytes
|
|
|
|
Data []byte // size: xgb.Pad(((int(NumItems) * (int(Format) / 8)) * 1))
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reply blocks and returns the reply data for a GetProviderProperty request.
|
|
|
|
func (cook GetProviderPropertyCookie) Reply() (*GetProviderPropertyReply, error) {
|
|
|
|
buf, err := cook.Cookie.Reply()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if buf == nil {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
return getProviderPropertyReply(buf), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// getProviderPropertyReply reads a byte slice into a GetProviderPropertyReply value.
|
|
|
|
func getProviderPropertyReply(buf []byte) *GetProviderPropertyReply {
|
|
|
|
v := new(GetProviderPropertyReply)
|
|
|
|
b := 1 // skip reply determinant
|
|
|
|
|
|
|
|
v.Format = buf[b]
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
v.Sequence = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.Length = xgb.Get32(buf[b:]) // 4-byte units
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Type = xproto.Atom(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.BytesAfter = xgb.Get32(buf[b:])
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.NumItems = xgb.Get32(buf[b:])
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
b += 12 // padding
|
|
|
|
|
|
|
|
v.Data = make([]byte, (int(v.NumItems) * (int(v.Format) / 8)))
|
|
|
|
copy(v.Data[:(int(v.NumItems)*(int(v.Format)/8))], buf[b:])
|
|
|
|
b += xgb.Pad(int((int(v.NumItems) * (int(v.Format) / 8))))
|
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write request to wire for GetProviderProperty
|
|
|
|
// getProviderPropertyRequest writes a GetProviderProperty request to a byte slice.
|
|
|
|
func getProviderPropertyRequest(c *xgb.Conn, Provider Provider, Property xproto.Atom, Type xproto.Atom, LongOffset uint32, LongLength uint32, Delete bool, Pending bool) []byte {
|
|
|
|
size := 28
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
buf[b] = 41 // 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(Provider))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(Property))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(Type))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], LongOffset)
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], LongLength)
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
if Delete {
|
|
|
|
buf[b] = 1
|
|
|
|
} else {
|
|
|
|
buf[b] = 0
|
|
|
|
}
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
if Pending {
|
|
|
|
buf[b] = 1
|
|
|
|
} else {
|
|
|
|
buf[b] = 0
|
|
|
|
}
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
b += 2 // padding
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetProvidersCookie is a cookie used only for GetProviders requests.
|
|
|
|
type GetProvidersCookie struct {
|
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetProviders sends a checked request.
|
|
|
|
// If an error occurs, it will be returned with the reply by calling GetProvidersCookie.Reply()
|
|
|
|
func GetProviders(c *xgb.Conn, Window xproto.Window) GetProvidersCookie {
|
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
|
|
|
panic("Cannot issue request 'GetProviders' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.")
|
|
|
|
}
|
|
|
|
cookie := c.NewCookie(true, true)
|
|
|
|
c.NewRequest(getProvidersRequest(c, Window), cookie)
|
|
|
|
return GetProvidersCookie{cookie}
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetProvidersUnchecked sends an unchecked request.
|
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
|
|
|
func GetProvidersUnchecked(c *xgb.Conn, Window xproto.Window) GetProvidersCookie {
|
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
|
|
|
panic("Cannot issue request 'GetProviders' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.")
|
|
|
|
}
|
|
|
|
cookie := c.NewCookie(false, true)
|
|
|
|
c.NewRequest(getProvidersRequest(c, Window), cookie)
|
|
|
|
return GetProvidersCookie{cookie}
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetProvidersReply represents the data returned from a GetProviders request.
|
|
|
|
type GetProvidersReply struct {
|
|
|
|
Sequence uint16 // sequence number of the request for this reply
|
|
|
|
Length uint32 // number of bytes in this reply
|
|
|
|
// padding: 1 bytes
|
|
|
|
Timestamp xproto.Timestamp
|
|
|
|
NumProviders uint16
|
|
|
|
// padding: 18 bytes
|
|
|
|
Providers []Provider // size: xgb.Pad((int(NumProviders) * 4))
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reply blocks and returns the reply data for a GetProviders request.
|
|
|
|
func (cook GetProvidersCookie) Reply() (*GetProvidersReply, error) {
|
|
|
|
buf, err := cook.Cookie.Reply()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if buf == nil {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
return getProvidersReply(buf), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// getProvidersReply reads a byte slice into a GetProvidersReply value.
|
|
|
|
func getProvidersReply(buf []byte) *GetProvidersReply {
|
|
|
|
v := new(GetProvidersReply)
|
|
|
|
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.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.NumProviders = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
b += 18 // padding
|
|
|
|
|
|
|
|
v.Providers = make([]Provider, v.NumProviders)
|
|
|
|
for i := 0; i < int(v.NumProviders); i++ {
|
|
|
|
v.Providers[i] = Provider(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
}
|
|
|
|
b = xgb.Pad(b)
|
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write request to wire for GetProviders
|
|
|
|
// getProvidersRequest writes a GetProviders request to a byte slice.
|
|
|
|
func getProvidersRequest(c *xgb.Conn, Window xproto.Window) []byte {
|
2012-05-10 23:01:42 +02:00
|
|
|
size := 8
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
b += 1
|
|
|
|
|
2013-12-28 15:25:18 +01:00
|
|
|
buf[b] = 32 // 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-12-28 15:25:18 +01:00
|
|
|
xgb.Put32(buf[b:], uint32(Window))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetScreenInfoCookie is a cookie used only for GetScreenInfo requests.
|
|
|
|
type GetScreenInfoCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetScreenInfo sends a checked request.
|
|
|
|
// If an error occurs, it will be returned with the reply by calling GetScreenInfoCookie.Reply()
|
|
|
|
func GetScreenInfo(c *xgb.Conn, Window xproto.Window) GetScreenInfoCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'GetScreenInfo' using the uninitialized extension 'RANDR'. randr.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(getScreenInfoRequest(c, Window), cookie)
|
|
|
|
return GetScreenInfoCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetScreenInfoUnchecked sends an unchecked request.
|
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
|
|
|
func GetScreenInfoUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenInfoCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'GetScreenInfo' using the uninitialized extension 'RANDR'. randr.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(getScreenInfoRequest(c, Window), cookie)
|
|
|
|
return GetScreenInfoCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetScreenInfoReply represents the data returned from a GetScreenInfo request.
|
|
|
|
type GetScreenInfoReply struct {
|
|
|
|
Sequence uint16 // sequence number of the request for this reply
|
|
|
|
Length uint32 // number of bytes in this reply
|
|
|
|
Rotations byte
|
|
|
|
Root xproto.Window
|
|
|
|
Timestamp xproto.Timestamp
|
|
|
|
ConfigTimestamp xproto.Timestamp
|
|
|
|
NSizes uint16
|
|
|
|
SizeID uint16
|
|
|
|
Rotation uint16
|
|
|
|
Rate uint16
|
|
|
|
NInfo uint16
|
|
|
|
// padding: 2 bytes
|
|
|
|
Sizes []ScreenSize // size: xgb.Pad((int(NSizes) * 8))
|
|
|
|
Rates []RefreshRates // size: RefreshRatesListSize(Rates)
|
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 GetScreenInfo request.
|
|
|
|
func (cook GetScreenInfoCookie) Reply() (*GetScreenInfoReply, error) {
|
|
|
|
buf, err := cook.Cookie.Reply()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if buf == nil {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
return getScreenInfoReply(buf), nil
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// getScreenInfoReply reads a byte slice into a GetScreenInfoReply value.
|
|
|
|
func getScreenInfoReply(buf []byte) *GetScreenInfoReply {
|
|
|
|
v := new(GetScreenInfoReply)
|
|
|
|
b := 1 // skip reply determinant
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Rotations = buf[b]
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
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.Root = xproto.Window(xgb.Get32(buf[b:]))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.ConfigTimestamp = xproto.Timestamp(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.NSizes = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.SizeID = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Rotation = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.Rate = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.NInfo = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
b += 2 // padding
|
|
|
|
|
|
|
|
v.Sizes = make([]ScreenSize, v.NSizes)
|
|
|
|
b += ScreenSizeReadList(buf[b:], v.Sizes)
|
|
|
|
|
|
|
|
v.Rates = make([]RefreshRates, (int(v.NInfo) - int(v.NSizes)))
|
|
|
|
b += RefreshRatesReadList(buf[b:], v.Rates)
|
|
|
|
|
|
|
|
return v
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for GetScreenInfo
|
|
|
|
// getScreenInfoRequest writes a GetScreenInfo request to a byte slice.
|
|
|
|
func getScreenInfoRequest(c *xgb.Conn, Window xproto.Window) []byte {
|
|
|
|
size := 8
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetScreenResourcesCookie is a cookie used only for GetScreenResources requests.
|
|
|
|
type GetScreenResourcesCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetScreenResources sends a checked request.
|
|
|
|
// If an error occurs, it will be returned with the reply by calling GetScreenResourcesCookie.Reply()
|
|
|
|
func GetScreenResources(c *xgb.Conn, Window xproto.Window) GetScreenResourcesCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'GetScreenResources' using the uninitialized extension 'RANDR'. randr.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(getScreenResourcesRequest(c, Window), cookie)
|
|
|
|
return GetScreenResourcesCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetScreenResourcesUnchecked 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 GetScreenResourcesUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenResourcesCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'GetScreenResources' using the uninitialized extension 'RANDR'. randr.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(getScreenResourcesRequest(c, Window), cookie)
|
|
|
|
return GetScreenResourcesCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetScreenResourcesReply represents the data returned from a GetScreenResources request.
|
|
|
|
type GetScreenResourcesReply struct {
|
|
|
|
Sequence uint16 // sequence number of the request for this reply
|
|
|
|
Length uint32 // number of bytes in this reply
|
|
|
|
// padding: 1 bytes
|
|
|
|
Timestamp xproto.Timestamp
|
|
|
|
ConfigTimestamp xproto.Timestamp
|
|
|
|
NumCrtcs uint16
|
|
|
|
NumOutputs uint16
|
|
|
|
NumModes uint16
|
|
|
|
NamesLen uint16
|
|
|
|
// padding: 8 bytes
|
|
|
|
Crtcs []Crtc // size: xgb.Pad((int(NumCrtcs) * 4))
|
|
|
|
Outputs []Output // size: xgb.Pad((int(NumOutputs) * 4))
|
|
|
|
Modes []ModeInfo // size: xgb.Pad((int(NumModes) * 32))
|
|
|
|
Names []byte // size: xgb.Pad((int(NamesLen) * 1))
|
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 GetScreenResources request.
|
|
|
|
func (cook GetScreenResourcesCookie) Reply() (*GetScreenResourcesReply, 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 getScreenResourcesReply(buf), nil
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// getScreenResourcesReply reads a byte slice into a GetScreenResourcesReply value.
|
|
|
|
func getScreenResourcesReply(buf []byte) *GetScreenResourcesReply {
|
|
|
|
v := new(GetScreenResourcesReply)
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 1 // skip reply determinant
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b += 1 // padding
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
v.Sequence = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.Length = xgb.Get32(buf[b:]) // 4-byte units
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.ConfigTimestamp = xproto.Timestamp(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.NumCrtcs = xgb.Get16(buf[b:])
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.NumOutputs = xgb.Get16(buf[b:])
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.NumModes = xgb.Get16(buf[b:])
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.NamesLen = xgb.Get16(buf[b:])
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b += 8 // padding
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Crtcs = make([]Crtc, v.NumCrtcs)
|
|
|
|
for i := 0; i < int(v.NumCrtcs); i++ {
|
|
|
|
v.Crtcs[i] = Crtc(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
}
|
|
|
|
b = xgb.Pad(b)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
v.Outputs = make([]Output, v.NumOutputs)
|
|
|
|
for i := 0; i < int(v.NumOutputs); i++ {
|
|
|
|
v.Outputs[i] = Output(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
}
|
|
|
|
b = xgb.Pad(b)
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Modes = make([]ModeInfo, v.NumModes)
|
|
|
|
b += ModeInfoReadList(buf[b:], v.Modes)
|
|
|
|
|
|
|
|
v.Names = make([]byte, v.NamesLen)
|
|
|
|
copy(v.Names[:v.NamesLen], buf[b:])
|
|
|
|
b += xgb.Pad(int(v.NamesLen))
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for GetScreenResources
|
|
|
|
// getScreenResourcesRequest writes a GetScreenResources request to a byte slice.
|
|
|
|
func getScreenResourcesRequest(c *xgb.Conn, Window xproto.Window) []byte {
|
|
|
|
size := 8
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
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(Window))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetScreenResourcesCurrentCookie is a cookie used only for GetScreenResourcesCurrent requests.
|
|
|
|
type GetScreenResourcesCurrentCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetScreenResourcesCurrent sends a checked request.
|
|
|
|
// If an error occurs, it will be returned with the reply by calling GetScreenResourcesCurrentCookie.Reply()
|
|
|
|
func GetScreenResourcesCurrent(c *xgb.Conn, Window xproto.Window) GetScreenResourcesCurrentCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'GetScreenResourcesCurrent' using the uninitialized extension 'RANDR'. randr.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(getScreenResourcesCurrentRequest(c, Window), cookie)
|
|
|
|
return GetScreenResourcesCurrentCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetScreenResourcesCurrentUnchecked 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 GetScreenResourcesCurrentUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenResourcesCurrentCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'GetScreenResourcesCurrent' using the uninitialized extension 'RANDR'. randr.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(getScreenResourcesCurrentRequest(c, Window), cookie)
|
|
|
|
return GetScreenResourcesCurrentCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetScreenResourcesCurrentReply represents the data returned from a GetScreenResourcesCurrent request.
|
|
|
|
type GetScreenResourcesCurrentReply struct {
|
|
|
|
Sequence uint16 // sequence number of the request for this reply
|
|
|
|
Length uint32 // number of bytes in this reply
|
|
|
|
// padding: 1 bytes
|
|
|
|
Timestamp xproto.Timestamp
|
|
|
|
ConfigTimestamp xproto.Timestamp
|
|
|
|
NumCrtcs uint16
|
|
|
|
NumOutputs uint16
|
|
|
|
NumModes uint16
|
|
|
|
NamesLen uint16
|
|
|
|
// padding: 8 bytes
|
|
|
|
Crtcs []Crtc // size: xgb.Pad((int(NumCrtcs) * 4))
|
|
|
|
Outputs []Output // size: xgb.Pad((int(NumOutputs) * 4))
|
|
|
|
Modes []ModeInfo // size: xgb.Pad((int(NumModes) * 32))
|
|
|
|
Names []byte // size: xgb.Pad((int(NamesLen) * 1))
|
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 GetScreenResourcesCurrent request.
|
|
|
|
func (cook GetScreenResourcesCurrentCookie) Reply() (*GetScreenResourcesCurrentReply, 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 getScreenResourcesCurrentReply(buf), nil
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// getScreenResourcesCurrentReply reads a byte slice into a GetScreenResourcesCurrentReply value.
|
|
|
|
func getScreenResourcesCurrentReply(buf []byte) *GetScreenResourcesCurrentReply {
|
|
|
|
v := new(GetScreenResourcesCurrentReply)
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 1 // skip reply determinant
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b += 1 // padding
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
v.Sequence = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.Length = xgb.Get32(buf[b:]) // 4-byte units
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.ConfigTimestamp = xproto.Timestamp(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.NumCrtcs = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.NumOutputs = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.NumModes = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.NamesLen = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
b += 8 // padding
|
|
|
|
|
|
|
|
v.Crtcs = make([]Crtc, v.NumCrtcs)
|
|
|
|
for i := 0; i < int(v.NumCrtcs); i++ {
|
|
|
|
v.Crtcs[i] = Crtc(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
}
|
|
|
|
b = xgb.Pad(b)
|
|
|
|
|
|
|
|
v.Outputs = make([]Output, v.NumOutputs)
|
|
|
|
for i := 0; i < int(v.NumOutputs); i++ {
|
|
|
|
v.Outputs[i] = Output(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
}
|
|
|
|
b = xgb.Pad(b)
|
|
|
|
|
|
|
|
v.Modes = make([]ModeInfo, v.NumModes)
|
|
|
|
b += ModeInfoReadList(buf[b:], v.Modes)
|
|
|
|
|
|
|
|
v.Names = make([]byte, v.NamesLen)
|
|
|
|
copy(v.Names[:v.NamesLen], buf[b:])
|
|
|
|
b += xgb.Pad(int(v.NamesLen))
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for GetScreenResourcesCurrent
|
|
|
|
// getScreenResourcesCurrentRequest writes a GetScreenResourcesCurrent request to a byte slice.
|
|
|
|
func getScreenResourcesCurrentRequest(c *xgb.Conn, Window xproto.Window) []byte {
|
|
|
|
size := 8
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 25 // 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
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetScreenSizeRangeCookie is a cookie used only for GetScreenSizeRange requests.
|
|
|
|
type GetScreenSizeRangeCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetScreenSizeRange sends a checked request.
|
|
|
|
// If an error occurs, it will be returned with the reply by calling GetScreenSizeRangeCookie.Reply()
|
|
|
|
func GetScreenSizeRange(c *xgb.Conn, Window xproto.Window) GetScreenSizeRangeCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'GetScreenSizeRange' using the uninitialized extension 'RANDR'. randr.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(getScreenSizeRangeRequest(c, Window), cookie)
|
|
|
|
return GetScreenSizeRangeCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetScreenSizeRangeUnchecked 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 GetScreenSizeRangeUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenSizeRangeCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'GetScreenSizeRange' using the uninitialized extension 'RANDR'. randr.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(getScreenSizeRangeRequest(c, Window), cookie)
|
|
|
|
return GetScreenSizeRangeCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// GetScreenSizeRangeReply represents the data returned from a GetScreenSizeRange request.
|
|
|
|
type GetScreenSizeRangeReply 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
|
2013-08-12 02:43:26 +02:00
|
|
|
// padding: 1 bytes
|
|
|
|
MinWidth uint16
|
|
|
|
MinHeight uint16
|
|
|
|
MaxWidth uint16
|
|
|
|
MaxHeight uint16
|
|
|
|
// padding: 16 bytes
|
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 GetScreenSizeRange request.
|
|
|
|
func (cook GetScreenSizeRangeCookie) Reply() (*GetScreenSizeRangeReply, 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 getScreenSizeRangeReply(buf), nil
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// getScreenSizeRangeReply reads a byte slice into a GetScreenSizeRangeReply value.
|
|
|
|
func getScreenSizeRangeReply(buf []byte) *GetScreenSizeRangeReply {
|
|
|
|
v := new(GetScreenSizeRangeReply)
|
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.MinWidth = xgb.Get16(buf[b:])
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.MinHeight = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.MaxWidth = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.MaxHeight = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
b += 16 // padding
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for GetScreenSizeRange
|
|
|
|
// getScreenSizeRangeRequest writes a GetScreenSizeRange request to a byte slice.
|
|
|
|
func getScreenSizeRangeRequest(c *xgb.Conn, Window xproto.Window) []byte {
|
2012-05-10 23:01:42 +02:00
|
|
|
size := 8
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// ListOutputPropertiesCookie is a cookie used only for ListOutputProperties requests.
|
|
|
|
type ListOutputPropertiesCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// ListOutputProperties sends a checked request.
|
|
|
|
// If an error occurs, it will be returned with the reply by calling ListOutputPropertiesCookie.Reply()
|
|
|
|
func ListOutputProperties(c *xgb.Conn, Output Output) ListOutputPropertiesCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'ListOutputProperties' using the uninitialized extension 'RANDR'. randr.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(listOutputPropertiesRequest(c, Output), cookie)
|
|
|
|
return ListOutputPropertiesCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// ListOutputPropertiesUnchecked 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 ListOutputPropertiesUnchecked(c *xgb.Conn, Output Output) ListOutputPropertiesCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'ListOutputProperties' using the uninitialized extension 'RANDR'. randr.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(listOutputPropertiesRequest(c, Output), cookie)
|
|
|
|
return ListOutputPropertiesCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// ListOutputPropertiesReply represents the data returned from a ListOutputProperties request.
|
|
|
|
type ListOutputPropertiesReply 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
|
|
|
NumAtoms uint16
|
2012-05-10 23:01:42 +02:00
|
|
|
// padding: 22 bytes
|
2013-08-12 02:43:26 +02:00
|
|
|
Atoms []xproto.Atom // size: xgb.Pad((int(NumAtoms) * 4))
|
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 ListOutputProperties request.
|
|
|
|
func (cook ListOutputPropertiesCookie) Reply() (*ListOutputPropertiesReply, 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 listOutputPropertiesReply(buf), nil
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// listOutputPropertiesReply reads a byte slice into a ListOutputPropertiesReply value.
|
|
|
|
func listOutputPropertiesReply(buf []byte) *ListOutputPropertiesReply {
|
|
|
|
v := new(ListOutputPropertiesReply)
|
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.NumAtoms = xgb.Get16(buf[b:])
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
|
|
|
b += 22 // padding
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.Atoms = make([]xproto.Atom, v.NumAtoms)
|
|
|
|
for i := 0; i < int(v.NumAtoms); i++ {
|
|
|
|
v.Atoms[i] = xproto.Atom(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
b = xgb.Pad(b)
|
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for ListOutputProperties
|
|
|
|
// listOutputPropertiesRequest writes a ListOutputProperties request to a byte slice.
|
|
|
|
func listOutputPropertiesRequest(c *xgb.Conn, Output Output) []byte {
|
2012-05-10 23:01:42 +02:00
|
|
|
size := 8
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
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
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Output))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-12-28 15:25:18 +01:00
|
|
|
// ListProviderPropertiesCookie is a cookie used only for ListProviderProperties requests.
|
|
|
|
type ListProviderPropertiesCookie struct {
|
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
|
|
|
// ListProviderProperties sends a checked request.
|
|
|
|
// If an error occurs, it will be returned with the reply by calling ListProviderPropertiesCookie.Reply()
|
|
|
|
func ListProviderProperties(c *xgb.Conn, Provider Provider) ListProviderPropertiesCookie {
|
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
|
|
|
panic("Cannot issue request 'ListProviderProperties' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.")
|
|
|
|
}
|
|
|
|
cookie := c.NewCookie(true, true)
|
|
|
|
c.NewRequest(listProviderPropertiesRequest(c, Provider), cookie)
|
|
|
|
return ListProviderPropertiesCookie{cookie}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ListProviderPropertiesUnchecked sends an unchecked request.
|
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
|
|
|
func ListProviderPropertiesUnchecked(c *xgb.Conn, Provider Provider) ListProviderPropertiesCookie {
|
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
|
|
|
panic("Cannot issue request 'ListProviderProperties' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.")
|
|
|
|
}
|
|
|
|
cookie := c.NewCookie(false, true)
|
|
|
|
c.NewRequest(listProviderPropertiesRequest(c, Provider), cookie)
|
|
|
|
return ListProviderPropertiesCookie{cookie}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ListProviderPropertiesReply represents the data returned from a ListProviderProperties request.
|
|
|
|
type ListProviderPropertiesReply struct {
|
|
|
|
Sequence uint16 // sequence number of the request for this reply
|
|
|
|
Length uint32 // number of bytes in this reply
|
|
|
|
// padding: 1 bytes
|
|
|
|
NumAtoms uint16
|
|
|
|
// padding: 22 bytes
|
|
|
|
Atoms []xproto.Atom // size: xgb.Pad((int(NumAtoms) * 4))
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reply blocks and returns the reply data for a ListProviderProperties request.
|
|
|
|
func (cook ListProviderPropertiesCookie) Reply() (*ListProviderPropertiesReply, error) {
|
|
|
|
buf, err := cook.Cookie.Reply()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if buf == nil {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
return listProviderPropertiesReply(buf), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// listProviderPropertiesReply reads a byte slice into a ListProviderPropertiesReply value.
|
|
|
|
func listProviderPropertiesReply(buf []byte) *ListProviderPropertiesReply {
|
|
|
|
v := new(ListProviderPropertiesReply)
|
|
|
|
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.NumAtoms = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
b += 22 // padding
|
|
|
|
|
|
|
|
v.Atoms = make([]xproto.Atom, v.NumAtoms)
|
|
|
|
for i := 0; i < int(v.NumAtoms); i++ {
|
|
|
|
v.Atoms[i] = xproto.Atom(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
}
|
|
|
|
b = xgb.Pad(b)
|
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write request to wire for ListProviderProperties
|
|
|
|
// listProviderPropertiesRequest writes a ListProviderProperties request to a byte slice.
|
|
|
|
func listProviderPropertiesRequest(c *xgb.Conn, Provider Provider) []byte {
|
|
|
|
size := 8
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
buf[b] = 36 // 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(Provider))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// QueryOutputPropertyCookie is a cookie used only for QueryOutputProperty requests.
|
|
|
|
type QueryOutputPropertyCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// QueryOutputProperty sends a checked request.
|
|
|
|
// If an error occurs, it will be returned with the reply by calling QueryOutputPropertyCookie.Reply()
|
|
|
|
func QueryOutputProperty(c *xgb.Conn, Output Output, Property xproto.Atom) QueryOutputPropertyCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'QueryOutputProperty' using the uninitialized extension 'RANDR'. randr.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(queryOutputPropertyRequest(c, Output, Property), cookie)
|
|
|
|
return QueryOutputPropertyCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// QueryOutputPropertyUnchecked sends an unchecked request.
|
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
|
|
|
func QueryOutputPropertyUnchecked(c *xgb.Conn, Output Output, Property xproto.Atom) QueryOutputPropertyCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'QueryOutputProperty' using the uninitialized extension 'RANDR'. randr.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(queryOutputPropertyRequest(c, Output, Property), cookie)
|
|
|
|
return QueryOutputPropertyCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// QueryOutputPropertyReply represents the data returned from a QueryOutputProperty request.
|
|
|
|
type QueryOutputPropertyReply struct {
|
|
|
|
Sequence uint16 // sequence number of the request for this reply
|
|
|
|
Length uint32 // number of bytes in this reply
|
|
|
|
// padding: 1 bytes
|
|
|
|
Pending bool
|
|
|
|
Range bool
|
|
|
|
Immutable bool
|
|
|
|
// padding: 21 bytes
|
|
|
|
ValidValues []int32 // size: xgb.Pad((int(Length) * 4))
|
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 QueryOutputProperty request.
|
|
|
|
func (cook QueryOutputPropertyCookie) Reply() (*QueryOutputPropertyReply, error) {
|
|
|
|
buf, err := cook.Cookie.Reply()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if buf == nil {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
return queryOutputPropertyReply(buf), nil
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// queryOutputPropertyReply reads a byte slice into a QueryOutputPropertyReply value.
|
|
|
|
func queryOutputPropertyReply(buf []byte) *QueryOutputPropertyReply {
|
|
|
|
v := new(QueryOutputPropertyReply)
|
|
|
|
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
|
|
|
if buf[b] == 1 {
|
|
|
|
v.Pending = true
|
|
|
|
} else {
|
|
|
|
v.Pending = false
|
|
|
|
}
|
|
|
|
b += 1
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
if buf[b] == 1 {
|
|
|
|
v.Range = true
|
|
|
|
} else {
|
|
|
|
v.Range = false
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
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
|
|
|
if buf[b] == 1 {
|
|
|
|
v.Immutable = true
|
|
|
|
} else {
|
|
|
|
v.Immutable = false
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
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
|
|
|
b += 21 // padding
|
|
|
|
|
|
|
|
v.ValidValues = make([]int32, v.Length)
|
|
|
|
for i := 0; i < int(v.Length); i++ {
|
|
|
|
v.ValidValues[i] = int32(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
b = xgb.Pad(b)
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write request to wire for QueryOutputProperty
|
|
|
|
// queryOutputPropertyRequest writes a QueryOutputProperty request to a byte slice.
|
|
|
|
func queryOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom) []byte {
|
|
|
|
size := 12
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
buf[b] = 11 // request opcode
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(Output))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(Property))
|
|
|
|
b += 4
|
|
|
|
|
2012-05-10 23:01:42 +02:00
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-12-28 15:25:18 +01:00
|
|
|
// QueryProviderPropertyCookie is a cookie used only for QueryProviderProperty requests.
|
|
|
|
type QueryProviderPropertyCookie struct {
|
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
|
|
|
// QueryProviderProperty sends a checked request.
|
|
|
|
// If an error occurs, it will be returned with the reply by calling QueryProviderPropertyCookie.Reply()
|
|
|
|
func QueryProviderProperty(c *xgb.Conn, Provider Provider, Property xproto.Atom) QueryProviderPropertyCookie {
|
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
|
|
|
panic("Cannot issue request 'QueryProviderProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.")
|
|
|
|
}
|
|
|
|
cookie := c.NewCookie(true, true)
|
|
|
|
c.NewRequest(queryProviderPropertyRequest(c, Provider, Property), cookie)
|
|
|
|
return QueryProviderPropertyCookie{cookie}
|
|
|
|
}
|
|
|
|
|
|
|
|
// QueryProviderPropertyUnchecked sends an unchecked request.
|
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
|
|
|
func QueryProviderPropertyUnchecked(c *xgb.Conn, Provider Provider, Property xproto.Atom) QueryProviderPropertyCookie {
|
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
|
|
|
panic("Cannot issue request 'QueryProviderProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.")
|
|
|
|
}
|
|
|
|
cookie := c.NewCookie(false, true)
|
|
|
|
c.NewRequest(queryProviderPropertyRequest(c, Provider, Property), cookie)
|
|
|
|
return QueryProviderPropertyCookie{cookie}
|
|
|
|
}
|
|
|
|
|
|
|
|
// QueryProviderPropertyReply represents the data returned from a QueryProviderProperty request.
|
|
|
|
type QueryProviderPropertyReply struct {
|
|
|
|
Sequence uint16 // sequence number of the request for this reply
|
|
|
|
Length uint32 // number of bytes in this reply
|
|
|
|
// padding: 1 bytes
|
|
|
|
Pending bool
|
|
|
|
Range bool
|
|
|
|
Immutable bool
|
|
|
|
// padding: 21 bytes
|
|
|
|
ValidValues []int32 // size: xgb.Pad((int(Length) * 4))
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reply blocks and returns the reply data for a QueryProviderProperty request.
|
|
|
|
func (cook QueryProviderPropertyCookie) Reply() (*QueryProviderPropertyReply, error) {
|
|
|
|
buf, err := cook.Cookie.Reply()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if buf == nil {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
return queryProviderPropertyReply(buf), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// queryProviderPropertyReply reads a byte slice into a QueryProviderPropertyReply value.
|
|
|
|
func queryProviderPropertyReply(buf []byte) *QueryProviderPropertyReply {
|
|
|
|
v := new(QueryProviderPropertyReply)
|
|
|
|
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
|
|
|
|
|
|
|
|
if buf[b] == 1 {
|
|
|
|
v.Pending = true
|
|
|
|
} else {
|
|
|
|
v.Pending = false
|
|
|
|
}
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
if buf[b] == 1 {
|
|
|
|
v.Range = true
|
|
|
|
} else {
|
|
|
|
v.Range = false
|
|
|
|
}
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
if buf[b] == 1 {
|
|
|
|
v.Immutable = true
|
|
|
|
} else {
|
|
|
|
v.Immutable = false
|
|
|
|
}
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
b += 21 // padding
|
|
|
|
|
|
|
|
v.ValidValues = make([]int32, v.Length)
|
|
|
|
for i := 0; i < int(v.Length); i++ {
|
|
|
|
v.ValidValues[i] = int32(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
}
|
|
|
|
b = xgb.Pad(b)
|
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write request to wire for QueryProviderProperty
|
|
|
|
// queryProviderPropertyRequest writes a QueryProviderProperty request to a byte slice.
|
|
|
|
func queryProviderPropertyRequest(c *xgb.Conn, Provider Provider, Property xproto.Atom) []byte {
|
|
|
|
size := 12
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
buf[b] = 37 // 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(Provider))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(Property))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// QueryVersionCookie is a cookie used only for QueryVersion requests.
|
|
|
|
type QueryVersionCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// QueryVersion sends a checked request.
|
|
|
|
// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply()
|
|
|
|
func QueryVersion(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'RANDR'. randr.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(queryVersionRequest(c, MajorVersion, MinorVersion), cookie)
|
|
|
|
return QueryVersionCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// QueryVersionUnchecked 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 QueryVersionUnchecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'RANDR'. randr.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(queryVersionRequest(c, MajorVersion, MinorVersion), cookie)
|
|
|
|
return QueryVersionCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// QueryVersionReply represents the data returned from a QueryVersion request.
|
|
|
|
type QueryVersionReply 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
|
|
|
MajorVersion uint32
|
|
|
|
MinorVersion uint32
|
|
|
|
// padding: 16 bytes
|
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 QueryVersion request.
|
|
|
|
func (cook QueryVersionCookie) Reply() (*QueryVersionReply, 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 queryVersionReply(buf), nil
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// queryVersionReply reads a byte slice into a QueryVersionReply value.
|
|
|
|
func queryVersionReply(buf []byte) *QueryVersionReply {
|
|
|
|
v := new(QueryVersionReply)
|
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.MajorVersion = xgb.Get32(buf[b:])
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
v.MinorVersion = xgb.Get32(buf[b:])
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b += 16 // padding
|
2012-05-10 23:01:42 +02:00
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for QueryVersion
|
|
|
|
// queryVersionRequest writes a QueryVersion request to a byte slice.
|
|
|
|
func queryVersionRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) []byte {
|
|
|
|
size := 12
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
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
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], MajorVersion)
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], MinorVersion)
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SelectInputCookie is a cookie used only for SelectInput requests.
|
|
|
|
type SelectInputCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SelectInput 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 SelectInput(c *xgb.Conn, Window xproto.Window, Enable uint16) SelectInputCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'SelectInput' using the uninitialized extension 'RANDR'. randr.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(selectInputRequest(c, Window, Enable), cookie)
|
|
|
|
return SelectInputCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SelectInputChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using SelectInputCookie.Check()
|
|
|
|
func SelectInputChecked(c *xgb.Conn, Window xproto.Window, Enable uint16) SelectInputCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'SelectInput' using the uninitialized extension 'RANDR'. randr.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(selectInputRequest(c, Window, Enable), cookie)
|
|
|
|
return SelectInputCookie{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 SelectInputCookie) Check() error {
|
2012-05-10 23:01:42 +02:00
|
|
|
return cook.Cookie.Check()
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for SelectInput
|
|
|
|
// selectInputRequest writes a SelectInput request to a byte slice.
|
|
|
|
func selectInputRequest(c *xgb.Conn, Window xproto.Window, Enable uint16) []byte {
|
|
|
|
size := 12
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 4 // 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
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], Enable)
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
|
|
|
b += 2 // padding
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SetCrtcConfigCookie is a cookie used only for SetCrtcConfig requests.
|
|
|
|
type SetCrtcConfigCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SetCrtcConfig sends a checked request.
|
|
|
|
// If an error occurs, it will be returned with the reply by calling SetCrtcConfigCookie.Reply()
|
|
|
|
func SetCrtcConfig(c *xgb.Conn, Crtc Crtc, Timestamp xproto.Timestamp, ConfigTimestamp xproto.Timestamp, X int16, Y int16, Mode Mode, Rotation uint16, Outputs []Output) SetCrtcConfigCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'SetCrtcConfig' using the uninitialized extension 'RANDR'. randr.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(setCrtcConfigRequest(c, Crtc, Timestamp, ConfigTimestamp, X, Y, Mode, Rotation, Outputs), cookie)
|
|
|
|
return SetCrtcConfigCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SetCrtcConfigUnchecked 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 SetCrtcConfigUnchecked(c *xgb.Conn, Crtc Crtc, Timestamp xproto.Timestamp, ConfigTimestamp xproto.Timestamp, X int16, Y int16, Mode Mode, Rotation uint16, Outputs []Output) SetCrtcConfigCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'SetCrtcConfig' using the uninitialized extension 'RANDR'. randr.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(setCrtcConfigRequest(c, Crtc, Timestamp, ConfigTimestamp, X, Y, Mode, Rotation, Outputs), cookie)
|
|
|
|
return SetCrtcConfigCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SetCrtcConfigReply represents the data returned from a SetCrtcConfig request.
|
|
|
|
type SetCrtcConfigReply struct {
|
|
|
|
Sequence uint16 // sequence number of the request for this reply
|
|
|
|
Length uint32 // number of bytes in this reply
|
|
|
|
Status byte
|
|
|
|
Timestamp xproto.Timestamp
|
|
|
|
// padding: 20 bytes
|
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 SetCrtcConfig request.
|
|
|
|
func (cook SetCrtcConfigCookie) Reply() (*SetCrtcConfigReply, 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 setCrtcConfigReply(buf), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// setCrtcConfigReply reads a byte slice into a SetCrtcConfigReply value.
|
|
|
|
func setCrtcConfigReply(buf []byte) *SetCrtcConfigReply {
|
|
|
|
v := new(SetCrtcConfigReply)
|
|
|
|
b := 1 // skip reply determinant
|
|
|
|
|
|
|
|
v.Status = buf[b]
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
v.Sequence = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.Length = xgb.Get32(buf[b:]) // 4-byte units
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
b += 20 // padding
|
|
|
|
|
|
|
|
return v
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for SetCrtcConfig
|
|
|
|
// setCrtcConfigRequest writes a SetCrtcConfig request to a byte slice.
|
|
|
|
func setCrtcConfigRequest(c *xgb.Conn, Crtc Crtc, Timestamp xproto.Timestamp, ConfigTimestamp xproto.Timestamp, X int16, Y int16, Mode Mode, Rotation uint16, Outputs []Output) []byte {
|
|
|
|
size := xgb.Pad((28 + xgb.Pad((len(Outputs) * 4))))
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
b += 1
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 21 // 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(Crtc))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Timestamp))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(ConfigTimestamp))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], uint16(X))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], uint16(Y))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Mode))
|
|
|
|
b += 4
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], Rotation)
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b += 2 // padding
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
for i := 0; i < int(len(Outputs)); i++ {
|
|
|
|
xgb.Put32(buf[b:], uint32(Outputs[i]))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
}
|
|
|
|
b = xgb.Pad(b)
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetCrtcGammaCookie is a cookie used only for SetCrtcGamma requests.
|
|
|
|
type SetCrtcGammaCookie struct {
|
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetCrtcGamma sends an unchecked request.
|
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
|
|
|
func SetCrtcGamma(c *xgb.Conn, Crtc Crtc, Size uint16, Red []uint16, Green []uint16, Blue []uint16) SetCrtcGammaCookie {
|
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
|
|
|
panic("Cannot issue request 'SetCrtcGamma' using the uninitialized extension 'RANDR'. randr.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(false, false)
|
|
|
|
c.NewRequest(setCrtcGammaRequest(c, Crtc, Size, Red, Green, Blue), cookie)
|
|
|
|
return SetCrtcGammaCookie{cookie}
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SetCrtcGammaChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using SetCrtcGammaCookie.Check()
|
|
|
|
func SetCrtcGammaChecked(c *xgb.Conn, Crtc Crtc, Size uint16, Red []uint16, Green []uint16, Blue []uint16) SetCrtcGammaCookie {
|
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
|
|
|
panic("Cannot issue request 'SetCrtcGamma' using the uninitialized extension 'RANDR'. randr.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(setCrtcGammaRequest(c, Crtc, Size, Red, Green, Blue), cookie)
|
|
|
|
return SetCrtcGammaCookie{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 SetCrtcGammaCookie) Check() error {
|
|
|
|
return cook.Cookie.Check()
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for SetCrtcGamma
|
|
|
|
// setCrtcGammaRequest writes a SetCrtcGamma request to a byte slice.
|
|
|
|
func setCrtcGammaRequest(c *xgb.Conn, Crtc Crtc, Size uint16, Red []uint16, Green []uint16, Blue []uint16) []byte {
|
|
|
|
size := xgb.Pad((((12 + xgb.Pad((int(Size) * 2))) + xgb.Pad((int(Size) * 2))) + xgb.Pad((int(Size) * 2))))
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 24 // 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(Crtc))
|
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], Size)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
b += 2 // padding
|
|
|
|
|
|
|
|
for i := 0; i < int(Size); i++ {
|
|
|
|
xgb.Put16(buf[b:], Red[i])
|
|
|
|
b += 2
|
|
|
|
}
|
|
|
|
b = xgb.Pad(b)
|
|
|
|
|
|
|
|
for i := 0; i < int(Size); i++ {
|
|
|
|
xgb.Put16(buf[b:], Green[i])
|
|
|
|
b += 2
|
|
|
|
}
|
|
|
|
b = xgb.Pad(b)
|
|
|
|
|
|
|
|
for i := 0; i < int(Size); i++ {
|
|
|
|
xgb.Put16(buf[b:], Blue[i])
|
|
|
|
b += 2
|
|
|
|
}
|
|
|
|
b = xgb.Pad(b)
|
|
|
|
|
2012-05-10 23:01:42 +02:00
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SetCrtcTransformCookie is a cookie used only for SetCrtcTransform requests.
|
|
|
|
type SetCrtcTransformCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SetCrtcTransform sends an unchecked request.
|
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
|
|
|
func SetCrtcTransform(c *xgb.Conn, Crtc Crtc, Transform render.Transform, FilterLen uint16, FilterName string, FilterParams []render.Fixed) SetCrtcTransformCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'SetCrtcTransform' using the uninitialized extension 'RANDR'. randr.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(setCrtcTransformRequest(c, Crtc, Transform, FilterLen, FilterName, FilterParams), cookie)
|
|
|
|
return SetCrtcTransformCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SetCrtcTransformChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using SetCrtcTransformCookie.Check()
|
|
|
|
func SetCrtcTransformChecked(c *xgb.Conn, Crtc Crtc, Transform render.Transform, FilterLen uint16, FilterName string, FilterParams []render.Fixed) SetCrtcTransformCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'SetCrtcTransform' using the uninitialized extension 'RANDR'. randr.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, false)
|
|
|
|
c.NewRequest(setCrtcTransformRequest(c, Crtc, Transform, FilterLen, FilterName, FilterParams), cookie)
|
|
|
|
return SetCrtcTransformCookie{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 SetCrtcTransformCookie) Check() error {
|
|
|
|
return cook.Cookie.Check()
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for SetCrtcTransform
|
|
|
|
// setCrtcTransformRequest writes a SetCrtcTransform request to a byte slice.
|
|
|
|
func setCrtcTransformRequest(c *xgb.Conn, Crtc Crtc, Transform render.Transform, FilterLen uint16, FilterName string, FilterParams []render.Fixed) []byte {
|
|
|
|
size := xgb.Pad(((48 + xgb.Pad((int(FilterLen) * 1))) + xgb.Pad((len(FilterParams) * 4))))
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
b += 1
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 26 // request opcode
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 1
|
|
|
|
|
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(Crtc))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
{
|
|
|
|
structBytes := Transform.Bytes()
|
|
|
|
copy(buf[b:], structBytes)
|
2013-12-28 15:33:09 +01:00
|
|
|
b += len(structBytes)
|
2013-08-12 02:43:26 +02:00
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], FilterLen)
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 2
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
b += 2 // padding
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
copy(buf[b:], FilterName[:FilterLen])
|
|
|
|
b += xgb.Pad(int(FilterLen))
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
for i := 0; i < int(len(FilterParams)); i++ {
|
|
|
|
xgb.Put32(buf[b:], uint32(FilterParams[i]))
|
|
|
|
b += 4
|
|
|
|
}
|
|
|
|
b = xgb.Pad(b)
|
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
|
|
|
// SetOutputPrimaryCookie is a cookie used only for SetOutputPrimary requests.
|
|
|
|
type SetOutputPrimaryCookie struct {
|
|
|
|
*xgb.Cookie
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SetOutputPrimary sends an unchecked request.
|
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
|
|
|
func SetOutputPrimary(c *xgb.Conn, Window xproto.Window, Output Output) SetOutputPrimaryCookie {
|
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
|
|
|
panic("Cannot issue request 'SetOutputPrimary' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.")
|
|
|
|
}
|
|
|
|
cookie := c.NewCookie(false, false)
|
|
|
|
c.NewRequest(setOutputPrimaryRequest(c, Window, Output), cookie)
|
|
|
|
return SetOutputPrimaryCookie{cookie}
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SetOutputPrimaryChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using SetOutputPrimaryCookie.Check()
|
|
|
|
func SetOutputPrimaryChecked(c *xgb.Conn, Window xproto.Window, Output Output) SetOutputPrimaryCookie {
|
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
|
|
|
panic("Cannot issue request 'SetOutputPrimary' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.")
|
|
|
|
}
|
|
|
|
cookie := c.NewCookie(true, false)
|
|
|
|
c.NewRequest(setOutputPrimaryRequest(c, Window, Output), cookie)
|
|
|
|
return SetOutputPrimaryCookie{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 SetOutputPrimaryCookie) Check() error {
|
|
|
|
return cook.Cookie.Check()
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for SetOutputPrimary
|
|
|
|
// setOutputPrimaryRequest writes a SetOutputPrimary request to a byte slice.
|
|
|
|
func setOutputPrimaryRequest(c *xgb.Conn, Window xproto.Window, Output Output) []byte {
|
|
|
|
size := 12
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
b += 1
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
buf[b] = 30 // 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))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(Output))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// SetPanningCookie is a cookie used only for SetPanning requests.
|
2012-05-10 23:01:42 +02:00
|
|
|
type SetPanningCookie struct {
|
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// SetPanning sends a checked request.
|
|
|
|
// If an error occurs, it will be returned with the reply by calling SetPanningCookie.Reply()
|
2012-05-10 23:01:42 +02:00
|
|
|
func SetPanning(c *xgb.Conn, Crtc Crtc, Timestamp xproto.Timestamp, Left uint16, Top uint16, Width uint16, Height uint16, TrackLeft uint16, TrackTop uint16, TrackWidth uint16, TrackHeight uint16, BorderLeft int16, BorderTop int16, BorderRight int16, BorderBottom int16) SetPanningCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
|
|
|
panic("Cannot issue request 'SetPanning' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.")
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(true, true)
|
|
|
|
c.NewRequest(setPanningRequest(c, Crtc, Timestamp, Left, Top, Width, Height, TrackLeft, TrackTop, TrackWidth, TrackHeight, BorderLeft, BorderTop, BorderRight, BorderBottom), cookie)
|
|
|
|
return SetPanningCookie{cookie}
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// SetPanningUnchecked 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 SetPanningUnchecked(c *xgb.Conn, Crtc Crtc, Timestamp xproto.Timestamp, Left uint16, Top uint16, Width uint16, Height uint16, TrackLeft uint16, TrackTop uint16, TrackWidth uint16, TrackHeight uint16, BorderLeft int16, BorderTop int16, BorderRight int16, BorderBottom int16) SetPanningCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
|
|
|
panic("Cannot issue request 'SetPanning' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.")
|
|
|
|
}
|
2012-05-10 23:01:42 +02:00
|
|
|
cookie := c.NewCookie(false, true)
|
|
|
|
c.NewRequest(setPanningRequest(c, Crtc, Timestamp, Left, Top, Width, Height, TrackLeft, TrackTop, TrackWidth, TrackHeight, BorderLeft, BorderTop, BorderRight, BorderBottom), cookie)
|
|
|
|
return SetPanningCookie{cookie}
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// SetPanningReply represents the data returned from a SetPanning request.
|
2012-05-10 23:01:42 +02:00
|
|
|
type SetPanningReply 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
|
|
|
Status byte
|
|
|
|
Timestamp xproto.Timestamp
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// Reply blocks and returns the reply data for a SetPanning request.
|
2012-05-10 23:01:42 +02:00
|
|
|
func (cook SetPanningCookie) Reply() (*SetPanningReply, error) {
|
|
|
|
buf, err := cook.Cookie.Reply()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if buf == nil {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
return setPanningReply(buf), nil
|
|
|
|
}
|
|
|
|
|
2012-05-11 05:57:34 +02:00
|
|
|
// setPanningReply reads a byte slice into a SetPanningReply value.
|
2012-05-10 23:01:42 +02:00
|
|
|
func setPanningReply(buf []byte) *SetPanningReply {
|
|
|
|
v := new(SetPanningReply)
|
|
|
|
b := 1 // skip reply determinant
|
|
|
|
|
|
|
|
v.Status = buf[b]
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
v.Sequence = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.Length = xgb.Get32(buf[b:]) // 4-byte units
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write request to wire for SetPanning
|
2012-05-11 05:57:34 +02:00
|
|
|
// setPanningRequest writes a SetPanning request to a byte slice.
|
2012-05-10 23:01:42 +02:00
|
|
|
func setPanningRequest(c *xgb.Conn, Crtc Crtc, Timestamp xproto.Timestamp, Left uint16, Top uint16, Width uint16, Height uint16, TrackLeft uint16, TrackTop uint16, TrackWidth uint16, TrackHeight uint16, BorderLeft int16, BorderTop int16, BorderRight int16, BorderBottom int16) []byte {
|
|
|
|
size := 36
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
buf[b] = 29 // 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(Crtc))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(Timestamp))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], Left)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], Top)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], Width)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], Height)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], TrackLeft)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], TrackTop)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], TrackWidth)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], TrackHeight)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(BorderLeft))
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(BorderTop))
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(BorderRight))
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], uint16(BorderBottom))
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-12-28 15:25:18 +01:00
|
|
|
// SetProviderOffloadSinkCookie is a cookie used only for SetProviderOffloadSink requests.
|
|
|
|
type SetProviderOffloadSinkCookie struct {
|
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetProviderOffloadSink sends an unchecked request.
|
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
|
|
|
func SetProviderOffloadSink(c *xgb.Conn, Provider Provider, SinkProvider Provider, ConfigTimestamp xproto.Timestamp) SetProviderOffloadSinkCookie {
|
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
|
|
|
panic("Cannot issue request 'SetProviderOffloadSink' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.")
|
|
|
|
}
|
|
|
|
cookie := c.NewCookie(false, false)
|
|
|
|
c.NewRequest(setProviderOffloadSinkRequest(c, Provider, SinkProvider, ConfigTimestamp), cookie)
|
|
|
|
return SetProviderOffloadSinkCookie{cookie}
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetProviderOffloadSinkChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using SetProviderOffloadSinkCookie.Check()
|
|
|
|
func SetProviderOffloadSinkChecked(c *xgb.Conn, Provider Provider, SinkProvider Provider, ConfigTimestamp xproto.Timestamp) SetProviderOffloadSinkCookie {
|
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
|
|
|
panic("Cannot issue request 'SetProviderOffloadSink' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.")
|
|
|
|
}
|
|
|
|
cookie := c.NewCookie(true, false)
|
|
|
|
c.NewRequest(setProviderOffloadSinkRequest(c, Provider, SinkProvider, ConfigTimestamp), cookie)
|
|
|
|
return SetProviderOffloadSinkCookie{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 SetProviderOffloadSinkCookie) Check() error {
|
|
|
|
return cook.Cookie.Check()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write request to wire for SetProviderOffloadSink
|
|
|
|
// setProviderOffloadSinkRequest writes a SetProviderOffloadSink request to a byte slice.
|
|
|
|
func setProviderOffloadSinkRequest(c *xgb.Conn, Provider Provider, SinkProvider Provider, ConfigTimestamp xproto.Timestamp) []byte {
|
|
|
|
size := 16
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
buf[b] = 34 // 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(Provider))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(SinkProvider))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(ConfigTimestamp))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetProviderOutputSourceCookie is a cookie used only for SetProviderOutputSource requests.
|
|
|
|
type SetProviderOutputSourceCookie struct {
|
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetProviderOutputSource sends an unchecked request.
|
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
|
|
|
func SetProviderOutputSource(c *xgb.Conn, Provider Provider, SourceProvider Provider, ConfigTimestamp xproto.Timestamp) SetProviderOutputSourceCookie {
|
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
|
|
|
panic("Cannot issue request 'SetProviderOutputSource' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.")
|
|
|
|
}
|
|
|
|
cookie := c.NewCookie(false, false)
|
|
|
|
c.NewRequest(setProviderOutputSourceRequest(c, Provider, SourceProvider, ConfigTimestamp), cookie)
|
|
|
|
return SetProviderOutputSourceCookie{cookie}
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetProviderOutputSourceChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using SetProviderOutputSourceCookie.Check()
|
|
|
|
func SetProviderOutputSourceChecked(c *xgb.Conn, Provider Provider, SourceProvider Provider, ConfigTimestamp xproto.Timestamp) SetProviderOutputSourceCookie {
|
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
|
|
|
panic("Cannot issue request 'SetProviderOutputSource' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.")
|
|
|
|
}
|
|
|
|
cookie := c.NewCookie(true, false)
|
|
|
|
c.NewRequest(setProviderOutputSourceRequest(c, Provider, SourceProvider, ConfigTimestamp), cookie)
|
|
|
|
return SetProviderOutputSourceCookie{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 SetProviderOutputSourceCookie) Check() error {
|
|
|
|
return cook.Cookie.Check()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write request to wire for SetProviderOutputSource
|
|
|
|
// setProviderOutputSourceRequest writes a SetProviderOutputSource request to a byte slice.
|
|
|
|
func setProviderOutputSourceRequest(c *xgb.Conn, Provider Provider, SourceProvider Provider, ConfigTimestamp xproto.Timestamp) []byte {
|
|
|
|
size := 16
|
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
buf[b] = 35 // 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(Provider))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(SourceProvider))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(ConfigTimestamp))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SetScreenConfigCookie is a cookie used only for SetScreenConfig requests.
|
|
|
|
type SetScreenConfigCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SetScreenConfig sends a checked request.
|
|
|
|
// If an error occurs, it will be returned with the reply by calling SetScreenConfigCookie.Reply()
|
|
|
|
func SetScreenConfig(c *xgb.Conn, Window xproto.Window, Timestamp xproto.Timestamp, ConfigTimestamp xproto.Timestamp, SizeID uint16, Rotation uint16, Rate uint16) SetScreenConfigCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'SetScreenConfig' using the uninitialized extension 'RANDR'. randr.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(setScreenConfigRequest(c, Window, Timestamp, ConfigTimestamp, SizeID, Rotation, Rate), cookie)
|
|
|
|
return SetScreenConfigCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SetScreenConfigUnchecked sends an unchecked request.
|
|
|
|
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
|
|
|
func SetScreenConfigUnchecked(c *xgb.Conn, Window xproto.Window, Timestamp xproto.Timestamp, ConfigTimestamp xproto.Timestamp, SizeID uint16, Rotation uint16, Rate uint16) SetScreenConfigCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'SetScreenConfig' using the uninitialized extension 'RANDR'. randr.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(setScreenConfigRequest(c, Window, Timestamp, ConfigTimestamp, SizeID, Rotation, Rate), cookie)
|
|
|
|
return SetScreenConfigCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SetScreenConfigReply represents the data returned from a SetScreenConfig request.
|
|
|
|
type SetScreenConfigReply struct {
|
|
|
|
Sequence uint16 // sequence number of the request for this reply
|
|
|
|
Length uint32 // number of bytes in this reply
|
|
|
|
Status byte
|
|
|
|
NewTimestamp xproto.Timestamp
|
|
|
|
ConfigTimestamp xproto.Timestamp
|
|
|
|
Root xproto.Window
|
|
|
|
SubpixelOrder uint16
|
|
|
|
// padding: 10 bytes
|
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 SetScreenConfig request.
|
|
|
|
func (cook SetScreenConfigCookie) Reply() (*SetScreenConfigReply, error) {
|
|
|
|
buf, err := cook.Cookie.Reply()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if buf == nil {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
return setScreenConfigReply(buf), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// setScreenConfigReply reads a byte slice into a SetScreenConfigReply value.
|
|
|
|
func setScreenConfigReply(buf []byte) *SetScreenConfigReply {
|
|
|
|
v := new(SetScreenConfigReply)
|
|
|
|
b := 1 // skip reply determinant
|
|
|
|
|
|
|
|
v.Status = buf[b]
|
|
|
|
b += 1
|
|
|
|
|
|
|
|
v.Sequence = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
v.Length = xgb.Get32(buf[b:]) // 4-byte units
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.NewTimestamp = xproto.Timestamp(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.ConfigTimestamp = xproto.Timestamp(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.Root = xproto.Window(xgb.Get32(buf[b:]))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
v.SubpixelOrder = xgb.Get16(buf[b:])
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
b += 10 // padding
|
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write request to wire for SetScreenConfig
|
|
|
|
// setScreenConfigRequest writes a SetScreenConfig request to a byte slice.
|
|
|
|
func setScreenConfigRequest(c *xgb.Conn, Window xproto.Window, Timestamp xproto.Timestamp, ConfigTimestamp xproto.Timestamp, SizeID uint16, Rotation uint16, Rate uint16) []byte {
|
|
|
|
size := 24
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
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(Window))
|
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put32(buf[b:], uint32(Timestamp))
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], uint32(ConfigTimestamp))
|
2012-05-10 23:01:42 +02:00
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], SizeID)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], Rotation)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], Rate)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
b += 2 // padding
|
|
|
|
|
2012-05-10 23:01:42 +02:00
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SetScreenSizeCookie is a cookie used only for SetScreenSize requests.
|
|
|
|
type SetScreenSizeCookie struct {
|
2012-05-10 23:01:42 +02:00
|
|
|
*xgb.Cookie
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SetScreenSize 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 SetScreenSize(c *xgb.Conn, Window xproto.Window, Width uint16, Height uint16, MmWidth uint32, MmHeight uint32) SetScreenSizeCookie {
|
2012-05-12 05:58:52 +02:00
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
2013-08-12 02:43:26 +02:00
|
|
|
panic("Cannot issue request 'SetScreenSize' using the uninitialized extension 'RANDR'. randr.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(setScreenSizeRequest(c, Window, Width, Height, MmWidth, MmHeight), cookie)
|
|
|
|
return SetScreenSizeCookie{cookie}
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// SetScreenSizeChecked sends a checked request.
|
|
|
|
// If an error occurs, it can be retrieved using SetScreenSizeCookie.Check()
|
|
|
|
func SetScreenSizeChecked(c *xgb.Conn, Window xproto.Window, Width uint16, Height uint16, MmWidth uint32, MmHeight uint32) SetScreenSizeCookie {
|
|
|
|
if _, ok := c.Extensions["RANDR"]; !ok {
|
|
|
|
panic("Cannot issue request 'SetScreenSize' using the uninitialized extension 'RANDR'. randr.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(setScreenSizeRequest(c, Window, Width, Height, MmWidth, MmHeight), cookie)
|
|
|
|
return SetScreenSizeCookie{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 SetScreenSizeCookie) Check() error {
|
|
|
|
return cook.Cookie.Check()
|
2012-05-10 23:01:42 +02:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
// Write request to wire for SetScreenSize
|
|
|
|
// setScreenSizeRequest writes a SetScreenSize request to a byte slice.
|
|
|
|
func setScreenSizeRequest(c *xgb.Conn, Window xproto.Window, Width uint16, Height uint16, MmWidth uint32, MmHeight uint32) []byte {
|
|
|
|
size := 20
|
2012-05-10 23:01:42 +02:00
|
|
|
b := 0
|
|
|
|
buf := make([]byte, size)
|
|
|
|
|
|
|
|
buf[b] = c.Extensions["RANDR"]
|
|
|
|
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(Window))
|
|
|
|
b += 4
|
|
|
|
|
2013-08-12 02:43:26 +02:00
|
|
|
xgb.Put16(buf[b:], Width)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put16(buf[b:], Height)
|
|
|
|
b += 2
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], MmWidth)
|
|
|
|
b += 4
|
|
|
|
|
|
|
|
xgb.Put32(buf[b:], MmHeight)
|
|
|
|
b += 4
|
|
|
|
|
2012-05-10 23:01:42 +02:00
|
|
|
return buf
|
|
|
|
}
|