From 0c50dc6241fa21712e041cfa2bfb9db4ccaef10a Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Thu, 10 May 2012 17:01:42 -0400 Subject: a huge commit. splitting extensions into their own sub-packages. --- nexgb/xf86dri/xf86dri.go | 1121 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1121 insertions(+) create mode 100644 nexgb/xf86dri/xf86dri.go (limited to 'nexgb/xf86dri') diff --git a/nexgb/xf86dri/xf86dri.go b/nexgb/xf86dri/xf86dri.go new file mode 100644 index 0000000..0259729 --- /dev/null +++ b/nexgb/xf86dri/xf86dri.go @@ -0,0 +1,1121 @@ +package xf86dri + +/* + This file was generated by xf86dri.xml on May 10 2012 4:20:28pm EDT. + This file is automatically generated. Edit at your peril! +*/ + +import ( + "github.com/BurntSushi/xgb" + + "github.com/BurntSushi/xgb/xproto" +) + +// Init must be called before using the XFree86-DRI extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 11, "XFree86-DRI").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named XFree86-DRI could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["XFree86-DRI"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["XFree86-DRI"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["XFree86-DRI"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["XFree86-DRI"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["XFree86-DRI"] = make(map[int]xgb.NewErrorFun) +} + +// 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' + +// 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' + +// 'DrmClipRect' struct definition +// Size: 8 +type DrmClipRect struct { + X1 int16 + Y1 int16 + X2 int16 + X3 int16 +} + +// Struct read DrmClipRect +func DrmClipRectRead(buf []byte, v *DrmClipRect) int { + b := 0 + + v.X1 = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Y1 = int16(xgb.Get16(buf[b:])) + b += 2 + + v.X2 = int16(xgb.Get16(buf[b:])) + b += 2 + + v.X3 = int16(xgb.Get16(buf[b:])) + b += 2 + + return b +} + +// Struct list read DrmClipRect +func DrmClipRectReadList(buf []byte, dest []DrmClipRect) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DrmClipRect{} + b += DrmClipRectRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write DrmClipRect +func (v DrmClipRect) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put16(buf[b:], uint16(v.X1)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.Y1)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.X2)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.X3)) + b += 2 + + return buf +} + +// Write struct list DrmClipRect +func DrmClipRectListBytes(buf []byte, list []DrmClipRect) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +// Request QueryVersion +// size: 4 +type QueryVersionCookie struct { + *xgb.Cookie +} + +func QueryVersion(c *xgb.Conn) QueryVersionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c), cookie) + return QueryVersionCookie{cookie} +} + +func QueryVersionUnchecked(c *xgb.Conn) QueryVersionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c), cookie) + return QueryVersionCookie{cookie} +} + +// Request reply for QueryVersion +// size: 16 +type QueryVersionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + DriMajorVersion uint16 + DriMinorVersion uint16 + DriMinorPatch uint32 +} + +// Waits and reads reply data from request QueryVersion +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 +} + +// Read reply into structure from buffer for QueryVersion +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 +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 +} + +// Request QueryDirectRenderingCapable +// size: 8 +type QueryDirectRenderingCapableCookie struct { + *xgb.Cookie +} + +func QueryDirectRenderingCapable(c *xgb.Conn, Screen uint32) QueryDirectRenderingCapableCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryDirectRenderingCapableRequest(c, Screen), cookie) + return QueryDirectRenderingCapableCookie{cookie} +} + +func QueryDirectRenderingCapableUnchecked(c *xgb.Conn, Screen uint32) QueryDirectRenderingCapableCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryDirectRenderingCapableRequest(c, Screen), cookie) + return QueryDirectRenderingCapableCookie{cookie} +} + +// Request reply for QueryDirectRenderingCapable +// size: 9 +type QueryDirectRenderingCapableReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + IsCapable bool +} + +// Waits and reads reply data from request QueryDirectRenderingCapable +func (cook QueryDirectRenderingCapableCookie) Reply() (*QueryDirectRenderingCapableReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryDirectRenderingCapableReply(buf), nil +} + +// Read reply into structure from buffer for QueryDirectRenderingCapable +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 +} + +// Write request to wire for QueryDirectRenderingCapable +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] = 1 // 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 + + return buf +} + +// Request OpenConnection +// size: 8 +type OpenConnectionCookie struct { + *xgb.Cookie +} + +func OpenConnection(c *xgb.Conn, Screen uint32) OpenConnectionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(openConnectionRequest(c, Screen), cookie) + return OpenConnectionCookie{cookie} +} + +func OpenConnectionUnchecked(c *xgb.Conn, Screen uint32) OpenConnectionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(openConnectionRequest(c, Screen), cookie) + return OpenConnectionCookie{cookie} +} + +// Request reply for OpenConnection +// size: (32 + xgb.Pad((int(BusIdLen) * 1))) +type OpenConnectionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + SareaHandleLow uint32 + SareaHandleHigh uint32 + BusIdLen uint32 + // padding: 12 bytes + BusId string // size: xgb.Pad((int(BusIdLen) * 1)) +} + +// Waits and reads reply data from request OpenConnection +func (cook OpenConnectionCookie) Reply() (*OpenConnectionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return openConnectionReply(buf), nil +} + +// Read reply into structure from buffer for OpenConnection +func openConnectionReply(buf []byte) *OpenConnectionReply { + v := new(OpenConnectionReply) + 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.SareaHandleLow = xgb.Get32(buf[b:]) + b += 4 + + v.SareaHandleHigh = 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 +func openConnectionRequest(c *xgb.Conn, Screen uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XFREE86-DRI"] + b += 1 + + buf[b] = 2 // 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 + + return buf +} + +// Request CloseConnection +// size: 8 +type CloseConnectionCookie struct { + *xgb.Cookie +} + +// Write request to wire for CloseConnection +func CloseConnection(c *xgb.Conn, Screen uint32) CloseConnectionCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(closeConnectionRequest(c, Screen), cookie) + return CloseConnectionCookie{cookie} +} + +func CloseConnectionChecked(c *xgb.Conn, Screen uint32) CloseConnectionCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(closeConnectionRequest(c, Screen), cookie) + return CloseConnectionCookie{cookie} +} + +func (cook CloseConnectionCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for CloseConnection +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:], Screen) + b += 4 + + return buf +} + +// Request GetClientDriverName +// size: 8 +type GetClientDriverNameCookie struct { + *xgb.Cookie +} + +func GetClientDriverName(c *xgb.Conn, Screen uint32) GetClientDriverNameCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getClientDriverNameRequest(c, Screen), cookie) + return GetClientDriverNameCookie{cookie} +} + +func GetClientDriverNameUnchecked(c *xgb.Conn, Screen uint32) GetClientDriverNameCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getClientDriverNameRequest(c, Screen), cookie) + return GetClientDriverNameCookie{cookie} +} + +// Request reply for GetClientDriverName +// size: (32 + xgb.Pad((int(ClientDriverNameLen) * 1))) +type GetClientDriverNameReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ClientDriverMajorVersion uint32 + ClientDriverMinorVersion uint32 + ClientDriverPatchVersion uint32 + ClientDriverNameLen uint32 + // padding: 8 bytes + ClientDriverName string // size: xgb.Pad((int(ClientDriverNameLen) * 1)) +} + +// Waits and reads reply data from request GetClientDriverName +func (cook GetClientDriverNameCookie) Reply() (*GetClientDriverNameReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getClientDriverNameReply(buf), nil +} + +// Read reply into structure from buffer for GetClientDriverName +func getClientDriverNameReply(buf []byte) *GetClientDriverNameReply { + v := new(GetClientDriverNameReply) + 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.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 GetClientDriverName +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] = 4 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + return buf +} + +// Request CreateContext +// size: 16 +type CreateContextCookie struct { + *xgb.Cookie +} + +func CreateContext(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) CreateContextCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(createContextRequest(c, Screen, Visual, Context), cookie) + return CreateContextCookie{cookie} +} + +func CreateContextUnchecked(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) CreateContextCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(createContextRequest(c, Screen, Visual, Context), cookie) + return CreateContextCookie{cookie} +} + +// Request reply for CreateContext +// size: 12 +type CreateContextReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + HwContext uint32 +} + +// Waits and reads reply data from request CreateContext +func (cook CreateContextCookie) Reply() (*CreateContextReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return createContextReply(buf), nil +} + +// Read reply into structure from buffer for CreateContext +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 +} + +// Write request to wire for CreateContext +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] = 5 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], Visual) + b += 4 + + xgb.Put32(buf[b:], Context) + b += 4 + + return buf +} + +// Request DestroyContext +// size: 12 +type DestroyContextCookie struct { + *xgb.Cookie +} + +// Write request to wire for DestroyContext +func DestroyContext(c *xgb.Conn, Screen uint32, Context uint32) DestroyContextCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroyContextRequest(c, Screen, Context), cookie) + return DestroyContextCookie{cookie} +} + +func DestroyContextChecked(c *xgb.Conn, Screen uint32, Context uint32) DestroyContextCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(destroyContextRequest(c, Screen, Context), cookie) + return DestroyContextCookie{cookie} +} + +func (cook DestroyContextCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DestroyContext +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] = 6 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], Context) + b += 4 + + return buf +} + +// Request CreateDrawable +// size: 12 +type CreateDrawableCookie struct { + *xgb.Cookie +} + +func CreateDrawable(c *xgb.Conn, Screen uint32, Drawable uint32) CreateDrawableCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(createDrawableRequest(c, Screen, Drawable), cookie) + return CreateDrawableCookie{cookie} +} + +func CreateDrawableUnchecked(c *xgb.Conn, Screen uint32, Drawable uint32) CreateDrawableCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(createDrawableRequest(c, Screen, Drawable), cookie) + return CreateDrawableCookie{cookie} +} + +// Request reply for CreateDrawable +// size: 12 +type CreateDrawableReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + HwDrawableHandle uint32 +} + +// Waits and reads reply data from request CreateDrawable +func (cook CreateDrawableCookie) Reply() (*CreateDrawableReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return createDrawableReply(buf), nil +} + +// Read reply into structure from buffer for CreateDrawable +func createDrawableReply(buf []byte) *CreateDrawableReply { + v := new(CreateDrawableReply) + 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.HwDrawableHandle = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for CreateDrawable +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] = 7 // 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:], Drawable) + b += 4 + + return buf +} + +// Request DestroyDrawable +// size: 12 +type DestroyDrawableCookie struct { + *xgb.Cookie +} + +// Write request to wire for DestroyDrawable +func DestroyDrawable(c *xgb.Conn, Screen uint32, Drawable uint32) DestroyDrawableCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(destroyDrawableRequest(c, Screen, Drawable), cookie) + return DestroyDrawableCookie{cookie} +} + +func DestroyDrawableChecked(c *xgb.Conn, Screen uint32, Drawable uint32) DestroyDrawableCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(destroyDrawableRequest(c, Screen, Drawable), cookie) + return DestroyDrawableCookie{cookie} +} + +func (cook DestroyDrawableCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for DestroyDrawable +func destroyDrawableRequest(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] = 8 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + xgb.Put32(buf[b:], Drawable) + b += 4 + + return buf +} + +// Request GetDrawableInfo +// size: 12 +type GetDrawableInfoCookie struct { + *xgb.Cookie +} + +func GetDrawableInfo(c *xgb.Conn, Screen uint32, Drawable uint32) GetDrawableInfoCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getDrawableInfoRequest(c, Screen, Drawable), cookie) + return GetDrawableInfoCookie{cookie} +} + +func GetDrawableInfoUnchecked(c *xgb.Conn, Screen uint32, Drawable uint32) GetDrawableInfoCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getDrawableInfoRequest(c, Screen, Drawable), cookie) + return GetDrawableInfoCookie{cookie} +} + +// Request reply for GetDrawableInfo +// size: ((36 + xgb.Pad((int(NumClipRects) * 8))) + xgb.Pad((int(NumBackClipRects) * 8))) +type GetDrawableInfoReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + DrawableTableIndex uint32 + DrawableTableStamp uint32 + DrawableOriginX int16 + DrawableOriginY int16 + DrawableSizeW int16 + DrawableSizeH int16 + NumClipRects uint32 + BackX int16 + BackY int16 + NumBackClipRects uint32 + ClipRects []DrmClipRect // size: xgb.Pad((int(NumClipRects) * 8)) + BackClipRects []DrmClipRect // size: xgb.Pad((int(NumBackClipRects) * 8)) +} + +// Waits and reads reply data from request GetDrawableInfo +func (cook GetDrawableInfoCookie) Reply() (*GetDrawableInfoReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getDrawableInfoReply(buf), nil +} + +// Read reply into structure from buffer for GetDrawableInfo +func getDrawableInfoReply(buf []byte) *GetDrawableInfoReply { + v := new(GetDrawableInfoReply) + 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.DrawableTableIndex = xgb.Get32(buf[b:]) + b += 4 + + v.DrawableTableStamp = xgb.Get32(buf[b:]) + b += 4 + + v.DrawableOriginX = int16(xgb.Get16(buf[b:])) + b += 2 + + v.DrawableOriginY = int16(xgb.Get16(buf[b:])) + b += 2 + + v.DrawableSizeW = int16(xgb.Get16(buf[b:])) + b += 2 + + v.DrawableSizeH = int16(xgb.Get16(buf[b:])) + b += 2 + + v.NumClipRects = xgb.Get32(buf[b:]) + b += 4 + + v.BackX = int16(xgb.Get16(buf[b:])) + b += 2 + + v.BackY = int16(xgb.Get16(buf[b:])) + b += 2 + + v.NumBackClipRects = xgb.Get32(buf[b:]) + b += 4 + + v.ClipRects = make([]DrmClipRect, v.NumClipRects) + b += DrmClipRectReadList(buf[b:], v.ClipRects) + + v.BackClipRects = make([]DrmClipRect, v.NumBackClipRects) + b += DrmClipRectReadList(buf[b:], v.BackClipRects) + + return v +} + +// Write request to wire for GetDrawableInfo +func getDrawableInfoRequest(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] = 9 // 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:], Drawable) + b += 4 + + return buf +} + +// Request GetDeviceInfo +// size: 8 +type GetDeviceInfoCookie struct { + *xgb.Cookie +} + +func GetDeviceInfo(c *xgb.Conn, Screen uint32) GetDeviceInfoCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getDeviceInfoRequest(c, Screen), cookie) + return GetDeviceInfoCookie{cookie} +} + +func GetDeviceInfoUnchecked(c *xgb.Conn, Screen uint32) GetDeviceInfoCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getDeviceInfoRequest(c, Screen), cookie) + return GetDeviceInfoCookie{cookie} +} + +// Request reply for GetDeviceInfo +// size: (32 + xgb.Pad((int(DevicePrivateSize) * 4))) +type GetDeviceInfoReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + FramebufferHandleLow uint32 + FramebufferHandleHigh uint32 + FramebufferOriginOffset uint32 + FramebufferSize uint32 + FramebufferStride uint32 + DevicePrivateSize uint32 + DevicePrivate []uint32 // size: xgb.Pad((int(DevicePrivateSize) * 4)) +} + +// Waits and reads reply data from request GetDeviceInfo +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 +} + +// Read reply into structure from buffer for GetDeviceInfo +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 GetDeviceInfo +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] = 10 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Screen) + b += 4 + + return buf +} + +// Request AuthConnection +// size: 12 +type AuthConnectionCookie struct { + *xgb.Cookie +} + +func AuthConnection(c *xgb.Conn, Screen uint32, Magic uint32) AuthConnectionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(authConnectionRequest(c, Screen, Magic), cookie) + return AuthConnectionCookie{cookie} +} + +func AuthConnectionUnchecked(c *xgb.Conn, Screen uint32, Magic uint32) AuthConnectionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(authConnectionRequest(c, Screen, Magic), cookie) + return AuthConnectionCookie{cookie} +} + +// Request reply for AuthConnection +// size: 12 +type AuthConnectionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Authenticated uint32 +} + +// Waits and reads reply data from request AuthConnection +func (cook AuthConnectionCookie) Reply() (*AuthConnectionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return authConnectionReply(buf), nil +} + +// Read reply into structure from buffer for AuthConnection +func authConnectionReply(buf []byte) *AuthConnectionReply { + v := new(AuthConnectionReply) + 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.Authenticated = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for AuthConnection +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] = 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 +} -- cgit v1.2.3 From a3363755cdfdafdf02d5a772bd47a462e99af057 Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Thu, 10 May 2012 20:06:22 -0400 Subject: adding package header comments --- nexgb/xf86dri/xf86dri.go | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'nexgb/xf86dri') diff --git a/nexgb/xf86dri/xf86dri.go b/nexgb/xf86dri/xf86dri.go index 0259729..ac87c0a 100644 --- a/nexgb/xf86dri/xf86dri.go +++ b/nexgb/xf86dri/xf86dri.go @@ -1,7 +1,8 @@ +// Package xf86dri is the X client API for the XFree86-DRI extension. package xf86dri /* - This file was generated by xf86dri.xml on May 10 2012 4:20:28pm EDT. + This file was generated by xf86dri.xml on May 10 2012 8:04:32pm EDT. This file is automatically generated. Edit at your peril! */ @@ -39,16 +40,6 @@ func init() { xgb.NewExtErrorFuncs["XFree86-DRI"] = make(map[int]xgb.NewErrorFun) } -// 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' // Skipping definition for base type 'Card16' @@ -63,6 +54,16 @@ func init() { // 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' + // 'DrmClipRect' struct definition // Size: 8 type DrmClipRect struct { -- cgit v1.2.3 From c00652934e4ec68016a152b9bea10273b0be8726 Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Thu, 10 May 2012 23:57:34 -0400 Subject: better docs --- nexgb/xf86dri/xf86dri.go | 240 +++++++++++++++++++++++++++-------------------- 1 file changed, 140 insertions(+), 100 deletions(-) (limited to 'nexgb/xf86dri') diff --git a/nexgb/xf86dri/xf86dri.go b/nexgb/xf86dri/xf86dri.go index ac87c0a..cd3ff35 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 May 10 2012 8:04:32pm EDT. + This file was generated by xf86dri.xml on May 10 2012 11:56:19pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,18 +40,6 @@ func init() { xgb.NewExtErrorFuncs["XFree86-DRI"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Int8' - -// 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' @@ -64,8 +52,18 @@ func init() { // Skipping definition for base type 'Byte' -// 'DrmClipRect' struct definition -// Size: 8 +// Skipping definition for base type 'Int8' + +// 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' + type DrmClipRect struct { X1 int16 Y1 int16 @@ -73,7 +71,7 @@ type DrmClipRect struct { X3 int16 } -// Struct read DrmClipRect +// DrmClipRectRead reads a byte slice into a DrmClipRect value. func DrmClipRectRead(buf []byte, v *DrmClipRect) int { b := 0 @@ -92,7 +90,7 @@ func DrmClipRectRead(buf []byte, v *DrmClipRect) int { return b } -// Struct list read DrmClipRect +// DrmClipRectReadList reads a byte slice into a list of DrmClipRect values. func DrmClipRectReadList(buf []byte, dest []DrmClipRect) int { b := 0 for i := 0; i < len(dest); i++ { @@ -102,7 +100,7 @@ func DrmClipRectReadList(buf []byte, dest []DrmClipRect) int { return xgb.Pad(b) } -// Struct write DrmClipRect +// Bytes writes a DrmClipRect value to a byte slice. func (v DrmClipRect) Bytes() []byte { buf := make([]byte, 8) b := 0 @@ -122,7 +120,7 @@ func (v DrmClipRect) Bytes() []byte { return buf } -// Write struct list DrmClipRect +// DrmClipRectListBytes writes a list of %s(MISSING) values to a byte slice. func DrmClipRectListBytes(buf []byte, list []DrmClipRect) int { b := 0 var structBytes []byte @@ -134,36 +132,38 @@ func DrmClipRectListBytes(buf []byte, list []DrmClipRect) int { return b } -// Request QueryVersion -// size: 4 +// 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 { 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 { cookie := c.NewCookie(false, true) c.NewRequest(queryVersionRequest(c), cookie) return QueryVersionCookie{cookie} } -// Request reply for QueryVersion -// size: 16 +// QueryVersionReply represents the data returned from a QueryVersion request. type QueryVersionReply struct { - Sequence uint16 - Length uint32 + 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 } -// Waits and reads reply data from request QueryVersion +// 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 { @@ -175,7 +175,7 @@ func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { return queryVersionReply(buf), nil } -// Read reply into structure from buffer for QueryVersion +// queryVersionReply reads a byte slice into a QueryVersionReply value. func queryVersionReply(buf []byte) *QueryVersionReply { v := new(QueryVersionReply) b := 1 // skip reply determinant @@ -201,6 +201,7 @@ func queryVersionReply(buf []byte) *QueryVersionReply { } // 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 @@ -218,34 +219,36 @@ func queryVersionRequest(c *xgb.Conn) []byte { return buf } -// Request QueryDirectRenderingCapable -// size: 8 +// QueryDirectRenderingCapableCookie is a cookie used only for QueryDirectRenderingCapable requests. type QueryDirectRenderingCapableCookie 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 { cookie := c.NewCookie(true, true) c.NewRequest(queryDirectRenderingCapableRequest(c, Screen), cookie) return QueryDirectRenderingCapableCookie{cookie} } +// QueryDirectRenderingCapableUnchecked 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 { cookie := c.NewCookie(false, true) c.NewRequest(queryDirectRenderingCapableRequest(c, Screen), cookie) return QueryDirectRenderingCapableCookie{cookie} } -// Request reply for QueryDirectRenderingCapable -// size: 9 +// QueryDirectRenderingCapableReply represents the data returned from a QueryDirectRenderingCapable request. type QueryDirectRenderingCapableReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes IsCapable bool } -// Waits and reads reply data from request QueryDirectRenderingCapable +// 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 { @@ -257,7 +260,7 @@ func (cook QueryDirectRenderingCapableCookie) Reply() (*QueryDirectRenderingCapa return queryDirectRenderingCapableReply(buf), nil } -// Read reply into structure from buffer for QueryDirectRenderingCapable +// queryDirectRenderingCapableReply reads a byte slice into a QueryDirectRenderingCapableReply value. func queryDirectRenderingCapableReply(buf []byte) *QueryDirectRenderingCapableReply { v := new(QueryDirectRenderingCapableReply) b := 1 // skip reply determinant @@ -281,6 +284,7 @@ func queryDirectRenderingCapableReply(buf []byte) *QueryDirectRenderingCapableRe } // 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 @@ -301,29 +305,31 @@ func queryDirectRenderingCapableRequest(c *xgb.Conn, Screen uint32) []byte { return buf } -// Request OpenConnection -// size: 8 +// OpenConnectionCookie is a cookie used only for OpenConnection requests. type OpenConnectionCookie 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 { cookie := c.NewCookie(true, true) c.NewRequest(openConnectionRequest(c, Screen), cookie) return OpenConnectionCookie{cookie} } +// OpenConnectionUnchecked 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 { cookie := c.NewCookie(false, true) c.NewRequest(openConnectionRequest(c, Screen), cookie) return OpenConnectionCookie{cookie} } -// Request reply for OpenConnection -// size: (32 + xgb.Pad((int(BusIdLen) * 1))) +// OpenConnectionReply represents the data returned from a OpenConnection request. type OpenConnectionReply struct { - Sequence uint16 - Length uint32 + 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 @@ -332,7 +338,7 @@ type OpenConnectionReply struct { BusId string // size: xgb.Pad((int(BusIdLen) * 1)) } -// Waits and reads reply data from request OpenConnection +// 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 { @@ -344,7 +350,7 @@ func (cook OpenConnectionCookie) Reply() (*OpenConnectionReply, error) { return openConnectionReply(buf), nil } -// Read reply into structure from buffer for OpenConnection +// openConnectionReply reads a byte slice into a OpenConnectionReply value. func openConnectionReply(buf []byte) *OpenConnectionReply { v := new(OpenConnectionReply) b := 1 // skip reply determinant @@ -379,6 +385,7 @@ func openConnectionReply(buf []byte) *OpenConnectionReply { } // 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 @@ -399,30 +406,35 @@ func openConnectionRequest(c *xgb.Conn, Screen uint32) []byte { return buf } -// Request CloseConnection -// size: 8 +// CloseConnectionCookie is a cookie used only for CloseConnection requests. type CloseConnectionCookie struct { *xgb.Cookie } -// Write request to wire for CloseConnection +// 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 { 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 { 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 @@ -443,29 +455,31 @@ func closeConnectionRequest(c *xgb.Conn, Screen uint32) []byte { return buf } -// Request GetClientDriverName -// size: 8 +// GetClientDriverNameCookie is a cookie used only for GetClientDriverName requests. type GetClientDriverNameCookie 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 { cookie := c.NewCookie(true, true) c.NewRequest(getClientDriverNameRequest(c, Screen), cookie) return GetClientDriverNameCookie{cookie} } +// GetClientDriverNameUnchecked 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 { cookie := c.NewCookie(false, true) c.NewRequest(getClientDriverNameRequest(c, Screen), cookie) return GetClientDriverNameCookie{cookie} } -// Request reply for GetClientDriverName -// size: (32 + xgb.Pad((int(ClientDriverNameLen) * 1))) +// GetClientDriverNameReply represents the data returned from a GetClientDriverName request. type GetClientDriverNameReply struct { - Sequence uint16 - Length uint32 + 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 @@ -475,7 +489,7 @@ type GetClientDriverNameReply struct { ClientDriverName string // size: xgb.Pad((int(ClientDriverNameLen) * 1)) } -// Waits and reads reply data from request GetClientDriverName +// 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 { @@ -487,7 +501,7 @@ func (cook GetClientDriverNameCookie) Reply() (*GetClientDriverNameReply, error) return getClientDriverNameReply(buf), nil } -// Read reply into structure from buffer for GetClientDriverName +// getClientDriverNameReply reads a byte slice into a GetClientDriverNameReply value. func getClientDriverNameReply(buf []byte) *GetClientDriverNameReply { v := new(GetClientDriverNameReply) b := 1 // skip reply determinant @@ -525,6 +539,7 @@ func getClientDriverNameReply(buf []byte) *GetClientDriverNameReply { } // 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 @@ -545,34 +560,36 @@ func getClientDriverNameRequest(c *xgb.Conn, Screen uint32) []byte { return buf } -// Request CreateContext -// size: 16 +// CreateContextCookie is a cookie used only for CreateContext requests. type CreateContextCookie 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 { cookie := c.NewCookie(true, true) c.NewRequest(createContextRequest(c, Screen, Visual, Context), cookie) return CreateContextCookie{cookie} } +// CreateContextUnchecked 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 { cookie := c.NewCookie(false, true) c.NewRequest(createContextRequest(c, Screen, Visual, Context), cookie) return CreateContextCookie{cookie} } -// Request reply for CreateContext -// size: 12 +// CreateContextReply represents the data returned from a CreateContext request. type CreateContextReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes HwContext uint32 } -// Waits and reads reply data from request CreateContext +// 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 { @@ -584,7 +601,7 @@ func (cook CreateContextCookie) Reply() (*CreateContextReply, error) { return createContextReply(buf), nil } -// Read reply into structure from buffer for CreateContext +// createContextReply reads a byte slice into a CreateContextReply value. func createContextReply(buf []byte) *CreateContextReply { v := new(CreateContextReply) b := 1 // skip reply determinant @@ -604,6 +621,7 @@ func createContextReply(buf []byte) *CreateContextReply { } // 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 @@ -630,30 +648,35 @@ func createContextRequest(c *xgb.Conn, Screen uint32, Visual uint32, Context uin return buf } -// Request DestroyContext -// size: 12 +// DestroyContextCookie is a cookie used only for DestroyContext requests. type DestroyContextCookie struct { *xgb.Cookie } -// Write request to wire for DestroyContext +// DestroyContext 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 { cookie := c.NewCookie(false, false) c.NewRequest(destroyContextRequest(c, Screen, Context), cookie) return DestroyContextCookie{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 { cookie := c.NewCookie(true, false) c.NewRequest(destroyContextRequest(c, Screen, Context), cookie) return DestroyContextCookie{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 { 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 { size := 12 b := 0 @@ -677,34 +700,36 @@ func destroyContextRequest(c *xgb.Conn, Screen uint32, Context uint32) []byte { return buf } -// Request CreateDrawable -// size: 12 +// CreateDrawableCookie is a cookie used only for CreateDrawable requests. type CreateDrawableCookie 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 { cookie := c.NewCookie(true, true) c.NewRequest(createDrawableRequest(c, Screen, Drawable), cookie) return CreateDrawableCookie{cookie} } +// CreateDrawableUnchecked 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 { cookie := c.NewCookie(false, true) c.NewRequest(createDrawableRequest(c, Screen, Drawable), cookie) return CreateDrawableCookie{cookie} } -// Request reply for CreateDrawable -// size: 12 +// CreateDrawableReply represents the data returned from a CreateDrawable request. type CreateDrawableReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes HwDrawableHandle uint32 } -// Waits and reads reply data from request CreateDrawable +// 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 { @@ -716,7 +741,7 @@ func (cook CreateDrawableCookie) Reply() (*CreateDrawableReply, error) { return createDrawableReply(buf), nil } -// Read reply into structure from buffer for CreateDrawable +// createDrawableReply reads a byte slice into a CreateDrawableReply value. func createDrawableReply(buf []byte) *CreateDrawableReply { v := new(CreateDrawableReply) b := 1 // skip reply determinant @@ -736,6 +761,7 @@ func createDrawableReply(buf []byte) *CreateDrawableReply { } // 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 @@ -759,30 +785,35 @@ func createDrawableRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte { return buf } -// Request DestroyDrawable -// size: 12 +// DestroyDrawableCookie is a cookie used only for DestroyDrawable requests. type DestroyDrawableCookie struct { *xgb.Cookie } -// Write request to wire for DestroyDrawable +// 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 { cookie := c.NewCookie(false, false) c.NewRequest(destroyDrawableRequest(c, Screen, Drawable), cookie) return DestroyDrawableCookie{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 { cookie := c.NewCookie(true, false) 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 DestroyDrawableCookie) Check() error { return cook.Cookie.Check() } // 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 @@ -806,29 +837,31 @@ func destroyDrawableRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte return buf } -// Request GetDrawableInfo -// size: 12 +// GetDrawableInfoCookie is a cookie used only for GetDrawableInfo requests. type GetDrawableInfoCookie struct { *xgb.Cookie } +// GetDrawableInfo sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetDrawableInfoCookie.Reply() func GetDrawableInfo(c *xgb.Conn, Screen uint32, Drawable uint32) GetDrawableInfoCookie { cookie := c.NewCookie(true, true) c.NewRequest(getDrawableInfoRequest(c, Screen, Drawable), cookie) return GetDrawableInfoCookie{cookie} } +// GetDrawableInfoUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetDrawableInfoUnchecked(c *xgb.Conn, Screen uint32, Drawable uint32) GetDrawableInfoCookie { cookie := c.NewCookie(false, true) c.NewRequest(getDrawableInfoRequest(c, Screen, Drawable), cookie) return GetDrawableInfoCookie{cookie} } -// Request reply for GetDrawableInfo -// size: ((36 + xgb.Pad((int(NumClipRects) * 8))) + xgb.Pad((int(NumBackClipRects) * 8))) +// GetDrawableInfoReply represents the data returned from a GetDrawableInfo request. type GetDrawableInfoReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes DrawableTableIndex uint32 DrawableTableStamp uint32 @@ -844,7 +877,7 @@ type GetDrawableInfoReply struct { BackClipRects []DrmClipRect // size: xgb.Pad((int(NumBackClipRects) * 8)) } -// Waits and reads reply data from request GetDrawableInfo +// Reply blocks and returns the reply data for a GetDrawableInfo request. func (cook GetDrawableInfoCookie) Reply() (*GetDrawableInfoReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -856,7 +889,7 @@ func (cook GetDrawableInfoCookie) Reply() (*GetDrawableInfoReply, error) { return getDrawableInfoReply(buf), nil } -// Read reply into structure from buffer for GetDrawableInfo +// getDrawableInfoReply reads a byte slice into a GetDrawableInfoReply value. func getDrawableInfoReply(buf []byte) *GetDrawableInfoReply { v := new(GetDrawableInfoReply) b := 1 // skip reply determinant @@ -909,6 +942,7 @@ func getDrawableInfoReply(buf []byte) *GetDrawableInfoReply { } // Write request to wire for GetDrawableInfo +// getDrawableInfoRequest writes a GetDrawableInfo request to a byte slice. func getDrawableInfoRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte { size := 12 b := 0 @@ -932,29 +966,31 @@ func getDrawableInfoRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte return buf } -// Request GetDeviceInfo -// size: 8 +// GetDeviceInfoCookie is a cookie used only for GetDeviceInfo requests. type GetDeviceInfoCookie 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 { cookie := c.NewCookie(true, true) c.NewRequest(getDeviceInfoRequest(c, Screen), cookie) return GetDeviceInfoCookie{cookie} } +// 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 { cookie := c.NewCookie(false, true) c.NewRequest(getDeviceInfoRequest(c, Screen), cookie) return GetDeviceInfoCookie{cookie} } -// Request reply for GetDeviceInfo -// size: (32 + xgb.Pad((int(DevicePrivateSize) * 4))) +// GetDeviceInfoReply represents the data returned from a GetDeviceInfo request. type GetDeviceInfoReply struct { - Sequence uint16 - Length uint32 + 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 @@ -965,7 +1001,7 @@ type GetDeviceInfoReply struct { DevicePrivate []uint32 // size: xgb.Pad((int(DevicePrivateSize) * 4)) } -// Waits and reads reply data from request GetDeviceInfo +// 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 { @@ -977,7 +1013,7 @@ func (cook GetDeviceInfoCookie) Reply() (*GetDeviceInfoReply, error) { return getDeviceInfoReply(buf), nil } -// Read reply into structure from buffer for GetDeviceInfo +// getDeviceInfoReply reads a byte slice into a GetDeviceInfoReply value. func getDeviceInfoReply(buf []byte) *GetDeviceInfoReply { v := new(GetDeviceInfoReply) b := 1 // skip reply determinant @@ -1019,6 +1055,7 @@ func getDeviceInfoReply(buf []byte) *GetDeviceInfoReply { } // 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 @@ -1039,34 +1076,36 @@ func getDeviceInfoRequest(c *xgb.Conn, Screen uint32) []byte { return buf } -// Request AuthConnection -// size: 12 +// AuthConnectionCookie is a cookie used only for AuthConnection requests. type AuthConnectionCookie 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 { cookie := c.NewCookie(true, true) c.NewRequest(authConnectionRequest(c, Screen, Magic), cookie) return AuthConnectionCookie{cookie} } +// AuthConnectionUnchecked 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 { cookie := c.NewCookie(false, true) c.NewRequest(authConnectionRequest(c, Screen, Magic), cookie) return AuthConnectionCookie{cookie} } -// Request reply for AuthConnection -// size: 12 +// AuthConnectionReply represents the data returned from a AuthConnection request. type AuthConnectionReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes Authenticated uint32 } -// Waits and reads reply data from request AuthConnection +// 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 { @@ -1078,7 +1117,7 @@ func (cook AuthConnectionCookie) Reply() (*AuthConnectionReply, error) { return authConnectionReply(buf), nil } -// Read reply into structure from buffer for AuthConnection +// authConnectionReply reads a byte slice into a AuthConnectionReply value. func authConnectionReply(buf []byte) *AuthConnectionReply { v := new(AuthConnectionReply) b := 1 // skip reply determinant @@ -1098,6 +1137,7 @@ func authConnectionReply(buf []byte) *AuthConnectionReply { } // 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 -- cgit v1.2.3 From 3e6b3544934cb71e3a3b0edf9bc184241ac1ad7f Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Fri, 11 May 2012 01:58:52 -0400 Subject: add a little more docs for errors --- nexgb/xf86dri/xf86dri.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'nexgb/xf86dri') diff --git a/nexgb/xf86dri/xf86dri.go b/nexgb/xf86dri/xf86dri.go index cd3ff35..1d7dd72 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 May 10 2012 11:56:19pm EDT. + This file was generated by xf86dri.xml on May 11 2012 1:58:36am EDT. This file is automatically generated. Edit at your peril! */ @@ -40,6 +40,8 @@ func init() { xgb.NewExtErrorFuncs["XFree86-DRI"] = make(map[int]xgb.NewErrorFun) } +// Skipping definition for base type 'Bool' + // Skipping definition for base type 'Float' // Skipping definition for base type 'Card8' @@ -62,8 +64,6 @@ func init() { // Skipping definition for base type 'Double' -// Skipping definition for base type 'Bool' - type DrmClipRect struct { X1 int16 Y1 int16 -- cgit v1.2.3 From 29942bf078c92fea681e42ca5029592526f00718 Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Fri, 11 May 2012 23:58:52 -0400 Subject: panic when an extension request is issued before an extension has been initialized. but give a nice error message for the happy people. --- nexgb/xf86dri/xf86dri.go | 78 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 75 insertions(+), 3 deletions(-) (limited to 'nexgb/xf86dri') diff --git a/nexgb/xf86dri/xf86dri.go b/nexgb/xf86dri/xf86dri.go index 1d7dd72..f0224a5 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 May 11 2012 1:58:36am EDT. + This file was generated by xf86dri.xml on May 11 2012 11:57:19pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,8 +40,6 @@ func init() { xgb.NewExtErrorFuncs["XFree86-DRI"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Bool' - // Skipping definition for base type 'Float' // Skipping definition for base type 'Card8' @@ -64,6 +62,8 @@ func init() { // Skipping definition for base type 'Double' +// Skipping definition for base type 'Bool' + type DrmClipRect struct { X1 int16 Y1 int16 @@ -140,6 +140,9 @@ type QueryVersionCookie struct { // 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} @@ -148,6 +151,9 @@ func QueryVersion(c *xgb.Conn) QueryVersionCookie { // 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} @@ -227,6 +233,9 @@ type QueryDirectRenderingCapableCookie struct { // 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} @@ -235,6 +244,9 @@ func QueryDirectRenderingCapable(c *xgb.Conn, Screen uint32) QueryDirectRenderin // QueryDirectRenderingCapableUnchecked 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 { + 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(false, true) c.NewRequest(queryDirectRenderingCapableRequest(c, Screen), cookie) return QueryDirectRenderingCapableCookie{cookie} @@ -313,6 +325,9 @@ type OpenConnectionCookie struct { // 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 'OpenConnection' 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} @@ -321,6 +336,9 @@ func OpenConnection(c *xgb.Conn, Screen uint32) OpenConnectionCookie { // OpenConnectionUnchecked 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 { + 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.") + } cookie := c.NewCookie(false, true) c.NewRequest(openConnectionRequest(c, Screen), cookie) return OpenConnectionCookie{cookie} @@ -414,6 +432,9 @@ type CloseConnectionCookie struct { // 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} @@ -422,6 +443,9 @@ func CloseConnection(c *xgb.Conn, Screen uint32) CloseConnectionCookie { // 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} @@ -463,6 +487,9 @@ type GetClientDriverNameCookie struct { // 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 'GetClientDriverName' 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} @@ -471,6 +498,9 @@ func GetClientDriverName(c *xgb.Conn, Screen uint32) GetClientDriverNameCookie { // GetClientDriverNameUnchecked 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 { + 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.") + } cookie := c.NewCookie(false, true) c.NewRequest(getClientDriverNameRequest(c, Screen), cookie) return GetClientDriverNameCookie{cookie} @@ -568,6 +598,9 @@ type CreateContextCookie struct { // 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} @@ -576,6 +609,9 @@ func CreateContext(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) Cr // CreateContextUnchecked 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 { + 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(false, true) c.NewRequest(createContextRequest(c, Screen, Visual, Context), cookie) return CreateContextCookie{cookie} @@ -656,6 +692,9 @@ type DestroyContextCookie struct { // DestroyContext 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 { + 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.") + } cookie := c.NewCookie(false, false) c.NewRequest(destroyContextRequest(c, Screen, Context), cookie) return DestroyContextCookie{cookie} @@ -664,6 +703,9 @@ func DestroyContext(c *xgb.Conn, Screen uint32, Context uint32) DestroyContextCo // 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.") + } cookie := c.NewCookie(true, false) c.NewRequest(destroyContextRequest(c, Screen, Context), cookie) return DestroyContextCookie{cookie} @@ -708,6 +750,9 @@ type CreateDrawableCookie struct { // 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 'CreateDrawable' 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} @@ -716,6 +761,9 @@ func CreateDrawable(c *xgb.Conn, Screen uint32, Drawable uint32) CreateDrawableC // CreateDrawableUnchecked 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 { + 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.") + } cookie := c.NewCookie(false, true) c.NewRequest(createDrawableRequest(c, Screen, Drawable), cookie) return CreateDrawableCookie{cookie} @@ -793,6 +841,9 @@ type DestroyDrawableCookie struct { // 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 { + 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.") + } cookie := c.NewCookie(false, false) c.NewRequest(destroyDrawableRequest(c, Screen, Drawable), cookie) return DestroyDrawableCookie{cookie} @@ -801,6 +852,9 @@ func DestroyDrawable(c *xgb.Conn, Screen uint32, Drawable uint32) DestroyDrawabl // 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 'DestroyDrawable' 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} @@ -845,6 +899,9 @@ type GetDrawableInfoCookie struct { // GetDrawableInfo sends a checked request. // If an error occurs, it will be returned with the reply by calling GetDrawableInfoCookie.Reply() func GetDrawableInfo(c *xgb.Conn, Screen uint32, Drawable uint32) GetDrawableInfoCookie { + if _, ok := c.Extensions["XFREE86-DRI"]; !ok { + panic("Cannot issue request 'GetDrawableInfo' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, true) c.NewRequest(getDrawableInfoRequest(c, Screen, Drawable), cookie) return GetDrawableInfoCookie{cookie} @@ -853,6 +910,9 @@ func GetDrawableInfo(c *xgb.Conn, Screen uint32, Drawable uint32) GetDrawableInf // GetDrawableInfoUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetDrawableInfoUnchecked(c *xgb.Conn, Screen uint32, Drawable uint32) GetDrawableInfoCookie { + if _, ok := c.Extensions["XFREE86-DRI"]; !ok { + panic("Cannot issue request 'GetDrawableInfo' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, true) c.NewRequest(getDrawableInfoRequest(c, Screen, Drawable), cookie) return GetDrawableInfoCookie{cookie} @@ -974,6 +1034,9 @@ type GetDeviceInfoCookie struct { // 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 'GetDeviceInfo' 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} @@ -982,6 +1045,9 @@ func GetDeviceInfo(c *xgb.Conn, Screen uint32) GetDeviceInfoCookie { // 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 'GetDeviceInfo' 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} @@ -1084,6 +1150,9 @@ type AuthConnectionCookie struct { // 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 'AuthConnection' 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} @@ -1092,6 +1161,9 @@ func AuthConnection(c *xgb.Conn, Screen uint32, Magic uint32) AuthConnectionCook // AuthConnectionUnchecked 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 { + 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.") + } cookie := c.NewCookie(false, true) c.NewRequest(authConnectionRequest(c, Screen, Magic), cookie) return AuthConnectionCookie{cookie} -- cgit v1.2.3 From 4ea94ca0fef7786ce21722cbb02a9cf069bdedd9 Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Sat, 26 May 2012 18:24:52 -0400 Subject: Bug fix in the generator that was outputting %(MISSING) crud. --- nexgb/xf86dri/xf86dri.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'nexgb/xf86dri') diff --git a/nexgb/xf86dri/xf86dri.go b/nexgb/xf86dri/xf86dri.go index f0224a5..0737f5b 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 May 11 2012 11:57:19pm EDT. + This file was generated by xf86dri.xml on May 26 2012 6:23:13pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,16 +40,6 @@ func init() { xgb.NewExtErrorFuncs["XFree86-DRI"] = make(map[int]xgb.NewErrorFun) } -// 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' @@ -64,6 +54,16 @@ func init() { // 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' + type DrmClipRect struct { X1 int16 Y1 int16 @@ -120,7 +120,7 @@ func (v DrmClipRect) Bytes() []byte { return buf } -// DrmClipRectListBytes writes a list of %s(MISSING) values to a byte slice. +// DrmClipRectListBytes writes a list of DrmClipRect values to a byte slice. func DrmClipRectListBytes(buf []byte, list []DrmClipRect) int { b := 0 var structBytes []byte -- cgit v1.2.3 From a9eae45cb3977bce5983e817d00d4584d176b044 Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Tue, 5 Jun 2012 00:14:34 -0400 Subject: Refresh build. Eh. --- nexgb/xf86dri/xf86dri.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'nexgb/xf86dri') diff --git a/nexgb/xf86dri/xf86dri.go b/nexgb/xf86dri/xf86dri.go index 0737f5b..d52654d 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 May 26 2012 6:23:13pm EDT. + This file was generated by xf86dri.xml on Jun 5 2012 12:11:59am EDT. This file is automatically generated. Edit at your peril! */ @@ -40,10 +40,6 @@ func init() { xgb.NewExtErrorFuncs["XFree86-DRI"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Byte' - -// Skipping definition for base type 'Int8' - // Skipping definition for base type 'Card16' // Skipping definition for base type 'Char' @@ -64,6 +60,10 @@ func init() { // 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 -- cgit v1.2.3 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 From b06a8ca97625c1134449c3af65d9ac3fb251a613 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Sun, 11 Aug 2013 20:45:36 -0400 Subject: Don't needlessly change source files every time. --- nexgb/xf86dri/xf86dri.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'nexgb/xf86dri') diff --git a/nexgb/xf86dri/xf86dri.go b/nexgb/xf86dri/xf86dri.go index 1a6fddf..5180b76 100644 --- a/nexgb/xf86dri/xf86dri.go +++ b/nexgb/xf86dri/xf86dri.go @@ -1,10 +1,7 @@ // Package xf86dri is the X client API for the XFree86-DRI extension. package xf86dri -/* - This file was generated by xf86dri.xml on Aug 11 2013 8:39:43pm EDT. - This file is automatically generated. Edit at your peril! -*/ +// This file is automatically generated from xf86dri.xml. Edit at your peril! import ( "github.com/BurntSushi/xgb" -- cgit v1.2.3 From 38b293e74db6631873d5dfd74cf731eb7b76737d Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Sun, 11 Aug 2013 20:54:15 -0400 Subject: Padding on a list is on the length of the list. There was a bug where padding was being computed on each element of the list. Close #5. --- nexgb/xf86dri/xf86dri.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'nexgb/xf86dri') diff --git a/nexgb/xf86dri/xf86dri.go b/nexgb/xf86dri/xf86dri.go index 5180b76..46fabca 100644 --- a/nexgb/xf86dri/xf86dri.go +++ b/nexgb/xf86dri/xf86dri.go @@ -100,9 +100,9 @@ func DrmClipRectListBytes(buf []byte, list []DrmClipRect) int { for _, item := range list { structBytes = item.Bytes() copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) + b += len(structBytes) } - return b + return xgb.Pad(b) } // Skipping definition for base type 'Bool' -- cgit v1.2.3 From 33509dbeb0acd7abbbb9e8c434d0c3f0ce8a3230 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Sat, 28 Dec 2013 10:02:18 -0500 Subject: It appears that the "Str" type (which is built into the core X protocol) doesn't specify any padding. So it has to be treated as a special case. Close #12. --- nexgb/xf86dri/xf86dri.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'nexgb/xf86dri') diff --git a/nexgb/xf86dri/xf86dri.go b/nexgb/xf86dri/xf86dri.go index 46fabca..65fcfa0 100644 --- a/nexgb/xf86dri/xf86dri.go +++ b/nexgb/xf86dri/xf86dri.go @@ -659,7 +659,7 @@ func getClientDriverNameReply(buf []byte) *GetClientDriverNameReply { byteString := make([]byte, v.ClientDriverNameLen) copy(byteString[:v.ClientDriverNameLen], buf[b:]) v.ClientDriverName = string(byteString) - b += xgb.Pad(int(v.ClientDriverNameLen)) + b += int(v.ClientDriverNameLen) } return v @@ -1017,7 +1017,7 @@ func openConnectionReply(buf []byte) *OpenConnectionReply { byteString := make([]byte, v.BusIdLen) copy(byteString[:v.BusIdLen], buf[b:]) v.BusId = string(byteString) - b += xgb.Pad(int(v.BusIdLen)) + b += int(v.BusIdLen) } return v -- cgit v1.2.3 From 76f9adb5991081e27ebc6eec82db6bdba36c910f Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Sat, 28 Dec 2013 10:13:20 -0500 Subject: Use consistent extension names. Close #6. --- nexgb/xf86dri/xf86dri.go | 72 ++++++++++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 36 deletions(-) (limited to 'nexgb/xf86dri') diff --git a/nexgb/xf86dri/xf86dri.go b/nexgb/xf86dri/xf86dri.go index 65fcfa0..d88cc5d 100644 --- a/nexgb/xf86dri/xf86dri.go +++ b/nexgb/xf86dri/xf86dri.go @@ -137,7 +137,7 @@ type AuthConnectionCookie struct { // 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 { + 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.") } cookie := c.NewCookie(true, true) @@ -148,7 +148,7 @@ func AuthConnection(c *xgb.Conn, Screen uint32, Magic uint32) AuthConnectionCook // AuthConnectionUnchecked 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 { - if _, ok := c.Extensions["XFREE86-DRI"]; !ok { + 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.") } cookie := c.NewCookie(false, true) @@ -202,7 +202,7 @@ func authConnectionRequest(c *xgb.Conn, Screen uint32, Magic uint32) []byte { b := 0 buf := make([]byte, size) - buf[b] = c.Extensions["XFREE86-DRI"] + buf[b] = c.Extensions["XFree86-DRI"] b += 1 buf[b] = 11 // request opcode @@ -228,7 +228,7 @@ type CloseConnectionCookie struct { // 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 { + 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) @@ -239,7 +239,7 @@ func CloseConnection(c *xgb.Conn, Screen uint32) CloseConnectionCookie { // 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 { + 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) @@ -260,7 +260,7 @@ func closeConnectionRequest(c *xgb.Conn, Screen uint32) []byte { b := 0 buf := make([]byte, size) - buf[b] = c.Extensions["XFREE86-DRI"] + buf[b] = c.Extensions["XFree86-DRI"] b += 1 buf[b] = 3 // request opcode @@ -283,7 +283,7 @@ type CreateContextCookie struct { // 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 { + 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) @@ -294,7 +294,7 @@ func CreateContext(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) Cr // CreateContextUnchecked 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 { - if _, ok := c.Extensions["XFREE86-DRI"]; !ok { + 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(false, true) @@ -348,7 +348,7 @@ func createContextRequest(c *xgb.Conn, Screen uint32, Visual uint32, Context uin b := 0 buf := make([]byte, size) - buf[b] = c.Extensions["XFREE86-DRI"] + buf[b] = c.Extensions["XFree86-DRI"] b += 1 buf[b] = 5 // request opcode @@ -377,7 +377,7 @@ type CreateDrawableCookie struct { // 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 { + 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.") } cookie := c.NewCookie(true, true) @@ -388,7 +388,7 @@ func CreateDrawable(c *xgb.Conn, Screen uint32, Drawable uint32) CreateDrawableC // CreateDrawableUnchecked 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 { - if _, ok := c.Extensions["XFREE86-DRI"]; !ok { + 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.") } cookie := c.NewCookie(false, true) @@ -442,7 +442,7 @@ func createDrawableRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte { b := 0 buf := make([]byte, size) - buf[b] = c.Extensions["XFREE86-DRI"] + buf[b] = c.Extensions["XFree86-DRI"] b += 1 buf[b] = 7 // request opcode @@ -468,7 +468,7 @@ type DestroyContextCookie struct { // DestroyContext 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 { - if _, ok := c.Extensions["XFREE86-DRI"]; !ok { + 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.") } cookie := c.NewCookie(false, false) @@ -479,7 +479,7 @@ func DestroyContext(c *xgb.Conn, Screen uint32, Context uint32) DestroyContextCo // 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 { + 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.") } cookie := c.NewCookie(true, false) @@ -500,7 +500,7 @@ func destroyContextRequest(c *xgb.Conn, Screen uint32, Context uint32) []byte { b := 0 buf := make([]byte, size) - buf[b] = c.Extensions["XFREE86-DRI"] + buf[b] = c.Extensions["XFree86-DRI"] b += 1 buf[b] = 6 // request opcode @@ -526,7 +526,7 @@ type DestroyDrawableCookie struct { // 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 { - if _, ok := c.Extensions["XFREE86-DRI"]; !ok { + 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.") } cookie := c.NewCookie(false, false) @@ -537,7 +537,7 @@ func DestroyDrawable(c *xgb.Conn, Screen uint32, Drawable uint32) DestroyDrawabl // 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 { + 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.") } cookie := c.NewCookie(true, false) @@ -558,7 +558,7 @@ func destroyDrawableRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte b := 0 buf := make([]byte, size) - buf[b] = c.Extensions["XFREE86-DRI"] + buf[b] = c.Extensions["XFree86-DRI"] b += 1 buf[b] = 8 // request opcode @@ -584,7 +584,7 @@ type GetClientDriverNameCookie struct { // 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 { + 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.") } cookie := c.NewCookie(true, true) @@ -595,7 +595,7 @@ func GetClientDriverName(c *xgb.Conn, Screen uint32) GetClientDriverNameCookie { // GetClientDriverNameUnchecked 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 { - if _, ok := c.Extensions["XFREE86-DRI"]; !ok { + 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.") } cookie := c.NewCookie(false, true) @@ -672,7 +672,7 @@ func getClientDriverNameRequest(c *xgb.Conn, Screen uint32) []byte { b := 0 buf := make([]byte, size) - buf[b] = c.Extensions["XFREE86-DRI"] + buf[b] = c.Extensions["XFree86-DRI"] b += 1 buf[b] = 4 // request opcode @@ -695,7 +695,7 @@ type GetDeviceInfoCookie struct { // 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 { + 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.") } cookie := c.NewCookie(true, true) @@ -706,7 +706,7 @@ func GetDeviceInfo(c *xgb.Conn, Screen uint32) GetDeviceInfoCookie { // 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 { + 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.") } cookie := c.NewCookie(false, true) @@ -788,7 +788,7 @@ func getDeviceInfoRequest(c *xgb.Conn, Screen uint32) []byte { b := 0 buf := make([]byte, size) - buf[b] = c.Extensions["XFREE86-DRI"] + buf[b] = c.Extensions["XFree86-DRI"] b += 1 buf[b] = 10 // request opcode @@ -811,7 +811,7 @@ type GetDrawableInfoCookie struct { // GetDrawableInfo sends a checked request. // If an error occurs, it will be returned with the reply by calling GetDrawableInfoCookie.Reply() func GetDrawableInfo(c *xgb.Conn, Screen uint32, Drawable uint32) GetDrawableInfoCookie { - if _, ok := c.Extensions["XFREE86-DRI"]; !ok { + if _, ok := c.Extensions["XFree86-DRI"]; !ok { panic("Cannot issue request 'GetDrawableInfo' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) @@ -822,7 +822,7 @@ func GetDrawableInfo(c *xgb.Conn, Screen uint32, Drawable uint32) GetDrawableInf // GetDrawableInfoUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetDrawableInfoUnchecked(c *xgb.Conn, Screen uint32, Drawable uint32) GetDrawableInfoCookie { - if _, ok := c.Extensions["XFREE86-DRI"]; !ok { + if _, ok := c.Extensions["XFree86-DRI"]; !ok { panic("Cannot issue request 'GetDrawableInfo' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) @@ -920,7 +920,7 @@ func getDrawableInfoRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte b := 0 buf := make([]byte, size) - buf[b] = c.Extensions["XFREE86-DRI"] + buf[b] = c.Extensions["XFree86-DRI"] b += 1 buf[b] = 9 // request opcode @@ -946,7 +946,7 @@ type OpenConnectionCookie struct { // 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 { + 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.") } cookie := c.NewCookie(true, true) @@ -957,7 +957,7 @@ func OpenConnection(c *xgb.Conn, Screen uint32) OpenConnectionCookie { // OpenConnectionUnchecked 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 { - if _, ok := c.Extensions["XFREE86-DRI"]; !ok { + 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.") } cookie := c.NewCookie(false, true) @@ -1030,7 +1030,7 @@ func openConnectionRequest(c *xgb.Conn, Screen uint32) []byte { b := 0 buf := make([]byte, size) - buf[b] = c.Extensions["XFREE86-DRI"] + buf[b] = c.Extensions["XFree86-DRI"] b += 1 buf[b] = 2 // request opcode @@ -1053,7 +1053,7 @@ type QueryDirectRenderingCapableCookie struct { // 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 { + 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) @@ -1064,7 +1064,7 @@ func QueryDirectRenderingCapable(c *xgb.Conn, Screen uint32) QueryDirectRenderin // QueryDirectRenderingCapableUnchecked 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 { - if _, ok := c.Extensions["XFREE86-DRI"]; !ok { + 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(false, true) @@ -1122,7 +1122,7 @@ func queryDirectRenderingCapableRequest(c *xgb.Conn, Screen uint32) []byte { b := 0 buf := make([]byte, size) - buf[b] = c.Extensions["XFREE86-DRI"] + buf[b] = c.Extensions["XFree86-DRI"] b += 1 buf[b] = 1 // request opcode @@ -1145,7 +1145,7 @@ type QueryVersionCookie struct { // 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 { + 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) @@ -1156,7 +1156,7 @@ func QueryVersion(c *xgb.Conn) QueryVersionCookie { // 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 { + 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) @@ -1218,7 +1218,7 @@ func queryVersionRequest(c *xgb.Conn) []byte { b := 0 buf := make([]byte, size) - buf[b] = c.Extensions["XFREE86-DRI"] + buf[b] = c.Extensions["XFree86-DRI"] b += 1 buf[b] = 0 // request opcode -- cgit v1.2.3 From a548d9d0f7b889627c43b18811357fad88760b2d Mon Sep 17 00:00:00 2001 From: aarzilli Date: Fri, 2 May 2014 15:09:23 +0200 Subject: Fix Issue #21: automatic calculation of alignment padding after lists --- nexgb/xf86dri/xf86dri.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'nexgb/xf86dri') diff --git a/nexgb/xf86dri/xf86dri.go b/nexgb/xf86dri/xf86dri.go index d88cc5d..6a07e41 100644 --- a/nexgb/xf86dri/xf86dri.go +++ b/nexgb/xf86dri/xf86dri.go @@ -90,7 +90,7 @@ func (v DrmClipRect) Bytes() []byte { xgb.Put16(buf[b:], uint16(v.X3)) b += 2 - return buf + return buf[:b] } // DrmClipRectListBytes writes a list of DrmClipRect values to a byte slice. @@ -776,7 +776,6 @@ func getDeviceInfoReply(buf []byte) *GetDeviceInfoReply { v.DevicePrivate[i] = xgb.Get32(buf[b:]) b += 4 } - b = xgb.Pad(b) return v } @@ -846,7 +845,8 @@ type GetDrawableInfoReply struct { BackY int16 NumBackClipRects uint32 ClipRects []DrmClipRect // size: xgb.Pad((int(NumClipRects) * 8)) - BackClipRects []DrmClipRect // size: xgb.Pad((int(NumBackClipRects) * 8)) + // alignment gap to multiple of 4 + BackClipRects []DrmClipRect // size: xgb.Pad((int(NumBackClipRects) * 8)) } // Reply blocks and returns the reply data for a GetDrawableInfo request. @@ -907,6 +907,8 @@ func getDrawableInfoReply(buf []byte) *GetDrawableInfoReply { v.ClipRects = make([]DrmClipRect, v.NumClipRects) b += DrmClipRectReadList(buf[b:], v.ClipRects) + b = (b + 3) & ^3 // alignment gap + v.BackClipRects = make([]DrmClipRect, v.NumBackClipRects) b += DrmClipRectReadList(buf[b:], v.BackClipRects) -- cgit v1.2.3 From becaf43dcb3e9832c3eb951ff9908ed697868152 Mon Sep 17 00:00:00 2001 From: aarzilli Date: Tue, 1 Mar 2016 15:41:38 +0100 Subject: Read/Write mutex for Extensions map --- nexgb/xf86dri/xf86dri.go | 77 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 74 insertions(+), 3 deletions(-) (limited to 'nexgb/xf86dri') diff --git a/nexgb/xf86dri/xf86dri.go b/nexgb/xf86dri/xf86dri.go index 6a07e41..51c9322 100644 --- a/nexgb/xf86dri/xf86dri.go +++ b/nexgb/xf86dri/xf86dri.go @@ -19,16 +19,15 @@ func Init(c *xgb.Conn) error { return xgb.Errorf("No extension named XFree86-DRI could be found on on the server.") } - xgb.ExtLock.Lock() + c.ExtLock.Lock() c.Extensions["XFree86-DRI"] = reply.MajorOpcode + c.ExtLock.Unlock() for evNum, fun := range xgb.NewExtEventFuncs["XFree86-DRI"] { xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun } for errNum, fun := range xgb.NewExtErrorFuncs["XFree86-DRI"] { xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun } - xgb.ExtLock.Unlock() - return nil } @@ -137,6 +136,8 @@ type AuthConnectionCookie struct { // 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 { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() 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.") } @@ -148,6 +149,8 @@ func AuthConnection(c *xgb.Conn, Screen uint32, Magic uint32) AuthConnectionCook // AuthConnectionUnchecked 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 { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() 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.") } @@ -202,7 +205,9 @@ func authConnectionRequest(c *xgb.Conn, Screen uint32, Magic uint32) []byte { b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XFree86-DRI"] + c.ExtLock.RUnlock() b += 1 buf[b] = 11 // request opcode @@ -228,6 +233,8 @@ type CloseConnectionCookie struct { // 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 { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() 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.") } @@ -239,6 +246,8 @@ func CloseConnection(c *xgb.Conn, Screen uint32) CloseConnectionCookie { // CloseConnectionChecked sends a checked request. // If an error occurs, it can be retrieved using CloseConnectionCookie.Check() func CloseConnectionChecked(c *xgb.Conn, Screen uint32) CloseConnectionCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() 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.") } @@ -260,7 +269,9 @@ func closeConnectionRequest(c *xgb.Conn, Screen uint32) []byte { b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XFree86-DRI"] + c.ExtLock.RUnlock() b += 1 buf[b] = 3 // request opcode @@ -283,6 +294,8 @@ type CreateContextCookie struct { // 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 { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() 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.") } @@ -294,6 +307,8 @@ func CreateContext(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) Cr // CreateContextUnchecked 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 { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() 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.") } @@ -348,7 +363,9 @@ func createContextRequest(c *xgb.Conn, Screen uint32, Visual uint32, Context uin b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XFree86-DRI"] + c.ExtLock.RUnlock() b += 1 buf[b] = 5 // request opcode @@ -377,6 +394,8 @@ type CreateDrawableCookie struct { // 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 { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() 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.") } @@ -388,6 +407,8 @@ func CreateDrawable(c *xgb.Conn, Screen uint32, Drawable uint32) CreateDrawableC // CreateDrawableUnchecked 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 { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() 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.") } @@ -442,7 +463,9 @@ func createDrawableRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte { b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XFree86-DRI"] + c.ExtLock.RUnlock() b += 1 buf[b] = 7 // request opcode @@ -468,6 +491,8 @@ type DestroyContextCookie struct { // DestroyContext 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 { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() 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.") } @@ -479,6 +504,8 @@ func DestroyContext(c *xgb.Conn, Screen uint32, Context uint32) DestroyContextCo // 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 { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() 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.") } @@ -500,7 +527,9 @@ func destroyContextRequest(c *xgb.Conn, Screen uint32, Context uint32) []byte { b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XFree86-DRI"] + c.ExtLock.RUnlock() b += 1 buf[b] = 6 // request opcode @@ -526,6 +555,8 @@ type DestroyDrawableCookie struct { // 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 { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() 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.") } @@ -537,6 +568,8 @@ func DestroyDrawable(c *xgb.Conn, Screen uint32, Drawable uint32) DestroyDrawabl // 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 { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() 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.") } @@ -558,7 +591,9 @@ func destroyDrawableRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XFree86-DRI"] + c.ExtLock.RUnlock() b += 1 buf[b] = 8 // request opcode @@ -584,6 +619,8 @@ type GetClientDriverNameCookie struct { // 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 { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() 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.") } @@ -595,6 +632,8 @@ func GetClientDriverName(c *xgb.Conn, Screen uint32) GetClientDriverNameCookie { // GetClientDriverNameUnchecked 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 { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() 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.") } @@ -672,7 +711,9 @@ func getClientDriverNameRequest(c *xgb.Conn, Screen uint32) []byte { b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XFree86-DRI"] + c.ExtLock.RUnlock() b += 1 buf[b] = 4 // request opcode @@ -695,6 +736,8 @@ type GetDeviceInfoCookie struct { // 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 { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() 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.") } @@ -706,6 +749,8 @@ func GetDeviceInfo(c *xgb.Conn, Screen uint32) GetDeviceInfoCookie { // 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 { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() 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.") } @@ -787,7 +832,9 @@ func getDeviceInfoRequest(c *xgb.Conn, Screen uint32) []byte { b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XFree86-DRI"] + c.ExtLock.RUnlock() b += 1 buf[b] = 10 // request opcode @@ -810,6 +857,8 @@ type GetDrawableInfoCookie struct { // GetDrawableInfo sends a checked request. // If an error occurs, it will be returned with the reply by calling GetDrawableInfoCookie.Reply() func GetDrawableInfo(c *xgb.Conn, Screen uint32, Drawable uint32) GetDrawableInfoCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XFree86-DRI"]; !ok { panic("Cannot issue request 'GetDrawableInfo' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } @@ -821,6 +870,8 @@ func GetDrawableInfo(c *xgb.Conn, Screen uint32, Drawable uint32) GetDrawableInf // GetDrawableInfoUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetDrawableInfoUnchecked(c *xgb.Conn, Screen uint32, Drawable uint32) GetDrawableInfoCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XFree86-DRI"]; !ok { panic("Cannot issue request 'GetDrawableInfo' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") } @@ -922,7 +973,9 @@ func getDrawableInfoRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XFree86-DRI"] + c.ExtLock.RUnlock() b += 1 buf[b] = 9 // request opcode @@ -948,6 +1001,8 @@ type OpenConnectionCookie struct { // 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 { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() 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.") } @@ -959,6 +1014,8 @@ func OpenConnection(c *xgb.Conn, Screen uint32) OpenConnectionCookie { // OpenConnectionUnchecked 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 { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() 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.") } @@ -1032,7 +1089,9 @@ func openConnectionRequest(c *xgb.Conn, Screen uint32) []byte { b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XFree86-DRI"] + c.ExtLock.RUnlock() b += 1 buf[b] = 2 // request opcode @@ -1055,6 +1114,8 @@ type QueryDirectRenderingCapableCookie struct { // 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 { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() 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.") } @@ -1066,6 +1127,8 @@ func QueryDirectRenderingCapable(c *xgb.Conn, Screen uint32) QueryDirectRenderin // QueryDirectRenderingCapableUnchecked 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 { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() 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.") } @@ -1124,7 +1187,9 @@ func queryDirectRenderingCapableRequest(c *xgb.Conn, Screen uint32) []byte { b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XFree86-DRI"] + c.ExtLock.RUnlock() b += 1 buf[b] = 1 // request opcode @@ -1147,6 +1212,8 @@ type QueryVersionCookie struct { // 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 { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() 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.") } @@ -1158,6 +1225,8 @@ func QueryVersion(c *xgb.Conn) QueryVersionCookie { // 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 { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() 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.") } @@ -1220,7 +1289,9 @@ func queryVersionRequest(c *xgb.Conn) []byte { b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XFree86-DRI"] + c.ExtLock.RUnlock() b += 1 buf[b] = 0 // request opcode -- cgit v1.2.3 From 3906399e7c2a40fbaf355de572cf50a314083f64 Mon Sep 17 00:00:00 2001 From: aarzilli Date: Wed, 18 Jan 2017 10:52:16 +0100 Subject: Regenerated from xcb-proto 1.12 --- nexgb/xf86dri/xf86dri.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'nexgb/xf86dri') diff --git a/nexgb/xf86dri/xf86dri.go b/nexgb/xf86dri/xf86dri.go index 51c9322..06f49a0 100644 --- a/nexgb/xf86dri/xf86dri.go +++ b/nexgb/xf86dri/xf86dri.go @@ -896,8 +896,7 @@ type GetDrawableInfoReply struct { BackY int16 NumBackClipRects uint32 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)) } // Reply blocks and returns the reply data for a GetDrawableInfo request. @@ -958,8 +957,6 @@ func getDrawableInfoReply(buf []byte) *GetDrawableInfoReply { v.ClipRects = make([]DrmClipRect, v.NumClipRects) b += DrmClipRectReadList(buf[b:], v.ClipRects) - b = (b + 3) & ^3 // alignment gap - v.BackClipRects = make([]DrmClipRect, v.NumBackClipRects) b += DrmClipRectReadList(buf[b:], v.BackClipRects) -- cgit v1.2.3