From 0685fb57e14104ee4ad9f70ec94f787a9a22c028 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Sun, 11 Aug 2013 20:43:26 -0400 Subject: Update to latest xproto XML. --- nexgb/xf86dri/xf86dri.go | 978 +++++++++++++++++++++++------------------------ 1 file changed, 489 insertions(+), 489 deletions(-) (limited to 'nexgb/xf86dri') diff --git a/nexgb/xf86dri/xf86dri.go b/nexgb/xf86dri/xf86dri.go index d52654d..1a6fddf 100644 --- a/nexgb/xf86dri/xf86dri.go +++ b/nexgb/xf86dri/xf86dri.go @@ -2,7 +2,7 @@ package xf86dri /* - This file was generated by xf86dri.xml on Jun 5 2012 12:11:59am EDT. + This file was generated by xf86dri.xml on Aug 11 2013 8:39:43pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,30 +40,6 @@ func init() { xgb.NewExtErrorFuncs["XFree86-DRI"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Card16' - -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - -// Skipping definition for base type 'Float' - -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - -// Skipping definition for base type 'Int8' - type DrmClipRect struct { X1 int16 Y1 int16 @@ -132,45 +108,67 @@ func DrmClipRectListBytes(buf []byte, list []DrmClipRect) int { return b } -// QueryVersionCookie is a cookie used only for QueryVersion requests. -type QueryVersionCookie struct { +// Skipping definition for base type 'Bool' + +// Skipping definition for base type 'Byte' + +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Float' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Card32' + +// AuthConnectionCookie is a cookie used only for AuthConnection requests. +type AuthConnectionCookie struct { *xgb.Cookie } -// QueryVersion sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() -func QueryVersion(c *xgb.Conn) QueryVersionCookie { +// AuthConnection sends a checked request. +// If an error occurs, it will be returned with the reply by calling AuthConnectionCookie.Reply() +func AuthConnection(c *xgb.Conn, Screen uint32, Magic uint32) AuthConnectionCookie { if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + panic("Cannot issue request 'AuthConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(queryVersionRequest(c), cookie) - return QueryVersionCookie{cookie} + c.NewRequest(authConnectionRequest(c, Screen, Magic), cookie) + return AuthConnectionCookie{cookie} } -// QueryVersionUnchecked sends an unchecked request. +// AuthConnectionUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryVersionUnchecked(c *xgb.Conn) QueryVersionCookie { +func AuthConnectionUnchecked(c *xgb.Conn, Screen uint32, Magic uint32) AuthConnectionCookie { if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + panic("Cannot issue request 'AuthConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(queryVersionRequest(c), cookie) - return QueryVersionCookie{cookie} + c.NewRequest(authConnectionRequest(c, Screen, Magic), cookie) + return AuthConnectionCookie{cookie} } -// QueryVersionReply represents the data returned from a QueryVersion request. -type QueryVersionReply struct { +// AuthConnectionReply represents the data returned from a AuthConnection request. +type AuthConnectionReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - DriMajorVersion uint16 - DriMinorVersion uint16 - DriMinorPatch uint32 + Authenticated uint32 } -// Reply blocks and returns the reply data for a QueryVersion request. -func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { +// Reply blocks and returns the reply data for a AuthConnection request. +func (cook AuthConnectionCookie) Reply() (*AuthConnectionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -178,12 +176,12 @@ func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { if buf == nil { return nil, nil } - return queryVersionReply(buf), nil + return authConnectionReply(buf), nil } -// queryVersionReply reads a byte slice into a QueryVersionReply value. -func queryVersionReply(buf []byte) *QueryVersionReply { - v := new(QueryVersionReply) +// authConnectionReply reads a byte slice into a AuthConnectionReply value. +func authConnectionReply(buf []byte) *AuthConnectionReply { + v := new(AuthConnectionReply) b := 1 // skip reply determinant b += 1 // padding @@ -194,110 +192,73 @@ func queryVersionReply(buf []byte) *QueryVersionReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.DriMajorVersion = xgb.Get16(buf[b:]) - b += 2 - - v.DriMinorVersion = xgb.Get16(buf[b:]) - b += 2 - - v.DriMinorPatch = xgb.Get32(buf[b:]) + v.Authenticated = xgb.Get32(buf[b:]) b += 4 return v } -// Write request to wire for QueryVersion -// queryVersionRequest writes a QueryVersion request to a byte slice. -func queryVersionRequest(c *xgb.Conn) []byte { - size := 4 +// Write request to wire for AuthConnection +// authConnectionRequest writes a AuthConnection request to a byte slice. +func authConnectionRequest(c *xgb.Conn, Screen uint32, Magic uint32) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFREE86-DRI"] b += 1 - buf[b] = 0 // request opcode + buf[b] = 11 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], Magic) + b += 4 + return buf } -// QueryDirectRenderingCapableCookie is a cookie used only for QueryDirectRenderingCapable requests. -type QueryDirectRenderingCapableCookie struct { +// CloseConnectionCookie is a cookie used only for CloseConnection requests. +type CloseConnectionCookie struct { *xgb.Cookie } -// QueryDirectRenderingCapable sends a checked request. -// If an error occurs, it will be returned with the reply by calling QueryDirectRenderingCapableCookie.Reply() -func QueryDirectRenderingCapable(c *xgb.Conn, Screen uint32) QueryDirectRenderingCapableCookie { - if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'QueryDirectRenderingCapable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(queryDirectRenderingCapableRequest(c, Screen), cookie) - return QueryDirectRenderingCapableCookie{cookie} -} - -// QueryDirectRenderingCapableUnchecked sends an unchecked request. +// CloseConnection sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryDirectRenderingCapableUnchecked(c *xgb.Conn, Screen uint32) QueryDirectRenderingCapableCookie { +func CloseConnection(c *xgb.Conn, Screen uint32) CloseConnectionCookie { if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'QueryDirectRenderingCapable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + panic("Cannot issue request 'CloseConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(queryDirectRenderingCapableRequest(c, Screen), cookie) - return QueryDirectRenderingCapableCookie{cookie} -} - -// QueryDirectRenderingCapableReply represents the data returned from a QueryDirectRenderingCapable request. -type QueryDirectRenderingCapableReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - IsCapable bool + cookie := c.NewCookie(false, false) + c.NewRequest(closeConnectionRequest(c, Screen), cookie) + return CloseConnectionCookie{cookie} } -// Reply blocks and returns the reply data for a QueryDirectRenderingCapable request. -func (cook QueryDirectRenderingCapableCookie) Reply() (*QueryDirectRenderingCapableReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil +// CloseConnectionChecked sends a checked request. +// If an error occurs, it can be retrieved using CloseConnectionCookie.Check() +func CloseConnectionChecked(c *xgb.Conn, Screen uint32) CloseConnectionCookie { + if _, ok := c.Extensions["XFREE86-DRI"]; !ok { + panic("Cannot issue request 'CloseConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } - return queryDirectRenderingCapableReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(closeConnectionRequest(c, Screen), cookie) + return CloseConnectionCookie{cookie} } -// queryDirectRenderingCapableReply reads a byte slice into a QueryDirectRenderingCapableReply value. -func queryDirectRenderingCapableReply(buf []byte) *QueryDirectRenderingCapableReply { - v := new(QueryDirectRenderingCapableReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 - - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 - - if buf[b] == 1 { - v.IsCapable = true - } else { - v.IsCapable = false - } - b += 1 - - return v +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook CloseConnectionCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for QueryDirectRenderingCapable -// queryDirectRenderingCapableRequest writes a QueryDirectRenderingCapable request to a byte slice. -func queryDirectRenderingCapableRequest(c *xgb.Conn, Screen uint32) []byte { +// Write request to wire for CloseConnection +// closeConnectionRequest writes a CloseConnection request to a byte slice. +func closeConnectionRequest(c *xgb.Conn, Screen uint32) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -305,7 +266,7 @@ func queryDirectRenderingCapableRequest(c *xgb.Conn, Screen uint32) []byte { buf[b] = c.Extensions["XFREE86-DRI"] b += 1 - buf[b] = 1 // request opcode + buf[b] = 3 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -317,47 +278,43 @@ func queryDirectRenderingCapableRequest(c *xgb.Conn, Screen uint32) []byte { return buf } -// OpenConnectionCookie is a cookie used only for OpenConnection requests. -type OpenConnectionCookie struct { +// CreateContextCookie is a cookie used only for CreateContext requests. +type CreateContextCookie struct { *xgb.Cookie } -// OpenConnection sends a checked request. -// If an error occurs, it will be returned with the reply by calling OpenConnectionCookie.Reply() -func OpenConnection(c *xgb.Conn, Screen uint32) OpenConnectionCookie { +// CreateContext sends a checked request. +// If an error occurs, it will be returned with the reply by calling CreateContextCookie.Reply() +func CreateContext(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) CreateContextCookie { if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'OpenConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateContext' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(openConnectionRequest(c, Screen), cookie) - return OpenConnectionCookie{cookie} + c.NewRequest(createContextRequest(c, Screen, Visual, Context), cookie) + return CreateContextCookie{cookie} } -// OpenConnectionUnchecked sends an unchecked request. +// CreateContextUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func OpenConnectionUnchecked(c *xgb.Conn, Screen uint32) OpenConnectionCookie { +func CreateContextUnchecked(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) CreateContextCookie { if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'OpenConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateContext' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(openConnectionRequest(c, Screen), cookie) - return OpenConnectionCookie{cookie} + c.NewRequest(createContextRequest(c, Screen, Visual, Context), cookie) + return CreateContextCookie{cookie} } -// OpenConnectionReply represents the data returned from a OpenConnection request. -type OpenConnectionReply struct { +// CreateContextReply represents the data returned from a CreateContext request. +type CreateContextReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - SareaHandleLow uint32 - SareaHandleHigh uint32 - BusIdLen uint32 - // padding: 12 bytes - BusId string // size: xgb.Pad((int(BusIdLen) * 1)) + HwContext uint32 } -// Reply blocks and returns the reply data for a OpenConnection request. -func (cook OpenConnectionCookie) Reply() (*OpenConnectionReply, error) { +// Reply blocks and returns the reply data for a CreateContext request. +func (cook CreateContextCookie) Reply() (*CreateContextReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -365,12 +322,12 @@ func (cook OpenConnectionCookie) Reply() (*OpenConnectionReply, error) { if buf == nil { return nil, nil } - return openConnectionReply(buf), nil + return createContextReply(buf), nil } -// openConnectionReply reads a byte slice into a OpenConnectionReply value. -func openConnectionReply(buf []byte) *OpenConnectionReply { - v := new(OpenConnectionReply) +// createContextReply reads a byte slice into a CreateContextReply value. +func createContextReply(buf []byte) *CreateContextReply { + v := new(CreateContextReply) b := 1 // skip reply determinant b += 1 // padding @@ -381,38 +338,23 @@ func openConnectionReply(buf []byte) *OpenConnectionReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.SareaHandleLow = xgb.Get32(buf[b:]) - b += 4 - - v.SareaHandleHigh = xgb.Get32(buf[b:]) + v.HwContext = xgb.Get32(buf[b:]) b += 4 - v.BusIdLen = xgb.Get32(buf[b:]) - b += 4 - - b += 12 // padding - - { - byteString := make([]byte, v.BusIdLen) - copy(byteString[:v.BusIdLen], buf[b:]) - v.BusId = string(byteString) - b += xgb.Pad(int(v.BusIdLen)) - } - return v } -// Write request to wire for OpenConnection -// openConnectionRequest writes a OpenConnection request to a byte slice. -func openConnectionRequest(c *xgb.Conn, Screen uint32) []byte { - size := 8 +// Write request to wire for CreateContext +// createContextRequest writes a CreateContext request to a byte slice. +func createContextRequest(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) []byte { + size := 16 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFREE86-DRI"] b += 1 - buf[b] = 2 // request opcode + buf[b] = 5 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -421,106 +363,52 @@ func openConnectionRequest(c *xgb.Conn, Screen uint32) []byte { xgb.Put32(buf[b:], Screen) b += 4 - return buf -} - -// CloseConnectionCookie is a cookie used only for CloseConnection requests. -type CloseConnectionCookie struct { - *xgb.Cookie -} - -// CloseConnection sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CloseConnection(c *xgb.Conn, Screen uint32) CloseConnectionCookie { - if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'CloseConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(closeConnectionRequest(c, Screen), cookie) - return CloseConnectionCookie{cookie} -} - -// CloseConnectionChecked sends a checked request. -// If an error occurs, it can be retrieved using CloseConnectionCookie.Check() -func CloseConnectionChecked(c *xgb.Conn, Screen uint32) CloseConnectionCookie { - if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'CloseConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(closeConnectionRequest(c, Screen), cookie) - return CloseConnectionCookie{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 CloseConnectionCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for CloseConnection -// closeConnectionRequest writes a CloseConnection request to a byte slice. -func closeConnectionRequest(c *xgb.Conn, Screen uint32) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XFREE86-DRI"] - b += 1 - - buf[b] = 3 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 + xgb.Put32(buf[b:], Visual) + b += 4 - xgb.Put32(buf[b:], Screen) + xgb.Put32(buf[b:], Context) b += 4 return buf } -// GetClientDriverNameCookie is a cookie used only for GetClientDriverName requests. -type GetClientDriverNameCookie struct { +// CreateDrawableCookie is a cookie used only for CreateDrawable requests. +type CreateDrawableCookie struct { *xgb.Cookie } -// GetClientDriverName sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetClientDriverNameCookie.Reply() -func GetClientDriverName(c *xgb.Conn, Screen uint32) GetClientDriverNameCookie { +// CreateDrawable sends a checked request. +// If an error occurs, it will be returned with the reply by calling CreateDrawableCookie.Reply() +func CreateDrawable(c *xgb.Conn, Screen uint32, Drawable uint32) CreateDrawableCookie { if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'GetClientDriverName' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getClientDriverNameRequest(c, Screen), cookie) - return GetClientDriverNameCookie{cookie} + c.NewRequest(createDrawableRequest(c, Screen, Drawable), cookie) + return CreateDrawableCookie{cookie} } -// GetClientDriverNameUnchecked sends an unchecked request. +// CreateDrawableUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetClientDriverNameUnchecked(c *xgb.Conn, Screen uint32) GetClientDriverNameCookie { +func CreateDrawableUnchecked(c *xgb.Conn, Screen uint32, Drawable uint32) CreateDrawableCookie { if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'GetClientDriverName' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + panic("Cannot issue request 'CreateDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getClientDriverNameRequest(c, Screen), cookie) - return GetClientDriverNameCookie{cookie} + c.NewRequest(createDrawableRequest(c, Screen, Drawable), cookie) + return CreateDrawableCookie{cookie} } -// GetClientDriverNameReply represents the data returned from a GetClientDriverName request. -type GetClientDriverNameReply struct { +// CreateDrawableReply represents the data returned from a CreateDrawable request. +type CreateDrawableReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - ClientDriverMajorVersion uint32 - ClientDriverMinorVersion uint32 - ClientDriverPatchVersion uint32 - ClientDriverNameLen uint32 - // padding: 8 bytes - ClientDriverName string // size: xgb.Pad((int(ClientDriverNameLen) * 1)) + HwDrawableHandle uint32 } -// Reply blocks and returns the reply data for a GetClientDriverName request. -func (cook GetClientDriverNameCookie) Reply() (*GetClientDriverNameReply, error) { +// Reply blocks and returns the reply data for a CreateDrawable request. +func (cook CreateDrawableCookie) Reply() (*CreateDrawableReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -528,12 +416,12 @@ func (cook GetClientDriverNameCookie) Reply() (*GetClientDriverNameReply, error) if buf == nil { return nil, nil } - return getClientDriverNameReply(buf), nil + return createDrawableReply(buf), nil } -// getClientDriverNameReply reads a byte slice into a GetClientDriverNameReply value. -func getClientDriverNameReply(buf []byte) *GetClientDriverNameReply { - v := new(GetClientDriverNameReply) +// createDrawableReply reads a byte slice into a CreateDrawableReply value. +func createDrawableReply(buf []byte) *CreateDrawableReply { + v := new(CreateDrawableReply) b := 1 // skip reply determinant b += 1 // padding @@ -544,41 +432,23 @@ func getClientDriverNameReply(buf []byte) *GetClientDriverNameReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.ClientDriverMajorVersion = xgb.Get32(buf[b:]) - b += 4 - - v.ClientDriverMinorVersion = xgb.Get32(buf[b:]) - b += 4 - - v.ClientDriverPatchVersion = xgb.Get32(buf[b:]) - b += 4 - - v.ClientDriverNameLen = xgb.Get32(buf[b:]) + v.HwDrawableHandle = xgb.Get32(buf[b:]) b += 4 - b += 8 // padding - - { - byteString := make([]byte, v.ClientDriverNameLen) - copy(byteString[:v.ClientDriverNameLen], buf[b:]) - v.ClientDriverName = string(byteString) - b += xgb.Pad(int(v.ClientDriverNameLen)) - } - return v } -// Write request to wire for GetClientDriverName -// getClientDriverNameRequest writes a GetClientDriverName request to a byte slice. -func getClientDriverNameRequest(c *xgb.Conn, Screen uint32) []byte { - size := 8 +// Write request to wire for CreateDrawable +// createDrawableRequest writes a CreateDrawable request to a byte slice. +func createDrawableRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFREE86-DRI"] b += 1 - buf[b] = 4 // request opcode + buf[b] = 7 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -587,86 +457,56 @@ func getClientDriverNameRequest(c *xgb.Conn, Screen uint32) []byte { xgb.Put32(buf[b:], Screen) b += 4 + xgb.Put32(buf[b:], Drawable) + b += 4 + return buf } -// CreateContextCookie is a cookie used only for CreateContext requests. -type CreateContextCookie struct { +// DestroyContextCookie is a cookie used only for DestroyContext requests. +type DestroyContextCookie struct { *xgb.Cookie } -// CreateContext sends a checked request. -// If an error occurs, it will be returned with the reply by calling CreateContextCookie.Reply() -func CreateContext(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) CreateContextCookie { - if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'CreateContext' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(createContextRequest(c, Screen, Visual, Context), cookie) - return CreateContextCookie{cookie} -} - -// CreateContextUnchecked sends an unchecked request. +// DestroyContext sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateContextUnchecked(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) CreateContextCookie { +func DestroyContext(c *xgb.Conn, Screen uint32, Context uint32) DestroyContextCookie { if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'CreateContext' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + panic("Cannot issue request 'DestroyContext' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(createContextRequest(c, Screen, Visual, Context), cookie) - return CreateContextCookie{cookie} -} - -// CreateContextReply represents the data returned from a CreateContext request. -type CreateContextReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - HwContext uint32 + cookie := c.NewCookie(false, false) + c.NewRequest(destroyContextRequest(c, Screen, Context), cookie) + return DestroyContextCookie{cookie} } -// Reply blocks and returns the reply data for a CreateContext request. -func (cook CreateContextCookie) Reply() (*CreateContextReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil +// DestroyContextChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroyContextCookie.Check() +func DestroyContextChecked(c *xgb.Conn, Screen uint32, Context uint32) DestroyContextCookie { + if _, ok := c.Extensions["XFREE86-DRI"]; !ok { + panic("Cannot issue request 'DestroyContext' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } - return createContextReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(destroyContextRequest(c, Screen, Context), cookie) + return DestroyContextCookie{cookie} } -// createContextReply reads a byte slice into a CreateContextReply value. -func createContextReply(buf []byte) *CreateContextReply { - v := new(CreateContextReply) - 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.HwContext = xgb.Get32(buf[b:]) - b += 4 - - return v +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook DestroyContextCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for CreateContext -// createContextRequest writes a CreateContext request to a byte slice. -func createContextRequest(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) []byte { - size := 16 +// Write request to wire for DestroyContext +// destroyContextRequest writes a DestroyContext request to a byte slice. +func destroyContextRequest(c *xgb.Conn, Screen uint32, Context uint32) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFREE86-DRI"] b += 1 - buf[b] = 5 // request opcode + buf[b] = 6 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -675,51 +515,48 @@ func createContextRequest(c *xgb.Conn, Screen uint32, Visual uint32, Context uin xgb.Put32(buf[b:], Screen) b += 4 - xgb.Put32(buf[b:], Visual) - b += 4 - xgb.Put32(buf[b:], Context) b += 4 return buf } -// DestroyContextCookie is a cookie used only for DestroyContext requests. -type DestroyContextCookie struct { +// DestroyDrawableCookie is a cookie used only for DestroyDrawable requests. +type DestroyDrawableCookie struct { *xgb.Cookie } -// DestroyContext sends an unchecked request. +// DestroyDrawable sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func DestroyContext(c *xgb.Conn, Screen uint32, Context uint32) DestroyContextCookie { +func DestroyDrawable(c *xgb.Conn, Screen uint32, Drawable uint32) DestroyDrawableCookie { if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'DestroyContext' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + panic("Cannot issue request 'DestroyDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(destroyContextRequest(c, Screen, Context), cookie) - return DestroyContextCookie{cookie} + c.NewRequest(destroyDrawableRequest(c, Screen, Drawable), cookie) + return DestroyDrawableCookie{cookie} } -// DestroyContextChecked sends a checked request. -// If an error occurs, it can be retrieved using DestroyContextCookie.Check() -func DestroyContextChecked(c *xgb.Conn, Screen uint32, Context uint32) DestroyContextCookie { +// DestroyDrawableChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroyDrawableCookie.Check() +func DestroyDrawableChecked(c *xgb.Conn, Screen uint32, Drawable uint32) DestroyDrawableCookie { if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'DestroyContext' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + panic("Cannot issue request 'DestroyDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(destroyContextRequest(c, Screen, Context), cookie) - return DestroyContextCookie{cookie} + c.NewRequest(destroyDrawableRequest(c, Screen, Drawable), cookie) + return DestroyDrawableCookie{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 DestroyContextCookie) Check() error { +func (cook DestroyDrawableCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for DestroyContext -// destroyContextRequest writes a DestroyContext request to a byte slice. -func destroyContextRequest(c *xgb.Conn, Screen uint32, Context uint32) []byte { +// Write request to wire for DestroyDrawable +// destroyDrawableRequest writes a DestroyDrawable request to a byte slice. +func destroyDrawableRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte { size := 12 b := 0 buf := make([]byte, size) @@ -727,7 +564,7 @@ func destroyContextRequest(c *xgb.Conn, Screen uint32, Context uint32) []byte { buf[b] = c.Extensions["XFREE86-DRI"] b += 1 - buf[b] = 6 // request opcode + buf[b] = 8 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -736,49 +573,54 @@ func destroyContextRequest(c *xgb.Conn, Screen uint32, Context uint32) []byte { xgb.Put32(buf[b:], Screen) b += 4 - xgb.Put32(buf[b:], Context) + xgb.Put32(buf[b:], Drawable) b += 4 return buf } -// CreateDrawableCookie is a cookie used only for CreateDrawable requests. -type CreateDrawableCookie struct { +// GetClientDriverNameCookie is a cookie used only for GetClientDriverName requests. +type GetClientDriverNameCookie struct { *xgb.Cookie } -// CreateDrawable sends a checked request. -// If an error occurs, it will be returned with the reply by calling CreateDrawableCookie.Reply() -func CreateDrawable(c *xgb.Conn, Screen uint32, Drawable uint32) CreateDrawableCookie { +// GetClientDriverName sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetClientDriverNameCookie.Reply() +func GetClientDriverName(c *xgb.Conn, Screen uint32) GetClientDriverNameCookie { if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'CreateDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + panic("Cannot issue request 'GetClientDriverName' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(createDrawableRequest(c, Screen, Drawable), cookie) - return CreateDrawableCookie{cookie} + c.NewRequest(getClientDriverNameRequest(c, Screen), cookie) + return GetClientDriverNameCookie{cookie} } -// CreateDrawableUnchecked sends an unchecked request. +// GetClientDriverNameUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CreateDrawableUnchecked(c *xgb.Conn, Screen uint32, Drawable uint32) CreateDrawableCookie { +func GetClientDriverNameUnchecked(c *xgb.Conn, Screen uint32) GetClientDriverNameCookie { if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'CreateDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + panic("Cannot issue request 'GetClientDriverName' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(createDrawableRequest(c, Screen, Drawable), cookie) - return CreateDrawableCookie{cookie} + c.NewRequest(getClientDriverNameRequest(c, Screen), cookie) + return GetClientDriverNameCookie{cookie} } -// CreateDrawableReply represents the data returned from a CreateDrawable request. -type CreateDrawableReply struct { +// GetClientDriverNameReply represents the data returned from a GetClientDriverName request. +type GetClientDriverNameReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - HwDrawableHandle uint32 + ClientDriverMajorVersion uint32 + ClientDriverMinorVersion uint32 + ClientDriverPatchVersion uint32 + ClientDriverNameLen uint32 + // padding: 8 bytes + ClientDriverName string // size: xgb.Pad((int(ClientDriverNameLen) * 1)) } -// Reply blocks and returns the reply data for a CreateDrawable request. -func (cook CreateDrawableCookie) Reply() (*CreateDrawableReply, error) { +// Reply blocks and returns the reply data for a GetClientDriverName request. +func (cook GetClientDriverNameCookie) Reply() (*GetClientDriverNameReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -786,12 +628,12 @@ func (cook CreateDrawableCookie) Reply() (*CreateDrawableReply, error) { if buf == nil { return nil, nil } - return createDrawableReply(buf), nil + return getClientDriverNameReply(buf), nil } -// createDrawableReply reads a byte slice into a CreateDrawableReply value. -func createDrawableReply(buf []byte) *CreateDrawableReply { - v := new(CreateDrawableReply) +// getClientDriverNameReply reads a byte slice into a GetClientDriverNameReply value. +func getClientDriverNameReply(buf []byte) *GetClientDriverNameReply { + v := new(GetClientDriverNameReply) b := 1 // skip reply determinant b += 1 // padding @@ -802,23 +644,41 @@ func createDrawableReply(buf []byte) *CreateDrawableReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.HwDrawableHandle = xgb.Get32(buf[b:]) + v.ClientDriverMajorVersion = xgb.Get32(buf[b:]) b += 4 + v.ClientDriverMinorVersion = xgb.Get32(buf[b:]) + b += 4 + + v.ClientDriverPatchVersion = xgb.Get32(buf[b:]) + b += 4 + + v.ClientDriverNameLen = xgb.Get32(buf[b:]) + b += 4 + + b += 8 // padding + + { + byteString := make([]byte, v.ClientDriverNameLen) + copy(byteString[:v.ClientDriverNameLen], buf[b:]) + v.ClientDriverName = string(byteString) + b += xgb.Pad(int(v.ClientDriverNameLen)) + } + return v } -// Write request to wire for CreateDrawable -// createDrawableRequest writes a CreateDrawable request to a byte slice. -func createDrawableRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte { - size := 12 +// Write request to wire for GetClientDriverName +// getClientDriverNameRequest writes a GetClientDriverName request to a byte slice. +func getClientDriverNameRequest(c *xgb.Conn, Screen uint32) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFREE86-DRI"] b += 1 - buf[b] = 7 // request opcode + buf[b] = 4 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -827,56 +687,114 @@ func createDrawableRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte { xgb.Put32(buf[b:], Screen) b += 4 - xgb.Put32(buf[b:], Drawable) - b += 4 - return buf } -// DestroyDrawableCookie is a cookie used only for DestroyDrawable requests. -type DestroyDrawableCookie struct { +// GetDeviceInfoCookie is a cookie used only for GetDeviceInfo requests. +type GetDeviceInfoCookie struct { *xgb.Cookie } -// DestroyDrawable sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func DestroyDrawable(c *xgb.Conn, Screen uint32, Drawable uint32) DestroyDrawableCookie { +// GetDeviceInfo sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetDeviceInfoCookie.Reply() +func GetDeviceInfo(c *xgb.Conn, Screen uint32) GetDeviceInfoCookie { if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'DestroyDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + panic("Cannot issue request 'GetDeviceInfo' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(destroyDrawableRequest(c, Screen, Drawable), cookie) - return DestroyDrawableCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getDeviceInfoRequest(c, Screen), cookie) + return GetDeviceInfoCookie{cookie} } -// DestroyDrawableChecked sends a checked request. -// If an error occurs, it can be retrieved using DestroyDrawableCookie.Check() -func DestroyDrawableChecked(c *xgb.Conn, Screen uint32, Drawable uint32) DestroyDrawableCookie { +// GetDeviceInfoUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetDeviceInfoUnchecked(c *xgb.Conn, Screen uint32) GetDeviceInfoCookie { if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'DestroyDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + panic("Cannot issue request 'GetDeviceInfo' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(destroyDrawableRequest(c, Screen, Drawable), cookie) - return DestroyDrawableCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getDeviceInfoRequest(c, Screen), cookie) + return GetDeviceInfoCookie{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 DestroyDrawableCookie) Check() error { - return cook.Cookie.Check() +// GetDeviceInfoReply represents the data returned from a GetDeviceInfo request. +type GetDeviceInfoReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + FramebufferHandleLow uint32 + FramebufferHandleHigh uint32 + FramebufferOriginOffset uint32 + FramebufferSize uint32 + FramebufferStride uint32 + DevicePrivateSize uint32 + DevicePrivate []uint32 // size: xgb.Pad((int(DevicePrivateSize) * 4)) +} + +// Reply blocks and returns the reply data for a GetDeviceInfo request. +func (cook GetDeviceInfoCookie) Reply() (*GetDeviceInfoReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDeviceInfoReply(buf), nil +} + +// getDeviceInfoReply reads a byte slice into a GetDeviceInfoReply value. +func getDeviceInfoReply(buf []byte) *GetDeviceInfoReply { + v := new(GetDeviceInfoReply) + 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.FramebufferHandleLow = xgb.Get32(buf[b:]) + b += 4 + + v.FramebufferHandleHigh = xgb.Get32(buf[b:]) + b += 4 + + v.FramebufferOriginOffset = xgb.Get32(buf[b:]) + b += 4 + + v.FramebufferSize = xgb.Get32(buf[b:]) + b += 4 + + v.FramebufferStride = xgb.Get32(buf[b:]) + b += 4 + + v.DevicePrivateSize = xgb.Get32(buf[b:]) + b += 4 + + v.DevicePrivate = make([]uint32, v.DevicePrivateSize) + for i := 0; i < int(v.DevicePrivateSize); i++ { + v.DevicePrivate[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v } -// Write request to wire for DestroyDrawable -// destroyDrawableRequest writes a DestroyDrawable request to a byte slice. -func destroyDrawableRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte { - size := 12 +// Write request to wire for GetDeviceInfo +// getDeviceInfoRequest writes a GetDeviceInfo request to a byte slice. +func getDeviceInfoRequest(c *xgb.Conn, Screen uint32) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFREE86-DRI"] b += 1 - buf[b] = 8 // request opcode + buf[b] = 10 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -885,9 +803,6 @@ func destroyDrawableRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte xgb.Put32(buf[b:], Screen) b += 4 - xgb.Put32(buf[b:], Drawable) - b += 4 - return buf } @@ -1026,49 +941,47 @@ func getDrawableInfoRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte return buf } -// GetDeviceInfoCookie is a cookie used only for GetDeviceInfo requests. -type GetDeviceInfoCookie struct { +// OpenConnectionCookie is a cookie used only for OpenConnection requests. +type OpenConnectionCookie struct { *xgb.Cookie } -// GetDeviceInfo sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetDeviceInfoCookie.Reply() -func GetDeviceInfo(c *xgb.Conn, Screen uint32) GetDeviceInfoCookie { +// OpenConnection sends a checked request. +// If an error occurs, it will be returned with the reply by calling OpenConnectionCookie.Reply() +func OpenConnection(c *xgb.Conn, Screen uint32) OpenConnectionCookie { if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'GetDeviceInfo' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + panic("Cannot issue request 'OpenConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getDeviceInfoRequest(c, Screen), cookie) - return GetDeviceInfoCookie{cookie} + c.NewRequest(openConnectionRequest(c, Screen), cookie) + return OpenConnectionCookie{cookie} } -// GetDeviceInfoUnchecked sends an unchecked request. +// OpenConnectionUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetDeviceInfoUnchecked(c *xgb.Conn, Screen uint32) GetDeviceInfoCookie { +func OpenConnectionUnchecked(c *xgb.Conn, Screen uint32) OpenConnectionCookie { if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'GetDeviceInfo' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + panic("Cannot issue request 'OpenConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getDeviceInfoRequest(c, Screen), cookie) - return GetDeviceInfoCookie{cookie} + c.NewRequest(openConnectionRequest(c, Screen), cookie) + return OpenConnectionCookie{cookie} } -// GetDeviceInfoReply represents the data returned from a GetDeviceInfo request. -type GetDeviceInfoReply struct { +// OpenConnectionReply represents the data returned from a OpenConnection request. +type OpenConnectionReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - FramebufferHandleLow uint32 - FramebufferHandleHigh uint32 - FramebufferOriginOffset uint32 - FramebufferSize uint32 - FramebufferStride uint32 - DevicePrivateSize uint32 - DevicePrivate []uint32 // size: xgb.Pad((int(DevicePrivateSize) * 4)) + SareaHandleLow uint32 + SareaHandleHigh uint32 + BusIdLen uint32 + // padding: 12 bytes + BusId string // size: xgb.Pad((int(BusIdLen) * 1)) } -// Reply blocks and returns the reply data for a GetDeviceInfo request. -func (cook GetDeviceInfoCookie) Reply() (*GetDeviceInfoReply, error) { +// Reply blocks and returns the reply data for a OpenConnection request. +func (cook OpenConnectionCookie) Reply() (*OpenConnectionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1076,12 +989,12 @@ func (cook GetDeviceInfoCookie) Reply() (*GetDeviceInfoReply, error) { if buf == nil { return nil, nil } - return getDeviceInfoReply(buf), nil + return openConnectionReply(buf), nil } -// getDeviceInfoReply reads a byte slice into a GetDeviceInfoReply value. -func getDeviceInfoReply(buf []byte) *GetDeviceInfoReply { - v := new(GetDeviceInfoReply) +// openConnectionReply reads a byte slice into a OpenConnectionReply value. +func openConnectionReply(buf []byte) *OpenConnectionReply { + v := new(OpenConnectionReply) b := 1 // skip reply determinant b += 1 // padding @@ -1092,37 +1005,30 @@ func getDeviceInfoReply(buf []byte) *GetDeviceInfoReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.FramebufferHandleLow = xgb.Get32(buf[b:]) - b += 4 - - v.FramebufferHandleHigh = xgb.Get32(buf[b:]) - b += 4 - - v.FramebufferOriginOffset = xgb.Get32(buf[b:]) + v.SareaHandleLow = xgb.Get32(buf[b:]) b += 4 - v.FramebufferSize = xgb.Get32(buf[b:]) + v.SareaHandleHigh = xgb.Get32(buf[b:]) b += 4 - v.FramebufferStride = xgb.Get32(buf[b:]) + v.BusIdLen = xgb.Get32(buf[b:]) b += 4 - v.DevicePrivateSize = xgb.Get32(buf[b:]) - b += 4 + b += 12 // padding - v.DevicePrivate = make([]uint32, v.DevicePrivateSize) - for i := 0; i < int(v.DevicePrivateSize); i++ { - v.DevicePrivate[i] = xgb.Get32(buf[b:]) - b += 4 + { + byteString := make([]byte, v.BusIdLen) + copy(byteString[:v.BusIdLen], buf[b:]) + v.BusId = string(byteString) + b += xgb.Pad(int(v.BusIdLen)) } - b = xgb.Pad(b) return v } -// Write request to wire for GetDeviceInfo -// getDeviceInfoRequest writes a GetDeviceInfo request to a byte slice. -func getDeviceInfoRequest(c *xgb.Conn, Screen uint32) []byte { +// Write request to wire for OpenConnection +// openConnectionRequest writes a OpenConnection request to a byte slice. +func openConnectionRequest(c *xgb.Conn, Screen uint32) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -1130,7 +1036,7 @@ func getDeviceInfoRequest(c *xgb.Conn, Screen uint32) []byte { buf[b] = c.Extensions["XFREE86-DRI"] b += 1 - buf[b] = 10 // request opcode + buf[b] = 2 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1142,43 +1048,43 @@ func getDeviceInfoRequest(c *xgb.Conn, Screen uint32) []byte { return buf } -// AuthConnectionCookie is a cookie used only for AuthConnection requests. -type AuthConnectionCookie struct { +// QueryDirectRenderingCapableCookie is a cookie used only for QueryDirectRenderingCapable requests. +type QueryDirectRenderingCapableCookie struct { *xgb.Cookie } -// AuthConnection sends a checked request. -// If an error occurs, it will be returned with the reply by calling AuthConnectionCookie.Reply() -func AuthConnection(c *xgb.Conn, Screen uint32, Magic uint32) AuthConnectionCookie { +// QueryDirectRenderingCapable sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryDirectRenderingCapableCookie.Reply() +func QueryDirectRenderingCapable(c *xgb.Conn, Screen uint32) QueryDirectRenderingCapableCookie { if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'AuthConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryDirectRenderingCapable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(authConnectionRequest(c, Screen, Magic), cookie) - return AuthConnectionCookie{cookie} + c.NewRequest(queryDirectRenderingCapableRequest(c, Screen), cookie) + return QueryDirectRenderingCapableCookie{cookie} } -// AuthConnectionUnchecked sends an unchecked request. +// QueryDirectRenderingCapableUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func AuthConnectionUnchecked(c *xgb.Conn, Screen uint32, Magic uint32) AuthConnectionCookie { +func QueryDirectRenderingCapableUnchecked(c *xgb.Conn, Screen uint32) QueryDirectRenderingCapableCookie { if _, ok := c.Extensions["XFREE86-DRI"]; !ok { - panic("Cannot issue request 'AuthConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryDirectRenderingCapable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(authConnectionRequest(c, Screen, Magic), cookie) - return AuthConnectionCookie{cookie} + c.NewRequest(queryDirectRenderingCapableRequest(c, Screen), cookie) + return QueryDirectRenderingCapableCookie{cookie} } -// AuthConnectionReply represents the data returned from a AuthConnection request. -type AuthConnectionReply struct { +// QueryDirectRenderingCapableReply represents the data returned from a QueryDirectRenderingCapable request. +type QueryDirectRenderingCapableReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - Authenticated uint32 + IsCapable bool } -// Reply blocks and returns the reply data for a AuthConnection request. -func (cook AuthConnectionCookie) Reply() (*AuthConnectionReply, error) { +// Reply blocks and returns the reply data for a QueryDirectRenderingCapable request. +func (cook QueryDirectRenderingCapableCookie) Reply() (*QueryDirectRenderingCapableReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -1186,12 +1092,12 @@ func (cook AuthConnectionCookie) Reply() (*AuthConnectionReply, error) { if buf == nil { return nil, nil } - return authConnectionReply(buf), nil + return queryDirectRenderingCapableReply(buf), nil } -// authConnectionReply reads a byte slice into a AuthConnectionReply value. -func authConnectionReply(buf []byte) *AuthConnectionReply { - v := new(AuthConnectionReply) +// queryDirectRenderingCapableReply reads a byte slice into a QueryDirectRenderingCapableReply value. +func queryDirectRenderingCapableReply(buf []byte) *QueryDirectRenderingCapableReply { + v := new(QueryDirectRenderingCapableReply) b := 1 // skip reply determinant b += 1 // padding @@ -1202,23 +1108,27 @@ func authConnectionReply(buf []byte) *AuthConnectionReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Authenticated = xgb.Get32(buf[b:]) - b += 4 + if buf[b] == 1 { + v.IsCapable = true + } else { + v.IsCapable = false + } + b += 1 return v } -// Write request to wire for AuthConnection -// authConnectionRequest writes a AuthConnection request to a byte slice. -func authConnectionRequest(c *xgb.Conn, Screen uint32, Magic uint32) []byte { - size := 12 +// Write request to wire for QueryDirectRenderingCapable +// queryDirectRenderingCapableRequest writes a QueryDirectRenderingCapable request to a byte slice. +func queryDirectRenderingCapableRequest(c *xgb.Conn, Screen uint32) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XFREE86-DRI"] b += 1 - buf[b] = 11 // request opcode + buf[b] = 1 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1227,8 +1137,98 @@ func authConnectionRequest(c *xgb.Conn, Screen uint32, Magic uint32) []byte { xgb.Put32(buf[b:], Screen) b += 4 - xgb.Put32(buf[b:], Magic) + return buf +} + +// QueryVersionCookie is a cookie used only for QueryVersion requests. +type QueryVersionCookie struct { + *xgb.Cookie +} + +// QueryVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() +func QueryVersion(c *xgb.Conn) QueryVersionCookie { + if _, ok := c.Extensions["XFREE86-DRI"]; !ok { + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c), cookie) + return QueryVersionCookie{cookie} +} + +// QueryVersionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func QueryVersionUnchecked(c *xgb.Conn) QueryVersionCookie { + if _, ok := c.Extensions["XFREE86-DRI"]; !ok { + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c), cookie) + return QueryVersionCookie{cookie} +} + +// QueryVersionReply represents the data returned from a QueryVersion request. +type QueryVersionReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + DriMajorVersion uint16 + DriMinorVersion uint16 + DriMinorPatch uint32 +} + +// Reply blocks and returns the reply data for a QueryVersion request. +func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryVersionReply(buf), nil +} + +// queryVersionReply reads a byte slice into a QueryVersionReply value. +func queryVersionReply(buf []byte) *QueryVersionReply { + v := new(QueryVersionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.DriMajorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.DriMinorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.DriMinorPatch = xgb.Get32(buf[b:]) b += 4 + return v +} + +// Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. +func queryVersionRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-DRI"] + b += 1 + + buf[b] = 0 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + return buf } -- cgit v1.2.3