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/xinerama/xinerama.go | 633 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 633 insertions(+) create mode 100644 nexgb/xinerama/xinerama.go (limited to 'nexgb/xinerama') diff --git a/nexgb/xinerama/xinerama.go b/nexgb/xinerama/xinerama.go new file mode 100644 index 0000000..eb7cd9a --- /dev/null +++ b/nexgb/xinerama/xinerama.go @@ -0,0 +1,633 @@ +package xinerama + +/* + This file was generated by xinerama.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 XINERAMA extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 8, "XINERAMA").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named XINERAMA could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["XINERAMA"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["XINERAMA"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["XINERAMA"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["XINERAMA"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["XINERAMA"] = 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' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + +// 'ScreenInfo' struct definition +// Size: 8 +type ScreenInfo struct { + XOrg int16 + YOrg int16 + Width uint16 + Height uint16 +} + +// Struct read ScreenInfo +func ScreenInfoRead(buf []byte, v *ScreenInfo) int { + b := 0 + + v.XOrg = int16(xgb.Get16(buf[b:])) + b += 2 + + v.YOrg = int16(xgb.Get16(buf[b:])) + b += 2 + + v.Width = xgb.Get16(buf[b:]) + b += 2 + + v.Height = xgb.Get16(buf[b:]) + b += 2 + + return b +} + +// Struct list read ScreenInfo +func ScreenInfoReadList(buf []byte, dest []ScreenInfo) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = ScreenInfo{} + b += ScreenInfoRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Struct write ScreenInfo +func (v ScreenInfo) Bytes() []byte { + buf := make([]byte, 8) + b := 0 + + xgb.Put16(buf[b:], uint16(v.XOrg)) + b += 2 + + xgb.Put16(buf[b:], uint16(v.YOrg)) + b += 2 + + xgb.Put16(buf[b:], v.Width) + b += 2 + + xgb.Put16(buf[b:], v.Height) + b += 2 + + return buf +} + +// Write struct list ScreenInfo +func ScreenInfoListBytes(buf []byte, list []ScreenInfo) 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: 8 +type QueryVersionCookie struct { + *xgb.Cookie +} + +func QueryVersion(c *xgb.Conn, Major byte, Minor byte) QueryVersionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c, Major, Minor), cookie) + return QueryVersionCookie{cookie} +} + +func QueryVersionUnchecked(c *xgb.Conn, Major byte, Minor byte) QueryVersionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c, Major, Minor), cookie) + return QueryVersionCookie{cookie} +} + +// Request reply for QueryVersion +// size: 12 +type QueryVersionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Major uint16 + Minor uint16 +} + +// 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.Major = xgb.Get16(buf[b:]) + b += 2 + + v.Minor = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Write request to wire for QueryVersion +func queryVersionRequest(c *xgb.Conn, Major byte, Minor byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINERAMA"] + 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 + + buf[b] = Major + b += 1 + + buf[b] = Minor + b += 1 + + return buf +} + +// Request GetState +// size: 8 +type GetStateCookie struct { + *xgb.Cookie +} + +func GetState(c *xgb.Conn, Window xproto.Window) GetStateCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getStateRequest(c, Window), cookie) + return GetStateCookie{cookie} +} + +func GetStateUnchecked(c *xgb.Conn, Window xproto.Window) GetStateCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getStateRequest(c, Window), cookie) + return GetStateCookie{cookie} +} + +// Request reply for GetState +// size: 12 +type GetStateReply struct { + Sequence uint16 + Length uint32 + State byte + Window xproto.Window +} + +// Waits and reads reply data from request GetState +func (cook GetStateCookie) Reply() (*GetStateReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getStateReply(buf), nil +} + +// Read reply into structure from buffer for GetState +func getStateReply(buf []byte) *GetStateReply { + v := new(GetStateReply) + b := 1 // skip reply determinant + + v.State = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Window = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Write request to wire for GetState +func getStateRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINERAMA"] + 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:], uint32(Window)) + b += 4 + + return buf +} + +// Request GetScreenCount +// size: 8 +type GetScreenCountCookie struct { + *xgb.Cookie +} + +func GetScreenCount(c *xgb.Conn, Window xproto.Window) GetScreenCountCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getScreenCountRequest(c, Window), cookie) + return GetScreenCountCookie{cookie} +} + +func GetScreenCountUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenCountCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getScreenCountRequest(c, Window), cookie) + return GetScreenCountCookie{cookie} +} + +// Request reply for GetScreenCount +// size: 12 +type GetScreenCountReply struct { + Sequence uint16 + Length uint32 + ScreenCount byte + Window xproto.Window +} + +// Waits and reads reply data from request GetScreenCount +func (cook GetScreenCountCookie) Reply() (*GetScreenCountReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getScreenCountReply(buf), nil +} + +// Read reply into structure from buffer for GetScreenCount +func getScreenCountReply(buf []byte) *GetScreenCountReply { + v := new(GetScreenCountReply) + b := 1 // skip reply determinant + + v.ScreenCount = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Window = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Write request to wire for GetScreenCount +func getScreenCountRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINERAMA"] + 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:], uint32(Window)) + b += 4 + + return buf +} + +// Request GetScreenSize +// size: 12 +type GetScreenSizeCookie struct { + *xgb.Cookie +} + +func GetScreenSize(c *xgb.Conn, Window xproto.Window, Screen uint32) GetScreenSizeCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getScreenSizeRequest(c, Window, Screen), cookie) + return GetScreenSizeCookie{cookie} +} + +func GetScreenSizeUnchecked(c *xgb.Conn, Window xproto.Window, Screen uint32) GetScreenSizeCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getScreenSizeRequest(c, Window, Screen), cookie) + return GetScreenSizeCookie{cookie} +} + +// Request reply for GetScreenSize +// size: 24 +type GetScreenSizeReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Width uint32 + Height uint32 + Window xproto.Window + Screen uint32 +} + +// Waits and reads reply data from request GetScreenSize +func (cook GetScreenSizeCookie) Reply() (*GetScreenSizeReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getScreenSizeReply(buf), nil +} + +// Read reply into structure from buffer for GetScreenSize +func getScreenSizeReply(buf []byte) *GetScreenSizeReply { + v := new(GetScreenSizeReply) + 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.Width = xgb.Get32(buf[b:]) + b += 4 + + v.Height = xgb.Get32(buf[b:]) + b += 4 + + v.Window = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + v.Screen = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for GetScreenSize +func getScreenSizeRequest(c *xgb.Conn, Window xproto.Window, Screen uint32) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINERAMA"] + 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:], uint32(Window)) + b += 4 + + xgb.Put32(buf[b:], Screen) + b += 4 + + return buf +} + +// Request IsActive +// size: 4 +type IsActiveCookie struct { + *xgb.Cookie +} + +func IsActive(c *xgb.Conn) IsActiveCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(isActiveRequest(c), cookie) + return IsActiveCookie{cookie} +} + +func IsActiveUnchecked(c *xgb.Conn) IsActiveCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(isActiveRequest(c), cookie) + return IsActiveCookie{cookie} +} + +// Request reply for IsActive +// size: 12 +type IsActiveReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + State uint32 +} + +// Waits and reads reply data from request IsActive +func (cook IsActiveCookie) Reply() (*IsActiveReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return isActiveReply(buf), nil +} + +// Read reply into structure from buffer for IsActive +func isActiveReply(buf []byte) *IsActiveReply { + v := new(IsActiveReply) + 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.State = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for IsActive +func isActiveRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINERAMA"] + 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 + + return buf +} + +// Request QueryScreens +// size: 4 +type QueryScreensCookie struct { + *xgb.Cookie +} + +func QueryScreens(c *xgb.Conn) QueryScreensCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(queryScreensRequest(c), cookie) + return QueryScreensCookie{cookie} +} + +func QueryScreensUnchecked(c *xgb.Conn) QueryScreensCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(queryScreensRequest(c), cookie) + return QueryScreensCookie{cookie} +} + +// Request reply for QueryScreens +// size: (32 + xgb.Pad((int(Number) * 8))) +type QueryScreensReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Number uint32 + // padding: 20 bytes + ScreenInfo []ScreenInfo // size: xgb.Pad((int(Number) * 8)) +} + +// Waits and reads reply data from request QueryScreens +func (cook QueryScreensCookie) Reply() (*QueryScreensReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return queryScreensReply(buf), nil +} + +// Read reply into structure from buffer for QueryScreens +func queryScreensReply(buf []byte) *QueryScreensReply { + v := new(QueryScreensReply) + 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.Number = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.ScreenInfo = make([]ScreenInfo, v.Number) + b += ScreenInfoReadList(buf[b:], v.ScreenInfo) + + return v +} + +// Write request to wire for QueryScreens +func queryScreensRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINERAMA"] + 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 + + 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/xinerama/xinerama.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'nexgb/xinerama') diff --git a/nexgb/xinerama/xinerama.go b/nexgb/xinerama/xinerama.go index eb7cd9a..587b628 100644 --- a/nexgb/xinerama/xinerama.go +++ b/nexgb/xinerama/xinerama.go @@ -1,7 +1,8 @@ +// Package xinerama is the X client API for the XINERAMA extension. package xinerama /* - This file was generated by xinerama.xml on May 10 2012 4:20:28pm EDT. + This file was generated by xinerama.xml on May 10 2012 8:04:32pm EDT. This file is automatically generated. Edit at your peril! */ @@ -39,6 +40,14 @@ func init() { xgb.NewExtErrorFuncs["XINERAMA"] = make(map[int]xgb.NewErrorFun) } +// 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' @@ -55,14 +64,6 @@ func init() { // 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' - // 'ScreenInfo' struct definition // Size: 8 type ScreenInfo 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/xinerama/xinerama.go | 126 +++++++++++++++++++++++++-------------------- 1 file changed, 71 insertions(+), 55 deletions(-) (limited to 'nexgb/xinerama') diff --git a/nexgb/xinerama/xinerama.go b/nexgb/xinerama/xinerama.go index 587b628..cc4eaaa 100644 --- a/nexgb/xinerama/xinerama.go +++ b/nexgb/xinerama/xinerama.go @@ -2,7 +2,7 @@ package xinerama /* - This file was generated by xinerama.xml on May 10 2012 8:04:32pm EDT. + This file was generated by xinerama.xml on May 10 2012 11:56:19pm EDT. This file is automatically generated. Edit at your peril! */ @@ -64,8 +64,6 @@ func init() { // Skipping definition for base type 'Card8' -// 'ScreenInfo' struct definition -// Size: 8 type ScreenInfo struct { XOrg int16 YOrg int16 @@ -73,7 +71,7 @@ type ScreenInfo struct { Height uint16 } -// Struct read ScreenInfo +// ScreenInfoRead reads a byte slice into a ScreenInfo value. func ScreenInfoRead(buf []byte, v *ScreenInfo) int { b := 0 @@ -92,7 +90,7 @@ func ScreenInfoRead(buf []byte, v *ScreenInfo) int { return b } -// Struct list read ScreenInfo +// ScreenInfoReadList reads a byte slice into a list of ScreenInfo values. func ScreenInfoReadList(buf []byte, dest []ScreenInfo) int { b := 0 for i := 0; i < len(dest); i++ { @@ -102,7 +100,7 @@ func ScreenInfoReadList(buf []byte, dest []ScreenInfo) int { return xgb.Pad(b) } -// Struct write ScreenInfo +// Bytes writes a ScreenInfo value to a byte slice. func (v ScreenInfo) Bytes() []byte { buf := make([]byte, 8) b := 0 @@ -122,7 +120,7 @@ func (v ScreenInfo) Bytes() []byte { return buf } -// Write struct list ScreenInfo +// ScreenInfoListBytes writes a list of %s(MISSING) values to a byte slice. func ScreenInfoListBytes(buf []byte, list []ScreenInfo) int { b := 0 var structBytes []byte @@ -134,35 +132,37 @@ func ScreenInfoListBytes(buf []byte, list []ScreenInfo) int { return b } -// Request QueryVersion -// size: 8 +// 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, Major byte, Minor byte) QueryVersionCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryVersionRequest(c, Major, Minor), 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, Major byte, Minor byte) QueryVersionCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryVersionRequest(c, Major, Minor), cookie) return QueryVersionCookie{cookie} } -// Request reply for QueryVersion -// size: 12 +// 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 Major uint16 Minor uint16 } -// 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 { @@ -174,7 +174,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 @@ -197,6 +197,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, Major byte, Minor byte) []byte { size := 8 b := 0 @@ -220,34 +221,36 @@ func queryVersionRequest(c *xgb.Conn, Major byte, Minor byte) []byte { return buf } -// Request GetState -// size: 8 +// GetStateCookie is a cookie used only for GetState requests. type GetStateCookie struct { *xgb.Cookie } +// GetState sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetStateCookie.Reply() func GetState(c *xgb.Conn, Window xproto.Window) GetStateCookie { cookie := c.NewCookie(true, true) c.NewRequest(getStateRequest(c, Window), cookie) return GetStateCookie{cookie} } +// GetStateUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetStateUnchecked(c *xgb.Conn, Window xproto.Window) GetStateCookie { cookie := c.NewCookie(false, true) c.NewRequest(getStateRequest(c, Window), cookie) return GetStateCookie{cookie} } -// Request reply for GetState -// size: 12 +// GetStateReply represents the data returned from a GetState request. type GetStateReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply State byte Window xproto.Window } -// Waits and reads reply data from request GetState +// Reply blocks and returns the reply data for a GetState request. func (cook GetStateCookie) Reply() (*GetStateReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -259,7 +262,7 @@ func (cook GetStateCookie) Reply() (*GetStateReply, error) { return getStateReply(buf), nil } -// Read reply into structure from buffer for GetState +// getStateReply reads a byte slice into a GetStateReply value. func getStateReply(buf []byte) *GetStateReply { v := new(GetStateReply) b := 1 // skip reply determinant @@ -280,6 +283,7 @@ func getStateReply(buf []byte) *GetStateReply { } // Write request to wire for GetState +// getStateRequest writes a GetState request to a byte slice. func getStateRequest(c *xgb.Conn, Window xproto.Window) []byte { size := 8 b := 0 @@ -300,34 +304,36 @@ func getStateRequest(c *xgb.Conn, Window xproto.Window) []byte { return buf } -// Request GetScreenCount -// size: 8 +// GetScreenCountCookie is a cookie used only for GetScreenCount requests. type GetScreenCountCookie struct { *xgb.Cookie } +// GetScreenCount sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetScreenCountCookie.Reply() func GetScreenCount(c *xgb.Conn, Window xproto.Window) GetScreenCountCookie { cookie := c.NewCookie(true, true) c.NewRequest(getScreenCountRequest(c, Window), cookie) return GetScreenCountCookie{cookie} } +// GetScreenCountUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetScreenCountUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenCountCookie { cookie := c.NewCookie(false, true) c.NewRequest(getScreenCountRequest(c, Window), cookie) return GetScreenCountCookie{cookie} } -// Request reply for GetScreenCount -// size: 12 +// GetScreenCountReply represents the data returned from a GetScreenCount request. type GetScreenCountReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply ScreenCount byte Window xproto.Window } -// Waits and reads reply data from request GetScreenCount +// Reply blocks and returns the reply data for a GetScreenCount request. func (cook GetScreenCountCookie) Reply() (*GetScreenCountReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -339,7 +345,7 @@ func (cook GetScreenCountCookie) Reply() (*GetScreenCountReply, error) { return getScreenCountReply(buf), nil } -// Read reply into structure from buffer for GetScreenCount +// getScreenCountReply reads a byte slice into a GetScreenCountReply value. func getScreenCountReply(buf []byte) *GetScreenCountReply { v := new(GetScreenCountReply) b := 1 // skip reply determinant @@ -360,6 +366,7 @@ func getScreenCountReply(buf []byte) *GetScreenCountReply { } // Write request to wire for GetScreenCount +// getScreenCountRequest writes a GetScreenCount request to a byte slice. func getScreenCountRequest(c *xgb.Conn, Window xproto.Window) []byte { size := 8 b := 0 @@ -380,29 +387,31 @@ func getScreenCountRequest(c *xgb.Conn, Window xproto.Window) []byte { return buf } -// Request GetScreenSize -// size: 12 +// GetScreenSizeCookie is a cookie used only for GetScreenSize requests. type GetScreenSizeCookie struct { *xgb.Cookie } +// GetScreenSize sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetScreenSizeCookie.Reply() func GetScreenSize(c *xgb.Conn, Window xproto.Window, Screen uint32) GetScreenSizeCookie { cookie := c.NewCookie(true, true) c.NewRequest(getScreenSizeRequest(c, Window, Screen), cookie) return GetScreenSizeCookie{cookie} } +// GetScreenSizeUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetScreenSizeUnchecked(c *xgb.Conn, Window xproto.Window, Screen uint32) GetScreenSizeCookie { cookie := c.NewCookie(false, true) c.NewRequest(getScreenSizeRequest(c, Window, Screen), cookie) return GetScreenSizeCookie{cookie} } -// Request reply for GetScreenSize -// size: 24 +// GetScreenSizeReply represents the data returned from a GetScreenSize request. type GetScreenSizeReply 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 Width uint32 Height uint32 @@ -410,7 +419,7 @@ type GetScreenSizeReply struct { Screen uint32 } -// Waits and reads reply data from request GetScreenSize +// Reply blocks and returns the reply data for a GetScreenSize request. func (cook GetScreenSizeCookie) Reply() (*GetScreenSizeReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -422,7 +431,7 @@ func (cook GetScreenSizeCookie) Reply() (*GetScreenSizeReply, error) { return getScreenSizeReply(buf), nil } -// Read reply into structure from buffer for GetScreenSize +// getScreenSizeReply reads a byte slice into a GetScreenSizeReply value. func getScreenSizeReply(buf []byte) *GetScreenSizeReply { v := new(GetScreenSizeReply) b := 1 // skip reply determinant @@ -451,6 +460,7 @@ func getScreenSizeReply(buf []byte) *GetScreenSizeReply { } // Write request to wire for GetScreenSize +// getScreenSizeRequest writes a GetScreenSize request to a byte slice. func getScreenSizeRequest(c *xgb.Conn, Window xproto.Window, Screen uint32) []byte { size := 12 b := 0 @@ -474,34 +484,36 @@ func getScreenSizeRequest(c *xgb.Conn, Window xproto.Window, Screen uint32) []by return buf } -// Request IsActive -// size: 4 +// IsActiveCookie is a cookie used only for IsActive requests. type IsActiveCookie struct { *xgb.Cookie } +// IsActive sends a checked request. +// If an error occurs, it will be returned with the reply by calling IsActiveCookie.Reply() func IsActive(c *xgb.Conn) IsActiveCookie { cookie := c.NewCookie(true, true) c.NewRequest(isActiveRequest(c), cookie) return IsActiveCookie{cookie} } +// IsActiveUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func IsActiveUnchecked(c *xgb.Conn) IsActiveCookie { cookie := c.NewCookie(false, true) c.NewRequest(isActiveRequest(c), cookie) return IsActiveCookie{cookie} } -// Request reply for IsActive -// size: 12 +// IsActiveReply represents the data returned from a IsActive request. type IsActiveReply 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 State uint32 } -// Waits and reads reply data from request IsActive +// Reply blocks and returns the reply data for a IsActive request. func (cook IsActiveCookie) Reply() (*IsActiveReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -513,7 +525,7 @@ func (cook IsActiveCookie) Reply() (*IsActiveReply, error) { return isActiveReply(buf), nil } -// Read reply into structure from buffer for IsActive +// isActiveReply reads a byte slice into a IsActiveReply value. func isActiveReply(buf []byte) *IsActiveReply { v := new(IsActiveReply) b := 1 // skip reply determinant @@ -533,6 +545,7 @@ func isActiveReply(buf []byte) *IsActiveReply { } // Write request to wire for IsActive +// isActiveRequest writes a IsActive request to a byte slice. func isActiveRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -550,36 +563,38 @@ func isActiveRequest(c *xgb.Conn) []byte { return buf } -// Request QueryScreens -// size: 4 +// QueryScreensCookie is a cookie used only for QueryScreens requests. type QueryScreensCookie struct { *xgb.Cookie } +// QueryScreens sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryScreensCookie.Reply() func QueryScreens(c *xgb.Conn) QueryScreensCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryScreensRequest(c), cookie) return QueryScreensCookie{cookie} } +// QueryScreensUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryScreensUnchecked(c *xgb.Conn) QueryScreensCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryScreensRequest(c), cookie) return QueryScreensCookie{cookie} } -// Request reply for QueryScreens -// size: (32 + xgb.Pad((int(Number) * 8))) +// QueryScreensReply represents the data returned from a QueryScreens request. type QueryScreensReply 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 Number uint32 // padding: 20 bytes ScreenInfo []ScreenInfo // size: xgb.Pad((int(Number) * 8)) } -// Waits and reads reply data from request QueryScreens +// Reply blocks and returns the reply data for a QueryScreens request. func (cook QueryScreensCookie) Reply() (*QueryScreensReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -591,7 +606,7 @@ func (cook QueryScreensCookie) Reply() (*QueryScreensReply, error) { return queryScreensReply(buf), nil } -// Read reply into structure from buffer for QueryScreens +// queryScreensReply reads a byte slice into a QueryScreensReply value. func queryScreensReply(buf []byte) *QueryScreensReply { v := new(QueryScreensReply) b := 1 // skip reply determinant @@ -616,6 +631,7 @@ func queryScreensReply(buf []byte) *QueryScreensReply { } // Write request to wire for QueryScreens +// queryScreensRequest writes a QueryScreens request to a byte slice. func queryScreensRequest(c *xgb.Conn) []byte { size := 4 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/xinerama/xinerama.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'nexgb/xinerama') diff --git a/nexgb/xinerama/xinerama.go b/nexgb/xinerama/xinerama.go index cc4eaaa..b03a381 100644 --- a/nexgb/xinerama/xinerama.go +++ b/nexgb/xinerama/xinerama.go @@ -2,7 +2,7 @@ package xinerama /* - This file was generated by xinerama.xml on May 10 2012 11:56:19pm EDT. + This file was generated by xinerama.xml on May 11 2012 1:58:36am EDT. This file is automatically generated. Edit at your peril! */ @@ -40,14 +40,6 @@ func init() { xgb.NewExtErrorFuncs["XINERAMA"] = make(map[int]xgb.NewErrorFun) } -// 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' @@ -64,6 +56,14 @@ func init() { // 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' + type ScreenInfo struct { XOrg int16 YOrg 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/xinerama/xinerama.go | 50 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 7 deletions(-) (limited to 'nexgb/xinerama') diff --git a/nexgb/xinerama/xinerama.go b/nexgb/xinerama/xinerama.go index b03a381..51b270a 100644 --- a/nexgb/xinerama/xinerama.go +++ b/nexgb/xinerama/xinerama.go @@ -2,7 +2,7 @@ package xinerama /* - This file was generated by xinerama.xml on May 11 2012 1:58:36am EDT. + This file was generated by xinerama.xml on May 11 2012 11:57:20pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,6 +40,12 @@ func init() { xgb.NewExtErrorFuncs["XINERAMA"] = make(map[int]xgb.NewErrorFun) } +// 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' @@ -58,12 +64,6 @@ func init() { // Skipping definition for base type 'Int16' -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - type ScreenInfo struct { XOrg int16 YOrg 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, Major byte, Minor byte) QueryVersionCookie { + if _, ok := c.Extensions["XINERAMA"]; !ok { + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, true) c.NewRequest(queryVersionRequest(c, Major, Minor), cookie) return QueryVersionCookie{cookie} @@ -148,6 +151,9 @@ func QueryVersion(c *xgb.Conn, Major byte, Minor byte) 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, Major byte, Minor byte) QueryVersionCookie { + if _, ok := c.Extensions["XINERAMA"]; !ok { + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, true) c.NewRequest(queryVersionRequest(c, Major, Minor), cookie) return QueryVersionCookie{cookie} @@ -229,6 +235,9 @@ type GetStateCookie struct { // GetState sends a checked request. // If an error occurs, it will be returned with the reply by calling GetStateCookie.Reply() func GetState(c *xgb.Conn, Window xproto.Window) GetStateCookie { + if _, ok := c.Extensions["XINERAMA"]; !ok { + panic("Cannot issue request 'GetState' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, true) c.NewRequest(getStateRequest(c, Window), cookie) return GetStateCookie{cookie} @@ -237,6 +246,9 @@ func GetState(c *xgb.Conn, Window xproto.Window) GetStateCookie { // GetStateUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetStateUnchecked(c *xgb.Conn, Window xproto.Window) GetStateCookie { + if _, ok := c.Extensions["XINERAMA"]; !ok { + panic("Cannot issue request 'GetState' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, true) c.NewRequest(getStateRequest(c, Window), cookie) return GetStateCookie{cookie} @@ -312,6 +324,9 @@ type GetScreenCountCookie struct { // GetScreenCount sends a checked request. // If an error occurs, it will be returned with the reply by calling GetScreenCountCookie.Reply() func GetScreenCount(c *xgb.Conn, Window xproto.Window) GetScreenCountCookie { + if _, ok := c.Extensions["XINERAMA"]; !ok { + panic("Cannot issue request 'GetScreenCount' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, true) c.NewRequest(getScreenCountRequest(c, Window), cookie) return GetScreenCountCookie{cookie} @@ -320,6 +335,9 @@ func GetScreenCount(c *xgb.Conn, Window xproto.Window) GetScreenCountCookie { // GetScreenCountUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetScreenCountUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenCountCookie { + if _, ok := c.Extensions["XINERAMA"]; !ok { + panic("Cannot issue request 'GetScreenCount' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, true) c.NewRequest(getScreenCountRequest(c, Window), cookie) return GetScreenCountCookie{cookie} @@ -395,6 +413,9 @@ type GetScreenSizeCookie struct { // GetScreenSize sends a checked request. // If an error occurs, it will be returned with the reply by calling GetScreenSizeCookie.Reply() func GetScreenSize(c *xgb.Conn, Window xproto.Window, Screen uint32) GetScreenSizeCookie { + if _, ok := c.Extensions["XINERAMA"]; !ok { + panic("Cannot issue request 'GetScreenSize' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, true) c.NewRequest(getScreenSizeRequest(c, Window, Screen), cookie) return GetScreenSizeCookie{cookie} @@ -403,6 +424,9 @@ func GetScreenSize(c *xgb.Conn, Window xproto.Window, Screen uint32) GetScreenSi // GetScreenSizeUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetScreenSizeUnchecked(c *xgb.Conn, Window xproto.Window, Screen uint32) GetScreenSizeCookie { + if _, ok := c.Extensions["XINERAMA"]; !ok { + panic("Cannot issue request 'GetScreenSize' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, true) c.NewRequest(getScreenSizeRequest(c, Window, Screen), cookie) return GetScreenSizeCookie{cookie} @@ -492,6 +516,9 @@ type IsActiveCookie struct { // IsActive sends a checked request. // If an error occurs, it will be returned with the reply by calling IsActiveCookie.Reply() func IsActive(c *xgb.Conn) IsActiveCookie { + if _, ok := c.Extensions["XINERAMA"]; !ok { + panic("Cannot issue request 'IsActive' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, true) c.NewRequest(isActiveRequest(c), cookie) return IsActiveCookie{cookie} @@ -500,6 +527,9 @@ func IsActive(c *xgb.Conn) IsActiveCookie { // IsActiveUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func IsActiveUnchecked(c *xgb.Conn) IsActiveCookie { + if _, ok := c.Extensions["XINERAMA"]; !ok { + panic("Cannot issue request 'IsActive' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, true) c.NewRequest(isActiveRequest(c), cookie) return IsActiveCookie{cookie} @@ -571,6 +601,9 @@ type QueryScreensCookie struct { // QueryScreens sends a checked request. // If an error occurs, it will be returned with the reply by calling QueryScreensCookie.Reply() func QueryScreens(c *xgb.Conn) QueryScreensCookie { + if _, ok := c.Extensions["XINERAMA"]; !ok { + panic("Cannot issue request 'QueryScreens' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, true) c.NewRequest(queryScreensRequest(c), cookie) return QueryScreensCookie{cookie} @@ -579,6 +612,9 @@ func QueryScreens(c *xgb.Conn) QueryScreensCookie { // QueryScreensUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryScreensUnchecked(c *xgb.Conn) QueryScreensCookie { + if _, ok := c.Extensions["XINERAMA"]; !ok { + panic("Cannot issue request 'QueryScreens' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, true) c.NewRequest(queryScreensRequest(c), cookie) return QueryScreensCookie{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/xinerama/xinerama.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'nexgb/xinerama') diff --git a/nexgb/xinerama/xinerama.go b/nexgb/xinerama/xinerama.go index 51b270a..24cba4a 100644 --- a/nexgb/xinerama/xinerama.go +++ b/nexgb/xinerama/xinerama.go @@ -2,7 +2,7 @@ package xinerama /* - This file was generated by xinerama.xml on May 11 2012 11:57:20pm EDT. + This file was generated by xinerama.xml on May 26 2012 6:23:14pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,10 +40,6 @@ func init() { xgb.NewExtErrorFuncs["XINERAMA"] = make(map[int]xgb.NewErrorFun) } -// 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 +60,10 @@ func init() { // Skipping definition for base type 'Int16' +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Void' + type ScreenInfo struct { XOrg int16 YOrg int16 @@ -120,7 +120,7 @@ func (v ScreenInfo) Bytes() []byte { return buf } -// ScreenInfoListBytes writes a list of %s(MISSING) values to a byte slice. +// ScreenInfoListBytes writes a list of ScreenInfo values to a byte slice. func ScreenInfoListBytes(buf []byte, list []ScreenInfo) 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/xinerama/xinerama.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'nexgb/xinerama') diff --git a/nexgb/xinerama/xinerama.go b/nexgb/xinerama/xinerama.go index 24cba4a..927ab82 100644 --- a/nexgb/xinerama/xinerama.go +++ b/nexgb/xinerama/xinerama.go @@ -2,7 +2,7 @@ package xinerama /* - This file was generated by xinerama.xml on May 26 2012 6:23:14pm EDT. + This file was generated by xinerama.xml on Jun 5 2012 12:12:00am EDT. This file is automatically generated. Edit at your peril! */ @@ -40,6 +40,14 @@ func init() { xgb.NewExtErrorFuncs["XINERAMA"] = 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' @@ -56,14 +64,6 @@ 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' - type ScreenInfo struct { XOrg int16 YOrg 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/xinerama/xinerama.go | 394 ++++++++++++++++++++++----------------------- 1 file changed, 197 insertions(+), 197 deletions(-) (limited to 'nexgb/xinerama') diff --git a/nexgb/xinerama/xinerama.go b/nexgb/xinerama/xinerama.go index 927ab82..dd3732f 100644 --- a/nexgb/xinerama/xinerama.go +++ b/nexgb/xinerama/xinerama.go @@ -2,7 +2,7 @@ package xinerama /* - This file was generated by xinerama.xml on Jun 5 2012 12:12:00am EDT. + This file was generated by xinerama.xml on Aug 11 2013 8:39:44pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,30 +40,6 @@ func init() { xgb.NewExtErrorFuncs["XINERAMA"] = 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' - type ScreenInfo struct { XOrg int16 YOrg int16 @@ -132,189 +108,29 @@ func ScreenInfoListBytes(buf []byte, list []ScreenInfo) int { return b } -// 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, Major byte, Minor byte) QueryVersionCookie { - if _, ok := c.Extensions["XINERAMA"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(queryVersionRequest(c, Major, Minor), 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, Major byte, Minor byte) QueryVersionCookie { - if _, ok := c.Extensions["XINERAMA"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(queryVersionRequest(c, Major, Minor), 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 - Major uint16 - Minor uint16 -} - -// 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.Major = xgb.Get16(buf[b:]) - b += 2 - - v.Minor = xgb.Get16(buf[b:]) - b += 2 - - return v -} - -// Write request to wire for QueryVersion -// queryVersionRequest writes a QueryVersion request to a byte slice. -func queryVersionRequest(c *xgb.Conn, Major byte, Minor byte) []byte { - size := 8 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["XINERAMA"] - 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 - - buf[b] = Major - b += 1 - - buf[b] = Minor - b += 1 - - return buf -} - -// GetStateCookie is a cookie used only for GetState requests. -type GetStateCookie struct { - *xgb.Cookie -} - -// GetState sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetStateCookie.Reply() -func GetState(c *xgb.Conn, Window xproto.Window) GetStateCookie { - if _, ok := c.Extensions["XINERAMA"]; !ok { - panic("Cannot issue request 'GetState' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getStateRequest(c, Window), cookie) - return GetStateCookie{cookie} -} - -// GetStateUnchecked sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetStateUnchecked(c *xgb.Conn, Window xproto.Window) GetStateCookie { - if _, ok := c.Extensions["XINERAMA"]; !ok { - panic("Cannot issue request 'GetState' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(getStateRequest(c, Window), cookie) - return GetStateCookie{cookie} -} - -// GetStateReply represents the data returned from a GetState request. -type GetStateReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - State byte - Window xproto.Window -} - -// Reply blocks and returns the reply data for a GetState request. -func (cook GetStateCookie) Reply() (*GetStateReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil - } - return getStateReply(buf), nil -} - -// getStateReply reads a byte slice into a GetStateReply value. -func getStateReply(buf []byte) *GetStateReply { - v := new(GetStateReply) - b := 1 // skip reply determinant +// Skipping definition for base type 'Bool' - v.State = buf[b] - b += 1 +// Skipping definition for base type 'Byte' - v.Sequence = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Card8' - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 +// Skipping definition for base type 'Char' - v.Window = xproto.Window(xgb.Get32(buf[b:])) - b += 4 +// Skipping definition for base type 'Void' - return v -} +// Skipping definition for base type 'Double' -// Write request to wire for GetState -// getStateRequest writes a GetState request to a byte slice. -func getStateRequest(c *xgb.Conn, Window xproto.Window) []byte { - size := 8 - b := 0 - buf := make([]byte, size) +// Skipping definition for base type 'Float' - buf[b] = c.Extensions["XINERAMA"] - b += 1 +// Skipping definition for base type 'Int16' - buf[b] = 1 // request opcode - b += 1 +// Skipping definition for base type 'Int32' - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 +// Skipping definition for base type 'Int8' - xgb.Put32(buf[b:], uint32(Window)) - b += 4 +// Skipping definition for base type 'Card16' - return buf -} +// Skipping definition for base type 'Card32' // GetScreenCountCookie is a cookie used only for GetScreenCount requests. type GetScreenCountCookie struct { @@ -508,6 +324,95 @@ func getScreenSizeRequest(c *xgb.Conn, Window xproto.Window, Screen uint32) []by return buf } +// GetStateCookie is a cookie used only for GetState requests. +type GetStateCookie struct { + *xgb.Cookie +} + +// GetState sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetStateCookie.Reply() +func GetState(c *xgb.Conn, Window xproto.Window) GetStateCookie { + if _, ok := c.Extensions["XINERAMA"]; !ok { + panic("Cannot issue request 'GetState' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getStateRequest(c, Window), cookie) + return GetStateCookie{cookie} +} + +// GetStateUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetStateUnchecked(c *xgb.Conn, Window xproto.Window) GetStateCookie { + if _, ok := c.Extensions["XINERAMA"]; !ok { + panic("Cannot issue request 'GetState' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(getStateRequest(c, Window), cookie) + return GetStateCookie{cookie} +} + +// GetStateReply represents the data returned from a GetState request. +type GetStateReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + State byte + Window xproto.Window +} + +// Reply blocks and returns the reply data for a GetState request. +func (cook GetStateCookie) Reply() (*GetStateReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getStateReply(buf), nil +} + +// getStateReply reads a byte slice into a GetStateReply value. +func getStateReply(buf []byte) *GetStateReply { + v := new(GetStateReply) + b := 1 // skip reply determinant + + v.State = buf[b] + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.Window = xproto.Window(xgb.Get32(buf[b:])) + b += 4 + + return v +} + +// Write request to wire for GetState +// getStateRequest writes a GetState request to a byte slice. +func getStateRequest(c *xgb.Conn, Window xproto.Window) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINERAMA"] + 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:], uint32(Window)) + b += 4 + + return buf +} + // IsActiveCookie is a cookie used only for IsActive requests. type IsActiveCookie struct { *xgb.Cookie @@ -684,3 +589,98 @@ func queryScreensRequest(c *xgb.Conn) []byte { 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, Major byte, Minor byte) QueryVersionCookie { + if _, ok := c.Extensions["XINERAMA"]; !ok { + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(queryVersionRequest(c, Major, Minor), 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, Major byte, Minor byte) QueryVersionCookie { + if _, ok := c.Extensions["XINERAMA"]; !ok { + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(queryVersionRequest(c, Major, Minor), 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 + Major uint16 + Minor uint16 +} + +// 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.Major = xgb.Get16(buf[b:]) + b += 2 + + v.Minor = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. +func queryVersionRequest(c *xgb.Conn, Major byte, Minor byte) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XINERAMA"] + 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 + + buf[b] = Major + b += 1 + + buf[b] = Minor + b += 1 + + 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/xinerama/xinerama.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'nexgb/xinerama') diff --git a/nexgb/xinerama/xinerama.go b/nexgb/xinerama/xinerama.go index dd3732f..7426e8e 100644 --- a/nexgb/xinerama/xinerama.go +++ b/nexgb/xinerama/xinerama.go @@ -1,10 +1,7 @@ // Package xinerama is the X client API for the XINERAMA extension. package xinerama -/* - This file was generated by xinerama.xml on Aug 11 2013 8:39:44pm EDT. - This file is automatically generated. Edit at your peril! -*/ +// This file is automatically generated from xinerama.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/xinerama/xinerama.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'nexgb/xinerama') diff --git a/nexgb/xinerama/xinerama.go b/nexgb/xinerama/xinerama.go index 7426e8e..28410c6 100644 --- a/nexgb/xinerama/xinerama.go +++ b/nexgb/xinerama/xinerama.go @@ -100,9 +100,9 @@ func ScreenInfoListBytes(buf []byte, list []ScreenInfo) 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 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/xinerama/xinerama.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nexgb/xinerama') diff --git a/nexgb/xinerama/xinerama.go b/nexgb/xinerama/xinerama.go index 28410c6..75c773c 100644 --- a/nexgb/xinerama/xinerama.go +++ b/nexgb/xinerama/xinerama.go @@ -90,7 +90,7 @@ func (v ScreenInfo) Bytes() []byte { xgb.Put16(buf[b:], v.Height) b += 2 - return buf + return buf[:b] } // ScreenInfoListBytes writes a list of ScreenInfo values to a byte slice. -- 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/xinerama/xinerama.go | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) (limited to 'nexgb/xinerama') diff --git a/nexgb/xinerama/xinerama.go b/nexgb/xinerama/xinerama.go index 75c773c..ec97406 100644 --- a/nexgb/xinerama/xinerama.go +++ b/nexgb/xinerama/xinerama.go @@ -19,16 +19,15 @@ func Init(c *xgb.Conn) error { return xgb.Errorf("No extension named XINERAMA could be found on on the server.") } - xgb.ExtLock.Lock() + c.ExtLock.Lock() c.Extensions["XINERAMA"] = reply.MajorOpcode + c.ExtLock.Unlock() for evNum, fun := range xgb.NewExtEventFuncs["XINERAMA"] { xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun } for errNum, fun := range xgb.NewExtErrorFuncs["XINERAMA"] { xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun } - xgb.ExtLock.Unlock() - return nil } @@ -137,6 +136,8 @@ type GetScreenCountCookie struct { // GetScreenCount sends a checked request. // If an error occurs, it will be returned with the reply by calling GetScreenCountCookie.Reply() func GetScreenCount(c *xgb.Conn, Window xproto.Window) GetScreenCountCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XINERAMA"]; !ok { panic("Cannot issue request 'GetScreenCount' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.") } @@ -148,6 +149,8 @@ func GetScreenCount(c *xgb.Conn, Window xproto.Window) GetScreenCountCookie { // GetScreenCountUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetScreenCountUnchecked(c *xgb.Conn, Window xproto.Window) GetScreenCountCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XINERAMA"]; !ok { panic("Cannot issue request 'GetScreenCount' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.") } @@ -203,7 +206,9 @@ func getScreenCountRequest(c *xgb.Conn, Window xproto.Window) []byte { b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XINERAMA"] + c.ExtLock.RUnlock() b += 1 buf[b] = 2 // request opcode @@ -226,6 +231,8 @@ type GetScreenSizeCookie struct { // GetScreenSize sends a checked request. // If an error occurs, it will be returned with the reply by calling GetScreenSizeCookie.Reply() func GetScreenSize(c *xgb.Conn, Window xproto.Window, Screen uint32) GetScreenSizeCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XINERAMA"]; !ok { panic("Cannot issue request 'GetScreenSize' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.") } @@ -237,6 +244,8 @@ func GetScreenSize(c *xgb.Conn, Window xproto.Window, Screen uint32) GetScreenSi // GetScreenSizeUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetScreenSizeUnchecked(c *xgb.Conn, Window xproto.Window, Screen uint32) GetScreenSizeCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XINERAMA"]; !ok { panic("Cannot issue request 'GetScreenSize' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.") } @@ -303,7 +312,9 @@ func getScreenSizeRequest(c *xgb.Conn, Window xproto.Window, Screen uint32) []by b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XINERAMA"] + c.ExtLock.RUnlock() b += 1 buf[b] = 3 // request opcode @@ -329,6 +340,8 @@ type GetStateCookie struct { // GetState sends a checked request. // If an error occurs, it will be returned with the reply by calling GetStateCookie.Reply() func GetState(c *xgb.Conn, Window xproto.Window) GetStateCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XINERAMA"]; !ok { panic("Cannot issue request 'GetState' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.") } @@ -340,6 +353,8 @@ func GetState(c *xgb.Conn, Window xproto.Window) GetStateCookie { // GetStateUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetStateUnchecked(c *xgb.Conn, Window xproto.Window) GetStateCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XINERAMA"]; !ok { panic("Cannot issue request 'GetState' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.") } @@ -395,7 +410,9 @@ func getStateRequest(c *xgb.Conn, Window xproto.Window) []byte { b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XINERAMA"] + c.ExtLock.RUnlock() b += 1 buf[b] = 1 // request opcode @@ -418,6 +435,8 @@ type IsActiveCookie struct { // IsActive sends a checked request. // If an error occurs, it will be returned with the reply by calling IsActiveCookie.Reply() func IsActive(c *xgb.Conn) IsActiveCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XINERAMA"]; !ok { panic("Cannot issue request 'IsActive' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.") } @@ -429,6 +448,8 @@ func IsActive(c *xgb.Conn) IsActiveCookie { // IsActiveUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func IsActiveUnchecked(c *xgb.Conn) IsActiveCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XINERAMA"]; !ok { panic("Cannot issue request 'IsActive' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.") } @@ -483,7 +504,9 @@ func isActiveRequest(c *xgb.Conn) []byte { b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XINERAMA"] + c.ExtLock.RUnlock() b += 1 buf[b] = 4 // request opcode @@ -503,6 +526,8 @@ type QueryScreensCookie struct { // QueryScreens sends a checked request. // If an error occurs, it will be returned with the reply by calling QueryScreensCookie.Reply() func QueryScreens(c *xgb.Conn) QueryScreensCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XINERAMA"]; !ok { panic("Cannot issue request 'QueryScreens' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.") } @@ -514,6 +539,8 @@ func QueryScreens(c *xgb.Conn) QueryScreensCookie { // QueryScreensUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryScreensUnchecked(c *xgb.Conn) QueryScreensCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XINERAMA"]; !ok { panic("Cannot issue request 'QueryScreens' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.") } @@ -575,7 +602,9 @@ func queryScreensRequest(c *xgb.Conn) []byte { b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XINERAMA"] + c.ExtLock.RUnlock() b += 1 buf[b] = 5 // request opcode @@ -595,6 +624,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, Major byte, Minor byte) QueryVersionCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XINERAMA"]; !ok { panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.") } @@ -606,6 +637,8 @@ func QueryVersion(c *xgb.Conn, Major byte, Minor byte) 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, Major byte, Minor byte) QueryVersionCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XINERAMA"]; !ok { panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XINERAMA'. xinerama.Init(connObj) must be called first.") } @@ -664,7 +697,9 @@ func queryVersionRequest(c *xgb.Conn, Major byte, Minor byte) []byte { b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XINERAMA"] + c.ExtLock.RUnlock() b += 1 buf[b] = 0 // request opcode -- cgit v1.2.3