Skip to content

Commit

Permalink
Merge pull request #10 from gen2brain/master
Browse files Browse the repository at this point in the history
Support for xcb-proto version 1.15.2, #issue 9
  • Loading branch information
jezek authored Nov 5, 2022
2 parents 7effddc + ba0b8dd commit a57abb5
Show file tree
Hide file tree
Showing 22 changed files with 1,475 additions and 530 deletions.
133 changes: 119 additions & 14 deletions glx/glx.go
Original file line number Diff line number Diff line change
Expand Up @@ -3165,14 +3165,14 @@ func getClipPlaneReply(buf []byte) *GetClipPlaneReply {
v := new(GetClipPlaneReply)
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

b += 1 // padding

b += 24 // padding

v.Data = make([]Float64, (int(v.Length) / 2))
Expand Down Expand Up @@ -4096,14 +4096,14 @@ func getDoublevReply(buf []byte) *GetDoublevReply {
v := new(GetDoublevReply)
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

b += 1 // padding

b += 4 // padding

v.N = xgb.Get32(buf[b:])
Expand Down Expand Up @@ -5340,14 +5340,14 @@ func getMapdvReply(buf []byte) *GetMapdvReply {
v := new(GetMapdvReply)
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

b += 1 // padding

b += 4 // padding

v.N = xgb.Get32(buf[b:])
Expand Down Expand Up @@ -7548,14 +7548,14 @@ func getTexGendvReply(buf []byte) *GetTexGendvReply {
v := new(GetTexGendvReply)
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

b += 1 // padding

b += 4 // padding

v.N = xgb.Get32(buf[b:])
Expand Down Expand Up @@ -8654,6 +8654,103 @@ func isDirectRequest(c *xgb.Conn, Context Context) []byte {
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.
type IsListCookie struct {
*xgb.Cookie
Expand Down Expand Up @@ -10260,7 +10357,7 @@ func (cook SetClientInfo2ARBCookie) Check() error {
// Write request to wire for SetClientInfo2ARB
// setClientInfo2ARBRequest writes a SetClientInfo2ARB request to a byte slice.
func setClientInfo2ARBRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) []byte {
size := xgb.Pad((((24 + xgb.Pad(((int(NumVersions) * 3) * 4))) + xgb.Pad((int(GlStrLen) * 1))) + xgb.Pad((int(GlxStrLen) * 1))))
size := xgb.Pad(((((24 + xgb.Pad(((int(NumVersions) * 3) * 4))) + xgb.Pad((int(GlStrLen) * 1))) + 4) + xgb.Pad((int(GlxStrLen) * 1))))
b := 0
buf := make([]byte, size)

Expand All @@ -10272,7 +10369,7 @@ func setClientInfo2ARBRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uin
buf[b] = 35 // request opcode
b += 1

xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
blen := b
b += 2

xgb.Put32(buf[b:], MajorVersion)
Expand All @@ -10298,10 +10395,14 @@ func setClientInfo2ARBRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uin
copy(buf[b:], GlExtensionString[:GlStrLen])
b += int(GlStrLen)

b = (b + 3) & ^3 // alignment gap

copy(buf[b:], GlxExtensionString[:GlxStrLen])
b += int(GlxStrLen)

return buf
b = xgb.Pad(b)
xgb.Put16(buf[blen:], uint16(b/4)) // write request size in 4-byte units
return buf[:b]
}

// SetClientInfoARBCookie is a cookie used only for SetClientInfoARB requests.
Expand Down Expand Up @@ -10344,7 +10445,7 @@ func (cook SetClientInfoARBCookie) Check() error {
// Write request to wire for SetClientInfoARB
// setClientInfoARBRequest writes a SetClientInfoARB request to a byte slice.
func setClientInfoARBRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32, NumVersions uint32, GlStrLen uint32, GlxStrLen uint32, GlVersions []uint32, GlExtensionString string, GlxExtensionString string) []byte {
size := xgb.Pad((((24 + xgb.Pad(((int(NumVersions) * 2) * 4))) + xgb.Pad((int(GlStrLen) * 1))) + xgb.Pad((int(GlxStrLen) * 1))))
size := xgb.Pad(((((24 + xgb.Pad(((int(NumVersions) * 2) * 4))) + xgb.Pad((int(GlStrLen) * 1))) + 4) + xgb.Pad((int(GlxStrLen) * 1))))
b := 0
buf := make([]byte, size)

Expand All @@ -10356,7 +10457,7 @@ func setClientInfoARBRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint
buf[b] = 33 // request opcode
b += 1

xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
blen := b
b += 2

xgb.Put32(buf[b:], MajorVersion)
Expand All @@ -10382,10 +10483,14 @@ func setClientInfoARBRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint
copy(buf[b:], GlExtensionString[:GlStrLen])
b += int(GlStrLen)

b = (b + 3) & ^3 // alignment gap

copy(buf[b:], GlxExtensionString[:GlxStrLen])
b += int(GlxStrLen)

return buf
b = xgb.Pad(b)
xgb.Put16(buf[blen:], uint16(b/4)) // write request size in 4-byte units
return buf[:b]
}

// SwapBuffersCookie is a cookie used only for SwapBuffers requests.
Expand Down
Loading

0 comments on commit a57abb5

Please sign in to comment.