Regenerated from xcb-proto 1.12

This commit is contained in:
aarzilli 2017-01-18 10:52:16 +01:00 committed by Přemysl Janouch
parent 1c01d79ba1
commit 3906399e7c
Signed by: p
GPG Key ID: A0420B94F92B9493
13 changed files with 667 additions and 264 deletions

View File

@ -3165,14 +3165,14 @@ func getClipPlaneReply(buf []byte) *GetClipPlaneReply {
v := new(GetClipPlaneReply) v := new(GetClipPlaneReply)
b := 1 // skip reply determinant b := 1 // skip reply determinant
b += 1 // padding
v.Sequence = xgb.Get16(buf[b:]) v.Sequence = xgb.Get16(buf[b:])
b += 2 b += 2
v.Length = xgb.Get32(buf[b:]) // 4-byte units v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4 b += 4
b += 1 // padding
b += 24 // padding b += 24 // padding
v.Data = make([]Float64, (int(v.Length) / 2)) v.Data = make([]Float64, (int(v.Length) / 2))
@ -4096,14 +4096,14 @@ func getDoublevReply(buf []byte) *GetDoublevReply {
v := new(GetDoublevReply) v := new(GetDoublevReply)
b := 1 // skip reply determinant b := 1 // skip reply determinant
b += 1 // padding
v.Sequence = xgb.Get16(buf[b:]) v.Sequence = xgb.Get16(buf[b:])
b += 2 b += 2
v.Length = xgb.Get32(buf[b:]) // 4-byte units v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4 b += 4
b += 1 // padding
b += 4 // padding b += 4 // padding
v.N = xgb.Get32(buf[b:]) v.N = xgb.Get32(buf[b:])
@ -5340,14 +5340,14 @@ func getMapdvReply(buf []byte) *GetMapdvReply {
v := new(GetMapdvReply) v := new(GetMapdvReply)
b := 1 // skip reply determinant b := 1 // skip reply determinant
b += 1 // padding
v.Sequence = xgb.Get16(buf[b:]) v.Sequence = xgb.Get16(buf[b:])
b += 2 b += 2
v.Length = xgb.Get32(buf[b:]) // 4-byte units v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4 b += 4
b += 1 // padding
b += 4 // padding b += 4 // padding
v.N = xgb.Get32(buf[b:]) v.N = xgb.Get32(buf[b:])
@ -7548,14 +7548,14 @@ func getTexGendvReply(buf []byte) *GetTexGendvReply {
v := new(GetTexGendvReply) v := new(GetTexGendvReply)
b := 1 // skip reply determinant b := 1 // skip reply determinant
b += 1 // padding
v.Sequence = xgb.Get16(buf[b:]) v.Sequence = xgb.Get16(buf[b:])
b += 2 b += 2
v.Length = xgb.Get32(buf[b:]) // 4-byte units v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4 b += 4
b += 1 // padding
b += 4 // padding b += 4 // padding
v.N = xgb.Get32(buf[b:]) v.N = xgb.Get32(buf[b:])
@ -8654,6 +8654,103 @@ func isDirectRequest(c *xgb.Conn, Context Context) []byte {
return buf return buf
} }
// IsEnabledCookie is a cookie used only for IsEnabled requests.
type IsEnabledCookie struct {
*xgb.Cookie
}
// IsEnabled sends a checked request.
// If an error occurs, it will be returned with the reply by calling IsEnabledCookie.Reply()
func IsEnabled(c *xgb.Conn, ContextTag ContextTag, Capability uint32) IsEnabledCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["GLX"]; !ok {
panic("Cannot issue request 'IsEnabled' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, true)
c.NewRequest(isEnabledRequest(c, ContextTag, Capability), cookie)
return IsEnabledCookie{cookie}
}
// IsEnabledUnchecked sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func IsEnabledUnchecked(c *xgb.Conn, ContextTag ContextTag, Capability uint32) IsEnabledCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["GLX"]; !ok {
panic("Cannot issue request 'IsEnabled' using the uninitialized extension 'GLX'. glx.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, true)
c.NewRequest(isEnabledRequest(c, ContextTag, Capability), cookie)
return IsEnabledCookie{cookie}
}
// IsEnabledReply represents the data returned from a IsEnabled request.
type IsEnabledReply struct {
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
// padding: 1 bytes
RetVal Bool32
}
// Reply blocks and returns the reply data for a IsEnabled request.
func (cook IsEnabledCookie) Reply() (*IsEnabledReply, error) {
buf, err := cook.Cookie.Reply()
if err != nil {
return nil, err
}
if buf == nil {
return nil, nil
}
return isEnabledReply(buf), nil
}
// isEnabledReply reads a byte slice into a IsEnabledReply value.
func isEnabledReply(buf []byte) *IsEnabledReply {
v := new(IsEnabledReply)
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.RetVal = Bool32(xgb.Get32(buf[b:]))
b += 4
return v
}
// Write request to wire for IsEnabled
// isEnabledRequest writes a IsEnabled request to a byte slice.
func isEnabledRequest(c *xgb.Conn, ContextTag ContextTag, Capability uint32) []byte {
size := 12
b := 0
buf := make([]byte, size)
c.ExtLock.RLock()
buf[b] = c.Extensions["GLX"]
c.ExtLock.RUnlock()
b += 1
buf[b] = 140 // 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(ContextTag))
b += 4
xgb.Put32(buf[b:], Capability)
b += 4
return buf
}
// IsListCookie is a cookie used only for IsList requests. // IsListCookie is a cookie used only for IsList requests.
type IsListCookie struct { type IsListCookie struct {
*xgb.Cookie *xgb.Cookie

View File

@ -503,6 +503,153 @@ func ModeInfoListBytes(buf []byte, list []ModeInfo) int {
return xgb.Pad(b) 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 ( const (
NotifyCrtcChange = 0 NotifyCrtcChange = 0
NotifyOutputChange = 1 NotifyOutputChange = 1
@ -2173,6 +2320,70 @@ func createModeRequest(c *xgb.Conn, Window xproto.Window, ModeInfo ModeInfo, Nam
return buf 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. // DeleteOutputModeCookie is a cookie used only for DeleteOutputMode requests.
type DeleteOutputModeCookie struct { type DeleteOutputModeCookie struct {
*xgb.Cookie *xgb.Cookie
@ -2465,9 +2676,7 @@ type GetCrtcGammaReply struct {
Size uint16 Size uint16
// padding: 22 bytes // padding: 22 bytes
Red []uint16 // size: xgb.Pad((int(Size) * 2)) Red []uint16 // size: xgb.Pad((int(Size) * 2))
// alignment gap to multiple of 2
Green []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))
} }
@ -2507,16 +2716,12 @@ func getCrtcGammaReply(buf []byte) *GetCrtcGammaReply {
b += 2 b += 2
} }
b = (b + 1) & ^1 // alignment gap
v.Green = make([]uint16, v.Size) v.Green = make([]uint16, v.Size)
for i := 0; i < int(v.Size); i++ { for i := 0; i < int(v.Size); i++ {
v.Green[i] = xgb.Get16(buf[b:]) v.Green[i] = xgb.Get16(buf[b:])
b += 2 b += 2
} }
b = (b + 1) & ^1 // alignment gap
v.Blue = make([]uint16, v.Size) v.Blue = make([]uint16, v.Size)
for i := 0; i < int(v.Size); i++ { for i := 0; i < int(v.Size); i++ {
v.Blue[i] = xgb.Get16(buf[b:]) v.Blue[i] = xgb.Get16(buf[b:])
@ -2694,7 +2899,6 @@ type GetCrtcInfoReply struct {
NumOutputs uint16 NumOutputs uint16
NumPossibleOutputs uint16 NumPossibleOutputs uint16
Outputs []Output // size: xgb.Pad((int(NumOutputs) * 4)) 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))
} }
@ -2760,8 +2964,6 @@ func getCrtcInfoReply(buf []byte) *GetCrtcInfoReply {
b += 4 b += 4
} }
b = (b + 3) & ^3 // alignment gap
v.Possible = make([]Output, v.NumPossibleOutputs) v.Possible = make([]Output, v.NumPossibleOutputs)
for i := 0; i < int(v.NumPossibleOutputs); i++ { for i := 0; i < int(v.NumPossibleOutputs); i++ {
v.Possible[i] = Output(xgb.Get32(buf[b:])) v.Possible[i] = Output(xgb.Get32(buf[b:]))
@ -2962,6 +3164,122 @@ func getCrtcTransformRequest(c *xgb.Conn, Crtc Crtc) []byte {
return buf 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. // GetOutputInfoCookie is a cookie used only for GetOutputInfo requests.
type GetOutputInfoCookie struct { type GetOutputInfoCookie struct {
*xgb.Cookie *xgb.Cookie
@ -3010,9 +3328,7 @@ type GetOutputInfoReply struct {
NumClones uint16 NumClones uint16
NameLen uint16 NameLen uint16
Crtcs []Crtc // size: xgb.Pad((int(NumCrtcs) * 4)) Crtcs []Crtc // size: xgb.Pad((int(NumCrtcs) * 4))
// alignment gap to multiple of 4
Modes []Mode // size: xgb.Pad((int(NumModes) * 4)) Modes []Mode // size: xgb.Pad((int(NumModes) * 4))
// alignment gap to multiple of 4
Clones []Output // size: xgb.Pad((int(NumClones) * 4)) Clones []Output // size: xgb.Pad((int(NumClones) * 4))
Name []byte // size: xgb.Pad((int(NameLen) * 1)) Name []byte // size: xgb.Pad((int(NameLen) * 1))
} }
@ -3082,16 +3398,12 @@ func getOutputInfoReply(buf []byte) *GetOutputInfoReply {
b += 4 b += 4
} }
b = (b + 3) & ^3 // alignment gap
v.Modes = make([]Mode, v.NumModes) v.Modes = make([]Mode, v.NumModes)
for i := 0; i < int(v.NumModes); i++ { for i := 0; i < int(v.NumModes); i++ {
v.Modes[i] = Mode(xgb.Get32(buf[b:])) v.Modes[i] = Mode(xgb.Get32(buf[b:]))
b += 4 b += 4
} }
b = (b + 3) & ^3 // alignment gap
v.Clones = make([]Output, v.NumClones) v.Clones = make([]Output, v.NumClones)
for i := 0; i < int(v.NumClones); i++ { for i := 0; i < int(v.NumClones); i++ {
v.Clones[i] = Output(xgb.Get32(buf[b:])) v.Clones[i] = Output(xgb.Get32(buf[b:]))
@ -3552,11 +3864,8 @@ type GetProviderInfoReply struct {
NameLen uint16 NameLen uint16
// padding: 8 bytes // padding: 8 bytes
Crtcs []Crtc // size: xgb.Pad((int(NumCrtcs) * 4)) Crtcs []Crtc // size: xgb.Pad((int(NumCrtcs) * 4))
// alignment gap to multiple of 4
Outputs []Output // size: xgb.Pad((int(NumOutputs) * 4)) Outputs []Output // size: xgb.Pad((int(NumOutputs) * 4))
// alignment gap to multiple of 4
AssociatedProviders []Provider // size: xgb.Pad((int(NumAssociatedProviders) * 4)) AssociatedProviders []Provider // size: xgb.Pad((int(NumAssociatedProviders) * 4))
// alignment gap to multiple of 4
AssociatedCapability []uint32 // size: xgb.Pad((int(NumAssociatedProviders) * 4)) AssociatedCapability []uint32 // size: xgb.Pad((int(NumAssociatedProviders) * 4))
Name string // size: xgb.Pad((int(NameLen) * 1)) Name string // size: xgb.Pad((int(NameLen) * 1))
} }
@ -3613,24 +3922,18 @@ func getProviderInfoReply(buf []byte) *GetProviderInfoReply {
b += 4 b += 4
} }
b = (b + 3) & ^3 // alignment gap
v.Outputs = make([]Output, v.NumOutputs) v.Outputs = make([]Output, v.NumOutputs)
for i := 0; i < int(v.NumOutputs); i++ { for i := 0; i < int(v.NumOutputs); i++ {
v.Outputs[i] = Output(xgb.Get32(buf[b:])) v.Outputs[i] = Output(xgb.Get32(buf[b:]))
b += 4 b += 4
} }
b = (b + 3) & ^3 // alignment gap
v.AssociatedProviders = make([]Provider, v.NumAssociatedProviders) v.AssociatedProviders = make([]Provider, v.NumAssociatedProviders)
for i := 0; i < int(v.NumAssociatedProviders); i++ { for i := 0; i < int(v.NumAssociatedProviders); i++ {
v.AssociatedProviders[i] = Provider(xgb.Get32(buf[b:])) v.AssociatedProviders[i] = Provider(xgb.Get32(buf[b:]))
b += 4 b += 4
} }
b = (b + 3) & ^3 // alignment gap
v.AssociatedCapability = make([]uint32, v.NumAssociatedProviders) v.AssociatedCapability = make([]uint32, v.NumAssociatedProviders)
for i := 0; i < int(v.NumAssociatedProviders); i++ { for i := 0; i < int(v.NumAssociatedProviders); i++ {
v.AssociatedCapability[i] = xgb.Get32(buf[b:]) v.AssociatedCapability[i] = xgb.Get32(buf[b:])
@ -3967,7 +4270,6 @@ type GetScreenInfoReply struct {
NInfo uint16 NInfo uint16
// padding: 2 bytes // padding: 2 bytes
Sizes []ScreenSize // size: xgb.Pad((int(NSizes) * 8)) Sizes []ScreenSize // size: xgb.Pad((int(NSizes) * 8))
// alignment gap to multiple of 2
Rates []RefreshRates // size: RefreshRatesListSize(Rates) Rates []RefreshRates // size: RefreshRatesListSize(Rates)
} }
@ -4026,8 +4328,6 @@ func getScreenInfoReply(buf []byte) *GetScreenInfoReply {
v.Sizes = make([]ScreenSize, v.NSizes) v.Sizes = make([]ScreenSize, v.NSizes)
b += ScreenSizeReadList(buf[b:], v.Sizes) b += ScreenSizeReadList(buf[b:], v.Sizes)
b = (b + 1) & ^1 // alignment gap
v.Rates = make([]RefreshRates, (int(v.NInfo) - int(v.NSizes))) v.Rates = make([]RefreshRates, (int(v.NInfo) - int(v.NSizes)))
b += RefreshRatesReadList(buf[b:], v.Rates) b += RefreshRatesReadList(buf[b:], v.Rates)
@ -4102,9 +4402,7 @@ type GetScreenResourcesReply struct {
NamesLen uint16 NamesLen uint16
// padding: 8 bytes // padding: 8 bytes
Crtcs []Crtc // size: xgb.Pad((int(NumCrtcs) * 4)) Crtcs []Crtc // size: xgb.Pad((int(NumCrtcs) * 4))
// alignment gap to multiple of 4
Outputs []Output // size: xgb.Pad((int(NumOutputs) * 4)) Outputs []Output // size: xgb.Pad((int(NumOutputs) * 4))
// alignment gap to multiple of 4
Modes []ModeInfo // size: xgb.Pad((int(NumModes) * 32)) Modes []ModeInfo // size: xgb.Pad((int(NumModes) * 32))
Names []byte // size: xgb.Pad((int(NamesLen) * 1)) Names []byte // size: xgb.Pad((int(NamesLen) * 1))
} }
@ -4160,16 +4458,12 @@ func getScreenResourcesReply(buf []byte) *GetScreenResourcesReply {
b += 4 b += 4
} }
b = (b + 3) & ^3 // alignment gap
v.Outputs = make([]Output, v.NumOutputs) v.Outputs = make([]Output, v.NumOutputs)
for i := 0; i < int(v.NumOutputs); i++ { for i := 0; i < int(v.NumOutputs); i++ {
v.Outputs[i] = Output(xgb.Get32(buf[b:])) v.Outputs[i] = Output(xgb.Get32(buf[b:]))
b += 4 b += 4
} }
b = (b + 3) & ^3 // alignment gap
v.Modes = make([]ModeInfo, v.NumModes) v.Modes = make([]ModeInfo, v.NumModes)
b += ModeInfoReadList(buf[b:], v.Modes) b += ModeInfoReadList(buf[b:], v.Modes)
@ -4248,9 +4542,7 @@ type GetScreenResourcesCurrentReply struct {
NamesLen uint16 NamesLen uint16
// padding: 8 bytes // padding: 8 bytes
Crtcs []Crtc // size: xgb.Pad((int(NumCrtcs) * 4)) Crtcs []Crtc // size: xgb.Pad((int(NumCrtcs) * 4))
// alignment gap to multiple of 4
Outputs []Output // size: xgb.Pad((int(NumOutputs) * 4)) Outputs []Output // size: xgb.Pad((int(NumOutputs) * 4))
// alignment gap to multiple of 4
Modes []ModeInfo // size: xgb.Pad((int(NumModes) * 32)) Modes []ModeInfo // size: xgb.Pad((int(NumModes) * 32))
Names []byte // size: xgb.Pad((int(NamesLen) * 1)) Names []byte // size: xgb.Pad((int(NamesLen) * 1))
} }
@ -4306,16 +4598,12 @@ func getScreenResourcesCurrentReply(buf []byte) *GetScreenResourcesCurrentReply
b += 4 b += 4
} }
b = (b + 3) & ^3 // alignment gap
v.Outputs = make([]Output, v.NumOutputs) v.Outputs = make([]Output, v.NumOutputs)
for i := 0; i < int(v.NumOutputs); i++ { for i := 0; i < int(v.NumOutputs); i++ {
v.Outputs[i] = Output(xgb.Get32(buf[b:])) v.Outputs[i] = Output(xgb.Get32(buf[b:]))
b += 4 b += 4
} }
b = (b + 3) & ^3 // alignment gap
v.Modes = make([]ModeInfo, v.NumModes) v.Modes = make([]ModeInfo, v.NumModes)
b += ModeInfoReadList(buf[b:], v.Modes) b += ModeInfoReadList(buf[b:], v.Modes)
@ -5254,7 +5542,7 @@ func (cook SetCrtcGammaCookie) Check() error {
// Write request to wire for SetCrtcGamma // Write request to wire for SetCrtcGamma
// setCrtcGammaRequest writes a SetCrtcGamma request to a byte slice. // 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 { 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 b := 0
buf := make([]byte, size) 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 buf[b] = 24 // request opcode
b += 1 b += 1
blen := b xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2 b += 2
xgb.Put32(buf[b:], uint32(Crtc)) 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 += 2
} }
b = (b + 1) & ^1 // alignment gap
for i := 0; i < int(Size); i++ { for i := 0; i < int(Size); i++ {
xgb.Put16(buf[b:], Green[i]) xgb.Put16(buf[b:], Green[i])
b += 2 b += 2
} }
b = (b + 1) & ^1 // alignment gap
for i := 0; i < int(Size); i++ { for i := 0; i < int(Size); i++ {
xgb.Put16(buf[b:], Blue[i]) xgb.Put16(buf[b:], Blue[i])
b += 2 b += 2
} }
b = xgb.Pad(b) return buf
xgb.Put16(buf[blen:], uint16(b/4)) // write request size in 4-byte units
return buf[:b]
} }
// SetCrtcTransformCookie is a cookie used only for SetCrtcTransform requests. // 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] 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. // SetOutputPrimaryCookie is a cookie used only for SetOutputPrimary requests.
type SetOutputPrimaryCookie struct { type SetOutputPrimaryCookie struct {
*xgb.Cookie *xgb.Cookie

View File

@ -554,7 +554,7 @@ func (cook CreateContextCookie) Check() error {
// Write request to wire for CreateContext // Write request to wire for CreateContext
// createContextRequest writes a CreateContext request to a byte slice. // createContextRequest writes a CreateContext request to a byte slice.
func createContextRequest(c *xgb.Conn, Context Context, ElementHeader ElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []ClientSpec, Ranges []Range) []byte { func createContextRequest(c *xgb.Conn, Context Context, ElementHeader ElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []ClientSpec, Ranges []Range) []byte {
size := xgb.Pad((((20 + xgb.Pad((int(NumClientSpecs) * 4))) + 4) + xgb.Pad((int(NumRanges) * 24)))) size := xgb.Pad(((20 + xgb.Pad((int(NumClientSpecs) * 4))) + xgb.Pad((int(NumRanges) * 24))))
b := 0 b := 0
buf := make([]byte, size) buf := make([]byte, size)
@ -566,7 +566,7 @@ func createContextRequest(c *xgb.Conn, Context Context, ElementHeader ElementHea
buf[b] = 1 // request opcode buf[b] = 1 // request opcode
b += 1 b += 1
blen := b xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2 b += 2
xgb.Put32(buf[b:], uint32(Context)) xgb.Put32(buf[b:], uint32(Context))
@ -588,13 +588,9 @@ func createContextRequest(c *xgb.Conn, Context Context, ElementHeader ElementHea
b += 4 b += 4
} }
b = (b + 3) & ^3 // alignment gap
b += RangeListBytes(buf[b:], Ranges) b += RangeListBytes(buf[b:], Ranges)
b = xgb.Pad(b) return buf
xgb.Put16(buf[blen:], uint16(b/4)) // write request size in 4-byte units
return buf[:b]
} }
// DisableContextCookie is a cookie used only for DisableContext requests. // DisableContextCookie is a cookie used only for DisableContext requests.
@ -1099,7 +1095,7 @@ func (cook RegisterClientsCookie) Check() error {
// Write request to wire for RegisterClients // Write request to wire for RegisterClients
// registerClientsRequest writes a RegisterClients request to a byte slice. // registerClientsRequest writes a RegisterClients request to a byte slice.
func registerClientsRequest(c *xgb.Conn, Context Context, ElementHeader ElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []ClientSpec, Ranges []Range) []byte { func registerClientsRequest(c *xgb.Conn, Context Context, ElementHeader ElementHeader, NumClientSpecs uint32, NumRanges uint32, ClientSpecs []ClientSpec, Ranges []Range) []byte {
size := xgb.Pad((((20 + xgb.Pad((int(NumClientSpecs) * 4))) + 4) + xgb.Pad((int(NumRanges) * 24)))) size := xgb.Pad(((20 + xgb.Pad((int(NumClientSpecs) * 4))) + xgb.Pad((int(NumRanges) * 24))))
b := 0 b := 0
buf := make([]byte, size) buf := make([]byte, size)
@ -1111,7 +1107,7 @@ func registerClientsRequest(c *xgb.Conn, Context Context, ElementHeader ElementH
buf[b] = 2 // request opcode buf[b] = 2 // request opcode
b += 1 b += 1
blen := b xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2 b += 2
xgb.Put32(buf[b:], uint32(Context)) xgb.Put32(buf[b:], uint32(Context))
@ -1133,13 +1129,9 @@ func registerClientsRequest(c *xgb.Conn, Context Context, ElementHeader ElementH
b += 4 b += 4
} }
b = (b + 3) & ^3 // alignment gap
b += RangeListBytes(buf[b:], Ranges) b += RangeListBytes(buf[b:], Ranges)
b = xgb.Pad(b) return buf
xgb.Put16(buf[blen:], uint16(b/4)) // write request size in 4-byte units
return buf[:b]
} }
// UnregisterClientsCookie is a cookie used only for UnregisterClients requests. // UnregisterClientsCookie is a cookie used only for UnregisterClients requests.

View File

@ -1613,7 +1613,7 @@ func (cook AddGlyphsCookie) Check() error {
// Write request to wire for AddGlyphs // Write request to wire for AddGlyphs
// addGlyphsRequest writes a AddGlyphs request to a byte slice. // addGlyphsRequest writes a AddGlyphs request to a byte slice.
func addGlyphsRequest(c *xgb.Conn, Glyphset Glyphset, GlyphsLen uint32, Glyphids []uint32, Glyphs []Glyphinfo, Data []byte) []byte { func addGlyphsRequest(c *xgb.Conn, Glyphset Glyphset, GlyphsLen uint32, Glyphids []uint32, Glyphs []Glyphinfo, Data []byte) []byte {
size := xgb.Pad(((((12 + xgb.Pad((int(GlyphsLen) * 4))) + 4) + xgb.Pad((int(GlyphsLen) * 12))) + xgb.Pad((len(Data) * 1)))) size := xgb.Pad((((12 + xgb.Pad((int(GlyphsLen) * 4))) + xgb.Pad((int(GlyphsLen) * 12))) + xgb.Pad((len(Data) * 1))))
b := 0 b := 0
buf := make([]byte, size) buf := make([]byte, size)
@ -1625,7 +1625,7 @@ func addGlyphsRequest(c *xgb.Conn, Glyphset Glyphset, GlyphsLen uint32, Glyphids
buf[b] = 20 // request opcode buf[b] = 20 // request opcode
b += 1 b += 1
blen := b xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2 b += 2
xgb.Put32(buf[b:], uint32(Glyphset)) xgb.Put32(buf[b:], uint32(Glyphset))
@ -1639,16 +1639,12 @@ func addGlyphsRequest(c *xgb.Conn, Glyphset Glyphset, GlyphsLen uint32, Glyphids
b += 4 b += 4
} }
b = (b + 3) & ^3 // alignment gap
b += GlyphinfoListBytes(buf[b:], Glyphs) b += GlyphinfoListBytes(buf[b:], Glyphs)
copy(buf[b:], Data[:len(Data)]) copy(buf[b:], Data[:len(Data)])
b += int(len(Data)) b += int(len(Data))
b = xgb.Pad(b) return buf
xgb.Put16(buf[blen:], uint16(b/4)) // write request size in 4-byte units
return buf[:b]
} }
// AddTrapsCookie is a cookie used only for AddTraps requests. // AddTrapsCookie is a cookie used only for AddTraps requests.
@ -1760,7 +1756,7 @@ func (cook ChangePictureCookie) Check() error {
// Write request to wire for ChangePicture // Write request to wire for ChangePicture
// changePictureRequest writes a ChangePicture request to a byte slice. // changePictureRequest writes a ChangePicture request to a byte slice.
func changePictureRequest(c *xgb.Conn, Picture Picture, ValueMask uint32, ValueList []uint32) []byte { func changePictureRequest(c *xgb.Conn, Picture Picture, ValueMask uint32, ValueList []uint32) []byte {
size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) size := xgb.Pad((12 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))
b := 0 b := 0
buf := make([]byte, size) buf := make([]byte, size)
@ -1780,6 +1776,7 @@ func changePictureRequest(c *xgb.Conn, Picture Picture, ValueMask uint32, ValueL
xgb.Put32(buf[b:], ValueMask) xgb.Put32(buf[b:], ValueMask)
b += 4 b += 4
for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { for i := 0; i < xgb.PopCount(int(ValueMask)); i++ {
xgb.Put32(buf[b:], ValueList[i]) xgb.Put32(buf[b:], ValueList[i])
b += 4 b += 4
@ -2240,7 +2237,7 @@ func (cook CreateConicalGradientCookie) Check() error {
// Write request to wire for CreateConicalGradient // Write request to wire for CreateConicalGradient
// createConicalGradientRequest writes a CreateConicalGradient request to a byte slice. // createConicalGradientRequest writes a CreateConicalGradient request to a byte slice.
func createConicalGradientRequest(c *xgb.Conn, Picture Picture, Center Pointfix, Angle Fixed, NumStops uint32, Stops []Fixed, Colors []Color) []byte { func createConicalGradientRequest(c *xgb.Conn, Picture Picture, Center Pointfix, Angle Fixed, NumStops uint32, Stops []Fixed, Colors []Color) []byte {
size := xgb.Pad((((24 + xgb.Pad((int(NumStops) * 4))) + 4) + xgb.Pad((int(NumStops) * 8)))) size := xgb.Pad(((24 + xgb.Pad((int(NumStops) * 4))) + xgb.Pad((int(NumStops) * 8))))
b := 0 b := 0
buf := make([]byte, size) buf := make([]byte, size)
@ -2252,7 +2249,7 @@ func createConicalGradientRequest(c *xgb.Conn, Picture Picture, Center Pointfix,
buf[b] = 36 // request opcode buf[b] = 36 // request opcode
b += 1 b += 1
blen := b xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2 b += 2
xgb.Put32(buf[b:], uint32(Picture)) xgb.Put32(buf[b:], uint32(Picture))
@ -2275,13 +2272,9 @@ func createConicalGradientRequest(c *xgb.Conn, Picture Picture, Center Pointfix,
b += 4 b += 4
} }
b = (b + 3) & ^3 // alignment gap
b += ColorListBytes(buf[b:], Colors) b += ColorListBytes(buf[b:], Colors)
b = xgb.Pad(b) return buf
xgb.Put16(buf[blen:], uint16(b/4)) // write request size in 4-byte units
return buf[:b]
} }
// CreateCursorCookie is a cookie used only for CreateCursor requests. // CreateCursorCookie is a cookie used only for CreateCursor requests.
@ -2458,7 +2451,7 @@ func (cook CreateLinearGradientCookie) Check() error {
// Write request to wire for CreateLinearGradient // Write request to wire for CreateLinearGradient
// createLinearGradientRequest writes a CreateLinearGradient request to a byte slice. // createLinearGradientRequest writes a CreateLinearGradient request to a byte slice.
func createLinearGradientRequest(c *xgb.Conn, Picture Picture, P1 Pointfix, P2 Pointfix, NumStops uint32, Stops []Fixed, Colors []Color) []byte { func createLinearGradientRequest(c *xgb.Conn, Picture Picture, P1 Pointfix, P2 Pointfix, NumStops uint32, Stops []Fixed, Colors []Color) []byte {
size := xgb.Pad((((28 + xgb.Pad((int(NumStops) * 4))) + 4) + xgb.Pad((int(NumStops) * 8)))) size := xgb.Pad(((28 + xgb.Pad((int(NumStops) * 4))) + xgb.Pad((int(NumStops) * 8))))
b := 0 b := 0
buf := make([]byte, size) buf := make([]byte, size)
@ -2470,7 +2463,7 @@ func createLinearGradientRequest(c *xgb.Conn, Picture Picture, P1 Pointfix, P2 P
buf[b] = 34 // request opcode buf[b] = 34 // request opcode
b += 1 b += 1
blen := b xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2 b += 2
xgb.Put32(buf[b:], uint32(Picture)) xgb.Put32(buf[b:], uint32(Picture))
@ -2496,13 +2489,9 @@ func createLinearGradientRequest(c *xgb.Conn, Picture Picture, P1 Pointfix, P2 P
b += 4 b += 4
} }
b = (b + 3) & ^3 // alignment gap
b += ColorListBytes(buf[b:], Colors) b += ColorListBytes(buf[b:], Colors)
b = xgb.Pad(b) return buf
xgb.Put16(buf[blen:], uint16(b/4)) // write request size in 4-byte units
return buf[:b]
} }
// CreatePictureCookie is a cookie used only for CreatePicture requests. // CreatePictureCookie is a cookie used only for CreatePicture requests.
@ -2545,7 +2534,7 @@ func (cook CreatePictureCookie) Check() error {
// Write request to wire for CreatePicture // Write request to wire for CreatePicture
// createPictureRequest writes a CreatePicture request to a byte slice. // createPictureRequest writes a CreatePicture request to a byte slice.
func createPictureRequest(c *xgb.Conn, Pid Picture, Drawable xproto.Drawable, Format Pictformat, ValueMask uint32, ValueList []uint32) []byte { func createPictureRequest(c *xgb.Conn, Pid Picture, Drawable xproto.Drawable, Format Pictformat, ValueMask uint32, ValueList []uint32) []byte {
size := xgb.Pad((16 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) size := xgb.Pad((20 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))
b := 0 b := 0
buf := make([]byte, size) buf := make([]byte, size)
@ -2571,6 +2560,7 @@ func createPictureRequest(c *xgb.Conn, Pid Picture, Drawable xproto.Drawable, Fo
xgb.Put32(buf[b:], ValueMask) xgb.Put32(buf[b:], ValueMask)
b += 4 b += 4
for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { for i := 0; i < xgb.PopCount(int(ValueMask)); i++ {
xgb.Put32(buf[b:], ValueList[i]) xgb.Put32(buf[b:], ValueList[i])
b += 4 b += 4
@ -2620,7 +2610,7 @@ func (cook CreateRadialGradientCookie) Check() error {
// Write request to wire for CreateRadialGradient // Write request to wire for CreateRadialGradient
// createRadialGradientRequest writes a CreateRadialGradient request to a byte slice. // createRadialGradientRequest writes a CreateRadialGradient request to a byte slice.
func createRadialGradientRequest(c *xgb.Conn, Picture Picture, Inner Pointfix, Outer Pointfix, InnerRadius Fixed, OuterRadius Fixed, NumStops uint32, Stops []Fixed, Colors []Color) []byte { func createRadialGradientRequest(c *xgb.Conn, Picture Picture, Inner Pointfix, Outer Pointfix, InnerRadius Fixed, OuterRadius Fixed, NumStops uint32, Stops []Fixed, Colors []Color) []byte {
size := xgb.Pad((((36 + xgb.Pad((int(NumStops) * 4))) + 4) + xgb.Pad((int(NumStops) * 8)))) size := xgb.Pad(((36 + xgb.Pad((int(NumStops) * 4))) + xgb.Pad((int(NumStops) * 8))))
b := 0 b := 0
buf := make([]byte, size) buf := make([]byte, size)
@ -2632,7 +2622,7 @@ func createRadialGradientRequest(c *xgb.Conn, Picture Picture, Inner Pointfix, O
buf[b] = 35 // request opcode buf[b] = 35 // request opcode
b += 1 b += 1
blen := b xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2 b += 2
xgb.Put32(buf[b:], uint32(Picture)) xgb.Put32(buf[b:], uint32(Picture))
@ -2664,13 +2654,9 @@ func createRadialGradientRequest(c *xgb.Conn, Picture Picture, Inner Pointfix, O
b += 4 b += 4
} }
b = (b + 3) & ^3 // alignment gap
b += ColorListBytes(buf[b:], Colors) b += ColorListBytes(buf[b:], Colors)
b = xgb.Pad(b) return buf
xgb.Put16(buf[blen:], uint16(b/4)) // write request size in 4-byte units
return buf[:b]
} }
// CreateSolidFillCookie is a cookie used only for CreateSolidFill requests. // CreateSolidFillCookie is a cookie used only for CreateSolidFill requests.
@ -3157,9 +3143,7 @@ type QueryPictFormatsReply struct {
NumSubpixel uint32 NumSubpixel uint32
// padding: 4 bytes // padding: 4 bytes
Formats []Pictforminfo // size: xgb.Pad((int(NumFormats) * 28)) Formats []Pictforminfo // size: xgb.Pad((int(NumFormats) * 28))
// alignment gap to multiple of 4
Screens []Pictscreen // size: PictscreenListSize(Screens) Screens []Pictscreen // size: PictscreenListSize(Screens)
// alignment gap to multiple of 4
Subpixels []uint32 // size: xgb.Pad((int(NumSubpixel) * 4)) Subpixels []uint32 // size: xgb.Pad((int(NumSubpixel) * 4))
} }
@ -3208,13 +3192,9 @@ func queryPictFormatsReply(buf []byte) *QueryPictFormatsReply {
v.Formats = make([]Pictforminfo, v.NumFormats) v.Formats = make([]Pictforminfo, v.NumFormats)
b += PictforminfoReadList(buf[b:], v.Formats) b += PictforminfoReadList(buf[b:], v.Formats)
b = (b + 3) & ^3 // alignment gap
v.Screens = make([]Pictscreen, v.NumScreens) v.Screens = make([]Pictscreen, v.NumScreens)
b += PictscreenReadList(buf[b:], v.Screens) b += PictscreenReadList(buf[b:], v.Screens)
b = (b + 3) & ^3 // alignment gap
v.Subpixels = make([]uint32, v.NumSubpixel) v.Subpixels = make([]uint32, v.NumSubpixel)
for i := 0; i < int(v.NumSubpixel); i++ { for i := 0; i < int(v.NumSubpixel); i++ {
v.Subpixels[i] = xgb.Get32(buf[b:]) v.Subpixels[i] = xgb.Get32(buf[b:])

View File

@ -513,7 +513,7 @@ func (cook SetAttributesCookie) Check() error {
// Write request to wire for SetAttributes // Write request to wire for SetAttributes
// setAttributesRequest writes a SetAttributes request to a byte slice. // setAttributesRequest writes a SetAttributes request to a byte slice.
func setAttributesRequest(c *xgb.Conn, Drawable xproto.Drawable, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class byte, Depth byte, Visual xproto.Visualid, ValueMask uint32, ValueList []uint32) []byte { func setAttributesRequest(c *xgb.Conn, Drawable xproto.Drawable, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class byte, Depth byte, Visual xproto.Visualid, ValueMask uint32, ValueList []uint32) []byte {
size := xgb.Pad((24 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) size := xgb.Pad((28 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))
b := 0 b := 0
buf := make([]byte, size) buf := make([]byte, size)
@ -557,6 +557,7 @@ func setAttributesRequest(c *xgb.Conn, Drawable xproto.Drawable, X int16, Y int1
xgb.Put32(buf[b:], ValueMask) xgb.Put32(buf[b:], ValueMask)
b += 4 b += 4
for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { for i := 0; i < xgb.PopCount(int(ValueMask)); i++ {
xgb.Put32(buf[b:], ValueList[i]) xgb.Put32(buf[b:], ValueList[i])
b += 4 b += 4

View File

@ -896,7 +896,6 @@ type GetDrawableInfoReply struct {
BackY int16 BackY int16
NumBackClipRects uint32 NumBackClipRects uint32
ClipRects []DrmClipRect // size: xgb.Pad((int(NumClipRects) * 8)) ClipRects []DrmClipRect // size: xgb.Pad((int(NumClipRects) * 8))
// alignment gap to multiple of 4
BackClipRects []DrmClipRect // size: xgb.Pad((int(NumBackClipRects) * 8)) BackClipRects []DrmClipRect // size: xgb.Pad((int(NumBackClipRects) * 8))
} }
@ -958,8 +957,6 @@ func getDrawableInfoReply(buf []byte) *GetDrawableInfoReply {
v.ClipRects = make([]DrmClipRect, v.NumClipRects) v.ClipRects = make([]DrmClipRect, v.NumClipRects)
b += DrmClipRectReadList(buf[b:], v.ClipRects) b += DrmClipRectReadList(buf[b:], v.ClipRects)
b = (b + 3) & ^3 // alignment gap
v.BackClipRects = make([]DrmClipRect, v.NumBackClipRects) v.BackClipRects = make([]DrmClipRect, v.NumBackClipRects)
b += DrmClipRectReadList(buf[b:], v.BackClipRects) b += DrmClipRectReadList(buf[b:], v.BackClipRects)

View File

@ -1153,9 +1153,7 @@ type GetGammaRampReply struct {
Size uint16 Size uint16
// padding: 22 bytes // padding: 22 bytes
Red []uint16 // size: xgb.Pad((((int(Size) + 1) & -2) * 2)) Red []uint16 // size: xgb.Pad((((int(Size) + 1) & -2) * 2))
// alignment gap to multiple of 2
Green []uint16 // size: xgb.Pad((((int(Size) + 1) & -2) * 2)) Green []uint16 // size: xgb.Pad((((int(Size) + 1) & -2) * 2))
// alignment gap to multiple of 2
Blue []uint16 // size: xgb.Pad((((int(Size) + 1) & -2) * 2)) Blue []uint16 // size: xgb.Pad((((int(Size) + 1) & -2) * 2))
} }
@ -1195,16 +1193,12 @@ func getGammaRampReply(buf []byte) *GetGammaRampReply {
b += 2 b += 2
} }
b = (b + 1) & ^1 // alignment gap
v.Green = make([]uint16, ((int(v.Size) + 1) & -2)) v.Green = make([]uint16, ((int(v.Size) + 1) & -2))
for i := 0; i < int(((int(v.Size) + 1) & -2)); i++ { for i := 0; i < int(((int(v.Size) + 1) & -2)); i++ {
v.Green[i] = xgb.Get16(buf[b:]) v.Green[i] = xgb.Get16(buf[b:])
b += 2 b += 2
} }
b = (b + 1) & ^1 // alignment gap
v.Blue = make([]uint16, ((int(v.Size) + 1) & -2)) v.Blue = make([]uint16, ((int(v.Size) + 1) & -2))
for i := 0; i < int(((int(v.Size) + 1) & -2)); i++ { for i := 0; i < int(((int(v.Size) + 1) & -2)); i++ {
v.Blue[i] = xgb.Get16(buf[b:]) v.Blue[i] = xgb.Get16(buf[b:])
@ -1533,7 +1527,6 @@ type GetMonitorReply struct {
NumVsync byte NumVsync byte
// padding: 20 bytes // padding: 20 bytes
Hsync []Syncrange // size: xgb.Pad((int(NumHsync) * 4)) Hsync []Syncrange // size: xgb.Pad((int(NumHsync) * 4))
// alignment gap to multiple of 4
Vsync []Syncrange // size: xgb.Pad((int(NumVsync) * 4)) Vsync []Syncrange // size: xgb.Pad((int(NumVsync) * 4))
Vendor string // size: xgb.Pad((int(VendorLength) * 1)) Vendor string // size: xgb.Pad((int(VendorLength) * 1))
AlignmentPad []byte // size: xgb.Pad(((((int(VendorLength) + 3) & -4) - int(VendorLength)) * 1)) AlignmentPad []byte // size: xgb.Pad(((((int(VendorLength) + 3) & -4) - int(VendorLength)) * 1))
@ -1585,8 +1578,6 @@ func getMonitorReply(buf []byte) *GetMonitorReply {
b += 4 b += 4
} }
b = (b + 3) & ^3 // alignment gap
v.Vsync = make([]Syncrange, v.NumVsync) v.Vsync = make([]Syncrange, v.NumVsync)
for i := 0; i < int(v.NumVsync); i++ { for i := 0; i < int(v.NumVsync); i++ {
v.Vsync[i] = Syncrange(xgb.Get32(buf[b:])) v.Vsync[i] = Syncrange(xgb.Get32(buf[b:]))
@ -2280,7 +2271,7 @@ func (cook SetGammaRampCookie) Check() error {
// Write request to wire for SetGammaRamp // Write request to wire for SetGammaRamp
// setGammaRampRequest writes a SetGammaRamp request to a byte slice. // setGammaRampRequest writes a SetGammaRamp request to a byte slice.
func setGammaRampRequest(c *xgb.Conn, Screen uint16, Size uint16, Red []uint16, Green []uint16, Blue []uint16) []byte { func setGammaRampRequest(c *xgb.Conn, Screen uint16, Size uint16, Red []uint16, Green []uint16, Blue []uint16) []byte {
size := xgb.Pad((((((8 + xgb.Pad((((int(Size) + 1) & -2) * 2))) + 2) + xgb.Pad((((int(Size) + 1) & -2) * 2))) + 2) + xgb.Pad((((int(Size) + 1) & -2) * 2)))) size := xgb.Pad((((8 + xgb.Pad((((int(Size) + 1) & -2) * 2))) + xgb.Pad((((int(Size) + 1) & -2) * 2))) + xgb.Pad((((int(Size) + 1) & -2) * 2))))
b := 0 b := 0
buf := make([]byte, size) buf := make([]byte, size)
@ -2292,7 +2283,7 @@ func setGammaRampRequest(c *xgb.Conn, Screen uint16, Size uint16, Red []uint16,
buf[b] = 18 // request opcode buf[b] = 18 // request opcode
b += 1 b += 1
blen := b xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2 b += 2
xgb.Put16(buf[b:], Screen) xgb.Put16(buf[b:], Screen)
@ -2306,23 +2297,17 @@ func setGammaRampRequest(c *xgb.Conn, Screen uint16, Size uint16, Red []uint16,
b += 2 b += 2
} }
b = (b + 1) & ^1 // alignment gap
for i := 0; i < int(((int(Size) + 1) & -2)); i++ { for i := 0; i < int(((int(Size) + 1) & -2)); i++ {
xgb.Put16(buf[b:], Green[i]) xgb.Put16(buf[b:], Green[i])
b += 2 b += 2
} }
b = (b + 1) & ^1 // alignment gap
for i := 0; i < int(((int(Size) + 1) & -2)); i++ { for i := 0; i < int(((int(Size) + 1) & -2)); i++ {
xgb.Put16(buf[b:], Blue[i]) xgb.Put16(buf[b:], Blue[i])
b += 2 b += 2
} }
b = xgb.Pad(b) return buf
xgb.Put16(buf[blen:], uint16(b/4)) // write request size in 4-byte units
return buf[:b]
} }
// SetViewPortCookie is a cookie used only for SetViewPort requests. // SetViewPortCookie is a cookie used only for SetViewPort requests.

View File

@ -1524,9 +1524,8 @@ type GetCursorImageAndNameReply struct {
CursorAtom xproto.Atom CursorAtom xproto.Atom
Nbytes uint16 Nbytes uint16
// padding: 2 bytes // padding: 2 bytes
Name string // size: xgb.Pad((int(Nbytes) * 1))
// alignment gap to multiple of 4
CursorImage []uint32 // size: xgb.Pad(((int(Width) * int(Height)) * 4)) CursorImage []uint32 // size: xgb.Pad(((int(Width) * int(Height)) * 4))
Name string // size: xgb.Pad((int(Nbytes) * 1))
} }
// Reply blocks and returns the reply data for a GetCursorImageAndName request. // Reply blocks and returns the reply data for a GetCursorImageAndName request.
@ -1583,6 +1582,12 @@ func getCursorImageAndNameReply(buf []byte) *GetCursorImageAndNameReply {
b += 2 // padding b += 2 // padding
v.CursorImage = make([]uint32, (int(v.Width) * int(v.Height)))
for i := 0; i < int((int(v.Width) * int(v.Height))); i++ {
v.CursorImage[i] = xgb.Get32(buf[b:])
b += 4
}
{ {
byteString := make([]byte, v.Nbytes) byteString := make([]byte, v.Nbytes)
copy(byteString[:v.Nbytes], buf[b:]) copy(byteString[:v.Nbytes], buf[b:])
@ -1590,14 +1595,6 @@ func getCursorImageAndNameReply(buf []byte) *GetCursorImageAndNameReply {
b += int(v.Nbytes) b += int(v.Nbytes)
} }
b = (b + 3) & ^3 // alignment gap
v.CursorImage = make([]uint32, (int(v.Width) * int(v.Height)))
for i := 0; i < int((int(v.Width) * int(v.Height))); i++ {
v.CursorImage[i] = xgb.Get32(buf[b:])
b += 4
}
return v return v
} }

View File

@ -342,6 +342,7 @@ func (f *SwitchField) Size() Size {
// TODO: size expression used here is not correct unless every element of // TODO: size expression used here is not correct unless every element of
// the switch is 32 bit long. This assumption holds for xproto but may not // the switch is 32 bit long. This assumption holds for xproto but may not
// hold for other protocols (xkb?) // hold for other protocols (xkb?)
listSize := newExpressionSize(&Function{ listSize := newExpressionSize(&Function{
Name: "xgb.Pad", Name: "xgb.Pad",
Expr: &BinaryOp{ Expr: &BinaryOp{

View File

@ -319,8 +319,10 @@ func NewPcontextId(c *xgb.Conn) (Pcontext, error) {
type Printer struct { type Printer struct {
NameLen uint32 NameLen uint32
Name []String8 // size: xgb.Pad((int(NameLen) * 1)) Name []String8 // size: xgb.Pad((int(NameLen) * 1))
// alignment gap to multiple of 4
DescLen uint32 DescLen uint32
Description []String8 // size: xgb.Pad((int(DescLen) * 1)) Description []String8 // size: xgb.Pad((int(DescLen) * 1))
// alignment gap to multiple of 4
} }
// PrinterRead reads a byte slice into a Printer value. // PrinterRead reads a byte slice into a Printer value.
@ -336,6 +338,8 @@ func PrinterRead(buf []byte, v *Printer) int {
b += 1 b += 1
} }
b = (b + 3) & ^3 // alignment gap
v.DescLen = xgb.Get32(buf[b:]) v.DescLen = xgb.Get32(buf[b:])
b += 4 b += 4
@ -345,6 +349,8 @@ func PrinterRead(buf []byte, v *Printer) int {
b += 1 b += 1
} }
b = (b + 3) & ^3 // alignment gap
return b return b
} }
@ -360,7 +366,7 @@ func PrinterReadList(buf []byte, dest []Printer) int {
// Bytes writes a Printer value to a byte slice. // Bytes writes a Printer value to a byte slice.
func (v Printer) Bytes() []byte { func (v Printer) Bytes() []byte {
buf := make([]byte, (((4 + xgb.Pad((int(v.NameLen) * 1))) + 4) + xgb.Pad((int(v.DescLen) * 1)))) buf := make([]byte, (((((4 + xgb.Pad((int(v.NameLen) * 1))) + 4) + 4) + xgb.Pad((int(v.DescLen) * 1))) + 4))
b := 0 b := 0
xgb.Put32(buf[b:], v.NameLen) xgb.Put32(buf[b:], v.NameLen)
@ -371,6 +377,8 @@ func (v Printer) Bytes() []byte {
b += 1 b += 1
} }
b = (b + 3) & ^3 // alignment gap
xgb.Put32(buf[b:], v.DescLen) xgb.Put32(buf[b:], v.DescLen)
b += 4 b += 4
@ -379,6 +387,8 @@ func (v Printer) Bytes() []byte {
b += 1 b += 1
} }
b = (b + 3) & ^3 // alignment gap
return buf[:b] return buf[:b]
} }
@ -398,7 +408,7 @@ func PrinterListBytes(buf []byte, list []Printer) int {
func PrinterListSize(list []Printer) int { func PrinterListSize(list []Printer) int {
size := 0 size := 0
for _, item := range list { for _, item := range list {
size += (((4 + xgb.Pad((int(item.NameLen) * 1))) + 4) + xgb.Pad((int(item.DescLen) * 1))) size += (((((4 + xgb.Pad((int(item.NameLen) * 1))) + 4) + 4) + xgb.Pad((int(item.DescLen) * 1))) + 4)
} }
return size return size
} }
@ -1644,9 +1654,7 @@ type PrintInputSelectedReply struct {
Length uint32 // number of bytes in this reply Length uint32 // number of bytes in this reply
// padding: 1 bytes // padding: 1 bytes
EventMask uint32 EventMask uint32
EventList []uint32
AllEventsMask uint32 AllEventsMask uint32
AllEventsList []uint32
} }
// Reply blocks and returns the reply data for a PrintInputSelected request. // Reply blocks and returns the reply data for a PrintInputSelected request.
@ -1677,23 +1685,9 @@ func printInputSelectedReply(buf []byte) *PrintInputSelectedReply {
v.EventMask = xgb.Get32(buf[b:]) v.EventMask = xgb.Get32(buf[b:])
b += 4 b += 4
v.EventList = make([]uint32, xgb.PopCount(int(v.EventMask)))
for i := 0; i < xgb.PopCount(int(v.EventMask)); i++ {
v.EventList[i] = xgb.Get32(buf[b:])
b += 4
}
b = xgb.Pad(b)
v.AllEventsMask = xgb.Get32(buf[b:]) v.AllEventsMask = xgb.Get32(buf[b:])
b += 4 b += 4
v.AllEventsList = make([]uint32, xgb.PopCount(int(v.AllEventsMask)))
for i := 0; i < xgb.PopCount(int(v.AllEventsMask)); i++ {
v.AllEventsList[i] = xgb.Get32(buf[b:])
b += 4
}
b = xgb.Pad(b)
return v return v
} }
@ -1761,7 +1755,7 @@ func (cook PrintPutDocumentDataCookie) Check() error {
// Write request to wire for PrintPutDocumentData // Write request to wire for PrintPutDocumentData
// printPutDocumentDataRequest writes a PrintPutDocumentData request to a byte slice. // printPutDocumentDataRequest writes a PrintPutDocumentData request to a byte slice.
func printPutDocumentDataRequest(c *xgb.Conn, Drawable xproto.Drawable, LenData uint32, LenFmt uint16, LenOptions uint16, Data []byte, DocFormat []String8, Options []String8) []byte { func printPutDocumentDataRequest(c *xgb.Conn, Drawable xproto.Drawable, LenData uint32, LenFmt uint16, LenOptions uint16, Data []byte, DocFormat []String8, Options []String8) []byte {
size := xgb.Pad((((16 + xgb.Pad((int(LenData) * 1))) + xgb.Pad((len(DocFormat) * 1))) + xgb.Pad((len(Options) * 1)))) size := xgb.Pad((((16 + xgb.Pad((int(LenData) * 1))) + xgb.Pad((int(LenFmt) * 1))) + xgb.Pad((int(LenOptions) * 1))))
b := 0 b := 0
buf := make([]byte, size) buf := make([]byte, size)
@ -1791,12 +1785,12 @@ func printPutDocumentDataRequest(c *xgb.Conn, Drawable xproto.Drawable, LenData
copy(buf[b:], Data[:LenData]) copy(buf[b:], Data[:LenData])
b += int(LenData) b += int(LenData)
for i := 0; i < int(len(DocFormat)); i++ { for i := 0; i < int(LenFmt); i++ {
buf[b] = byte(DocFormat[i]) buf[b] = byte(DocFormat[i])
b += 1 b += 1
} }
for i := 0; i < int(len(Options)); i++ { for i := 0; i < int(LenOptions); i++ {
buf[b] = byte(Options[i]) buf[b] = byte(Options[i])
b += 1 b += 1
} }
@ -2065,27 +2059,27 @@ type PrintSelectInputCookie struct {
// PrintSelectInput sends an unchecked request. // PrintSelectInput sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func PrintSelectInput(c *xgb.Conn, Context Pcontext, EventMask uint32, EventList []uint32) PrintSelectInputCookie { func PrintSelectInput(c *xgb.Conn, Context Pcontext, EventMask uint32) PrintSelectInputCookie {
c.ExtLock.RLock() c.ExtLock.RLock()
defer c.ExtLock.RUnlock() defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XpExtension"]; !ok { if _, ok := c.Extensions["XpExtension"]; !ok {
panic("Cannot issue request 'PrintSelectInput' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") panic("Cannot issue request 'PrintSelectInput' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.")
} }
cookie := c.NewCookie(false, false) cookie := c.NewCookie(false, false)
c.NewRequest(printSelectInputRequest(c, Context, EventMask, EventList), cookie) c.NewRequest(printSelectInputRequest(c, Context, EventMask), cookie)
return PrintSelectInputCookie{cookie} return PrintSelectInputCookie{cookie}
} }
// PrintSelectInputChecked sends a checked request. // PrintSelectInputChecked sends a checked request.
// If an error occurs, it can be retrieved using PrintSelectInputCookie.Check() // If an error occurs, it can be retrieved using PrintSelectInputCookie.Check()
func PrintSelectInputChecked(c *xgb.Conn, Context Pcontext, EventMask uint32, EventList []uint32) PrintSelectInputCookie { func PrintSelectInputChecked(c *xgb.Conn, Context Pcontext, EventMask uint32) PrintSelectInputCookie {
c.ExtLock.RLock() c.ExtLock.RLock()
defer c.ExtLock.RUnlock() defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XpExtension"]; !ok { if _, ok := c.Extensions["XpExtension"]; !ok {
panic("Cannot issue request 'PrintSelectInput' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.") panic("Cannot issue request 'PrintSelectInput' using the uninitialized extension 'XpExtension'. xprint.Init(connObj) must be called first.")
} }
cookie := c.NewCookie(true, false) cookie := c.NewCookie(true, false)
c.NewRequest(printSelectInputRequest(c, Context, EventMask, EventList), cookie) c.NewRequest(printSelectInputRequest(c, Context, EventMask), cookie)
return PrintSelectInputCookie{cookie} return PrintSelectInputCookie{cookie}
} }
@ -2097,8 +2091,8 @@ func (cook PrintSelectInputCookie) Check() error {
// Write request to wire for PrintSelectInput // Write request to wire for PrintSelectInput
// printSelectInputRequest writes a PrintSelectInput request to a byte slice. // printSelectInputRequest writes a PrintSelectInput request to a byte slice.
func printSelectInputRequest(c *xgb.Conn, Context Pcontext, EventMask uint32, EventList []uint32) []byte { func printSelectInputRequest(c *xgb.Conn, Context Pcontext, EventMask uint32) []byte {
size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(EventMask))))))) size := 12
b := 0 b := 0
buf := make([]byte, size) buf := make([]byte, size)
@ -2118,11 +2112,6 @@ func printSelectInputRequest(c *xgb.Conn, Context Pcontext, EventMask uint32, Ev
xgb.Put32(buf[b:], EventMask) xgb.Put32(buf[b:], EventMask)
b += 4 b += 4
for i := 0; i < xgb.PopCount(int(EventMask)); i++ {
xgb.Put32(buf[b:], EventList[i])
b += 4
}
b = xgb.Pad(b)
return buf return buf
} }

View File

@ -343,6 +343,8 @@ const (
BlankingDefault = 2 BlankingDefault = 2
) )
type Bool32 uint32
type Button byte type Button byte
const ( const (
@ -1204,6 +1206,10 @@ func NewColormapId(c *xgb.Conn) (Colormap, error) {
return Colormap(id), nil return Colormap(id), nil
} }
const (
ColormapNone = 0
)
// BadColormap is the error number for a BadColormap. // BadColormap is the error number for a BadColormap.
const BadColormap = 12 const BadColormap = 12
@ -1242,10 +1248,6 @@ func init() {
xgb.NewErrorFuncs[12] = ColormapErrorNew xgb.NewErrorFuncs[12] = ColormapErrorNew
} }
const (
ColormapNone = 0
)
const ( const (
ColormapAllocNone = 0 ColormapAllocNone = 0
ColormapAllocAll = 1 ColormapAllocAll = 1
@ -2474,6 +2476,10 @@ func NewFontId(c *xgb.Conn) (Font, error) {
return Font(id), nil return Font(id), nil
} }
const (
FontNone = 0
)
// BadFont is the error number for a BadFont. // BadFont is the error number for a BadFont.
const BadFont = 7 const BadFont = 7
@ -2512,10 +2518,6 @@ func init() {
xgb.NewErrorFuncs[7] = FontErrorNew xgb.NewErrorFuncs[7] = FontErrorNew
} }
const (
FontNone = 0
)
const ( const (
FontDrawLeftToRight = 0 FontDrawLeftToRight = 0
FontDrawRightToLeft = 1 FontDrawRightToLeft = 1
@ -3046,6 +3048,7 @@ type Host struct {
// padding: 1 bytes // padding: 1 bytes
AddressLen uint16 AddressLen uint16
Address []byte // size: xgb.Pad((int(AddressLen) * 1)) Address []byte // size: xgb.Pad((int(AddressLen) * 1))
// alignment gap to multiple of 4
} }
// HostRead reads a byte slice into a Host value. // HostRead reads a byte slice into a Host value.
@ -3064,6 +3067,8 @@ func HostRead(buf []byte, v *Host) int {
copy(v.Address[:v.AddressLen], buf[b:]) copy(v.Address[:v.AddressLen], buf[b:])
b += int(v.AddressLen) b += int(v.AddressLen)
b = (b + 3) & ^3 // alignment gap
return b return b
} }
@ -3079,7 +3084,7 @@ func HostReadList(buf []byte, dest []Host) int {
// Bytes writes a Host value to a byte slice. // Bytes writes a Host value to a byte slice.
func (v Host) Bytes() []byte { func (v Host) Bytes() []byte {
buf := make([]byte, (4 + xgb.Pad((int(v.AddressLen) * 1)))) buf := make([]byte, ((4 + xgb.Pad((int(v.AddressLen) * 1))) + 4))
b := 0 b := 0
buf[b] = v.Family buf[b] = v.Family
@ -3093,6 +3098,8 @@ func (v Host) Bytes() []byte {
copy(buf[b:], v.Address[:v.AddressLen]) copy(buf[b:], v.Address[:v.AddressLen])
b += int(v.AddressLen) b += int(v.AddressLen)
b = (b + 3) & ^3 // alignment gap
return buf[:b] return buf[:b]
} }
@ -3112,7 +3119,7 @@ func HostListBytes(buf []byte, list []Host) int {
func HostListSize(list []Host) int { func HostListSize(list []Host) int {
size := 0 size := 0
for _, item := range list { for _, item := range list {
size += (4 + xgb.Pad((int(item.AddressLen) * 1))) size += ((4 + xgb.Pad((int(item.AddressLen) * 1))) + 4)
} }
return size return size
} }
@ -3445,6 +3452,8 @@ func init() {
type Keycode byte type Keycode byte
type Keycode32 uint32
// KeymapNotify is the event number for a KeymapNotifyEvent. // KeymapNotify is the event number for a KeymapNotifyEvent.
const KeymapNotify = 11 const KeymapNotify = 11
@ -5569,7 +5578,6 @@ type SetupInfo struct {
Vendor string // size: xgb.Pad((int(VendorLen) * 1)) Vendor string // size: xgb.Pad((int(VendorLen) * 1))
// alignment gap to multiple of 4 // alignment gap to multiple of 4
PixmapFormats []Format // size: xgb.Pad((int(PixmapFormatsLen) * 8)) PixmapFormats []Format // size: xgb.Pad((int(PixmapFormatsLen) * 8))
// alignment gap to multiple of 4
Roots []ScreenInfo // size: ScreenInfoListSize(Roots) Roots []ScreenInfo // size: ScreenInfoListSize(Roots)
} }
@ -5647,8 +5655,6 @@ func SetupInfoRead(buf []byte, v *SetupInfo) int {
v.PixmapFormats = make([]Format, v.PixmapFormatsLen) v.PixmapFormats = make([]Format, v.PixmapFormatsLen)
b += FormatReadList(buf[b:], v.PixmapFormats) b += FormatReadList(buf[b:], v.PixmapFormats)
b = (b + 3) & ^3 // alignment gap
v.Roots = make([]ScreenInfo, v.RootsLen) v.Roots = make([]ScreenInfo, v.RootsLen)
b += ScreenInfoReadList(buf[b:], v.Roots) b += ScreenInfoReadList(buf[b:], v.Roots)
@ -5667,7 +5673,7 @@ func SetupInfoReadList(buf []byte, dest []SetupInfo) int {
// Bytes writes a SetupInfo value to a byte slice. // Bytes writes a SetupInfo value to a byte slice.
func (v SetupInfo) Bytes() []byte { func (v SetupInfo) Bytes() []byte {
buf := make([]byte, (((((40 + xgb.Pad((int(v.VendorLen) * 1))) + 4) + xgb.Pad((int(v.PixmapFormatsLen) * 8))) + 4) + ScreenInfoListSize(v.Roots))) buf := make([]byte, ((((40 + xgb.Pad((int(v.VendorLen) * 1))) + 4) + xgb.Pad((int(v.PixmapFormatsLen) * 8))) + ScreenInfoListSize(v.Roots)))
b := 0 b := 0
buf[b] = v.Status buf[b] = v.Status
@ -5735,8 +5741,6 @@ func (v SetupInfo) Bytes() []byte {
b += FormatListBytes(buf[b:], v.PixmapFormats) b += FormatListBytes(buf[b:], v.PixmapFormats)
b = (b + 3) & ^3 // alignment gap
b += ScreenInfoListBytes(buf[b:], v.Roots) b += ScreenInfoListBytes(buf[b:], v.Roots)
return buf[:b] return buf[:b]
@ -5758,7 +5762,7 @@ func SetupInfoListBytes(buf []byte, list []SetupInfo) int {
func SetupInfoListSize(list []SetupInfo) int { func SetupInfoListSize(list []SetupInfo) int {
size := 0 size := 0
for _, item := range list { for _, item := range list {
size += (((((40 + xgb.Pad((int(item.VendorLen) * 1))) + 4) + xgb.Pad((int(item.PixmapFormatsLen) * 8))) + 4) + ScreenInfoListSize(item.Roots)) size += ((((40 + xgb.Pad((int(item.VendorLen) * 1))) + 4) + xgb.Pad((int(item.PixmapFormatsLen) * 8))) + ScreenInfoListSize(item.Roots))
} }
return size return size
} }
@ -6588,7 +6592,6 @@ type AllocColorCellsReply struct {
MasksLen uint16 MasksLen uint16
// padding: 20 bytes // padding: 20 bytes
Pixels []uint32 // size: xgb.Pad((int(PixelsLen) * 4)) Pixels []uint32 // size: xgb.Pad((int(PixelsLen) * 4))
// alignment gap to multiple of 4
Masks []uint32 // size: xgb.Pad((int(MasksLen) * 4)) Masks []uint32 // size: xgb.Pad((int(MasksLen) * 4))
} }
@ -6631,8 +6634,6 @@ func allocColorCellsReply(buf []byte) *AllocColorCellsReply {
b += 4 b += 4
} }
b = (b + 3) & ^3 // alignment gap
v.Masks = make([]uint32, v.MasksLen) v.Masks = make([]uint32, v.MasksLen)
for i := 0; i < int(v.MasksLen); i++ { for i := 0; i < int(v.MasksLen); i++ {
v.Masks[i] = xgb.Get32(buf[b:]) v.Masks[i] = xgb.Get32(buf[b:])
@ -7091,7 +7092,7 @@ func (cook ChangeGCCookie) Check() error {
// Write request to wire for ChangeGC // Write request to wire for ChangeGC
// changeGCRequest writes a ChangeGC request to a byte slice. // changeGCRequest writes a ChangeGC request to a byte slice.
func changeGCRequest(c *xgb.Conn, Gc Gcontext, ValueMask uint32, ValueList []uint32) []byte { func changeGCRequest(c *xgb.Conn, Gc Gcontext, ValueMask uint32, ValueList []uint32) []byte {
size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) size := xgb.Pad((12 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))
b := 0 b := 0
buf := make([]byte, size) buf := make([]byte, size)
@ -7108,6 +7109,7 @@ func changeGCRequest(c *xgb.Conn, Gc Gcontext, ValueMask uint32, ValueList []uin
xgb.Put32(buf[b:], ValueMask) xgb.Put32(buf[b:], ValueMask)
b += 4 b += 4
for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { for i := 0; i < xgb.PopCount(int(ValueMask)); i++ {
xgb.Put32(buf[b:], ValueList[i]) xgb.Put32(buf[b:], ValueList[i])
b += 4 b += 4
@ -7204,7 +7206,7 @@ func (cook ChangeKeyboardControlCookie) Check() error {
// Write request to wire for ChangeKeyboardControl // Write request to wire for ChangeKeyboardControl
// changeKeyboardControlRequest writes a ChangeKeyboardControl request to a byte slice. // changeKeyboardControlRequest writes a ChangeKeyboardControl request to a byte slice.
func changeKeyboardControlRequest(c *xgb.Conn, ValueMask uint32, ValueList []uint32) []byte { func changeKeyboardControlRequest(c *xgb.Conn, ValueMask uint32, ValueList []uint32) []byte {
size := xgb.Pad((4 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) size := xgb.Pad((8 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))
b := 0 b := 0
buf := make([]byte, size) buf := make([]byte, size)
@ -7218,6 +7220,7 @@ func changeKeyboardControlRequest(c *xgb.Conn, ValueMask uint32, ValueList []uin
xgb.Put32(buf[b:], ValueMask) xgb.Put32(buf[b:], ValueMask)
b += 4 b += 4
for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { for i := 0; i < xgb.PopCount(int(ValueMask)); i++ {
xgb.Put32(buf[b:], ValueList[i]) xgb.Put32(buf[b:], ValueList[i])
b += 4 b += 4
@ -7499,7 +7502,7 @@ func (cook ChangeWindowAttributesCookie) Check() error {
// Write request to wire for ChangeWindowAttributes // Write request to wire for ChangeWindowAttributes
// changeWindowAttributesRequest writes a ChangeWindowAttributes request to a byte slice. // changeWindowAttributesRequest writes a ChangeWindowAttributes request to a byte slice.
func changeWindowAttributesRequest(c *xgb.Conn, Window Window, ValueMask uint32, ValueList []uint32) []byte { func changeWindowAttributesRequest(c *xgb.Conn, Window Window, ValueMask uint32, ValueList []uint32) []byte {
size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) size := xgb.Pad((12 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))
b := 0 b := 0
buf := make([]byte, size) buf := make([]byte, size)
@ -7516,6 +7519,7 @@ func changeWindowAttributesRequest(c *xgb.Conn, Window Window, ValueMask uint32,
xgb.Put32(buf[b:], ValueMask) xgb.Put32(buf[b:], ValueMask)
b += 4 b += 4
for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { for i := 0; i < xgb.PopCount(int(ValueMask)); i++ {
xgb.Put32(buf[b:], ValueList[i]) xgb.Put32(buf[b:], ValueList[i])
b += 4 b += 4
@ -7717,7 +7721,7 @@ func (cook ConfigureWindowCookie) Check() error {
// Write request to wire for ConfigureWindow // Write request to wire for ConfigureWindow
// configureWindowRequest writes a ConfigureWindow request to a byte slice. // configureWindowRequest writes a ConfigureWindow request to a byte slice.
func configureWindowRequest(c *xgb.Conn, Window Window, ValueMask uint16, ValueList []uint32) []byte { func configureWindowRequest(c *xgb.Conn, Window Window, ValueMask uint16, ValueList []uint32) []byte {
size := xgb.Pad((10 + (2 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) size := xgb.Pad((12 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))
b := 0 b := 0
buf := make([]byte, size) buf := make([]byte, size)
@ -8221,7 +8225,7 @@ func (cook CreateGCCookie) Check() error {
// Write request to wire for CreateGC // Write request to wire for CreateGC
// createGCRequest writes a CreateGC request to a byte slice. // createGCRequest writes a CreateGC request to a byte slice.
func createGCRequest(c *xgb.Conn, Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) []byte { func createGCRequest(c *xgb.Conn, Cid Gcontext, Drawable Drawable, ValueMask uint32, ValueList []uint32) []byte {
size := xgb.Pad((12 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) size := xgb.Pad((16 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))
b := 0 b := 0
buf := make([]byte, size) buf := make([]byte, size)
@ -8241,6 +8245,7 @@ func createGCRequest(c *xgb.Conn, Cid Gcontext, Drawable Drawable, ValueMask uin
xgb.Put32(buf[b:], ValueMask) xgb.Put32(buf[b:], ValueMask)
b += 4 b += 4
for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { for i := 0; i < xgb.PopCount(int(ValueMask)); i++ {
xgb.Put32(buf[b:], ValueList[i]) xgb.Put32(buf[b:], ValueList[i])
b += 4 b += 4
@ -8416,7 +8421,7 @@ func (cook CreateWindowCookie) Check() error {
// Write request to wire for CreateWindow // Write request to wire for CreateWindow
// createWindowRequest writes a CreateWindow request to a byte slice. // createWindowRequest writes a CreateWindow request to a byte slice.
func createWindowRequest(c *xgb.Conn, Depth byte, Wid Window, Parent Window, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class uint16, Visual Visualid, ValueMask uint32, ValueList []uint32) []byte { func createWindowRequest(c *xgb.Conn, Depth byte, Wid Window, Parent Window, X int16, Y int16, Width uint16, Height uint16, BorderWidth uint16, Class uint16, Visual Visualid, ValueMask uint32, ValueList []uint32) []byte {
size := xgb.Pad((28 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) size := xgb.Pad((32 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))
b := 0 b := 0
buf := make([]byte, size) buf := make([]byte, size)
@ -8458,6 +8463,7 @@ func createWindowRequest(c *xgb.Conn, Depth byte, Wid Window, Parent Window, X i
xgb.Put32(buf[b:], ValueMask) xgb.Put32(buf[b:], ValueMask)
b += 4 b += 4
for i := 0; i < xgb.PopCount(int(ValueMask)); i++ { for i := 0; i < xgb.PopCount(int(ValueMask)); i++ {
xgb.Put32(buf[b:], ValueList[i]) xgb.Put32(buf[b:], ValueList[i])
b += 4 b += 4
@ -12904,7 +12910,6 @@ type QueryFontReply struct {
FontDescent int16 FontDescent int16
CharInfosLen uint32 CharInfosLen uint32
Properties []Fontprop // size: xgb.Pad((int(PropertiesLen) * 8)) Properties []Fontprop // size: xgb.Pad((int(PropertiesLen) * 8))
// alignment gap to multiple of 4
CharInfos []Charinfo // size: xgb.Pad((int(CharInfosLen) * 12)) CharInfos []Charinfo // size: xgb.Pad((int(CharInfosLen) * 12))
} }
@ -12983,8 +12988,6 @@ func queryFontReply(buf []byte) *QueryFontReply {
v.Properties = make([]Fontprop, v.PropertiesLen) v.Properties = make([]Fontprop, v.PropertiesLen)
b += FontpropReadList(buf[b:], v.Properties) b += FontpropReadList(buf[b:], v.Properties)
b = (b + 3) & ^3 // alignment gap
v.CharInfos = make([]Charinfo, v.CharInfosLen) v.CharInfos = make([]Charinfo, v.CharInfosLen)
b += CharinfoReadList(buf[b:], v.CharInfos) b += CharinfoReadList(buf[b:], v.CharInfos)

View File

@ -41,7 +41,9 @@ type ListItem struct {
ObjectContextLen uint32 ObjectContextLen uint32
DataContextLen uint32 DataContextLen uint32
ObjectContext string // size: xgb.Pad((int(ObjectContextLen) * 1)) ObjectContext string // size: xgb.Pad((int(ObjectContextLen) * 1))
// alignment gap to multiple of 4
DataContext string // size: xgb.Pad((int(DataContextLen) * 1)) DataContext string // size: xgb.Pad((int(DataContextLen) * 1))
// alignment gap to multiple of 4
} }
// ListItemRead reads a byte slice into a ListItem value. // ListItemRead reads a byte slice into a ListItem value.
@ -64,6 +66,8 @@ func ListItemRead(buf []byte, v *ListItem) int {
b += int(v.ObjectContextLen) b += int(v.ObjectContextLen)
} }
b = (b + 3) & ^3 // alignment gap
{ {
byteString := make([]byte, v.DataContextLen) byteString := make([]byte, v.DataContextLen)
copy(byteString[:v.DataContextLen], buf[b:]) copy(byteString[:v.DataContextLen], buf[b:])
@ -71,6 +75,8 @@ func ListItemRead(buf []byte, v *ListItem) int {
b += int(v.DataContextLen) b += int(v.DataContextLen)
} }
b = (b + 3) & ^3 // alignment gap
return b return b
} }
@ -86,7 +92,7 @@ func ListItemReadList(buf []byte, dest []ListItem) int {
// Bytes writes a ListItem value to a byte slice. // Bytes writes a ListItem value to a byte slice.
func (v ListItem) Bytes() []byte { func (v ListItem) Bytes() []byte {
buf := make([]byte, ((12 + xgb.Pad((int(v.ObjectContextLen) * 1))) + xgb.Pad((int(v.DataContextLen) * 1)))) buf := make([]byte, ((((12 + xgb.Pad((int(v.ObjectContextLen) * 1))) + 4) + xgb.Pad((int(v.DataContextLen) * 1))) + 4))
b := 0 b := 0
xgb.Put32(buf[b:], uint32(v.Name)) xgb.Put32(buf[b:], uint32(v.Name))
@ -101,9 +107,13 @@ func (v ListItem) Bytes() []byte {
copy(buf[b:], v.ObjectContext[:v.ObjectContextLen]) copy(buf[b:], v.ObjectContext[:v.ObjectContextLen])
b += int(v.ObjectContextLen) b += int(v.ObjectContextLen)
b = (b + 3) & ^3 // alignment gap
copy(buf[b:], v.DataContext[:v.DataContextLen]) copy(buf[b:], v.DataContext[:v.DataContextLen])
b += int(v.DataContextLen) b += int(v.DataContextLen)
b = (b + 3) & ^3 // alignment gap
return buf[:b] return buf[:b]
} }
@ -123,7 +133,7 @@ func ListItemListBytes(buf []byte, list []ListItem) int {
func ListItemListSize(list []ListItem) int { func ListItemListSize(list []ListItem) int {
size := 0 size := 0
for _, item := range list { for _, item := range list {
size += ((12 + xgb.Pad((int(item.ObjectContextLen) * 1))) + xgb.Pad((int(item.DataContextLen) * 1))) size += ((((12 + xgb.Pad((int(item.ObjectContextLen) * 1))) + 4) + xgb.Pad((int(item.DataContextLen) * 1))) + 4)
} }
return size return size
} }

View File

@ -45,7 +45,7 @@ type AdaptorInfo struct {
Type byte Type byte
// padding: 1 bytes // padding: 1 bytes
Name string // size: xgb.Pad((int(NameSize) * 1)) Name string // size: xgb.Pad((int(NameSize) * 1))
// padding: 0 bytes // alignment gap to multiple of 4
Formats []Format // size: xgb.Pad((int(NumFormats) * 8)) Formats []Format // size: xgb.Pad((int(NumFormats) * 8))
} }
@ -77,7 +77,7 @@ func AdaptorInfoRead(buf []byte, v *AdaptorInfo) int {
b += int(v.NameSize) b += int(v.NameSize)
} }
b += 0 // padding b = (b + 3) & ^3 // alignment gap
v.Formats = make([]Format, v.NumFormats) v.Formats = make([]Format, v.NumFormats)
b += FormatReadList(buf[b:], v.Formats) b += FormatReadList(buf[b:], v.Formats)
@ -97,7 +97,7 @@ func AdaptorInfoReadList(buf []byte, dest []AdaptorInfo) int {
// Bytes writes a AdaptorInfo value to a byte slice. // Bytes writes a AdaptorInfo value to a byte slice.
func (v AdaptorInfo) Bytes() []byte { func (v AdaptorInfo) Bytes() []byte {
buf := make([]byte, (((12 + xgb.Pad((int(v.NameSize) * 1))) + 0) + xgb.Pad((int(v.NumFormats) * 8)))) buf := make([]byte, (((12 + xgb.Pad((int(v.NameSize) * 1))) + 4) + xgb.Pad((int(v.NumFormats) * 8))))
b := 0 b := 0
xgb.Put32(buf[b:], uint32(v.BaseId)) xgb.Put32(buf[b:], uint32(v.BaseId))
@ -120,7 +120,7 @@ func (v AdaptorInfo) Bytes() []byte {
copy(buf[b:], v.Name[:v.NameSize]) copy(buf[b:], v.Name[:v.NameSize])
b += int(v.NameSize) b += int(v.NameSize)
b += 0 // padding b = (b + 3) & ^3 // alignment gap
b += FormatListBytes(buf[b:], v.Formats) b += FormatListBytes(buf[b:], v.Formats)
@ -143,7 +143,7 @@ func AdaptorInfoListBytes(buf []byte, list []AdaptorInfo) int {
func AdaptorInfoListSize(list []AdaptorInfo) int { func AdaptorInfoListSize(list []AdaptorInfo) int {
size := 0 size := 0
for _, item := range list { for _, item := range list {
size += (((12 + xgb.Pad((int(item.NameSize) * 1))) + 0) + xgb.Pad((int(item.NumFormats) * 8))) size += (((12 + xgb.Pad((int(item.NameSize) * 1))) + 4) + xgb.Pad((int(item.NumFormats) * 8)))
} }
return size return size
} }
@ -159,6 +159,7 @@ type AttributeInfo struct {
Max int32 Max int32
Size uint32 Size uint32
Name string // size: xgb.Pad((int(Size) * 1)) Name string // size: xgb.Pad((int(Size) * 1))
// alignment gap to multiple of 4
} }
// AttributeInfoRead reads a byte slice into a AttributeInfo value. // AttributeInfoRead reads a byte slice into a AttributeInfo value.
@ -184,6 +185,8 @@ func AttributeInfoRead(buf []byte, v *AttributeInfo) int {
b += int(v.Size) b += int(v.Size)
} }
b = (b + 3) & ^3 // alignment gap
return b return b
} }
@ -199,7 +202,7 @@ func AttributeInfoReadList(buf []byte, dest []AttributeInfo) int {
// Bytes writes a AttributeInfo value to a byte slice. // Bytes writes a AttributeInfo value to a byte slice.
func (v AttributeInfo) Bytes() []byte { func (v AttributeInfo) Bytes() []byte {
buf := make([]byte, (16 + xgb.Pad((int(v.Size) * 1)))) buf := make([]byte, ((16 + xgb.Pad((int(v.Size) * 1))) + 4))
b := 0 b := 0
xgb.Put32(buf[b:], v.Flags) xgb.Put32(buf[b:], v.Flags)
@ -217,6 +220,8 @@ func (v AttributeInfo) Bytes() []byte {
copy(buf[b:], v.Name[:v.Size]) copy(buf[b:], v.Name[:v.Size])
b += int(v.Size) b += int(v.Size)
b = (b + 3) & ^3 // alignment gap
return buf[:b] return buf[:b]
} }
@ -236,7 +241,7 @@ func AttributeInfoListBytes(buf []byte, list []AttributeInfo) int {
func AttributeInfoListSize(list []AttributeInfo) int { func AttributeInfoListSize(list []AttributeInfo) int {
size := 0 size := 0
for _, item := range list { for _, item := range list {
size += (16 + xgb.Pad((int(item.Size) * 1))) size += ((16 + xgb.Pad((int(item.Size) * 1))) + 4)
} }
return size return size
} }
@ -397,6 +402,7 @@ type EncodingInfo struct {
// padding: 2 bytes // padding: 2 bytes
Rate Rational Rate Rational
Name string // size: xgb.Pad((int(NameSize) * 1)) Name string // size: xgb.Pad((int(NameSize) * 1))
// alignment gap to multiple of 4
} }
// EncodingInfoRead reads a byte slice into a EncodingInfo value. // EncodingInfoRead reads a byte slice into a EncodingInfo value.
@ -427,6 +433,8 @@ func EncodingInfoRead(buf []byte, v *EncodingInfo) int {
b += int(v.NameSize) b += int(v.NameSize)
} }
b = (b + 3) & ^3 // alignment gap
return b return b
} }
@ -442,7 +450,7 @@ func EncodingInfoReadList(buf []byte, dest []EncodingInfo) int {
// Bytes writes a EncodingInfo value to a byte slice. // Bytes writes a EncodingInfo value to a byte slice.
func (v EncodingInfo) Bytes() []byte { func (v EncodingInfo) Bytes() []byte {
buf := make([]byte, (20 + xgb.Pad((int(v.NameSize) * 1)))) buf := make([]byte, ((20 + xgb.Pad((int(v.NameSize) * 1))) + 4))
b := 0 b := 0
xgb.Put32(buf[b:], uint32(v.Encoding)) xgb.Put32(buf[b:], uint32(v.Encoding))
@ -468,6 +476,8 @@ func (v EncodingInfo) Bytes() []byte {
copy(buf[b:], v.Name[:v.NameSize]) copy(buf[b:], v.Name[:v.NameSize])
b += int(v.NameSize) b += int(v.NameSize)
b = (b + 3) & ^3 // alignment gap
return buf[:b] return buf[:b]
} }
@ -487,7 +497,7 @@ func EncodingInfoListBytes(buf []byte, list []EncodingInfo) int {
func EncodingInfoListSize(list []EncodingInfo) int { func EncodingInfoListSize(list []EncodingInfo) int {
size := 0 size := 0
for _, item := range list { for _, item := range list {
size += (20 + xgb.Pad((int(item.NameSize) * 1))) size += ((20 + xgb.Pad((int(item.NameSize) * 1))) + 4)
} }
return size return size
} }
@ -567,7 +577,6 @@ type Image struct {
DataSize uint32 DataSize uint32
NumPlanes uint32 NumPlanes uint32
Pitches []uint32 // size: xgb.Pad((int(NumPlanes) * 4)) Pitches []uint32 // size: xgb.Pad((int(NumPlanes) * 4))
// alignment gap to multiple of 4
Offsets []uint32 // size: xgb.Pad((int(NumPlanes) * 4)) Offsets []uint32 // size: xgb.Pad((int(NumPlanes) * 4))
Data []byte // size: xgb.Pad((int(DataSize) * 1)) Data []byte // size: xgb.Pad((int(DataSize) * 1))
} }
@ -597,8 +606,6 @@ func ImageRead(buf []byte, v *Image) int {
b += 4 b += 4
} }
b = (b + 3) & ^3 // alignment gap
v.Offsets = make([]uint32, v.NumPlanes) v.Offsets = make([]uint32, v.NumPlanes)
for i := 0; i < int(v.NumPlanes); i++ { for i := 0; i < int(v.NumPlanes); i++ {
v.Offsets[i] = xgb.Get32(buf[b:]) v.Offsets[i] = xgb.Get32(buf[b:])
@ -624,7 +631,7 @@ func ImageReadList(buf []byte, dest []Image) int {
// Bytes writes a Image value to a byte slice. // Bytes writes a Image value to a byte slice.
func (v Image) Bytes() []byte { func (v Image) Bytes() []byte {
buf := make([]byte, ((((16 + xgb.Pad((int(v.NumPlanes) * 4))) + 4) + xgb.Pad((int(v.NumPlanes) * 4))) + xgb.Pad((int(v.DataSize) * 1)))) buf := make([]byte, (((16 + xgb.Pad((int(v.NumPlanes) * 4))) + xgb.Pad((int(v.NumPlanes) * 4))) + xgb.Pad((int(v.DataSize) * 1))))
b := 0 b := 0
xgb.Put32(buf[b:], v.Id) xgb.Put32(buf[b:], v.Id)
@ -647,8 +654,6 @@ func (v Image) Bytes() []byte {
b += 4 b += 4
} }
b = (b + 3) & ^3 // alignment gap
for i := 0; i < int(v.NumPlanes); i++ { for i := 0; i < int(v.NumPlanes); i++ {
xgb.Put32(buf[b:], v.Offsets[i]) xgb.Put32(buf[b:], v.Offsets[i])
b += 4 b += 4
@ -676,7 +681,7 @@ func ImageListBytes(buf []byte, list []Image) int {
func ImageListSize(list []Image) int { func ImageListSize(list []Image) int {
size := 0 size := 0
for _, item := range list { for _, item := range list {
size += ((((16 + xgb.Pad((int(item.NumPlanes) * 4))) + 4) + xgb.Pad((int(item.NumPlanes) * 4))) + xgb.Pad((int(item.DataSize) * 1))) size += (((16 + xgb.Pad((int(item.NumPlanes) * 4))) + xgb.Pad((int(item.NumPlanes) * 4))) + xgb.Pad((int(item.DataSize) * 1)))
} }
return size return size
} }
@ -2416,7 +2421,6 @@ type QueryImageAttributesReply struct {
Height uint16 Height uint16
// padding: 12 bytes // padding: 12 bytes
Pitches []uint32 // size: xgb.Pad((int(NumPlanes) * 4)) Pitches []uint32 // size: xgb.Pad((int(NumPlanes) * 4))
// alignment gap to multiple of 4
Offsets []uint32 // size: xgb.Pad((int(NumPlanes) * 4)) Offsets []uint32 // size: xgb.Pad((int(NumPlanes) * 4))
} }
@ -2465,8 +2469,6 @@ func queryImageAttributesReply(buf []byte) *QueryImageAttributesReply {
b += 4 b += 4
} }
b = (b + 3) & ^3 // alignment gap
v.Offsets = make([]uint32, v.NumPlanes) v.Offsets = make([]uint32, v.NumPlanes)
for i := 0; i < int(v.NumPlanes); i++ { for i := 0; i < int(v.NumPlanes); i++ {
v.Offsets[i] = xgb.Get32(buf[b:]) v.Offsets[i] = xgb.Get32(buf[b:])