From 0685fb57e14104ee4ad9f70ec94f787a9a22c028 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Sun, 11 Aug 2013 20:43:26 -0400 Subject: Update to latest xproto XML. --- nexgb/randr/randr.go | 4112 +++++++++++++++++++++++++------------------------- 1 file changed, 2056 insertions(+), 2056 deletions(-) (limited to 'nexgb/randr/randr.go') diff --git a/nexgb/randr/randr.go b/nexgb/randr/randr.go index 6e2eecc..81104eb 100644 --- a/nexgb/randr/randr.go +++ b/nexgb/randr/randr.go @@ -2,7 +2,7 @@ package randr /* - This file was generated by randr.xml on Jun 5 2012 12:11:59am EDT. + This file was generated by randr.xml on Aug 11 2013 8:39:43pm EDT. This file is automatically generated. Edit at your peril! */ @@ -41,231 +41,258 @@ func init() { xgb.NewExtErrorFuncs["RANDR"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Card16' - -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' +// BadBadCrtc is the error number for a BadBadCrtc. +const BadBadCrtc = 1 -// Skipping definition for base type 'Bool' +type BadCrtcError struct { + Sequence uint16 + NiceName string +} -// Skipping definition for base type 'Float' +// BadCrtcErrorNew constructs a BadCrtcError value that implements xgb.Error from a byte slice. +func BadCrtcErrorNew(buf []byte) xgb.Error { + v := BadCrtcError{} + v.NiceName = "BadCrtc" -// Skipping definition for base type 'Card8' + b := 1 // skip error determinant + b += 1 // don't read error number -// Skipping definition for base type 'Int16' + v.Sequence = xgb.Get16(buf[b:]) + b += 2 -// Skipping definition for base type 'Int32' + return v +} -// Skipping definition for base type 'Void' +// SequenceId returns the sequence id attached to the BadBadCrtc error. +// This is mostly used internally. +func (err BadCrtcError) SequenceId() uint16 { + return err.Sequence +} -// Skipping definition for base type 'Byte' +// 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 +} -// Skipping definition for base type 'Int8' +// Error returns a rudimentary string representation of the BadBadCrtc error. -const ( - RotationRotate0 = 1 - RotationRotate90 = 2 - RotationRotate180 = 4 - RotationRotate270 = 8 - RotationReflectX = 16 - RotationReflectY = 32 -) +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, ", ") + "}" +} -const ( - SetConfigSuccess = 0 - SetConfigInvalidConfigTime = 1 - SetConfigInvalidTime = 2 - SetConfigFailed = 3 -) +func init() { + xgb.NewExtErrorFuncs["RANDR"][1] = BadCrtcErrorNew +} -const ( - NotifyMaskScreenChange = 1 - NotifyMaskCrtcChange = 2 - NotifyMaskOutputChange = 4 - NotifyMaskOutputProperty = 8 -) +// BadBadMode is the error number for a BadBadMode. +const BadBadMode = 2 -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 -) +type BadModeError struct { + Sequence uint16 + NiceName string +} -const ( - ConnectionConnected = 0 - ConnectionDisconnected = 1 - ConnectionUnknown = 2 -) +// BadModeErrorNew constructs a BadModeError value that implements xgb.Error from a byte slice. +func BadModeErrorNew(buf []byte) xgb.Error { + v := BadModeError{} + v.NiceName = "BadMode" -const ( - NotifyCrtcChange = 0 - NotifyOutputChange = 1 - NotifyOutputProperty = 2 -) + b := 1 // skip error determinant + b += 1 // don't read error number -type Mode uint32 + v.Sequence = xgb.Get16(buf[b:]) + b += 2 -func NewModeId(c *xgb.Conn) (Mode, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Mode(id), nil + return v } -type Crtc uint32 +// SequenceId returns the sequence id attached to the BadBadMode error. +// This is mostly used internally. +func (err BadModeError) SequenceId() uint16 { + return err.Sequence +} -func NewCrtcId(c *xgb.Conn) (Crtc, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Crtc(id), nil +// 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 } -type Output uint32 +// Error returns a rudimentary string representation of the BadBadMode error. -func NewOutputId(c *xgb.Conn) (Output, error) { - id, err := c.NewId() - if err != nil { - return 0, err - } - return Output(id), nil +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, ", ") + "}" } -type ScreenSize struct { - Width uint16 - Height uint16 - Mwidth uint16 - Mheight uint16 +func init() { + xgb.NewExtErrorFuncs["RANDR"][2] = BadModeErrorNew } -// ScreenSizeRead reads a byte slice into a ScreenSize value. -func ScreenSizeRead(buf []byte, v *ScreenSize) int { - b := 0 +// BadBadOutput is the error number for a BadBadOutput. +const BadBadOutput = 0 - v.Width = xgb.Get16(buf[b:]) - b += 2 +type BadOutputError struct { + Sequence uint16 + NiceName string +} - v.Height = xgb.Get16(buf[b:]) - b += 2 +// BadOutputErrorNew constructs a BadOutputError value that implements xgb.Error from a byte slice. +func BadOutputErrorNew(buf []byte) xgb.Error { + v := BadOutputError{} + v.NiceName = "BadOutput" - v.Mwidth = xgb.Get16(buf[b:]) - b += 2 + b := 1 // skip error determinant + b += 1 // don't read error number - v.Mheight = xgb.Get16(buf[b:]) + v.Sequence = xgb.Get16(buf[b:]) b += 2 - return b + return v } -// ScreenSizeReadList reads a byte slice into a list of ScreenSize values. -func ScreenSizeReadList(buf []byte, dest []ScreenSize) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = ScreenSize{} - b += ScreenSizeRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) +// SequenceId returns the sequence id attached to the BadBadOutput error. +// This is mostly used internally. +func (err BadOutputError) SequenceId() uint16 { + return err.Sequence } -// Bytes writes a ScreenSize value to a byte slice. -func (v ScreenSize) Bytes() []byte { - buf := make([]byte, 8) - b := 0 +// 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 +} - xgb.Put16(buf[b:], v.Width) - b += 2 +// Error returns a rudimentary string representation of the BadBadOutput error. - xgb.Put16(buf[b:], v.Height) - b += 2 +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, ", ") + "}" +} - xgb.Put16(buf[b:], v.Mwidth) - b += 2 +func init() { + xgb.NewExtErrorFuncs["RANDR"][0] = BadOutputErrorNew +} - xgb.Put16(buf[b:], v.Mheight) - b += 2 +const ( + ConnectionConnected = 0 + ConnectionDisconnected = 1 + ConnectionUnknown = 2 +) - return buf -} +type Crtc uint32 -// 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) - b += xgb.Pad(len(structBytes)) +func NewCrtcId(c *xgb.Conn) (Crtc, error) { + id, err := c.NewId() + if err != nil { + return 0, err } - return b + return Crtc(id), nil } -type RefreshRates struct { - NRates uint16 - Rates []uint16 // size: xgb.Pad((int(NRates) * 2)) -} +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 -// RefreshRatesRead reads a byte slice into a RefreshRates value. -func RefreshRatesRead(buf []byte, v *RefreshRates) int { - b := 0 + v.X = int16(xgb.Get16(buf[b:])) + b += 2 - v.NRates = xgb.Get16(buf[b:]) + v.Y = int16(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) + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 return b } -// RefreshRatesReadList reads a byte slice into a list of RefreshRates values. -func RefreshRatesReadList(buf []byte, dest []RefreshRates) int { +// CrtcChangeReadList reads a byte slice into a list of CrtcChange values. +func CrtcChangeReadList(buf []byte, dest []CrtcChange) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = RefreshRates{} - b += RefreshRatesRead(buf[b:], &dest[i]) + dest[i] = CrtcChange{} + b += CrtcChangeRead(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)))) +// Bytes writes a CrtcChange value to a byte slice. +func (v CrtcChange) Bytes() []byte { + buf := make([]byte, 28) b := 0 - xgb.Put16(buf[b:], v.NRates) + 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) b += 2 - for i := 0; i < int(v.NRates); i++ { - xgb.Put16(buf[b:], v.Rates[i]) - b += 2 - } - b = xgb.Pad(b) + 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 return buf } -// RefreshRatesListBytes writes a list of RefreshRates values to a byte slice. -func RefreshRatesListBytes(buf []byte, list []RefreshRates) int { +// CrtcChangeListBytes writes a list of CrtcChange values to a byte slice. +func CrtcChangeListBytes(buf []byte, list []CrtcChange) int { b := 0 var structBytes []byte for _, item := range list { @@ -276,15 +303,33 @@ func RefreshRatesListBytes(buf []byte, list []RefreshRates) int { return 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))) +type Mode uint32 + +func NewModeId(c *xgb.Conn) (Mode, error) { + id, err := c.NewId() + if err != nil { + return 0, err } - return size + return Mode(id), nil } +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 +) + type ModeInfo struct { Id uint32 Width uint16 @@ -416,114 +461,259 @@ func ModeInfoListBytes(buf []byte, list []ModeInfo) int { return b } -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 +// 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) + b += xgb.Pad(len(unionBytes)) + } + + 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 +} + +const ( + NotifyCrtcChange = 0 + NotifyOutputChange = 1 + NotifyOutputProperty = 2 +) + +// 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 +type NotifyDataUnion struct { + Cc CrtcChange + Oc OutputChange + Op OutputProperty +} + +// 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) + b += xgb.Pad(len(structBytes)) + } + + // 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) + + 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) + b += xgb.Pad(len(structBytes)) + } + + // 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) + + return v } -// CrtcChangeRead reads a byte slice into a CrtcChange value. -func CrtcChangeRead(buf []byte, v *CrtcChange) int { - b := 0 +// NotifyDataUnionOpNew constructs a new NotifyDataUnion union type with the Op field. +func NotifyDataUnionOpNew(Op OutputProperty) NotifyDataUnion { + var b int + buf := make([]byte, 28) - v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 + { + structBytes := Op.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } - v.Window = xproto.Window(xgb.Get32(buf[b:])) - b += 4 + // Create the Union type + v := NotifyDataUnion{} - v.Crtc = Crtc(xgb.Get32(buf[b:])) - b += 4 + // Now copy buf into all fields - v.Mode = Mode(xgb.Get32(buf[b:])) - b += 4 + b = 0 // always read the same bytes + v.Cc = CrtcChange{} + b += CrtcChangeRead(buf[b:], &v.Cc) - v.Rotation = xgb.Get16(buf[b:]) - b += 2 + b = 0 // always read the same bytes + v.Oc = OutputChange{} + b += OutputChangeRead(buf[b:], &v.Oc) - b += 2 // padding + b = 0 // always read the same bytes + v.Op = OutputProperty{} + b += OutputPropertyRead(buf[b:], &v.Op) - v.X = int16(xgb.Get16(buf[b:])) - b += 2 + return v +} - v.Y = int16(xgb.Get16(buf[b:])) - b += 2 +// NotifyDataUnionRead reads a byte slice into a NotifyDataUnion value. +func NotifyDataUnionRead(buf []byte, v *NotifyDataUnion) int { + var b int - v.Width = xgb.Get16(buf[b:]) - b += 2 + b = 0 // re-read the same bytes + v.Cc = CrtcChange{} + b += CrtcChangeRead(buf[b:], &v.Cc) - v.Height = xgb.Get16(buf[b:]) - b += 2 + b = 0 // re-read the same bytes + v.Oc = OutputChange{} + b += OutputChangeRead(buf[b:], &v.Oc) - return b + b = 0 // re-read the same bytes + v.Op = OutputProperty{} + b += OutputPropertyRead(buf[b:], &v.Op) + + return 28 } -// CrtcChangeReadList reads a byte slice into a list of CrtcChange values. -func CrtcChangeReadList(buf []byte, dest []CrtcChange) int { +// NotifyDataUnionReadList reads a byte slice into a list of NotifyDataUnion values. +func NotifyDataUnionReadList(buf []byte, dest []NotifyDataUnion) int { b := 0 for i := 0; i < len(dest); i++ { - dest[i] = CrtcChange{} - b += CrtcChangeRead(buf[b:], &dest[i]) + dest[i] = NotifyDataUnion{} + b += NotifyDataUnionRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// Bytes writes a CrtcChange value to a byte slice. -func (v CrtcChange) Bytes() []byte { +// 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 { buf := make([]byte, 28) b := 0 - 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) - b += 2 - - 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 - + { + structBytes := v.Cc.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } return buf } -// CrtcChangeListBytes writes a list of CrtcChange values to a byte slice. -func CrtcChangeListBytes(buf []byte, list []CrtcChange) int { +// NotifyDataUnionListBytes writes a list of %s(MISSING) values to a byte slice. +func NotifyDataUnionListBytes(buf []byte, list []NotifyDataUnion) int { b := 0 - var structBytes []byte + var unionBytes []byte for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) + unionBytes = item.Bytes() + copy(buf[b:], unionBytes) + b += xgb.Pad(len(unionBytes)) } return b } +const ( + NotifyMaskScreenChange = 1 + NotifyMaskCrtcChange = 2 + NotifyMaskOutputChange = 4 + NotifyMaskOutputProperty = 8 +) + +type Output uint32 + +func NewOutputId(c *xgb.Conn) (Output, error) { + id, err := c.NewId() + if err != nil { + return 0, err + } + return Output(id), nil +} + type OutputChange struct { Timestamp xproto.Timestamp ConfigTimestamp xproto.Timestamp @@ -707,168 +897,85 @@ func OutputPropertyListBytes(buf []byte, list []OutputProperty) int { return b } -// 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 -type NotifyDataUnion struct { - Cc CrtcChange - Oc OutputChange - Op OutputProperty -} - -// 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) - b += xgb.Pad(len(structBytes)) - } - - // 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) - - 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) - b += xgb.Pad(len(structBytes)) - } - - // 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) - - return v -} - -// NotifyDataUnionOpNew constructs a new NotifyDataUnion union type with the Op field. -func NotifyDataUnionOpNew(Op OutputProperty) NotifyDataUnion { - var b int - buf := make([]byte, 28) - - { - structBytes := Op.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - - // 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) - - return v +type RefreshRates struct { + NRates uint16 + Rates []uint16 // size: xgb.Pad((int(NRates) * 2)) } -// NotifyDataUnionRead reads a byte slice into a NotifyDataUnion value. -func NotifyDataUnionRead(buf []byte, v *NotifyDataUnion) int { - var b int - - b = 0 // re-read the same bytes - v.Cc = CrtcChange{} - b += CrtcChangeRead(buf[b:], &v.Cc) +// RefreshRatesRead reads a byte slice into a RefreshRates value. +func RefreshRatesRead(buf []byte, v *RefreshRates) int { + b := 0 - b = 0 // re-read the same bytes - v.Oc = OutputChange{} - b += OutputChangeRead(buf[b:], &v.Oc) + v.NRates = xgb.Get16(buf[b:]) + b += 2 - b = 0 // re-read the same bytes - v.Op = OutputProperty{} - b += OutputPropertyRead(buf[b:], &v.Op) + 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 28 + return b } -// NotifyDataUnionReadList reads a byte slice into a list of NotifyDataUnion values. -func NotifyDataUnionReadList(buf []byte, dest []NotifyDataUnion) int { +// 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] = NotifyDataUnion{} - b += NotifyDataUnionRead(buf[b:], &dest[i]) + dest[i] = RefreshRates{} + b += RefreshRatesRead(buf[b:], &dest[i]) } return xgb.Pad(b) } -// 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 { - buf := make([]byte, 28) +// 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 - { - structBytes := v.Cc.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) + 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 } -// NotifyDataUnionListBytes writes a list of %s(MISSING) values to a byte slice. -func NotifyDataUnionListBytes(buf []byte, list []NotifyDataUnion) int { +// RefreshRatesListBytes writes a list of RefreshRates values to a byte slice. +func RefreshRatesListBytes(buf []byte, list []RefreshRates) int { b := 0 - var unionBytes []byte + var structBytes []byte for _, item := range list { - unionBytes = item.Bytes() - copy(buf[b:], unionBytes) - b += xgb.Pad(len(unionBytes)) + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) } return 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 +} + +const ( + RotationRotate0 = 1 + RotationRotate90 = 2 + RotationRotate180 = 4 + RotationRotate270 = 8 + RotationReflectX = 16 + RotationReflectY = 32 +) + // ScreenChangeNotify is the event number for a ScreenChangeNotifyEvent. const ScreenChangeNotify = 0 @@ -1007,288 +1114,141 @@ func init() { xgb.NewExtEventFuncs["RANDR"][0] = ScreenChangeNotifyEventNew } -// Notify is the event number for a NotifyEvent. -const Notify = 1 - -type NotifyEvent struct { - Sequence uint16 - SubCode byte - U NotifyDataUnion +type ScreenSize struct { + Width uint16 + Height uint16 + Mwidth uint16 + Mheight uint16 } -// 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 +// ScreenSizeRead reads a byte slice into a ScreenSize value. +func ScreenSizeRead(buf []byte, v *ScreenSize) int { + b := 0 - v.SubCode = buf[b] - b += 1 + v.Width = xgb.Get16(buf[b:]) + b += 2 - v.Sequence = xgb.Get16(buf[b:]) + v.Height = xgb.Get16(buf[b:]) b += 2 - v.U = NotifyDataUnion{} - b += NotifyDataUnionRead(buf[b:], &v.U) + v.Mwidth = xgb.Get16(buf[b:]) + b += 2 - return v + v.Mheight = xgb.Get16(buf[b:]) + b += 2 + + return b } -// Bytes writes a NotifyEvent value to a byte slice. -func (v NotifyEvent) Bytes() []byte { - buf := make([]byte, 32) +// ScreenSizeReadList reads a byte slice into a list of ScreenSize values. +func ScreenSizeReadList(buf []byte, dest []ScreenSize) int { 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) - b += xgb.Pad(len(unionBytes)) + for i := 0; i < len(dest); i++ { + dest[i] = ScreenSize{} + b += ScreenSizeRead(buf[b:], &dest[i]) } - - 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 -} - -// BadBadOutput is the error number for a BadBadOutput. -const BadBadOutput = 0 - -type BadOutputError struct { - Sequence uint16 - NiceName string + return xgb.Pad(b) } -// BadOutputErrorNew constructs a BadOutputError value that implements xgb.Error from a byte slice. -func BadOutputErrorNew(buf []byte) xgb.Error { - v := BadOutputError{} - v.NiceName = "BadOutput" - - b := 1 // skip error determinant - b += 1 // don't read error number +// Bytes writes a ScreenSize value to a byte slice. +func (v ScreenSize) Bytes() []byte { + buf := make([]byte, 8) + b := 0 - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], v.Width) b += 2 - return v -} - -// SequenceId returns the sequence id attached to the BadBadOutput error. -// This is mostly used internally. -func (err BadOutputError) SequenceId() uint16 { - return err.Sequence -} - -// 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 -} - -// Error returns a rudimentary string representation of the BadBadOutput error. - -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, ", ") + "}" -} - -func init() { - xgb.NewExtErrorFuncs["RANDR"][0] = BadOutputErrorNew -} - -// BadBadCrtc is the error number for a BadBadCrtc. -const BadBadCrtc = 1 - -type BadCrtcError struct { - Sequence uint16 - NiceName string -} - -// BadCrtcErrorNew constructs a BadCrtcError value that implements xgb.Error from a byte slice. -func BadCrtcErrorNew(buf []byte) xgb.Error { - v := BadCrtcError{} - v.NiceName = "BadCrtc" - - b := 1 // skip error determinant - b += 1 // don't read error number + xgb.Put16(buf[b:], v.Height) + b += 2 - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], v.Mwidth) b += 2 - return v -} + xgb.Put16(buf[b:], v.Mheight) + b += 2 -// SequenceId returns the sequence id attached to the BadBadCrtc error. -// This is mostly used internally. -func (err BadCrtcError) SequenceId() uint16 { - return err.Sequence + return buf } -// 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 +// 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) + b += xgb.Pad(len(structBytes)) + } + return b } -// Error returns a rudimentary string representation of the BadBadCrtc error. - -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, ", ") + "}" -} +const ( + SetConfigSuccess = 0 + SetConfigInvalidConfigTime = 1 + SetConfigInvalidTime = 2 + SetConfigFailed = 3 +) -func init() { - xgb.NewExtErrorFuncs["RANDR"][1] = BadCrtcErrorNew -} +// Skipping definition for base type 'Bool' -// BadBadMode is the error number for a BadBadMode. -const BadBadMode = 2 +// Skipping definition for base type 'Byte' -type BadModeError struct { - Sequence uint16 - NiceName string -} +// Skipping definition for base type 'Card8' -// BadModeErrorNew constructs a BadModeError value that implements xgb.Error from a byte slice. -func BadModeErrorNew(buf []byte) xgb.Error { - v := BadModeError{} - v.NiceName = "BadMode" +// Skipping definition for base type 'Char' - b := 1 // skip error determinant - b += 1 // don't read error number +// Skipping definition for base type 'Void' - v.Sequence = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Double' - return v -} +// Skipping definition for base type 'Float' -// SequenceId returns the sequence id attached to the BadBadMode error. -// This is mostly used internally. -func (err BadModeError) SequenceId() uint16 { - return err.Sequence -} +// Skipping definition for base type 'Int16' -// 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 -} +// Skipping definition for base type 'Int32' -// Error returns a rudimentary string representation of the BadBadMode error. +// Skipping definition for base type 'Int8' -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, ", ") + "}" -} +// Skipping definition for base type 'Card16' -func init() { - xgb.NewExtErrorFuncs["RANDR"][2] = BadModeErrorNew -} +// Skipping definition for base type 'Card32' -// QueryVersionCookie is a cookie used only for QueryVersion requests. -type QueryVersionCookie struct { +// AddOutputModeCookie is a cookie used only for AddOutputMode requests. +type AddOutputModeCookie struct { *xgb.Cookie } -// 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 { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) - return QueryVersionCookie{cookie} -} - -// QueryVersionUnchecked sends an unchecked request. +// AddOutputMode sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryVersionUnchecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { +func AddOutputMode(c *xgb.Conn, Output Output, Mode Mode) AddOutputModeCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'AddOutputMode' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) - return QueryVersionCookie{cookie} -} - -// QueryVersionReply represents the data returned from a QueryVersion request. -type QueryVersionReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - MajorVersion uint32 - MinorVersion uint32 - // padding: 16 bytes + cookie := c.NewCookie(false, false) + c.NewRequest(addOutputModeRequest(c, Output, Mode), cookie) + return AddOutputModeCookie{cookie} } -// Reply blocks and returns the reply data for a QueryVersion request. -func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil +// 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.") } - return queryVersionReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(addOutputModeRequest(c, Output, Mode), cookie) + return AddOutputModeCookie{cookie} } -// queryVersionReply reads a byte slice into a QueryVersionReply value. -func queryVersionReply(buf []byte) *QueryVersionReply { - v := new(QueryVersionReply) - 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.MajorVersion = xgb.Get32(buf[b:]) - b += 4 - - v.MinorVersion = xgb.Get32(buf[b:]) - b += 4 - - b += 16 // padding - - return v +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook AddOutputModeCookie) Check() error { + return cook.Cookie.Check() } -// 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 { +// 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 { size := 12 b := 0 buf := make([]byte, size) @@ -1296,249 +1256,214 @@ func queryVersionRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 0 // request opcode + buf[b] = 18 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], MajorVersion) + xgb.Put32(buf[b:], uint32(Output)) b += 4 - xgb.Put32(buf[b:], MinorVersion) + xgb.Put32(buf[b:], uint32(Mode)) b += 4 return buf } -// SetScreenConfigCookie is a cookie used only for SetScreenConfig requests. -type SetScreenConfigCookie struct { +// ChangeOutputPropertyCookie is a cookie used only for ChangeOutputProperty requests. +type ChangeOutputPropertyCookie struct { *xgb.Cookie } -// 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 { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'SetScreenConfig' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(setScreenConfigRequest(c, Window, Timestamp, ConfigTimestamp, SizeID, Rotation, Rate), cookie) - return SetScreenConfigCookie{cookie} -} - -// SetScreenConfigUnchecked sends an unchecked request. +// ChangeOutputProperty 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 { +func ChangeOutputProperty(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 'SetScreenConfig' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'ChangeOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(setScreenConfigRequest(c, Window, Timestamp, ConfigTimestamp, SizeID, Rotation, Rate), cookie) - return SetScreenConfigCookie{cookie} -} - -// 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 + cookie := c.NewCookie(false, false) + c.NewRequest(changeOutputPropertyRequest(c, Output, Property, Type, Format, Mode, NumUnits, Data), cookie) + return ChangeOutputPropertyCookie{cookie} } -// 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 +// 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.") } - return setScreenConfigReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(changeOutputPropertyRequest(c, Output, Property, Type, Format, Mode, NumUnits, Data), cookie) + return ChangeOutputPropertyCookie{cookie} } -// 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 +// 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() } -// 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 +// 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)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 2 // request opcode + buf[b] = 13 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Window)) + xgb.Put32(buf[b:], uint32(Output)) b += 4 - xgb.Put32(buf[b:], uint32(Timestamp)) + xgb.Put32(buf[b:], uint32(Property)) b += 4 - xgb.Put32(buf[b:], uint32(ConfigTimestamp)) + xgb.Put32(buf[b:], uint32(Type)) b += 4 - xgb.Put16(buf[b:], SizeID) - b += 2 - - xgb.Put16(buf[b:], Rotation) - b += 2 + buf[b] = Format + b += 1 - xgb.Put16(buf[b:], Rate) - b += 2 + buf[b] = Mode + b += 1 b += 2 // padding + 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))) + return buf } -// SelectInputCookie is a cookie used only for SelectInput requests. -type SelectInputCookie struct { +// ConfigureOutputPropertyCookie is a cookie used only for ConfigureOutputProperty requests. +type ConfigureOutputPropertyCookie struct { *xgb.Cookie } -// SelectInput sends an unchecked request. +// ConfigureOutputProperty sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SelectInput(c *xgb.Conn, Window xproto.Window, Enable uint16) SelectInputCookie { +func ConfigureOutputProperty(c *xgb.Conn, Output Output, Property xproto.Atom, Pending bool, Range bool, Values []int32) ConfigureOutputPropertyCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'SelectInput' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'ConfigureOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(selectInputRequest(c, Window, Enable), cookie) - return SelectInputCookie{cookie} + c.NewRequest(configureOutputPropertyRequest(c, Output, Property, Pending, Range, Values), cookie) + return ConfigureOutputPropertyCookie{cookie} } -// 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 { +// 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 { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'SelectInput' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'ConfigureOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(selectInputRequest(c, Window, Enable), cookie) - return SelectInputCookie{cookie} + c.NewRequest(configureOutputPropertyRequest(c, Output, Property, Pending, Range, Values), cookie) + return ConfigureOutputPropertyCookie{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 SelectInputCookie) Check() error { +func (cook ConfigureOutputPropertyCookie) Check() error { return cook.Cookie.Check() } -// 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 +// 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)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 4 // request opcode + buf[b] = 12 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Window)) + xgb.Put32(buf[b:], uint32(Output)) b += 4 - xgb.Put16(buf[b:], Enable) - b += 2 + 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 } -// GetScreenInfoCookie is a cookie used only for GetScreenInfo requests. -type GetScreenInfoCookie struct { +// CreateModeCookie is a cookie used only for CreateMode requests. +type CreateModeCookie struct { *xgb.Cookie } -// 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 { +// 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 { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetScreenInfo' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateMode' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getScreenInfoRequest(c, Window), cookie) - return GetScreenInfoCookie{cookie} + c.NewRequest(createModeRequest(c, Window, ModeInfo, Name), cookie) + return CreateModeCookie{cookie} } -// GetScreenInfoUnchecked sends an unchecked request. +// CreateModeUnchecked 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 { +func CreateModeUnchecked(c *xgb.Conn, Window xproto.Window, ModeInfo ModeInfo, Name string) CreateModeCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetScreenInfo' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateMode' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getScreenInfoRequest(c, Window), cookie) - return GetScreenInfoCookie{cookie} + c.NewRequest(createModeRequest(c, Window, ModeInfo, Name), cookie) + return CreateModeCookie{cookie} } -// 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) +// 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 } -// Reply blocks and returns the reply data for a GetScreenInfo request. -func (cook GetScreenInfoCookie) Reply() (*GetScreenInfoReply, error) { +// Reply blocks and returns the reply data for a CreateMode request. +func (cook CreateModeCookie) Reply() (*CreateModeReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1546,16 +1471,15 @@ func (cook GetScreenInfoCookie) Reply() (*GetScreenInfoReply, error) { if buf == nil { return nil, nil } - return getScreenInfoReply(buf), nil + return createModeReply(buf), nil } -// getScreenInfoReply reads a byte slice into a GetScreenInfoReply value. -func getScreenInfoReply(buf []byte) *GetScreenInfoReply { - v := new(GetScreenInfoReply) +// createModeReply reads a byte slice into a CreateModeReply value. +func createModeReply(buf []byte) *CreateModeReply { + v := new(CreateModeReply) b := 1 // skip reply determinant - v.Rotations = buf[b] - b += 1 + b += 1 // padding v.Sequence = xgb.Get16(buf[b:]) b += 2 @@ -1563,52 +1487,25 @@ func getScreenInfoReply(buf []byte) *GetScreenInfoReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Root = xproto.Window(xgb.Get32(buf[b:])) - b += 4 - - v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 - - v.ConfigTimestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + v.Mode = Mode(xgb.Get32(buf[b:])) b += 4 - v.NSizes = xgb.Get16(buf[b:]) - b += 2 - - v.SizeID = xgb.Get16(buf[b:]) - b += 2 - - 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) + b += 20 // padding return v } -// 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 +// 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)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 5 // request opcode + buf[b] = 16 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1617,226 +1514,230 @@ func getScreenInfoRequest(c *xgb.Conn, Window xproto.Window) []byte { xgb.Put32(buf[b:], uint32(Window)) b += 4 + { + structBytes := ModeInfo.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + + copy(buf[b:], Name[:len(Name)]) + b += xgb.Pad(int(len(Name))) + return buf } -// GetScreenSizeRangeCookie is a cookie used only for GetScreenSizeRange requests. -type GetScreenSizeRangeCookie struct { +// DeleteOutputModeCookie is a cookie used only for DeleteOutputMode requests. +type DeleteOutputModeCookie struct { *xgb.Cookie } -// 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 { +// 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 { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetScreenSizeRange' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'DeleteOutputMode' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, true) - c.NewRequest(getScreenSizeRangeRequest(c, Window), cookie) - return GetScreenSizeRangeCookie{cookie} + cookie := c.NewCookie(false, false) + c.NewRequest(deleteOutputModeRequest(c, Output, Mode), cookie) + return DeleteOutputModeCookie{cookie} } -// GetScreenSizeRangeUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetScreenSizeRangeUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenSizeRangeCookie { +// 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 { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetScreenSizeRange' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'DeleteOutputMode' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(getScreenSizeRangeRequest(c, Window), cookie) - return GetScreenSizeRangeCookie{cookie} -} - -// GetScreenSizeRangeReply represents the data returned from a GetScreenSizeRange request. -type GetScreenSizeRangeReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - MinWidth uint16 - MinHeight uint16 - MaxWidth uint16 - MaxHeight uint16 - // padding: 16 bytes + cookie := c.NewCookie(true, false) + c.NewRequest(deleteOutputModeRequest(c, Output, Mode), cookie) + return DeleteOutputModeCookie{cookie} } -// Reply blocks and returns the reply data for a GetScreenSizeRange request. -func (cook GetScreenSizeRangeCookie) Reply() (*GetScreenSizeRangeReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getScreenSizeRangeReply(buf), nil +// 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() } -// getScreenSizeRangeReply reads a byte slice into a GetScreenSizeRangeReply value. -func getScreenSizeRangeReply(buf []byte) *GetScreenSizeRangeReply { - v := new(GetScreenSizeRangeReply) - b := 1 // skip reply determinant +// 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) - b += 1 // padding + buf[b] = c.Extensions["RANDR"] + b += 1 - v.Sequence = xgb.Get16(buf[b:]) + buf[b] = 19 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], uint32(Output)) b += 4 - v.MinWidth = xgb.Get16(buf[b:]) - b += 2 + xgb.Put32(buf[b:], uint32(Mode)) + b += 4 - v.MinHeight = xgb.Get16(buf[b:]) - b += 2 + return buf +} - v.MaxWidth = xgb.Get16(buf[b:]) - b += 2 +// DeleteOutputPropertyCookie is a cookie used only for DeleteOutputProperty requests. +type DeleteOutputPropertyCookie struct { + *xgb.Cookie +} - v.MaxHeight = xgb.Get16(buf[b:]) - b += 2 +// 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} +} - b += 16 // padding +// 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} +} - return v +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook DeleteOutputPropertyCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for GetScreenSizeRange -// getScreenSizeRangeRequest writes a GetScreenSizeRange request to a byte slice. -func getScreenSizeRangeRequest(c *xgb.Conn, Window xproto.Window) []byte { - size := 8 +// 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 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 6 // request opcode + buf[b] = 14 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Window)) + xgb.Put32(buf[b:], uint32(Output)) + b += 4 + + xgb.Put32(buf[b:], uint32(Property)) b += 4 return buf } -// SetScreenSizeCookie is a cookie used only for SetScreenSize requests. -type SetScreenSizeCookie struct { +// DestroyModeCookie is a cookie used only for DestroyMode requests. +type DestroyModeCookie struct { *xgb.Cookie } -// SetScreenSize sends an unchecked request. +// DestroyMode sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetScreenSize(c *xgb.Conn, Window xproto.Window, Width uint16, Height uint16, MmWidth uint32, MmHeight uint32) SetScreenSizeCookie { +func DestroyMode(c *xgb.Conn, Mode Mode) DestroyModeCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'SetScreenSize' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'DestroyMode' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(setScreenSizeRequest(c, Window, Width, Height, MmWidth, MmHeight), cookie) - return SetScreenSizeCookie{cookie} + c.NewRequest(destroyModeRequest(c, Mode), cookie) + return DestroyModeCookie{cookie} } -// 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 { +// DestroyModeChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroyModeCookie.Check() +func DestroyModeChecked(c *xgb.Conn, Mode Mode) DestroyModeCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'SetScreenSize' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'DestroyMode' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(setScreenSizeRequest(c, Window, Width, Height, MmWidth, MmHeight), cookie) - return SetScreenSizeCookie{cookie} + c.NewRequest(destroyModeRequest(c, Mode), cookie) + return DestroyModeCookie{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 SetScreenSizeCookie) Check() error { +func (cook DestroyModeCookie) Check() error { return cook.Cookie.Check() } -// 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 +// 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 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 7 // request opcode + buf[b] = 17 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Window)) - b += 4 - - 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) + xgb.Put32(buf[b:], uint32(Mode)) b += 4 return buf } -// GetScreenResourcesCookie is a cookie used only for GetScreenResources requests. -type GetScreenResourcesCookie struct { +// GetCrtcGammaCookie is a cookie used only for GetCrtcGamma requests. +type GetCrtcGammaCookie struct { *xgb.Cookie } -// 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 { +// 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 { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetScreenResources' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetCrtcGamma' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getScreenResourcesRequest(c, Window), cookie) - return GetScreenResourcesCookie{cookie} + c.NewRequest(getCrtcGammaRequest(c, Crtc), cookie) + return GetCrtcGammaCookie{cookie} } -// GetScreenResourcesUnchecked sends an unchecked request. +// GetCrtcGammaUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetScreenResourcesUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenResourcesCookie { +func GetCrtcGammaUnchecked(c *xgb.Conn, Crtc Crtc) GetCrtcGammaCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetScreenResources' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetCrtcGamma' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getScreenResourcesRequest(c, Window), cookie) - return GetScreenResourcesCookie{cookie} + c.NewRequest(getCrtcGammaRequest(c, Crtc), cookie) + return GetCrtcGammaCookie{cookie} } -// GetScreenResourcesReply represents the data returned from a GetScreenResources request. -type GetScreenResourcesReply struct { +// GetCrtcGammaReply represents the data returned from a GetCrtcGamma request. +type GetCrtcGammaReply 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)) + 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)) } -// Reply blocks and returns the reply data for a GetScreenResources request. -func (cook GetScreenResourcesCookie) Reply() (*GetScreenResourcesReply, error) { +// Reply blocks and returns the reply data for a GetCrtcGamma request. +func (cook GetCrtcGammaCookie) Reply() (*GetCrtcGammaReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1844,12 +1745,12 @@ func (cook GetScreenResourcesCookie) Reply() (*GetScreenResourcesReply, error) { if buf == nil { return nil, nil } - return getScreenResourcesReply(buf), nil + return getCrtcGammaReply(buf), nil } -// getScreenResourcesReply reads a byte slice into a GetScreenResourcesReply value. -func getScreenResourcesReply(buf []byte) *GetScreenResourcesReply { - v := new(GetScreenResourcesReply) +// getCrtcGammaReply reads a byte slice into a GetCrtcGammaReply value. +func getCrtcGammaReply(buf []byte) *GetCrtcGammaReply { + v := new(GetCrtcGammaReply) b := 1 // skip reply determinant b += 1 // padding @@ -1860,53 +1761,38 @@ func getScreenResourcesReply(buf []byte) *GetScreenResourcesReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 - - 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:]) + v.Size = xgb.Get16(buf[b:]) b += 2 - b += 8 // padding + b += 22 // 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 + v.Red = make([]uint16, v.Size) + for i := 0; i < int(v.Size); i++ { + v.Red[i] = xgb.Get16(buf[b:]) + b += 2 } 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 + v.Green = make([]uint16, v.Size) + for i := 0; i < int(v.Size); i++ { + v.Green[i] = xgb.Get16(buf[b:]) + b += 2 } 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)) + 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) return v } -// Write request to wire for GetScreenResources -// getScreenResourcesRequest writes a GetScreenResources request to a byte slice. -func getScreenResourcesRequest(c *xgb.Conn, Window xproto.Window) []byte { +// Write request to wire for GetCrtcGamma +// getCrtcGammaRequest writes a GetCrtcGamma request to a byte slice. +func getCrtcGammaRequest(c *xgb.Conn, Crtc Crtc) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -1914,69 +1800,56 @@ func getScreenResourcesRequest(c *xgb.Conn, Window xproto.Window) []byte { buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 8 // request opcode + buf[b] = 23 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Window)) + xgb.Put32(buf[b:], uint32(Crtc)) b += 4 return buf } -// GetOutputInfoCookie is a cookie used only for GetOutputInfo requests. -type GetOutputInfoCookie struct { +// GetCrtcGammaSizeCookie is a cookie used only for GetCrtcGammaSize requests. +type GetCrtcGammaSizeCookie struct { *xgb.Cookie } -// 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 { +// 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 { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetOutputInfo' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetCrtcGammaSize' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getOutputInfoRequest(c, Output, ConfigTimestamp), cookie) - return GetOutputInfoCookie{cookie} + c.NewRequest(getCrtcGammaSizeRequest(c, Crtc), cookie) + return GetCrtcGammaSizeCookie{cookie} } -// GetOutputInfoUnchecked sends an unchecked request. +// GetCrtcGammaSizeUnchecked 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 { +func GetCrtcGammaSizeUnchecked(c *xgb.Conn, Crtc Crtc) GetCrtcGammaSizeCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetOutputInfo' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetCrtcGammaSize' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getOutputInfoRequest(c, Output, ConfigTimestamp), cookie) - return GetOutputInfoCookie{cookie} + c.NewRequest(getCrtcGammaSizeRequest(c, Crtc), cookie) + return GetCrtcGammaSizeCookie{cookie} } -// 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)) +// 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 } -// Reply blocks and returns the reply data for a GetOutputInfo request. -func (cook GetOutputInfoCookie) Reply() (*GetOutputInfoReply, error) { +// Reply blocks and returns the reply data for a GetCrtcGammaSize request. +func (cook GetCrtcGammaSizeCookie) Reply() (*GetCrtcGammaSizeReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1984,16 +1857,15 @@ func (cook GetOutputInfoCookie) Reply() (*GetOutputInfoReply, error) { if buf == nil { return nil, nil } - return getOutputInfoReply(buf), nil + return getCrtcGammaSizeReply(buf), nil } -// getOutputInfoReply reads a byte slice into a GetOutputInfoReply value. -func getOutputInfoReply(buf []byte) *GetOutputInfoReply { - v := new(GetOutputInfoReply) +// getCrtcGammaSizeReply reads a byte slice into a GetCrtcGammaSizeReply value. +func getCrtcGammaSizeReply(buf []byte) *GetCrtcGammaSizeReply { + v := new(GetCrtcGammaSizeReply) b := 1 // skip reply determinant - v.Status = buf[b] - b += 1 + b += 1 // padding v.Sequence = xgb.Get16(buf[b:]) b += 2 @@ -2001,131 +1873,84 @@ func getOutputInfoReply(buf []byte) *GetOutputInfoReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) - b += 4 - - 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] - b += 1 - - v.SubpixelOrder = buf[b] - b += 1 - - v.NumCrtcs = xgb.Get16(buf[b:]) - b += 2 - - v.NumModes = xgb.Get16(buf[b:]) - b += 2 - - v.NumPreferred = xgb.Get16(buf[b:]) - b += 2 - - v.NumClones = xgb.Get16(buf[b:]) - b += 2 - - v.NameLen = xgb.Get16(buf[b:]) + v.Size = 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) - - v.Modes = make([]Mode, v.NumModes) - for i := 0; i < int(v.NumModes); i++ { - v.Modes[i] = Mode(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) - - v.Clones = make([]Output, v.NumClones) - for i := 0; i < int(v.NumClones); i++ { - v.Clones[i] = Output(xgb.Get32(buf[b:])) - b += 4 - } - b = xgb.Pad(b) - - v.Name = make([]byte, v.NameLen) - copy(v.Name[:v.NameLen], buf[b:]) - b += xgb.Pad(int(v.NameLen)) + b += 22 // padding return v } -// 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 +// 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 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 9 // request opcode + buf[b] = 22 // 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(ConfigTimestamp)) + xgb.Put32(buf[b:], uint32(Crtc)) b += 4 return buf } -// ListOutputPropertiesCookie is a cookie used only for ListOutputProperties requests. -type ListOutputPropertiesCookie struct { +// GetCrtcInfoCookie is a cookie used only for GetCrtcInfo requests. +type GetCrtcInfoCookie struct { *xgb.Cookie } -// 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 { +// 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 { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'ListOutputProperties' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetCrtcInfo' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(listOutputPropertiesRequest(c, Output), cookie) - return ListOutputPropertiesCookie{cookie} + c.NewRequest(getCrtcInfoRequest(c, Crtc, ConfigTimestamp), cookie) + return GetCrtcInfoCookie{cookie} } -// ListOutputPropertiesUnchecked sends an unchecked request. +// GetCrtcInfoUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ListOutputPropertiesUnchecked(c *xgb.Conn, Output Output) ListOutputPropertiesCookie { +func GetCrtcInfoUnchecked(c *xgb.Conn, Crtc Crtc, ConfigTimestamp xproto.Timestamp) GetCrtcInfoCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'ListOutputProperties' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetCrtcInfo' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(listOutputPropertiesRequest(c, Output), cookie) - return ListOutputPropertiesCookie{cookie} + c.NewRequest(getCrtcInfoRequest(c, Crtc, ConfigTimestamp), cookie) + return GetCrtcInfoCookie{cookie} } -// ListOutputPropertiesReply represents the data returned from a ListOutputProperties request. -type ListOutputPropertiesReply 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)) +// 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)) } -// Reply blocks and returns the reply data for a ListOutputProperties request. -func (cook ListOutputPropertiesCookie) Reply() (*ListOutputPropertiesReply, error) { +// Reply blocks and returns the reply data for a GetCrtcInfo request. +func (cook GetCrtcInfoCookie) Reply() (*GetCrtcInfoReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -2133,15 +1958,16 @@ func (cook ListOutputPropertiesCookie) Reply() (*ListOutputPropertiesReply, erro if buf == nil { return nil, nil } - return listOutputPropertiesReply(buf), nil + return getCrtcInfoReply(buf), nil } -// listOutputPropertiesReply reads a byte slice into a ListOutputPropertiesReply value. -func listOutputPropertiesReply(buf []byte) *ListOutputPropertiesReply { - v := new(ListOutputPropertiesReply) +// getCrtcInfoReply reads a byte slice into a GetCrtcInfoReply value. +func getCrtcInfoReply(buf []byte) *GetCrtcInfoReply { + v := new(GetCrtcInfoReply) b := 1 // skip reply determinant - b += 1 // padding + v.Status = buf[b] + b += 1 v.Sequence = xgb.Get16(buf[b:]) b += 2 @@ -2149,14 +1975,46 @@ func listOutputPropertiesReply(buf []byte) *ListOutputPropertiesReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.NumAtoms = xgb.Get16(buf[b:]) + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 + + v.X = int16(xgb.Get16(buf[b:])) b += 2 - b += 22 // padding + v.Y = int16(xgb.Get16(buf[b:])) + b += 2 - v.Atoms = make([]xproto.Atom, v.NumAtoms) - for i := 0; i < int(v.NumAtoms); i++ { - v.Atoms[i] = xproto.Atom(xgb.Get32(buf[b:])) + 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:])) b += 4 } b = xgb.Pad(b) @@ -2164,69 +2022,80 @@ func listOutputPropertiesReply(buf []byte) *ListOutputPropertiesReply { return v } -// Write request to wire for ListOutputProperties -// listOutputPropertiesRequest writes a ListOutputProperties request to a byte slice. -func listOutputPropertiesRequest(c *xgb.Conn, Output Output) []byte { - size := 8 +// 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 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 10 // request opcode + buf[b] = 20 // 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)) + xgb.Put32(buf[b:], uint32(Crtc)) + b += 4 + + xgb.Put32(buf[b:], uint32(ConfigTimestamp)) b += 4 return buf } -// QueryOutputPropertyCookie is a cookie used only for QueryOutputProperty requests. -type QueryOutputPropertyCookie struct { +// GetCrtcTransformCookie is a cookie used only for GetCrtcTransform requests. +type GetCrtcTransformCookie struct { *xgb.Cookie } -// 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 { +// 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 { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'QueryOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetCrtcTransform' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(queryOutputPropertyRequest(c, Output, Property), cookie) - return QueryOutputPropertyCookie{cookie} + c.NewRequest(getCrtcTransformRequest(c, Crtc), cookie) + return GetCrtcTransformCookie{cookie} } -// QueryOutputPropertyUnchecked sends an unchecked request. +// GetCrtcTransformUnchecked 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 { +func GetCrtcTransformUnchecked(c *xgb.Conn, Crtc Crtc) GetCrtcTransformCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'QueryOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetCrtcTransform' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(queryOutputPropertyRequest(c, Output, Property), cookie) - return QueryOutputPropertyCookie{cookie} + c.NewRequest(getCrtcTransformRequest(c, Crtc), cookie) + return GetCrtcTransformCookie{cookie} } -// QueryOutputPropertyReply represents the data returned from a QueryOutputProperty request. -type QueryOutputPropertyReply struct { +// GetCrtcTransformReply represents the data returned from a GetCrtcTransform request. +type GetCrtcTransformReply 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)) + 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)) } -// Reply blocks and returns the reply data for a QueryOutputProperty request. -func (cook QueryOutputPropertyCookie) Reply() (*QueryOutputPropertyReply, error) { +// Reply blocks and returns the reply data for a GetCrtcTransform request. +func (cook GetCrtcTransformCookie) Reply() (*GetCrtcTransformReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -2234,12 +2103,12 @@ func (cook QueryOutputPropertyCookie) Reply() (*QueryOutputPropertyReply, error) if buf == nil { return nil, nil } - return queryOutputPropertyReply(buf), nil + return getCrtcTransformReply(buf), nil } -// queryOutputPropertyReply reads a byte slice into a QueryOutputPropertyReply value. -func queryOutputPropertyReply(buf []byte) *QueryOutputPropertyReply { - v := new(QueryOutputPropertyReply) +// getCrtcTransformReply reads a byte slice into a GetCrtcTransformReply value. +func getCrtcTransformReply(buf []byte) *GetCrtcTransformReply { + v := new(GetCrtcTransformReply) b := 1 // skip reply determinant b += 1 // padding @@ -2250,32 +2119,59 @@ func queryOutputPropertyReply(buf []byte) *QueryOutputPropertyReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 + v.PendingTransform = render.Transform{} + b += render.TransformRead(buf[b:], &v.PendingTransform) + if buf[b] == 1 { - v.Pending = true + v.HasTransforms = true } else { - v.Pending = false + v.HasTransforms = false } b += 1 - if buf[b] == 1 { - v.Range = true - } else { - v.Range = false + 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) + b += xgb.Pad(int(v.PendingLen)) } - b += 1 - if buf[b] == 1 { - v.Immutable = true - } else { - v.Immutable = false + 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 } - b += 1 + b = xgb.Pad(b) - b += 21 // padding + { + byteString := make([]byte, v.CurrentLen) + copy(byteString[:v.CurrentLen], buf[b:]) + v.CurrentFilterName = string(byteString) + b += xgb.Pad(int(v.CurrentLen)) + } - v.ValidValues = make([]int32, v.Length) - for i := 0; i < int(v.Length); i++ { - v.ValidValues[i] = int32(xgb.Get32(buf[b:])) + v.CurrentParams = make([]render.Fixed, v.CurrentNparams) + for i := 0; i < int(v.CurrentNparams); i++ { + v.CurrentParams[i] = render.Fixed(xgb.Get32(buf[b:])) b += 4 } b = xgb.Pad(b) @@ -2283,155 +2179,175 @@ func queryOutputPropertyReply(buf []byte) *QueryOutputPropertyReply { 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 +// 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 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 11 // request opcode + buf[b] = 27 // 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)) + xgb.Put32(buf[b:], uint32(Crtc)) b += 4 return buf } -// ConfigureOutputPropertyCookie is a cookie used only for ConfigureOutputProperty requests. -type ConfigureOutputPropertyCookie struct { +// GetOutputInfoCookie is a cookie used only for GetOutputInfo requests. +type GetOutputInfoCookie struct { *xgb.Cookie } -// ConfigureOutputProperty sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ConfigureOutputProperty(c *xgb.Conn, Output Output, Property xproto.Atom, Pending bool, Range bool, Values []int32) ConfigureOutputPropertyCookie { +// 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 { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'ConfigureOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetOutputInfo' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(configureOutputPropertyRequest(c, Output, Property, Pending, Range, Values), cookie) - return ConfigureOutputPropertyCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getOutputInfoRequest(c, Output, ConfigTimestamp), cookie) + return GetOutputInfoCookie{cookie} } -// 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 { +// 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 { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'ConfigureOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetOutputInfo' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(configureOutputPropertyRequest(c, Output, Property, Pending, Range, Values), cookie) - return ConfigureOutputPropertyCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getOutputInfoRequest(c, Output, ConfigTimestamp), cookie) + return GetOutputInfoCookie{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 ConfigureOutputPropertyCookie) Check() error { - return cook.Cookie.Check() +// 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)) } -// 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)))) - b := 0 - buf := make([]byte, size) +// 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 +} - buf[b] = c.Extensions["RANDR"] - b += 1 +// getOutputInfoReply reads a byte slice into a GetOutputInfoReply value. +func getOutputInfoReply(buf []byte) *GetOutputInfoReply { + v := new(GetOutputInfoReply) + b := 1 // skip reply determinant - buf[b] = 12 // request opcode + v.Status = buf[b] b += 1 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(Output)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put32(buf[b:], uint32(Property)) + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) b += 4 - if Pending { - buf[b] = 1 - } else { - buf[b] = 0 - } + 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] b += 1 - if Range { - buf[b] = 1 - } else { - buf[b] = 0 - } + v.SubpixelOrder = buf[b] b += 1 - b += 2 // padding + v.NumCrtcs = xgb.Get16(buf[b:]) + b += 2 - for i := 0; i < int(len(Values)); i++ { - xgb.Put32(buf[b:], uint32(Values[i])) - b += 4 - } - b = xgb.Pad(b) + v.NumModes = xgb.Get16(buf[b:]) + b += 2 - return buf -} + v.NumPreferred = xgb.Get16(buf[b:]) + b += 2 -// ChangeOutputPropertyCookie is a cookie used only for ChangeOutputProperty requests. -type ChangeOutputPropertyCookie struct { - *xgb.Cookie -} + 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) -// ChangeOutputProperty sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ChangeOutputProperty(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.") + v.Modes = make([]Mode, v.NumModes) + for i := 0; i < int(v.NumModes); i++ { + v.Modes[i] = Mode(xgb.Get32(buf[b:])) + b += 4 } - cookie := c.NewCookie(false, false) - c.NewRequest(changeOutputPropertyRequest(c, Output, Property, Type, Format, Mode, NumUnits, Data), cookie) - return ChangeOutputPropertyCookie{cookie} -} + b = xgb.Pad(b) -// 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.") + v.Clones = make([]Output, v.NumClones) + for i := 0; i < int(v.NumClones); i++ { + v.Clones[i] = Output(xgb.Get32(buf[b:])) + b += 4 } - cookie := c.NewCookie(true, false) - c.NewRequest(changeOutputPropertyRequest(c, Output, Property, Type, Format, Mode, NumUnits, Data), cookie) - return ChangeOutputPropertyCookie{cookie} -} + b = xgb.Pad(b) -// 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() + v.Name = make([]byte, v.NameLen) + copy(v.Name[:v.NameLen], buf[b:]) + b += xgb.Pad(int(v.NameLen)) + + return v } -// 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)))) +// 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 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 13 // request opcode + buf[b] = 9 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -2440,82 +2356,95 @@ func changeOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Ato xgb.Put32(buf[b:], uint32(Output)) 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:], NumUnits) + xgb.Put32(buf[b:], uint32(ConfigTimestamp)) b += 4 - copy(buf[b:], Data[:((int(NumUnits)*int(Format))/8)]) - b += xgb.Pad(int(((int(NumUnits) * int(Format)) / 8))) - return buf } -// DeleteOutputPropertyCookie is a cookie used only for DeleteOutputProperty requests. -type DeleteOutputPropertyCookie struct { +// GetOutputPrimaryCookie is a cookie used only for GetOutputPrimary requests. +type GetOutputPrimaryCookie struct { *xgb.Cookie } -// 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 { +// 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 { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'DeleteOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetOutputPrimary' 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} + cookie := c.NewCookie(true, true) + c.NewRequest(getOutputPrimaryRequest(c, Window), cookie) + return GetOutputPrimaryCookie{cookie} } -// 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 { +// 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 { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'DeleteOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetOutputPrimary' 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} + cookie := c.NewCookie(false, true) + c.NewRequest(getOutputPrimaryRequest(c, Window), cookie) + return GetOutputPrimaryCookie{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 DeleteOutputPropertyCookie) Check() error { - return cook.Cookie.Check() +// 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 } -// 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 +// 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 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 14 // request opcode + buf[b] = 31 // 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)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 return buf @@ -2654,44 +2583,55 @@ func getOutputPropertyRequest(c *xgb.Conn, Output Output, Property xproto.Atom, return buf } -// CreateModeCookie is a cookie used only for CreateMode requests. -type CreateModeCookie struct { +// GetPanningCookie is a cookie used only for GetPanning requests. +type GetPanningCookie 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 { +// 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 { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'CreateMode' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetPanning' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(createModeRequest(c, Window, ModeInfo, Name), cookie) - return CreateModeCookie{cookie} + c.NewRequest(getPanningRequest(c, Crtc), cookie) + return GetPanningCookie{cookie} } -// CreateModeUnchecked sends an unchecked request. +// GetPanningUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateModeUnchecked(c *xgb.Conn, Window xproto.Window, ModeInfo ModeInfo, Name string) CreateModeCookie { +func GetPanningUnchecked(c *xgb.Conn, Crtc Crtc) GetPanningCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'CreateMode' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetPanning' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(createModeRequest(c, Window, ModeInfo, Name), cookie) - return CreateModeCookie{cookie} + c.NewRequest(getPanningRequest(c, Crtc), cookie) + return GetPanningCookie{cookie} } -// 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 +// 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 } -// Reply blocks and returns the reply data for a CreateMode request. -func (cook CreateModeCookie) Reply() (*CreateModeReply, error) { +// Reply blocks and returns the reply data for a GetPanning request. +func (cook GetPanningCookie) Reply() (*GetPanningReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -2699,15 +2639,16 @@ func (cook CreateModeCookie) Reply() (*CreateModeReply, error) { if buf == nil { return nil, nil } - return createModeReply(buf), nil + return getPanningReply(buf), nil } -// createModeReply reads a byte slice into a CreateModeReply value. -func createModeReply(buf []byte) *CreateModeReply { - v := new(CreateModeReply) +// getPanningReply reads a byte slice into a GetPanningReply value. +func getPanningReply(buf []byte) *GetPanningReply { + v := new(GetPanningReply) b := 1 // skip reply determinant - b += 1 // padding + v.Status = buf[b] + b += 1 v.Sequence = xgb.Get16(buf[b:]) b += 2 @@ -2715,81 +2656,51 @@ func createModeReply(buf []byte) *CreateModeReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Mode = Mode(xgb.Get32(buf[b:])) + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) b += 4 - b += 20 // padding - - return v -} + v.Left = xgb.Get16(buf[b:]) + b += 2 -// 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)))) - b := 0 - buf := make([]byte, size) + v.Top = xgb.Get16(buf[b:]) + b += 2 - buf[b] = c.Extensions["RANDR"] - b += 1 + v.Width = xgb.Get16(buf[b:]) + b += 2 - buf[b] = 16 // request opcode - b += 1 + v.Height = xgb.Get16(buf[b:]) + b += 2 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.TrackLeft = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(Window)) - b += 4 + v.TrackTop = xgb.Get16(buf[b:]) + b += 2 - { - structBytes := ModeInfo.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } + v.TrackWidth = xgb.Get16(buf[b:]) + b += 2 - copy(buf[b:], Name[:len(Name)]) - b += xgb.Pad(int(len(Name))) + v.TrackHeight = xgb.Get16(buf[b:]) + b += 2 - return buf -} + v.BorderLeft = int16(xgb.Get16(buf[b:])) + b += 2 -// DestroyModeCookie is a cookie used only for DestroyMode requests. -type DestroyModeCookie struct { - *xgb.Cookie -} + v.BorderTop = int16(xgb.Get16(buf[b:])) + b += 2 -// DestroyMode sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func DestroyMode(c *xgb.Conn, Mode Mode) DestroyModeCookie { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'DestroyMode' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(destroyModeRequest(c, Mode), cookie) - return DestroyModeCookie{cookie} -} + v.BorderRight = int16(xgb.Get16(buf[b:])) + b += 2 -// DestroyModeChecked sends a checked request. -// If an error occurs, it can be retrieved using DestroyModeCookie.Check() -func DestroyModeChecked(c *xgb.Conn, Mode Mode) DestroyModeCookie { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'DestroyMode' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(destroyModeRequest(c, Mode), cookie) - return DestroyModeCookie{cookie} -} + v.BorderBottom = int16(xgb.Get16(buf[b:])) + b += 2 -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook DestroyModeCookie) Check() error { - return cook.Cookie.Check() + return v } -// Write request to wire for DestroyMode -// destroyModeRequest writes a DestroyMode request to a byte slice. -func destroyModeRequest(c *xgb.Conn, Mode Mode) []byte { +// 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) @@ -2797,182 +2708,193 @@ func destroyModeRequest(c *xgb.Conn, Mode Mode) []byte { buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 17 // request opcode + 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(Mode)) + xgb.Put32(buf[b:], uint32(Crtc)) b += 4 return buf } -// AddOutputModeCookie is a cookie used only for AddOutputMode requests. -type AddOutputModeCookie struct { +// GetScreenInfoCookie is a cookie used only for GetScreenInfo requests. +type GetScreenInfoCookie struct { *xgb.Cookie } -// AddOutputMode sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func AddOutputMode(c *xgb.Conn, Output Output, Mode Mode) AddOutputModeCookie { +// 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 { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'AddOutputMode' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetScreenInfo' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(addOutputModeRequest(c, Output, Mode), cookie) - return AddOutputModeCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getScreenInfoRequest(c, Window), cookie) + return GetScreenInfoCookie{cookie} } -// 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 { +// 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 { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'AddOutputMode' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetScreenInfo' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(addOutputModeRequest(c, Output, Mode), cookie) - return AddOutputModeCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getScreenInfoRequest(c, Window), cookie) + return GetScreenInfoCookie{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 AddOutputModeCookie) Check() error { - return cook.Cookie.Check() +// 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) } -// 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 { - size := 12 - b := 0 - buf := make([]byte, size) +// 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 +} - buf[b] = c.Extensions["RANDR"] - b += 1 +// getScreenInfoReply reads a byte slice into a GetScreenInfoReply value. +func getScreenInfoReply(buf []byte) *GetScreenInfoReply { + v := new(GetScreenInfoReply) + b := 1 // skip reply determinant - buf[b] = 18 // request opcode + v.Rotations = buf[b] b += 1 - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(Output)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put32(buf[b:], uint32(Mode)) + v.Root = xproto.Window(xgb.Get32(buf[b:])) b += 4 - return buf -} + v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 -// DeleteOutputModeCookie is a cookie used only for DeleteOutputMode requests. -type DeleteOutputModeCookie struct { - *xgb.Cookie -} + v.ConfigTimestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 -// 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 { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'DeleteOutputMode' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(deleteOutputModeRequest(c, Output, Mode), cookie) - return DeleteOutputModeCookie{cookie} -} + v.NSizes = xgb.Get16(buf[b:]) + b += 2 -// 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 { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'DeleteOutputMode' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(deleteOutputModeRequest(c, Output, Mode), cookie) - return DeleteOutputModeCookie{cookie} -} + v.SizeID = xgb.Get16(buf[b:]) + b += 2 -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook DeleteOutputModeCookie) Check() error { - return cook.Cookie.Check() + 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 } -// 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 +// 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 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 19 // request opcode + buf[b] = 5 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Output)) - b += 4 - - xgb.Put32(buf[b:], uint32(Mode)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 return buf } -// GetCrtcInfoCookie is a cookie used only for GetCrtcInfo requests. -type GetCrtcInfoCookie struct { +// GetScreenResourcesCookie is a cookie used only for GetScreenResources requests. +type GetScreenResourcesCookie struct { *xgb.Cookie } -// 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 { +// 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 { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetCrtcInfo' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetScreenResources' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getCrtcInfoRequest(c, Crtc, ConfigTimestamp), cookie) - return GetCrtcInfoCookie{cookie} + c.NewRequest(getScreenResourcesRequest(c, Window), cookie) + return GetScreenResourcesCookie{cookie} } -// GetCrtcInfoUnchecked sends an unchecked request. +// GetScreenResourcesUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetCrtcInfoUnchecked(c *xgb.Conn, Crtc Crtc, ConfigTimestamp xproto.Timestamp) GetCrtcInfoCookie { +func GetScreenResourcesUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenResourcesCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetCrtcInfo' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetScreenResources' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getCrtcInfoRequest(c, Crtc, ConfigTimestamp), cookie) - return GetCrtcInfoCookie{cookie} + c.NewRequest(getScreenResourcesRequest(c, Window), cookie) + return GetScreenResourcesCookie{cookie} } -// 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)) +// 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)) } -// Reply blocks and returns the reply data for a GetCrtcInfo request. -func (cook GetCrtcInfoCookie) Reply() (*GetCrtcInfoReply, error) { +// Reply blocks and returns the reply data for a GetScreenResources request. +func (cook GetScreenResourcesCookie) Reply() (*GetScreenResourcesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -2980,16 +2902,15 @@ func (cook GetCrtcInfoCookie) Reply() (*GetCrtcInfoReply, error) { if buf == nil { return nil, nil } - return getCrtcInfoReply(buf), nil + return getScreenResourcesReply(buf), nil } -// getCrtcInfoReply reads a byte slice into a GetCrtcInfoReply value. -func getCrtcInfoReply(buf []byte) *GetCrtcInfoReply { - v := new(GetCrtcInfoReply) +// getScreenResourcesReply reads a byte slice into a GetScreenResourcesReply value. +func getScreenResourcesReply(buf []byte) *GetScreenResourcesReply { + v := new(GetScreenResourcesReply) b := 1 // skip reply determinant - v.Status = buf[b] - b += 1 + b += 1 // padding v.Sequence = xgb.Get16(buf[b:]) b += 2 @@ -3000,32 +2921,29 @@ func getCrtcInfoReply(buf []byte) *GetCrtcInfoReply { v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) b += 4 - v.X = int16(xgb.Get16(buf[b:])) - b += 2 - - v.Y = int16(xgb.Get16(buf[b:])) - b += 2 + v.ConfigTimestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + b += 4 - v.Width = xgb.Get16(buf[b:]) + v.NumCrtcs = xgb.Get16(buf[b:]) b += 2 - v.Height = xgb.Get16(buf[b:]) + v.NumOutputs = xgb.Get16(buf[b:]) b += 2 - v.Mode = Mode(xgb.Get32(buf[b:])) - b += 4 - - v.Rotation = xgb.Get16(buf[b:]) + v.NumModes = xgb.Get16(buf[b:]) b += 2 - v.Rotations = xgb.Get16(buf[b:]) + v.NamesLen = xgb.Get16(buf[b:]) b += 2 - v.NumOutputs = xgb.Get16(buf[b:]) - b += 2 + b += 8 // padding - v.NumPossibleOutputs = 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) v.Outputs = make([]Output, v.NumOutputs) for i := 0; i < int(v.NumOutputs); i++ { @@ -3034,79 +2952,85 @@ func getCrtcInfoReply(buf []byte) *GetCrtcInfoReply { } 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:])) - 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)) return v } -// 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 +// 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 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 20 // request opcode + buf[b] = 8 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Crtc)) - b += 4 - - xgb.Put32(buf[b:], uint32(ConfigTimestamp)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 return buf } -// SetCrtcConfigCookie is a cookie used only for SetCrtcConfig requests. -type SetCrtcConfigCookie struct { +// GetScreenResourcesCurrentCookie is a cookie used only for GetScreenResourcesCurrent requests. +type GetScreenResourcesCurrentCookie struct { *xgb.Cookie } -// 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 { +// 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 { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'SetCrtcConfig' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetScreenResourcesCurrent' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(setCrtcConfigRequest(c, Crtc, Timestamp, ConfigTimestamp, X, Y, Mode, Rotation, Outputs), cookie) - return SetCrtcConfigCookie{cookie} + c.NewRequest(getScreenResourcesCurrentRequest(c, Window), cookie) + return GetScreenResourcesCurrentCookie{cookie} } -// SetCrtcConfigUnchecked sends an unchecked request. +// GetScreenResourcesCurrentUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetCrtcConfigUnchecked(c *xgb.Conn, Crtc Crtc, Timestamp xproto.Timestamp, ConfigTimestamp xproto.Timestamp, X int16, Y int16, Mode Mode, Rotation uint16, Outputs []Output) SetCrtcConfigCookie { +func GetScreenResourcesCurrentUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenResourcesCurrentCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'SetCrtcConfig' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetScreenResourcesCurrent' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(setCrtcConfigRequest(c, Crtc, Timestamp, ConfigTimestamp, X, Y, Mode, Rotation, Outputs), cookie) - return SetCrtcConfigCookie{cookie} + c.NewRequest(getScreenResourcesCurrentRequest(c, Window), cookie) + return GetScreenResourcesCurrentCookie{cookie} } -// 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 +// 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)) } -// Reply blocks and returns the reply data for a SetCrtcConfig request. -func (cook SetCrtcConfigCookie) Reply() (*SetCrtcConfigReply, error) { +// Reply blocks and returns the reply data for a GetScreenResourcesCurrent request. +func (cook GetScreenResourcesCurrentCookie) Reply() (*GetScreenResourcesCurrentReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -3114,16 +3038,15 @@ func (cook SetCrtcConfigCookie) Reply() (*SetCrtcConfigReply, error) { if buf == nil { return nil, nil } - return setCrtcConfigReply(buf), nil + return getScreenResourcesCurrentReply(buf), nil } -// setCrtcConfigReply reads a byte slice into a SetCrtcConfigReply value. -func setCrtcConfigReply(buf []byte) *SetCrtcConfigReply { - v := new(SetCrtcConfigReply) +// getScreenResourcesCurrentReply reads a byte slice into a GetScreenResourcesCurrentReply value. +func getScreenResourcesCurrentReply(buf []byte) *GetScreenResourcesCurrentReply { + v := new(GetScreenResourcesCurrentReply) b := 1 // skip reply determinant - v.Status = buf[b] - b += 1 + b += 1 // padding v.Sequence = xgb.Get16(buf[b:]) b += 2 @@ -3134,97 +3057,110 @@ func setCrtcConfigReply(buf []byte) *SetCrtcConfigReply { v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) b += 4 - b += 20 // padding + 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)) return v } -// 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)))) +// 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 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 21 // request opcode + buf[b] = 25 // 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.Put32(buf[b:], uint32(ConfigTimestamp)) - b += 4 - - xgb.Put16(buf[b:], uint16(X)) - b += 2 - - xgb.Put16(buf[b:], uint16(Y)) - b += 2 - - xgb.Put32(buf[b:], uint32(Mode)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - xgb.Put16(buf[b:], Rotation) - b += 2 - - b += 2 // padding - - for i := 0; i < int(len(Outputs)); i++ { - xgb.Put32(buf[b:], uint32(Outputs[i])) - b += 4 - } - b = xgb.Pad(b) - return buf } -// GetCrtcGammaSizeCookie is a cookie used only for GetCrtcGammaSize requests. -type GetCrtcGammaSizeCookie struct { +// GetScreenSizeRangeCookie is a cookie used only for GetScreenSizeRange requests. +type GetScreenSizeRangeCookie struct { *xgb.Cookie } -// 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 { +// 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 { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetCrtcGammaSize' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetScreenSizeRange' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getCrtcGammaSizeRequest(c, Crtc), cookie) - return GetCrtcGammaSizeCookie{cookie} + c.NewRequest(getScreenSizeRangeRequest(c, Window), cookie) + return GetScreenSizeRangeCookie{cookie} } -// GetCrtcGammaSizeUnchecked sends an unchecked request. +// GetScreenSizeRangeUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetCrtcGammaSizeUnchecked(c *xgb.Conn, Crtc Crtc) GetCrtcGammaSizeCookie { +func GetScreenSizeRangeUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenSizeRangeCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetCrtcGammaSize' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'GetScreenSizeRange' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getCrtcGammaSizeRequest(c, Crtc), cookie) - return GetCrtcGammaSizeCookie{cookie} + c.NewRequest(getScreenSizeRangeRequest(c, Window), cookie) + return GetScreenSizeRangeCookie{cookie} } -// GetCrtcGammaSizeReply represents the data returned from a GetCrtcGammaSize request. -type GetCrtcGammaSizeReply struct { +// GetScreenSizeRangeReply represents the data returned from a GetScreenSizeRange request. +type GetScreenSizeRangeReply 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 + // padding: 1 bytes + MinWidth uint16 + MinHeight uint16 + MaxWidth uint16 + MaxHeight uint16 + // padding: 16 bytes } -// Reply blocks and returns the reply data for a GetCrtcGammaSize request. -func (cook GetCrtcGammaSizeCookie) Reply() (*GetCrtcGammaSizeReply, error) { +// Reply blocks and returns the reply data for a GetScreenSizeRange request. +func (cook GetScreenSizeRangeCookie) Reply() (*GetScreenSizeRangeReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -3232,12 +3168,12 @@ func (cook GetCrtcGammaSizeCookie) Reply() (*GetCrtcGammaSizeReply, error) { if buf == nil { return nil, nil } - return getCrtcGammaSizeReply(buf), nil + return getScreenSizeRangeReply(buf), nil } -// getCrtcGammaSizeReply reads a byte slice into a GetCrtcGammaSizeReply value. -func getCrtcGammaSizeReply(buf []byte) *GetCrtcGammaSizeReply { - v := new(GetCrtcGammaSizeReply) +// getScreenSizeRangeReply reads a byte slice into a GetScreenSizeRangeReply value. +func getScreenSizeRangeReply(buf []byte) *GetScreenSizeRangeReply { + v := new(GetScreenSizeRangeReply) b := 1 // skip reply determinant b += 1 // padding @@ -3248,17 +3184,26 @@ func getCrtcGammaSizeReply(buf []byte) *GetCrtcGammaSizeReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Size = xgb.Get16(buf[b:]) + v.MinWidth = xgb.Get16(buf[b:]) b += 2 - b += 22 // padding + 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 return v } -// Write request to wire for GetCrtcGammaSize -// getCrtcGammaSizeRequest writes a GetCrtcGammaSize request to a byte slice. -func getCrtcGammaSizeRequest(c *xgb.Conn, Crtc Crtc) []byte { +// Write request to wire for GetScreenSizeRange +// getScreenSizeRangeRequest writes a GetScreenSizeRange request to a byte slice. +func getScreenSizeRangeRequest(c *xgb.Conn, Window xproto.Window) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -3266,59 +3211,57 @@ func getCrtcGammaSizeRequest(c *xgb.Conn, Crtc Crtc) []byte { buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 22 // request opcode + buf[b] = 6 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Crtc)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 return buf } -// GetCrtcGammaCookie is a cookie used only for GetCrtcGamma requests. -type GetCrtcGammaCookie struct { +// ListOutputPropertiesCookie is a cookie used only for ListOutputProperties requests. +type ListOutputPropertiesCookie struct { *xgb.Cookie } -// 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 { +// 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 { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetCrtcGamma' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'ListOutputProperties' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getCrtcGammaRequest(c, Crtc), cookie) - return GetCrtcGammaCookie{cookie} + c.NewRequest(listOutputPropertiesRequest(c, Output), cookie) + return ListOutputPropertiesCookie{cookie} } -// GetCrtcGammaUnchecked sends an unchecked request. +// ListOutputPropertiesUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetCrtcGammaUnchecked(c *xgb.Conn, Crtc Crtc) GetCrtcGammaCookie { +func ListOutputPropertiesUnchecked(c *xgb.Conn, Output Output) ListOutputPropertiesCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetCrtcGamma' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'ListOutputProperties' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getCrtcGammaRequest(c, Crtc), cookie) - return GetCrtcGammaCookie{cookie} + c.NewRequest(listOutputPropertiesRequest(c, Output), cookie) + return ListOutputPropertiesCookie{cookie} } -// GetCrtcGammaReply represents the data returned from a GetCrtcGamma request. -type GetCrtcGammaReply struct { +// ListOutputPropertiesReply represents the data returned from a ListOutputProperties request. +type ListOutputPropertiesReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - Size uint16 + NumAtoms 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)) + Atoms []xproto.Atom // size: xgb.Pad((int(NumAtoms) * 4)) } -// Reply blocks and returns the reply data for a GetCrtcGamma request. -func (cook GetCrtcGammaCookie) Reply() (*GetCrtcGammaReply, error) { +// Reply blocks and returns the reply data for a ListOutputProperties request. +func (cook ListOutputPropertiesCookie) Reply() (*ListOutputPropertiesReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -3326,12 +3269,12 @@ func (cook GetCrtcGammaCookie) Reply() (*GetCrtcGammaReply, error) { if buf == nil { return nil, nil } - return getCrtcGammaReply(buf), nil + return listOutputPropertiesReply(buf), nil } -// getCrtcGammaReply reads a byte slice into a GetCrtcGammaReply value. -func getCrtcGammaReply(buf []byte) *GetCrtcGammaReply { - v := new(GetCrtcGammaReply) +// listOutputPropertiesReply reads a byte slice into a ListOutputPropertiesReply value. +func listOutputPropertiesReply(buf []byte) *ListOutputPropertiesReply { + v := new(ListOutputPropertiesReply) b := 1 // skip reply determinant b += 1 // padding @@ -3342,38 +3285,24 @@ func getCrtcGammaReply(buf []byte) *GetCrtcGammaReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Size = xgb.Get16(buf[b:]) + v.NumAtoms = xgb.Get16(buf[b:]) b += 2 b += 22 // padding - v.Red = make([]uint16, v.Size) - for i := 0; i < int(v.Size); i++ { - v.Red[i] = xgb.Get16(buf[b:]) - b += 2 - } - b = xgb.Pad(b) - - v.Green = make([]uint16, v.Size) - for i := 0; i < int(v.Size); i++ { - v.Green[i] = xgb.Get16(buf[b:]) - b += 2 - } - b = xgb.Pad(b) - - v.Blue = make([]uint16, v.Size) - for i := 0; i < int(v.Size); i++ { - v.Blue[i] = xgb.Get16(buf[b:]) - b += 2 + 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 GetCrtcGamma -// getCrtcGammaRequest writes a GetCrtcGamma request to a byte slice. -func getCrtcGammaRequest(c *xgb.Conn, Crtc Crtc) []byte { +// Write request to wire for ListOutputProperties +// listOutputPropertiesRequest writes a ListOutputProperties request to a byte slice. +func listOutputPropertiesRequest(c *xgb.Conn, Output Output) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -3381,143 +3310,179 @@ func getCrtcGammaRequest(c *xgb.Conn, Crtc Crtc) []byte { buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 23 // request opcode + buf[b] = 10 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Crtc)) + xgb.Put32(buf[b:], uint32(Output)) b += 4 return buf } -// SetCrtcGammaCookie is a cookie used only for SetCrtcGamma requests. -type SetCrtcGammaCookie struct { +// QueryOutputPropertyCookie is a cookie used only for QueryOutputProperty requests. +type QueryOutputPropertyCookie 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 { +// 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 { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'SetCrtcGamma' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(setCrtcGammaRequest(c, Crtc, Size, Red, Green, Blue), cookie) - return SetCrtcGammaCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(queryOutputPropertyRequest(c, Output, Property), cookie) + return QueryOutputPropertyCookie{cookie} } -// 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 { +// 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 { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'SetCrtcGamma' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryOutputProperty' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(setCrtcGammaRequest(c, Crtc, Size, Red, Green, Blue), cookie) - return SetCrtcGammaCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(queryOutputPropertyRequest(c, Output, Property), cookie) + return QueryOutputPropertyCookie{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 SetCrtcGammaCookie) Check() error { - return cook.Cookie.Check() +// 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)) } -// 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)))) - b := 0 - buf := make([]byte, size) +// 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 +} - buf[b] = c.Extensions["RANDR"] - b += 1 +// queryOutputPropertyReply reads a byte slice into a QueryOutputPropertyReply value. +func queryOutputPropertyReply(buf []byte) *QueryOutputPropertyReply { + v := new(QueryOutputPropertyReply) + b := 1 // skip reply determinant - buf[b] = 24 // request opcode - b += 1 + b += 1 // padding - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + v.Sequence = xgb.Get16(buf[b:]) b += 2 - xgb.Put32(buf[b:], uint32(Crtc)) + v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - xgb.Put16(buf[b:], Size) - b += 2 - - b += 2 // padding + if buf[b] == 1 { + v.Pending = true + } else { + v.Pending = false + } + b += 1 - for i := 0; i < int(Size); i++ { - xgb.Put16(buf[b:], Red[i]) - b += 2 + if buf[b] == 1 { + v.Range = true + } else { + v.Range = false } - b = xgb.Pad(b) + b += 1 - for i := 0; i < int(Size); i++ { - xgb.Put16(buf[b:], Green[i]) - b += 2 + if buf[b] == 1 { + v.Immutable = true + } else { + v.Immutable = false } - b = xgb.Pad(b) + b += 1 - for i := 0; i < int(Size); i++ { - xgb.Put16(buf[b:], Blue[i]) - b += 2 + 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 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 + return buf } -// GetScreenResourcesCurrentCookie is a cookie used only for GetScreenResourcesCurrent requests. -type GetScreenResourcesCurrentCookie struct { +// QueryVersionCookie is a cookie used only for QueryVersion requests. +type QueryVersionCookie struct { *xgb.Cookie } -// 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 { +// 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 { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetScreenResourcesCurrent' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getScreenResourcesCurrentRequest(c, Window), cookie) - return GetScreenResourcesCurrentCookie{cookie} + c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) + return QueryVersionCookie{cookie} } -// GetScreenResourcesCurrentUnchecked sends an unchecked request. +// QueryVersionUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetScreenResourcesCurrentUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenResourcesCurrentCookie { +func QueryVersionUnchecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetScreenResourcesCurrent' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getScreenResourcesCurrentRequest(c, Window), cookie) - return GetScreenResourcesCurrentCookie{cookie} + c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) + return QueryVersionCookie{cookie} } -// GetScreenResourcesCurrentReply represents the data returned from a GetScreenResourcesCurrent request. -type GetScreenResourcesCurrentReply struct { +// QueryVersionReply represents the data returned from a QueryVersion request. +type QueryVersionReply 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)) + MajorVersion uint32 + MinorVersion uint32 + // padding: 16 bytes } -// Reply blocks and returns the reply data for a GetScreenResourcesCurrent request. -func (cook GetScreenResourcesCurrentCookie) Reply() (*GetScreenResourcesCurrentReply, error) { +// Reply blocks and returns the reply data for a QueryVersion request. +func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -3525,12 +3490,12 @@ func (cook GetScreenResourcesCurrentCookie) Reply() (*GetScreenResourcesCurrentR if buf == nil { return nil, nil } - return getScreenResourcesCurrentReply(buf), nil + return queryVersionReply(buf), nil } -// getScreenResourcesCurrentReply reads a byte slice into a GetScreenResourcesCurrentReply value. -func getScreenResourcesCurrentReply(buf []byte) *GetScreenResourcesCurrentReply { - v := new(GetScreenResourcesCurrentReply) +// queryVersionReply reads a byte slice into a QueryVersionReply value. +func queryVersionReply(buf []byte) *QueryVersionReply { + v := new(QueryVersionReply) b := 1 // skip reply determinant b += 1 // padding @@ -3541,196 +3506,140 @@ func getScreenResourcesCurrentReply(buf []byte) *GetScreenResourcesCurrentReply v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + v.MajorVersion = xgb.Get32(buf[b:]) b += 4 - v.ConfigTimestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + v.MinorVersion = 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)) + b += 16 // padding return v } -// 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 +// 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 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 25 // request opcode + buf[b] = 0 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Window)) + xgb.Put32(buf[b:], MajorVersion) + b += 4 + + xgb.Put32(buf[b:], MinorVersion) b += 4 return buf } -// SetCrtcTransformCookie is a cookie used only for SetCrtcTransform requests. -type SetCrtcTransformCookie struct { +// SelectInputCookie is a cookie used only for SelectInput requests. +type SelectInputCookie struct { *xgb.Cookie } -// SetCrtcTransform sends an unchecked request. +// SelectInput 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 { +func SelectInput(c *xgb.Conn, Window xproto.Window, Enable uint16) SelectInputCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'SetCrtcTransform' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'SelectInput' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(setCrtcTransformRequest(c, Crtc, Transform, FilterLen, FilterName, FilterParams), cookie) - return SetCrtcTransformCookie{cookie} + c.NewRequest(selectInputRequest(c, Window, Enable), cookie) + return SelectInputCookie{cookie} } -// 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 { +// 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 { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'SetCrtcTransform' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'SelectInput' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(setCrtcTransformRequest(c, Crtc, Transform, FilterLen, FilterName, FilterParams), cookie) - return SetCrtcTransformCookie{cookie} + c.NewRequest(selectInputRequest(c, Window, Enable), cookie) + return SelectInputCookie{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 SetCrtcTransformCookie) Check() error { +func (cook SelectInputCookie) Check() error { return cook.Cookie.Check() } -// 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)))) +// 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 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 26 // request opcode + buf[b] = 4 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Crtc)) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - { - structBytes := Transform.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - - xgb.Put16(buf[b:], FilterLen) + xgb.Put16(buf[b:], Enable) b += 2 b += 2 // padding - copy(buf[b:], FilterName[:FilterLen]) - b += xgb.Pad(int(FilterLen)) - - for i := 0; i < int(len(FilterParams)); i++ { - xgb.Put32(buf[b:], uint32(FilterParams[i])) - b += 4 - } - b = xgb.Pad(b) - return buf } -// GetCrtcTransformCookie is a cookie used only for GetCrtcTransform requests. -type GetCrtcTransformCookie struct { +// SetCrtcConfigCookie is a cookie used only for SetCrtcConfig requests. +type SetCrtcConfigCookie struct { *xgb.Cookie } -// 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 { +// 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 { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetCrtcTransform' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'SetCrtcConfig' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getCrtcTransformRequest(c, Crtc), cookie) - return GetCrtcTransformCookie{cookie} + c.NewRequest(setCrtcConfigRequest(c, Crtc, Timestamp, ConfigTimestamp, X, Y, Mode, Rotation, Outputs), cookie) + return SetCrtcConfigCookie{cookie} } -// GetCrtcTransformUnchecked sends an unchecked request. +// SetCrtcConfigUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetCrtcTransformUnchecked(c *xgb.Conn, Crtc Crtc) GetCrtcTransformCookie { +func SetCrtcConfigUnchecked(c *xgb.Conn, Crtc Crtc, Timestamp xproto.Timestamp, ConfigTimestamp xproto.Timestamp, X int16, Y int16, Mode Mode, Rotation uint16, Outputs []Output) SetCrtcConfigCookie { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetCrtcTransform' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'SetCrtcConfig' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getCrtcTransformRequest(c, Crtc), cookie) - return GetCrtcTransformCookie{cookie} + c.NewRequest(setCrtcConfigRequest(c, Crtc, Timestamp, ConfigTimestamp, X, Y, Mode, Rotation, Outputs), cookie) + return SetCrtcConfigCookie{cookie} } -// GetCrtcTransformReply represents the data returned from a GetCrtcTransform request. -type GetCrtcTransformReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - 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)) +// 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 } -// Reply blocks and returns the reply data for a GetCrtcTransform request. -func (cook GetCrtcTransformCookie) Reply() (*GetCrtcTransformReply, error) { +// Reply blocks and returns the reply data for a SetCrtcConfig request. +func (cook SetCrtcConfigCookie) Reply() (*SetCrtcConfigReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -3738,93 +3647,123 @@ func (cook GetCrtcTransformCookie) Reply() (*GetCrtcTransformReply, error) { if buf == nil { return nil, nil } - return getCrtcTransformReply(buf), nil + 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 } -// getCrtcTransformReply reads a byte slice into a GetCrtcTransformReply value. -func getCrtcTransformReply(buf []byte) *GetCrtcTransformReply { - v := new(GetCrtcTransformReply) - b := 1 // skip reply determinant +// 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 - b += 1 // padding + buf[b] = 21 // request opcode + b += 1 - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + xgb.Put32(buf[b:], uint32(Crtc)) b += 4 - v.PendingTransform = render.Transform{} - b += render.TransformRead(buf[b:], &v.PendingTransform) - - if buf[b] == 1 { - v.HasTransforms = true - } else { - v.HasTransforms = false - } - b += 1 - - b += 3 // padding - - v.CurrentTransform = render.Transform{} - b += render.TransformRead(buf[b:], &v.CurrentTransform) + xgb.Put32(buf[b:], uint32(Timestamp)) + b += 4 - b += 4 // padding + xgb.Put32(buf[b:], uint32(ConfigTimestamp)) + b += 4 - v.PendingLen = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(X)) b += 2 - v.PendingNparams = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(Y)) b += 2 - v.CurrentLen = xgb.Get16(buf[b:]) - b += 2 + xgb.Put32(buf[b:], uint32(Mode)) + b += 4 - v.CurrentNparams = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], Rotation) b += 2 - { - byteString := make([]byte, v.PendingLen) - copy(byteString[:v.PendingLen], buf[b:]) - v.PendingFilterName = string(byteString) - b += xgb.Pad(int(v.PendingLen)) - } + b += 2 // padding - v.PendingParams = make([]render.Fixed, v.PendingNparams) - for i := 0; i < int(v.PendingNparams); i++ { - v.PendingParams[i] = render.Fixed(xgb.Get32(buf[b:])) + for i := 0; i < int(len(Outputs)); i++ { + xgb.Put32(buf[b:], uint32(Outputs[i])) b += 4 } b = xgb.Pad(b) - { - byteString := make([]byte, v.CurrentLen) - copy(byteString[:v.CurrentLen], buf[b:]) - v.CurrentFilterName = string(byteString) - b += xgb.Pad(int(v.CurrentLen)) + 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.") } + cookie := c.NewCookie(false, false) + c.NewRequest(setCrtcGammaRequest(c, Crtc, Size, Red, Green, Blue), cookie) + return SetCrtcGammaCookie{cookie} +} - v.CurrentParams = make([]render.Fixed, v.CurrentNparams) - for i := 0; i < int(v.CurrentNparams); i++ { - v.CurrentParams[i] = render.Fixed(xgb.Get32(buf[b:])) - b += 4 +// 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.") } - b = xgb.Pad(b) + cookie := c.NewCookie(true, false) + c.NewRequest(setCrtcGammaRequest(c, Crtc, Size, Red, Green, Blue), cookie) + return SetCrtcGammaCookie{cookie} +} - return v +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook SetCrtcGammaCookie) Check() error { + return cook.Cookie.Check() } -// 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 +// 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)))) b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 27 // request opcode + buf[b] = 24 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -3833,141 +3772,160 @@ func getCrtcTransformRequest(c *xgb.Conn, Crtc Crtc) []byte { xgb.Put32(buf[b:], uint32(Crtc)) b += 4 + 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) + return buf } -// GetPanningCookie is a cookie used only for GetPanning requests. -type GetPanningCookie struct { +// SetCrtcTransformCookie is a cookie used only for SetCrtcTransform requests. +type SetCrtcTransformCookie struct { *xgb.Cookie } -// 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 { +// 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 { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetPanning' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'SetCrtcTransform' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, true) - c.NewRequest(getPanningRequest(c, Crtc), cookie) - return GetPanningCookie{cookie} + cookie := c.NewCookie(false, false) + c.NewRequest(setCrtcTransformRequest(c, Crtc, Transform, FilterLen, FilterName, FilterParams), cookie) + return SetCrtcTransformCookie{cookie} } -// GetPanningUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetPanningUnchecked(c *xgb.Conn, Crtc Crtc) GetPanningCookie { +// 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 { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetPanning' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'SetCrtcTransform' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(getPanningRequest(c, Crtc), cookie) - return GetPanningCookie{cookie} + cookie := c.NewCookie(true, false) + c.NewRequest(setCrtcTransformRequest(c, Crtc, Transform, FilterLen, FilterName, FilterParams), cookie) + return SetCrtcTransformCookie{cookie} } -// 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 +// 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() } -// Reply blocks and returns the reply data for a GetPanning request. -func (cook GetPanningCookie) Reply() (*GetPanningReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getPanningReply(buf), nil -} +// 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) -// getPanningReply reads a byte slice into a GetPanningReply value. -func getPanningReply(buf []byte) *GetPanningReply { - v := new(GetPanningReply) - b := 1 // skip reply determinant + buf[b] = c.Extensions["RANDR"] + b += 1 - v.Status = buf[b] + buf[b] = 26 // request opcode b += 1 - v.Sequence = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:])) + xgb.Put32(buf[b:], uint32(Crtc)) b += 4 - v.Left = xgb.Get16(buf[b:]) - b += 2 - - v.Top = xgb.Get16(buf[b:]) - b += 2 - - v.Width = xgb.Get16(buf[b:]) - b += 2 - - v.Height = xgb.Get16(buf[b:]) - b += 2 + { + structBytes := Transform.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } - v.TrackLeft = xgb.Get16(buf[b:]) + xgb.Put16(buf[b:], FilterLen) b += 2 - v.TrackTop = xgb.Get16(buf[b:]) - b += 2 + b += 2 // padding - v.TrackWidth = xgb.Get16(buf[b:]) - b += 2 + copy(buf[b:], FilterName[:FilterLen]) + b += xgb.Pad(int(FilterLen)) - v.TrackHeight = xgb.Get16(buf[b:]) - b += 2 + for i := 0; i < int(len(FilterParams)); i++ { + xgb.Put32(buf[b:], uint32(FilterParams[i])) + b += 4 + } + b = xgb.Pad(b) - v.BorderLeft = int16(xgb.Get16(buf[b:])) - b += 2 + return buf +} - v.BorderTop = int16(xgb.Get16(buf[b:])) - b += 2 +// SetOutputPrimaryCookie is a cookie used only for SetOutputPrimary requests. +type SetOutputPrimaryCookie struct { + *xgb.Cookie +} - v.BorderRight = int16(xgb.Get16(buf[b:])) - b += 2 +// 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} +} - v.BorderBottom = int16(xgb.Get16(buf[b:])) - b += 2 +// 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} +} - return v +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook SetOutputPrimaryCookie) Check() error { + return cook.Cookie.Check() } -// 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 +// 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 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 28 // request opcode + buf[b] = 30 // 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)) + xgb.Put32(buf[b:], uint32(Window)) + b += 4 + + xgb.Put32(buf[b:], uint32(Output)) b += 4 return buf @@ -4101,50 +4059,99 @@ func setPanningRequest(c *xgb.Conn, Crtc Crtc, Timestamp xproto.Timestamp, Left return buf } -// SetOutputPrimaryCookie is a cookie used only for SetOutputPrimary requests. -type SetOutputPrimaryCookie struct { +// SetScreenConfigCookie is a cookie used only for SetScreenConfig requests. +type SetScreenConfigCookie struct { *xgb.Cookie } -// 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 { +// 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 { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'SetOutputPrimary' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'SetScreenConfig' 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} + cookie := c.NewCookie(true, true) + c.NewRequest(setScreenConfigRequest(c, Window, Timestamp, ConfigTimestamp, SizeID, Rotation, Rate), cookie) + return SetScreenConfigCookie{cookie} } -// 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 { +// 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 { if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'SetOutputPrimary' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'SetScreenConfig' 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} + cookie := c.NewCookie(false, true) + c.NewRequest(setScreenConfigRequest(c, Window, Timestamp, ConfigTimestamp, SizeID, Rotation, Rate), cookie) + return SetScreenConfigCookie{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 SetOutputPrimaryCookie) Check() error { - return cook.Cookie.Check() +// 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 } -// 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 +// 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 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 30 // request opcode + buf[b] = 2 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -4153,89 +4160,70 @@ func setOutputPrimaryRequest(c *xgb.Conn, Window xproto.Window, Output Output) [ xgb.Put32(buf[b:], uint32(Window)) b += 4 - xgb.Put32(buf[b:], uint32(Output)) + xgb.Put32(buf[b:], uint32(Timestamp)) + b += 4 + + xgb.Put32(buf[b:], uint32(ConfigTimestamp)) b += 4 + xgb.Put16(buf[b:], SizeID) + b += 2 + + xgb.Put16(buf[b:], Rotation) + b += 2 + + xgb.Put16(buf[b:], Rate) + b += 2 + + b += 2 // padding + return buf } -// GetOutputPrimaryCookie is a cookie used only for GetOutputPrimary requests. -type GetOutputPrimaryCookie struct { +// SetScreenSizeCookie is a cookie used only for SetScreenSize requests. +type SetScreenSizeCookie struct { *xgb.Cookie } -// 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 { - if _, ok := c.Extensions["RANDR"]; !ok { - panic("Cannot issue request 'GetOutputPrimary' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getOutputPrimaryRequest(c, Window), cookie) - return GetOutputPrimaryCookie{cookie} -} - -// GetOutputPrimaryUnchecked sends an unchecked request. +// SetScreenSize 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 { +func SetScreenSize(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 'GetOutputPrimary' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") + panic("Cannot issue request 'SetScreenSize' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(getOutputPrimaryRequest(c, Window), cookie) - return GetOutputPrimaryCookie{cookie} -} - -// 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 + cookie := c.NewCookie(false, false) + c.NewRequest(setScreenSizeRequest(c, Window, Width, Height, MmWidth, MmHeight), cookie) + return SetScreenSizeCookie{cookie} } -// 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 +// 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.") } - return getOutputPrimaryReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(setScreenSizeRequest(c, Window, Width, Height, MmWidth, MmHeight), cookie) + return SetScreenSizeCookie{cookie} } -// 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 +// 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() } -// 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 +// 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 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["RANDR"] b += 1 - buf[b] = 31 // request opcode + buf[b] = 7 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -4244,5 +4232,17 @@ func getOutputPrimaryRequest(c *xgb.Conn, Window xproto.Window) []byte { xgb.Put32(buf[b:], uint32(Window)) b += 4 + 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 + return buf } -- cgit v1.2.3