Regenerated from xcb-proto 1.12
This commit is contained in:
@@ -503,6 +503,153 @@ func ModeInfoListBytes(buf []byte, list []ModeInfo) int {
|
||||
return xgb.Pad(b)
|
||||
}
|
||||
|
||||
type MonitorInfo struct {
|
||||
Name xproto.Atom
|
||||
Primary bool
|
||||
Automatic bool
|
||||
NOutput uint16
|
||||
X int16
|
||||
Y int16
|
||||
Width uint16
|
||||
Height uint16
|
||||
WidthInMillimeters uint32
|
||||
HeightInMillimeters uint32
|
||||
Outputs []Output // size: xgb.Pad((int(NOutput) * 4))
|
||||
}
|
||||
|
||||
// MonitorInfoRead reads a byte slice into a MonitorInfo value.
|
||||
func MonitorInfoRead(buf []byte, v *MonitorInfo) int {
|
||||
b := 0
|
||||
|
||||
v.Name = xproto.Atom(xgb.Get32(buf[b:]))
|
||||
b += 4
|
||||
|
||||
if buf[b] == 1 {
|
||||
v.Primary = true
|
||||
} else {
|
||||
v.Primary = false
|
||||
}
|
||||
b += 1
|
||||
|
||||
if buf[b] == 1 {
|
||||
v.Automatic = true
|
||||
} else {
|
||||
v.Automatic = false
|
||||
}
|
||||
b += 1
|
||||
|
||||
v.NOutput = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.X = int16(xgb.Get16(buf[b:]))
|
||||
b += 2
|
||||
|
||||
v.Y = int16(xgb.Get16(buf[b:]))
|
||||
b += 2
|
||||
|
||||
v.Width = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Height = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.WidthInMillimeters = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
v.HeightInMillimeters = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
v.Outputs = make([]Output, v.NOutput)
|
||||
for i := 0; i < int(v.NOutput); i++ {
|
||||
v.Outputs[i] = Output(xgb.Get32(buf[b:]))
|
||||
b += 4
|
||||
}
|
||||
|
||||
return b
|
||||
}
|
||||
|
||||
// MonitorInfoReadList reads a byte slice into a list of MonitorInfo values.
|
||||
func MonitorInfoReadList(buf []byte, dest []MonitorInfo) int {
|
||||
b := 0
|
||||
for i := 0; i < len(dest); i++ {
|
||||
dest[i] = MonitorInfo{}
|
||||
b += MonitorInfoRead(buf[b:], &dest[i])
|
||||
}
|
||||
return xgb.Pad(b)
|
||||
}
|
||||
|
||||
// Bytes writes a MonitorInfo value to a byte slice.
|
||||
func (v MonitorInfo) Bytes() []byte {
|
||||
buf := make([]byte, (24 + xgb.Pad((int(v.NOutput) * 4))))
|
||||
b := 0
|
||||
|
||||
xgb.Put32(buf[b:], uint32(v.Name))
|
||||
b += 4
|
||||
|
||||
if v.Primary {
|
||||
buf[b] = 1
|
||||
} else {
|
||||
buf[b] = 0
|
||||
}
|
||||
b += 1
|
||||
|
||||
if v.Automatic {
|
||||
buf[b] = 1
|
||||
} else {
|
||||
buf[b] = 0
|
||||
}
|
||||
b += 1
|
||||
|
||||
xgb.Put16(buf[b:], v.NOutput)
|
||||
b += 2
|
||||
|
||||
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
|
||||
|
||||
xgb.Put32(buf[b:], v.WidthInMillimeters)
|
||||
b += 4
|
||||
|
||||
xgb.Put32(buf[b:], v.HeightInMillimeters)
|
||||
b += 4
|
||||
|
||||
for i := 0; i < int(v.NOutput); i++ {
|
||||
xgb.Put32(buf[b:], uint32(v.Outputs[i]))
|
||||
b += 4
|
||||
}
|
||||
|
||||
return buf[:b]
|
||||
}
|
||||
|
||||
// MonitorInfoListBytes writes a list of MonitorInfo values to a byte slice.
|
||||
func MonitorInfoListBytes(buf []byte, list []MonitorInfo) int {
|
||||
b := 0
|
||||
var structBytes []byte
|
||||
for _, item := range list {
|
||||
structBytes = item.Bytes()
|
||||
copy(buf[b:], structBytes)
|
||||
b += len(structBytes)
|
||||
}
|
||||
return xgb.Pad(b)
|
||||
}
|
||||
|
||||
// MonitorInfoListSize computes the size (bytes) of a list of MonitorInfo values.
|
||||
func MonitorInfoListSize(list []MonitorInfo) int {
|
||||
size := 0
|
||||
for _, item := range list {
|
||||
size += (24 + xgb.Pad((int(item.NOutput) * 4)))
|
||||
}
|
||||
return size
|
||||
}
|
||||
|
||||
const (
|
||||
NotifyCrtcChange = 0
|
||||
NotifyOutputChange = 1
|
||||
@@ -2173,6 +2320,70 @@ func createModeRequest(c *xgb.Conn, Window xproto.Window, ModeInfo ModeInfo, Nam
|
||||
return buf
|
||||
}
|
||||
|
||||
// DeleteMonitorCookie is a cookie used only for DeleteMonitor requests.
|
||||
type DeleteMonitorCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
// DeleteMonitor sends an unchecked request.
|
||||
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
||||
func DeleteMonitor(c *xgb.Conn, Window xproto.Window, Name xproto.Atom) DeleteMonitorCookie {
|
||||
c.ExtLock.RLock()
|
||||
defer c.ExtLock.RUnlock()
|
||||
if _, ok := c.Extensions["RANDR"]; !ok {
|
||||
panic("Cannot issue request 'DeleteMonitor' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.")
|
||||
}
|
||||
cookie := c.NewCookie(false, false)
|
||||
c.NewRequest(deleteMonitorRequest(c, Window, Name), cookie)
|
||||
return DeleteMonitorCookie{cookie}
|
||||
}
|
||||
|
||||
// DeleteMonitorChecked sends a checked request.
|
||||
// If an error occurs, it can be retrieved using DeleteMonitorCookie.Check()
|
||||
func DeleteMonitorChecked(c *xgb.Conn, Window xproto.Window, Name xproto.Atom) DeleteMonitorCookie {
|
||||
c.ExtLock.RLock()
|
||||
defer c.ExtLock.RUnlock()
|
||||
if _, ok := c.Extensions["RANDR"]; !ok {
|
||||
panic("Cannot issue request 'DeleteMonitor' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.")
|
||||
}
|
||||
cookie := c.NewCookie(true, false)
|
||||
c.NewRequest(deleteMonitorRequest(c, Window, Name), cookie)
|
||||
return DeleteMonitorCookie{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 DeleteMonitorCookie) Check() error {
|
||||
return cook.Cookie.Check()
|
||||
}
|
||||
|
||||
// Write request to wire for DeleteMonitor
|
||||
// deleteMonitorRequest writes a DeleteMonitor request to a byte slice.
|
||||
func deleteMonitorRequest(c *xgb.Conn, Window xproto.Window, Name xproto.Atom) []byte {
|
||||
size := 12
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
c.ExtLock.RLock()
|
||||
buf[b] = c.Extensions["RANDR"]
|
||||
c.ExtLock.RUnlock()
|
||||
b += 1
|
||||
|
||||
buf[b] = 44 // 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.Put32(buf[b:], uint32(Name))
|
||||
b += 4
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// DeleteOutputModeCookie is a cookie used only for DeleteOutputMode requests.
|
||||
type DeleteOutputModeCookie struct {
|
||||
*xgb.Cookie
|
||||
@@ -2464,11 +2675,9 @@ type GetCrtcGammaReply struct {
|
||||
// padding: 1 bytes
|
||||
Size uint16
|
||||
// padding: 22 bytes
|
||||
Red []uint16 // size: xgb.Pad((int(Size) * 2))
|
||||
// alignment gap to multiple of 2
|
||||
Red []uint16 // size: xgb.Pad((int(Size) * 2))
|
||||
Green []uint16 // size: xgb.Pad((int(Size) * 2))
|
||||
// alignment gap to multiple of 2
|
||||
Blue []uint16 // size: xgb.Pad((int(Size) * 2))
|
||||
Blue []uint16 // size: xgb.Pad((int(Size) * 2))
|
||||
}
|
||||
|
||||
// Reply blocks and returns the reply data for a GetCrtcGamma request.
|
||||
@@ -2507,16 +2716,12 @@ func getCrtcGammaReply(buf []byte) *GetCrtcGammaReply {
|
||||
b += 2
|
||||
}
|
||||
|
||||
b = (b + 1) & ^1 // alignment gap
|
||||
|
||||
v.Green = make([]uint16, v.Size)
|
||||
for i := 0; i < int(v.Size); i++ {
|
||||
v.Green[i] = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
}
|
||||
|
||||
b = (b + 1) & ^1 // alignment gap
|
||||
|
||||
v.Blue = make([]uint16, v.Size)
|
||||
for i := 0; i < int(v.Size); i++ {
|
||||
v.Blue[i] = xgb.Get16(buf[b:])
|
||||
@@ -2694,8 +2899,7 @@ type GetCrtcInfoReply struct {
|
||||
NumOutputs uint16
|
||||
NumPossibleOutputs uint16
|
||||
Outputs []Output // size: xgb.Pad((int(NumOutputs) * 4))
|
||||
// alignment gap to multiple of 4
|
||||
Possible []Output // size: xgb.Pad((int(NumPossibleOutputs) * 4))
|
||||
Possible []Output // size: xgb.Pad((int(NumPossibleOutputs) * 4))
|
||||
}
|
||||
|
||||
// Reply blocks and returns the reply data for a GetCrtcInfo request.
|
||||
@@ -2760,8 +2964,6 @@ func getCrtcInfoReply(buf []byte) *GetCrtcInfoReply {
|
||||
b += 4
|
||||
}
|
||||
|
||||
b = (b + 3) & ^3 // alignment gap
|
||||
|
||||
v.Possible = make([]Output, v.NumPossibleOutputs)
|
||||
for i := 0; i < int(v.NumPossibleOutputs); i++ {
|
||||
v.Possible[i] = Output(xgb.Get32(buf[b:]))
|
||||
@@ -2962,6 +3164,122 @@ func getCrtcTransformRequest(c *xgb.Conn, Crtc Crtc) []byte {
|
||||
return buf
|
||||
}
|
||||
|
||||
// GetMonitorsCookie is a cookie used only for GetMonitors requests.
|
||||
type GetMonitorsCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
// GetMonitors sends a checked request.
|
||||
// If an error occurs, it will be returned with the reply by calling GetMonitorsCookie.Reply()
|
||||
func GetMonitors(c *xgb.Conn, Window xproto.Window, GetActive bool) GetMonitorsCookie {
|
||||
c.ExtLock.RLock()
|
||||
defer c.ExtLock.RUnlock()
|
||||
if _, ok := c.Extensions["RANDR"]; !ok {
|
||||
panic("Cannot issue request 'GetMonitors' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.")
|
||||
}
|
||||
cookie := c.NewCookie(true, true)
|
||||
c.NewRequest(getMonitorsRequest(c, Window, GetActive), cookie)
|
||||
return GetMonitorsCookie{cookie}
|
||||
}
|
||||
|
||||
// GetMonitorsUnchecked sends an unchecked request.
|
||||
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
||||
func GetMonitorsUnchecked(c *xgb.Conn, Window xproto.Window, GetActive bool) GetMonitorsCookie {
|
||||
c.ExtLock.RLock()
|
||||
defer c.ExtLock.RUnlock()
|
||||
if _, ok := c.Extensions["RANDR"]; !ok {
|
||||
panic("Cannot issue request 'GetMonitors' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.")
|
||||
}
|
||||
cookie := c.NewCookie(false, true)
|
||||
c.NewRequest(getMonitorsRequest(c, Window, GetActive), cookie)
|
||||
return GetMonitorsCookie{cookie}
|
||||
}
|
||||
|
||||
// GetMonitorsReply represents the data returned from a GetMonitors request.
|
||||
type GetMonitorsReply 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
|
||||
NMonitors uint32
|
||||
NOutputs uint32
|
||||
// padding: 12 bytes
|
||||
Monitors []MonitorInfo // size: MonitorInfoListSize(Monitors)
|
||||
}
|
||||
|
||||
// Reply blocks and returns the reply data for a GetMonitors request.
|
||||
func (cook GetMonitorsCookie) Reply() (*GetMonitorsReply, error) {
|
||||
buf, err := cook.Cookie.Reply()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return getMonitorsReply(buf), nil
|
||||
}
|
||||
|
||||
// getMonitorsReply reads a byte slice into a GetMonitorsReply value.
|
||||
func getMonitorsReply(buf []byte) *GetMonitorsReply {
|
||||
v := new(GetMonitorsReply)
|
||||
b := 1 // skip reply determinant
|
||||
|
||||
b += 1 // padding
|
||||
|
||||
v.Sequence = xgb.Get16(buf[b:])
|
||||
b += 2
|
||||
|
||||
v.Length = xgb.Get32(buf[b:]) // 4-byte units
|
||||
b += 4
|
||||
|
||||
v.Timestamp = xproto.Timestamp(xgb.Get32(buf[b:]))
|
||||
b += 4
|
||||
|
||||
v.NMonitors = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
v.NOutputs = xgb.Get32(buf[b:])
|
||||
b += 4
|
||||
|
||||
b += 12 // padding
|
||||
|
||||
v.Monitors = make([]MonitorInfo, v.NMonitors)
|
||||
b += MonitorInfoReadList(buf[b:], v.Monitors)
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Write request to wire for GetMonitors
|
||||
// getMonitorsRequest writes a GetMonitors request to a byte slice.
|
||||
func getMonitorsRequest(c *xgb.Conn, Window xproto.Window, GetActive bool) []byte {
|
||||
size := 12
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
c.ExtLock.RLock()
|
||||
buf[b] = c.Extensions["RANDR"]
|
||||
c.ExtLock.RUnlock()
|
||||
b += 1
|
||||
|
||||
buf[b] = 42 // 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
|
||||
|
||||
if GetActive {
|
||||
buf[b] = 1
|
||||
} else {
|
||||
buf[b] = 0
|
||||
}
|
||||
b += 1
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// GetOutputInfoCookie is a cookie used only for GetOutputInfo requests.
|
||||
type GetOutputInfoCookie struct {
|
||||
*xgb.Cookie
|
||||
@@ -3009,12 +3327,10 @@ type GetOutputInfoReply struct {
|
||||
NumPreferred uint16
|
||||
NumClones uint16
|
||||
NameLen uint16
|
||||
Crtcs []Crtc // size: xgb.Pad((int(NumCrtcs) * 4))
|
||||
// alignment gap to multiple of 4
|
||||
Modes []Mode // size: xgb.Pad((int(NumModes) * 4))
|
||||
// alignment gap to multiple of 4
|
||||
Clones []Output // size: xgb.Pad((int(NumClones) * 4))
|
||||
Name []byte // size: xgb.Pad((int(NameLen) * 1))
|
||||
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))
|
||||
}
|
||||
|
||||
// Reply blocks and returns the reply data for a GetOutputInfo request.
|
||||
@@ -3082,16 +3398,12 @@ func getOutputInfoReply(buf []byte) *GetOutputInfoReply {
|
||||
b += 4
|
||||
}
|
||||
|
||||
b = (b + 3) & ^3 // alignment gap
|
||||
|
||||
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 = (b + 3) & ^3 // alignment gap
|
||||
|
||||
v.Clones = make([]Output, v.NumClones)
|
||||
for i := 0; i < int(v.NumClones); i++ {
|
||||
v.Clones[i] = Output(xgb.Get32(buf[b:]))
|
||||
@@ -3551,14 +3863,11 @@ type GetProviderInfoReply struct {
|
||||
NumAssociatedProviders uint16
|
||||
NameLen uint16
|
||||
// padding: 8 bytes
|
||||
Crtcs []Crtc // size: xgb.Pad((int(NumCrtcs) * 4))
|
||||
// alignment gap to multiple of 4
|
||||
Outputs []Output // size: xgb.Pad((int(NumOutputs) * 4))
|
||||
// alignment gap to multiple of 4
|
||||
AssociatedProviders []Provider // size: xgb.Pad((int(NumAssociatedProviders) * 4))
|
||||
// alignment gap to multiple of 4
|
||||
AssociatedCapability []uint32 // size: xgb.Pad((int(NumAssociatedProviders) * 4))
|
||||
Name string // size: xgb.Pad((int(NameLen) * 1))
|
||||
Crtcs []Crtc // size: xgb.Pad((int(NumCrtcs) * 4))
|
||||
Outputs []Output // size: xgb.Pad((int(NumOutputs) * 4))
|
||||
AssociatedProviders []Provider // size: xgb.Pad((int(NumAssociatedProviders) * 4))
|
||||
AssociatedCapability []uint32 // size: xgb.Pad((int(NumAssociatedProviders) * 4))
|
||||
Name string // size: xgb.Pad((int(NameLen) * 1))
|
||||
}
|
||||
|
||||
// Reply blocks and returns the reply data for a GetProviderInfo request.
|
||||
@@ -3613,24 +3922,18 @@ func getProviderInfoReply(buf []byte) *GetProviderInfoReply {
|
||||
b += 4
|
||||
}
|
||||
|
||||
b = (b + 3) & ^3 // alignment gap
|
||||
|
||||
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 = (b + 3) & ^3 // alignment gap
|
||||
|
||||
v.AssociatedProviders = make([]Provider, v.NumAssociatedProviders)
|
||||
for i := 0; i < int(v.NumAssociatedProviders); i++ {
|
||||
v.AssociatedProviders[i] = Provider(xgb.Get32(buf[b:]))
|
||||
b += 4
|
||||
}
|
||||
|
||||
b = (b + 3) & ^3 // alignment gap
|
||||
|
||||
v.AssociatedCapability = make([]uint32, v.NumAssociatedProviders)
|
||||
for i := 0; i < int(v.NumAssociatedProviders); i++ {
|
||||
v.AssociatedCapability[i] = xgb.Get32(buf[b:])
|
||||
@@ -3966,8 +4269,7 @@ type GetScreenInfoReply struct {
|
||||
Rate uint16
|
||||
NInfo uint16
|
||||
// padding: 2 bytes
|
||||
Sizes []ScreenSize // size: xgb.Pad((int(NSizes) * 8))
|
||||
// alignment gap to multiple of 2
|
||||
Sizes []ScreenSize // size: xgb.Pad((int(NSizes) * 8))
|
||||
Rates []RefreshRates // size: RefreshRatesListSize(Rates)
|
||||
}
|
||||
|
||||
@@ -4026,8 +4328,6 @@ func getScreenInfoReply(buf []byte) *GetScreenInfoReply {
|
||||
v.Sizes = make([]ScreenSize, v.NSizes)
|
||||
b += ScreenSizeReadList(buf[b:], v.Sizes)
|
||||
|
||||
b = (b + 1) & ^1 // alignment gap
|
||||
|
||||
v.Rates = make([]RefreshRates, (int(v.NInfo) - int(v.NSizes)))
|
||||
b += RefreshRatesReadList(buf[b:], v.Rates)
|
||||
|
||||
@@ -4101,12 +4401,10 @@ type GetScreenResourcesReply struct {
|
||||
NumModes uint16
|
||||
NamesLen uint16
|
||||
// padding: 8 bytes
|
||||
Crtcs []Crtc // size: xgb.Pad((int(NumCrtcs) * 4))
|
||||
// alignment gap to multiple of 4
|
||||
Outputs []Output // size: xgb.Pad((int(NumOutputs) * 4))
|
||||
// alignment gap to multiple of 4
|
||||
Modes []ModeInfo // size: xgb.Pad((int(NumModes) * 32))
|
||||
Names []byte // size: xgb.Pad((int(NamesLen) * 1))
|
||||
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 GetScreenResources request.
|
||||
@@ -4160,16 +4458,12 @@ func getScreenResourcesReply(buf []byte) *GetScreenResourcesReply {
|
||||
b += 4
|
||||
}
|
||||
|
||||
b = (b + 3) & ^3 // alignment gap
|
||||
|
||||
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 = (b + 3) & ^3 // alignment gap
|
||||
|
||||
v.Modes = make([]ModeInfo, v.NumModes)
|
||||
b += ModeInfoReadList(buf[b:], v.Modes)
|
||||
|
||||
@@ -4247,12 +4541,10 @@ type GetScreenResourcesCurrentReply struct {
|
||||
NumModes uint16
|
||||
NamesLen uint16
|
||||
// padding: 8 bytes
|
||||
Crtcs []Crtc // size: xgb.Pad((int(NumCrtcs) * 4))
|
||||
// alignment gap to multiple of 4
|
||||
Outputs []Output // size: xgb.Pad((int(NumOutputs) * 4))
|
||||
// alignment gap to multiple of 4
|
||||
Modes []ModeInfo // size: xgb.Pad((int(NumModes) * 32))
|
||||
Names []byte // size: xgb.Pad((int(NamesLen) * 1))
|
||||
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 GetScreenResourcesCurrent request.
|
||||
@@ -4306,16 +4598,12 @@ func getScreenResourcesCurrentReply(buf []byte) *GetScreenResourcesCurrentReply
|
||||
b += 4
|
||||
}
|
||||
|
||||
b = (b + 3) & ^3 // alignment gap
|
||||
|
||||
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 = (b + 3) & ^3 // alignment gap
|
||||
|
||||
v.Modes = make([]ModeInfo, v.NumModes)
|
||||
b += ModeInfoReadList(buf[b:], v.Modes)
|
||||
|
||||
@@ -5254,7 +5542,7 @@ func (cook SetCrtcGammaCookie) Check() error {
|
||||
// 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))) + 2) + xgb.Pad((int(Size) * 2))) + 2) + xgb.Pad((int(Size) * 2))))
|
||||
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)
|
||||
|
||||
@@ -5266,7 +5554,7 @@ func setCrtcGammaRequest(c *xgb.Conn, Crtc Crtc, Size uint16, Red []uint16, Gree
|
||||
buf[b] = 24 // request opcode
|
||||
b += 1
|
||||
|
||||
blen := b
|
||||
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
|
||||
b += 2
|
||||
|
||||
xgb.Put32(buf[b:], uint32(Crtc))
|
||||
@@ -5282,23 +5570,17 @@ func setCrtcGammaRequest(c *xgb.Conn, Crtc Crtc, Size uint16, Red []uint16, Gree
|
||||
b += 2
|
||||
}
|
||||
|
||||
b = (b + 1) & ^1 // alignment gap
|
||||
|
||||
for i := 0; i < int(Size); i++ {
|
||||
xgb.Put16(buf[b:], Green[i])
|
||||
b += 2
|
||||
}
|
||||
|
||||
b = (b + 1) & ^1 // alignment gap
|
||||
|
||||
for i := 0; i < int(Size); i++ {
|
||||
xgb.Put16(buf[b:], Blue[i])
|
||||
b += 2
|
||||
}
|
||||
|
||||
b = xgb.Pad(b)
|
||||
xgb.Put16(buf[blen:], uint16(b/4)) // write request size in 4-byte units
|
||||
return buf[:b]
|
||||
return buf
|
||||
}
|
||||
|
||||
// SetCrtcTransformCookie is a cookie used only for SetCrtcTransform requests.
|
||||
@@ -5385,6 +5667,73 @@ func setCrtcTransformRequest(c *xgb.Conn, Crtc Crtc, Transform render.Transform,
|
||||
return buf[:b]
|
||||
}
|
||||
|
||||
// SetMonitorCookie is a cookie used only for SetMonitor requests.
|
||||
type SetMonitorCookie struct {
|
||||
*xgb.Cookie
|
||||
}
|
||||
|
||||
// SetMonitor sends an unchecked request.
|
||||
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
|
||||
func SetMonitor(c *xgb.Conn, Window xproto.Window, Monitorinfo MonitorInfo) SetMonitorCookie {
|
||||
c.ExtLock.RLock()
|
||||
defer c.ExtLock.RUnlock()
|
||||
if _, ok := c.Extensions["RANDR"]; !ok {
|
||||
panic("Cannot issue request 'SetMonitor' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.")
|
||||
}
|
||||
cookie := c.NewCookie(false, false)
|
||||
c.NewRequest(setMonitorRequest(c, Window, Monitorinfo), cookie)
|
||||
return SetMonitorCookie{cookie}
|
||||
}
|
||||
|
||||
// SetMonitorChecked sends a checked request.
|
||||
// If an error occurs, it can be retrieved using SetMonitorCookie.Check()
|
||||
func SetMonitorChecked(c *xgb.Conn, Window xproto.Window, Monitorinfo MonitorInfo) SetMonitorCookie {
|
||||
c.ExtLock.RLock()
|
||||
defer c.ExtLock.RUnlock()
|
||||
if _, ok := c.Extensions["RANDR"]; !ok {
|
||||
panic("Cannot issue request 'SetMonitor' using the uninitialized extension 'RANDR'. randr.Init(connObj) must be called first.")
|
||||
}
|
||||
cookie := c.NewCookie(true, false)
|
||||
c.NewRequest(setMonitorRequest(c, Window, Monitorinfo), cookie)
|
||||
return SetMonitorCookie{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 SetMonitorCookie) Check() error {
|
||||
return cook.Cookie.Check()
|
||||
}
|
||||
|
||||
// Write request to wire for SetMonitor
|
||||
// setMonitorRequest writes a SetMonitor request to a byte slice.
|
||||
func setMonitorRequest(c *xgb.Conn, Window xproto.Window, Monitorinfo MonitorInfo) []byte {
|
||||
size := xgb.Pad((8 + (24 + xgb.Pad((int(Monitorinfo.NOutput) * 4)))))
|
||||
b := 0
|
||||
buf := make([]byte, size)
|
||||
|
||||
c.ExtLock.RLock()
|
||||
buf[b] = c.Extensions["RANDR"]
|
||||
c.ExtLock.RUnlock()
|
||||
b += 1
|
||||
|
||||
buf[b] = 43 // 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
|
||||
|
||||
{
|
||||
structBytes := Monitorinfo.Bytes()
|
||||
copy(buf[b:], structBytes)
|
||||
b += len(structBytes)
|
||||
}
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// SetOutputPrimaryCookie is a cookie used only for SetOutputPrimary requests.
|
||||
type SetOutputPrimaryCookie struct {
|
||||
*xgb.Cookie
|
||||
|
||||
Reference in New Issue
Block a user